[PATCH v2 09/10] ddraw: Track location for surfaces with the second texture.

Paul Gofman pgofman at codeweavers.com
Tue Mar 9 03:56:46 CST 2021


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
v2:
    - no changes.

 dlls/ddraw/ddraw_private.h | 46 ++++++++++++++++++++++++------
 dlls/ddraw/device.c        | 39 +++++++++++--------------
 dlls/ddraw/executebuffer.c |  9 ++----
 dlls/ddraw/surface.c       | 58 ++++++++++++++++++++------------------
 4 files changed, 89 insertions(+), 63 deletions(-)

diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 432e28065e0..1c28e081b8a 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -155,6 +155,9 @@ void DDRAW_Convert_DDSCAPS_1_To_2(const DDSCAPS *pIn, DDSCAPS2 *pOut) DECLSPEC_H
 void DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1(const DDDEVICEIDENTIFIER2 *pIn, DDDEVICEIDENTIFIER *pOut) DECLSPEC_HIDDEN;
 struct wined3d_vertex_declaration *ddraw_find_decl(struct ddraw *ddraw, DWORD fvf) DECLSPEC_HIDDEN;
 
+#define DDRAW_SURFACE_LOCATION_DEFAULT 0x00000001
+#define DDRAW_SURFACE_LOCATION_DRAW    0x00000002
+
 struct ddraw_surface
 {
     /* IUnknown fields */
@@ -175,6 +178,7 @@ struct ddraw_surface
 
     /* Connections to other Objects */
     struct ddraw *ddraw;
+    unsigned int texture_location;
     struct wined3d_texture *wined3d_texture;
     struct wined3d_texture *draw_texture;
     unsigned int sub_resource_idx;
@@ -654,22 +658,48 @@ static inline BOOL ddraw_surface_can_be_lost(const struct ddraw_surface *surface
     return surface->sysmem_fallback;
 }
 
-static inline void d3d_surface_sync_textures(struct ddraw_surface *surface, BOOL upload)
+#define DDRAW_SURFACE_READ   0x00000001
+#define DDRAW_SURFACE_WRITE  0x00000002
+#define DDRAW_SURFACE_RW (DDRAW_SURFACE_READ | DDRAW_SURFACE_WRITE)
+
+static inline struct wined3d_texture *ddraw_surface_get_default_texture(struct ddraw_surface *surface, unsigned int flags)
+{
+    if (surface->draw_texture)
+    {
+        if (flags & DDRAW_SURFACE_READ && !(surface->texture_location & DDRAW_SURFACE_LOCATION_DEFAULT))
+        {
+            wined3d_device_copy_sub_resource_region(surface->ddraw->wined3d_device,
+                    wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx, 0, 0, 0,
+                    wined3d_texture_get_resource(surface->draw_texture), surface->sub_resource_idx, NULL, 0);
+            surface->texture_location |= DDRAW_SURFACE_LOCATION_DEFAULT;
+        }
+
+        if (flags & DDRAW_SURFACE_WRITE)
+            surface->texture_location = DDRAW_SURFACE_LOCATION_DEFAULT;
+    }
+    return surface->wined3d_texture;
+}
+
+static inline struct wined3d_texture *ddraw_surface_get_draw_texture(struct ddraw_surface *surface, unsigned int flags)
 {
     if (!surface->draw_texture)
-        return;
+        return surface->wined3d_texture;
 
-    if (upload)
+    if (flags & DDRAW_SURFACE_READ && !(surface->texture_location & DDRAW_SURFACE_LOCATION_DRAW))
+    {
         wined3d_device_copy_sub_resource_region(surface->ddraw->wined3d_device,
                 wined3d_texture_get_resource(surface->draw_texture), surface->sub_resource_idx, 0, 0, 0,
                 wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx, NULL, 0);
-    else
-        wined3d_device_copy_sub_resource_region(surface->ddraw->wined3d_device,
-                wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx, 0, 0, 0,
-                wined3d_texture_get_resource(surface->draw_texture), surface->sub_resource_idx, NULL, 0);
+        surface->texture_location |= DDRAW_SURFACE_LOCATION_DRAW;
+    }
+
+    if (flags & DDRAW_SURFACE_WRITE)
+        surface->texture_location = DDRAW_SURFACE_LOCATION_DRAW;
+
+    return surface->draw_texture;
 }
 
-void d3d_device_sync_surfaces(struct d3d_device *device, BOOL upload) DECLSPEC_HIDDEN;
+void d3d_device_sync_surfaces(struct d3d_device *device) DECLSPEC_HIDDEN;
 
 /* Used for generic dumping */
 struct flag_info
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 005de0805e1..b2392f54b01 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -3427,7 +3427,7 @@ static HRESULT d3d_device_prepare_vertex_buffer(struct d3d_device *device, UINT
     return D3D_OK;
 }
 
-static void d3d_device_sync_rendertarget(struct d3d_device *device, BOOL upload)
+static void d3d_device_sync_rendertarget(struct d3d_device *device)
 {
     struct wined3d_rendertarget_view *rtv;
 
@@ -3435,13 +3435,13 @@ static void d3d_device_sync_rendertarget(struct d3d_device *device, BOOL upload)
         return;
 
     if ((rtv = wined3d_device_get_rendertarget_view(device->wined3d_device, 0)))
-        d3d_surface_sync_textures(wined3d_rendertarget_view_get_parent(rtv), upload);
+        ddraw_surface_get_draw_texture(wined3d_rendertarget_view_get_parent(rtv), DDRAW_SURFACE_RW);
 
     if ((rtv = wined3d_device_get_depth_stencil_view(device->wined3d_device)))
-        d3d_surface_sync_textures(wined3d_rendertarget_view_get_parent(rtv), upload);
+        ddraw_surface_get_draw_texture(wined3d_rendertarget_view_get_parent(rtv), DDRAW_SURFACE_RW);
 }
 
-void d3d_device_sync_surfaces(struct d3d_device *device, BOOL upload)
+void d3d_device_sync_surfaces(struct d3d_device *device)
 {
     const struct wined3d_stateblock_state *state = device->stateblock_state;
     struct ddraw_surface *surface;
@@ -3450,7 +3450,7 @@ void d3d_device_sync_surfaces(struct d3d_device *device, BOOL upload)
     if (device->hardware_device)
         return;
 
-    d3d_device_sync_rendertarget(device, upload);
+    d3d_device_sync_rendertarget(device);
 
     for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
     {
@@ -3462,7 +3462,7 @@ void d3d_device_sync_surfaces(struct d3d_device *device, BOOL upload)
         {
             if (!surface->draw_texture)
                 break;
-            d3d_surface_sync_textures(surface, upload);
+            ddraw_surface_get_draw_texture(surface, DDRAW_SURFACE_READ);
             ++j;
         }
     }
@@ -3522,9 +3522,8 @@ static HRESULT d3d_device7_DrawPrimitive(IDirect3DDevice7 *iface,
     wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf));
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / stride, vertex_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
 done:
     wined3d_mutex_unlock();
@@ -3736,9 +3735,8 @@ static HRESULT d3d_device7_DrawIndexedPrimitive(IDirect3DDevice7 *iface,
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_stateblock_set_base_vertex_index(device->state, vb_pos / stride);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(*indices), index_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
 done:
     wined3d_mutex_unlock();
@@ -4064,9 +4062,8 @@ static HRESULT d3d_device7_DrawPrimitiveStrided(IDirect3DDevice7 *iface, D3DPRIM
 
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_primitive(device->wined3d_device, vb_pos / dst_stride, vertex_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
 done:
     wined3d_mutex_unlock();
@@ -4202,9 +4199,8 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveStrided(IDirect3DDevice7 *iface,
     wined3d_stateblock_set_vertex_declaration(device->state, ddraw_find_decl(device->ddraw, fvf));
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(WORD), index_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
 done:
     wined3d_mutex_unlock();
@@ -4326,9 +4322,8 @@ static HRESULT d3d_device7_DrawPrimitiveVB(IDirect3DDevice7 *iface, D3DPRIMITIVE
     /* Now draw the primitives */
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_primitive(device->wined3d_device, start_vertex, vertex_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
     wined3d_mutex_unlock();
 
@@ -4482,9 +4477,8 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
 
     wined3d_device_set_primitive_type(device->wined3d_device, wined3d_primitive_type_from_ddraw(primitive_type), 0);
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_surfaces(device, TRUE);
+    d3d_device_sync_surfaces(device);
     hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / sizeof(WORD), index_count);
-    d3d_device_sync_surfaces(device, FALSE);
 
     wined3d_mutex_unlock();
 
@@ -5323,9 +5317,8 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count,
 
     wined3d_mutex_lock();
     wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-    d3d_device_sync_rendertarget(device, TRUE);
+    d3d_device_sync_rendertarget(device);
     hr = wined3d_device_clear(device->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil);
-    d3d_device_sync_rendertarget(device, FALSE);
     wined3d_mutex_unlock();
 
     return hr;
@@ -6178,8 +6171,10 @@ static void copy_mipmap_chain(struct d3d_device *device, struct ddraw_surface *d
             UINT src_h = src_rect.bottom - src_rect.top;
             RECT dst_rect = {point.x, point.y, point.x + src_w, point.y + src_h};
 
-            if (FAILED(hr = wined3d_texture_blt(dst_level->wined3d_texture, dst_level->sub_resource_idx, &dst_rect,
-                    src_level->wined3d_texture, src_level->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT)))
+            if (FAILED(hr = wined3d_texture_blt(ddraw_surface_get_default_texture(dst_level, DDRAW_SURFACE_RW),
+                    dst_level->sub_resource_idx, &dst_rect,
+                    ddraw_surface_get_default_texture(src_level, DDRAW_SURFACE_READ),
+                    src_level->sub_resource_idx, &src_rect, 0, NULL, WINED3D_TEXF_POINT)))
                 ERR("Blit failed, hr %#x.\n", hr);
 
             ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index 6900059b05f..d87878883c7 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -81,10 +81,9 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
                         ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
 
                 wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-                d3d_device_sync_surfaces(device, TRUE);
+                d3d_device_sync_surfaces(device);
                 for (i = 0; i < count; ++i)
                     wined3d_device_draw_primitive(device->wined3d_device, p[i].wFirst, p[i].wCount);
-                d3d_device_sync_surfaces(device, FALSE);
 
                 instr += sizeof(*p) * count;
                 break;
@@ -191,9 +190,8 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
                         ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
                 wined3d_stateblock_set_index_buffer(device->state, buffer->index_buffer, WINED3DFMT_R16_UINT);
                 wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-                d3d_device_sync_surfaces(device, TRUE);
+                d3d_device_sync_surfaces(device);
                 wined3d_device_draw_indexed_primitive(device->wined3d_device, index_pos, index_count);
-                d3d_device_sync_surfaces(device, FALSE);
 
                 buffer->index_pos = index_pos + index_count;
                 break;
@@ -314,10 +312,9 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer, struct d3d
                                     ddraw_find_decl(device->ddraw, op == D3DPROCESSVERTICES_TRANSFORMLIGHT
                                     ? D3DFVF_VERTEX : D3DFVF_LVERTEX));
                             wined3d_device_apply_stateblock(device->wined3d_device, device->state);
-                            d3d_device_sync_surfaces(device, TRUE);
+                            d3d_device_sync_surfaces(device);
                             wined3d_device_process_vertices(device->wined3d_device, ci->wStart, ci->wDest,
                                     ci->dwCount, buffer->dst_vertex_buffer, NULL, 0, D3DFVF_TLVERTEX);
-                            d3d_device_sync_surfaces(device, FALSE);
                             break;
 
                         case D3DPROCESSVERTICES_COPY:
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 6ad91983ae2..e7fb8b0ab03 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -56,8 +56,8 @@ static BOOL ddraw_gdi_is_front(struct ddraw *ddraw)
 HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
         const RECT *rect, BOOL read, unsigned int swap_interval)
 {
+    struct wined3d_texture *dst_texture, *src_texture;
     struct ddraw *ddraw = surface->ddraw;
-    struct wined3d_texture *dst_texture;
     HDC surface_dc, screen_dc;
     int x, y, w, h;
     HRESULT hr;
@@ -112,8 +112,9 @@ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
         else
             dst_texture = ddraw->wined3d_frontbuffer;
 
-        if (SUCCEEDED(hr = wined3d_texture_blt(dst_texture, 0, rect, surface->wined3d_texture,
-                surface->sub_resource_idx, rect, 0, NULL, WINED3D_TEXF_POINT)) && swap_interval)
+        if (SUCCEEDED(hr = wined3d_texture_blt(dst_texture, 0, rect,
+                ddraw_surface_get_default_texture(surface, DDRAW_SURFACE_READ), surface->sub_resource_idx, rect, 0,
+                NULL, WINED3D_TEXF_POINT)) && swap_interval)
         {
             hr = wined3d_swapchain_present(ddraw->wined3d_swapchain, rect, rect, NULL, swap_interval, 0);
             ddraw->flags |= DDRAW_SWAPPED;
@@ -121,7 +122,10 @@ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
         return hr;
     }
 
-    if (FAILED(hr = wined3d_texture_get_dc(surface->wined3d_texture, surface->sub_resource_idx, &surface_dc)))
+    src_texture = ddraw_surface_get_default_texture(surface, read ? (rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE)
+            : DDRAW_SURFACE_READ);
+
+    if (FAILED(hr = wined3d_texture_get_dc(src_texture, surface->sub_resource_idx, &surface_dc)))
     {
         ERR("Failed to get surface DC, hr %#x.\n", hr);
         return hr;
@@ -131,7 +135,7 @@ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
 
     if (!(screen_dc = GetDC(NULL)))
     {
-        wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, surface_dc);
+        wined3d_texture_release_dc(src_texture, surface->sub_resource_idx, surface_dc);
         ERR("Failed to get screen DC.\n");
         return E_FAIL;
     }
@@ -144,7 +148,7 @@ HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
                 surface_dc, x, y, SRCCOPY);
 
     ReleaseDC(NULL, screen_dc);
-    wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, surface_dc);
+    wined3d_texture_release_dc(src_texture, surface->sub_resource_idx, surface_dc);
 
     if (!ret)
     {
@@ -1057,9 +1061,9 @@ static HRESULT surface_lock(struct ddraw_surface *surface,
     if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
         hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE, 0);
     if (SUCCEEDED(hr))
-        hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
-                surface->sub_resource_idx, &map_desc, rect ? &box : NULL,
-                wined3dmapflags_from_ddrawmapflags(flags));
+        hr = wined3d_resource_map(wined3d_texture_get_resource
+                (ddraw_surface_get_default_texture(surface, DDRAW_SURFACE_RW)), surface->sub_resource_idx,
+                &map_desc, rect ? &box : NULL, wined3dmapflags_from_ddrawmapflags(flags));
     if (FAILED(hr))
     {
         wined3d_mutex_unlock();
@@ -1235,7 +1239,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface1_Unlock(IDirectDrawSurface
     TRACE("iface %p, data %p.\n", iface, data);
 
     wined3d_mutex_lock();
-    hr = wined3d_resource_unmap(wined3d_texture_get_resource(surface->wined3d_texture), surface->sub_resource_idx);
+    hr = wined3d_resource_unmap(wined3d_texture_get_resource
+            (ddraw_surface_get_default_texture(surface, 0)), surface->sub_resource_idx);
     if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
         hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE, 0);
     wined3d_mutex_unlock();
@@ -1507,7 +1512,6 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
     struct wined3d_device *wined3d_device = dst_surface->ddraw->wined3d_device;
     struct wined3d_color colour;
     DWORD wined3d_flags;
-    HRESULT hr;
 
     if (flags & DDBLT_COLORFILL)
     {
@@ -1520,12 +1524,10 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
             return DDERR_INVALIDPARAMS;
 
         wined3d_device_apply_stateblock(wined3d_device, dst_surface->ddraw->state);
-        d3d_surface_sync_textures(dst_surface, TRUE);
-        hr = wined3d_device_clear_rendertarget_view(wined3d_device,
+        ddraw_surface_get_draw_texture(dst_surface, dst_rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE);
+        return wined3d_device_clear_rendertarget_view(wined3d_device,
                 ddraw_surface_get_rendertarget_view(dst_surface),
                 dst_rect, wined3d_flags, &colour, 0.0f, 0);
-        d3d_surface_sync_textures(dst_surface, FALSE);
-        return hr;
     }
 
     if (flags & DDBLT_DEPTHFILL)
@@ -1539,12 +1541,10 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
             return DDERR_INVALIDPARAMS;
 
         wined3d_device_apply_stateblock(wined3d_device, dst_surface->ddraw->state);
-        d3d_surface_sync_textures(dst_surface, TRUE);
-        hr = wined3d_device_clear_rendertarget_view(wined3d_device,
+        ddraw_surface_get_draw_texture(dst_surface, dst_rect ? DDRAW_SURFACE_RW : DDRAW_SURFACE_WRITE);
+        return wined3d_device_clear_rendertarget_view(wined3d_device,
                 ddraw_surface_get_rendertarget_view(dst_surface),
                 dst_rect, wined3d_flags, NULL, colour.r, 0);
-        d3d_surface_sync_textures(dst_surface, FALSE);
-        return hr;
     }
 
     wined3d_flags = flags & ~DDBLT_ASYNC;
@@ -1557,8 +1557,9 @@ static HRESULT ddraw_surface_blt(struct ddraw_surface *dst_surface, const RECT *
     if (!(flags & DDBLT_ASYNC))
         wined3d_flags |= WINED3D_BLT_SYNCHRONOUS;
 
-    return wined3d_texture_blt(dst_surface->wined3d_texture, dst_surface->sub_resource_idx, dst_rect,
-            src_surface->wined3d_texture, src_surface->sub_resource_idx, src_rect, wined3d_flags, fx, filter);
+    return wined3d_texture_blt(ddraw_surface_get_default_texture(dst_surface, DDRAW_SURFACE_RW),
+            dst_surface->sub_resource_idx, dst_rect, ddraw_surface_get_default_texture(src_surface, DDRAW_SURFACE_READ),
+            src_surface->sub_resource_idx, src_rect, wined3d_flags, fx, filter);
 }
 
 static HRESULT ddraw_surface_blt_clipped(struct ddraw_surface *dst_surface, const RECT *dst_rect_in,
@@ -2328,7 +2329,7 @@ static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *dc)
     else if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
         hr = ddraw_surface_update_frontbuffer(surface, NULL, TRUE, 0);
     if (SUCCEEDED(hr))
-        hr = wined3d_texture_get_dc(surface->wined3d_texture, surface->sub_resource_idx, dc);
+        hr = wined3d_texture_get_dc(ddraw_surface_get_default_texture(surface, DDRAW_SURFACE_RW), surface->sub_resource_idx, dc);
 
     if (SUCCEEDED(hr))
     {
@@ -2424,7 +2425,8 @@ static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC h
     {
         hr = DDERR_NODC;
     }
-    else if (SUCCEEDED(hr = wined3d_texture_release_dc(surface->wined3d_texture, surface->sub_resource_idx, hdc)))
+    else if (SUCCEEDED(hr = wined3d_texture_release_dc(ddraw_surface_get_default_texture(surface, 0),
+            surface->sub_resource_idx, hdc)))
     {
         surface->dc = NULL;
         if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
@@ -4404,8 +4406,9 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_BltFast(IDirectDrawSurfac
     if (src_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
         hr = ddraw_surface_update_frontbuffer(src_impl, src_rect, TRUE, 0);
     if (SUCCEEDED(hr))
-        hr = wined3d_texture_blt(dst_impl->wined3d_texture, dst_impl->sub_resource_idx, &dst_rect,
-                src_impl->wined3d_texture, src_impl->sub_resource_idx, src_rect, flags, NULL, WINED3D_TEXF_POINT);
+        hr = wined3d_texture_blt(ddraw_surface_get_default_texture(dst_impl, DDRAW_SURFACE_RW),
+                dst_impl->sub_resource_idx, &dst_rect, ddraw_surface_get_default_texture(src_impl,DDRAW_SURFACE_READ),
+                src_impl->sub_resource_idx, src_rect, flags, NULL, WINED3D_TEXF_POINT);
     if (SUCCEEDED(hr) && (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
         hr = ddraw_surface_update_frontbuffer(dst_impl, &dst_rect, FALSE, 0);
     wined3d_mutex_unlock();
@@ -5341,8 +5344,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
 
     wined3d_mutex_lock();
 
-    dst_resource = wined3d_texture_get_resource(dst_surface->wined3d_texture);
-    src_resource = wined3d_texture_get_resource(src_surface->wined3d_texture);
+    dst_resource = wined3d_texture_get_resource(ddraw_surface_get_default_texture(dst_surface, DDRAW_SURFACE_WRITE));
+    src_resource = wined3d_texture_get_resource(ddraw_surface_get_default_texture(src_surface, DDRAW_SURFACE_READ));
 
     if (((src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
             != (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP))
@@ -6784,6 +6787,7 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
     wined3d_texture_incref(surface->wined3d_texture = wined3d_texture);
     surface->sub_resource_idx = sub_resource_idx;
     *parent_ops = &ddraw_surface_wined3d_parent_ops;
+    surface->texture_location = DDRAW_SURFACE_LOCATION_DEFAULT;
 
     wined3d_private_store_init(&surface->private_store);
 }
-- 
2.29.2




More information about the wine-devel mailing list