[PATCH 3/5] wined3d: Get rid of surface_modify_ds_location().

Henri Verbeet hverbeet at codeweavers.com
Thu Jan 26 06:25:19 CST 2017


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/cs.c              |  3 ++-
 dlls/wined3d/device.c          |  7 ++++---
 dlls/wined3d/drawprim.c        |  7 ++++---
 dlls/wined3d/surface.c         | 17 ++++-------------
 dlls/wined3d/swapchain.c       |  3 ++-
 dlls/wined3d/wined3d_private.h |  1 -
 6 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index f1aef77..6a366b8 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -632,7 +632,8 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const
         if (prev_surface && (device->swapchains[0]->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
                 || prev_surface->container->flags & WINED3D_TEXTURE_DISCARD))
         {
-            surface_modify_ds_location(prev_surface, WINED3D_LOCATION_DISCARDED);
+            wined3d_texture_validate_location(prev_surface->container,
+                    prev->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
             if (prev_surface == device->onscreen_depth_stencil)
             {
                 wined3d_texture_decref(device->onscreen_depth_stencil->container);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 302df96..10c5df1 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -204,8 +204,8 @@ void device_switch_onscreen_ds(struct wined3d_device *device,
     if (device->onscreen_depth_stencil)
     {
         surface_load_location(device->onscreen_depth_stencil, context, WINED3D_LOCATION_TEXTURE_RGB);
-
-        surface_modify_ds_location(device->onscreen_depth_stencil, WINED3D_LOCATION_TEXTURE_RGB);
+        wined3d_texture_invalidate_location(device->onscreen_depth_stencil->container,
+                surface_get_sub_resource_idx(device->onscreen_depth_stencil), ~WINED3D_LOCATION_TEXTURE_RGB);
         wined3d_texture_decref(device->onscreen_depth_stencil->container);
     }
     device->onscreen_depth_stencil = depth_stencil;
@@ -331,7 +331,8 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
     {
         DWORD location = render_offscreen ? dsv->resource->draw_binding : WINED3D_LOCATION_DRAWABLE;
 
-        surface_modify_ds_location(depth_stencil, location);
+        wined3d_texture_validate_location(depth_stencil->container, dsv->sub_resource_idx, location);
+        wined3d_texture_invalidate_location(depth_stencil->container, dsv->sub_resource_idx, ~location);
 
         gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE);
         context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZWRITEENABLE));
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index d846b8f..ddeb238 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -483,12 +483,13 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
         return;
     }
 
-    if (fb->depth_stencil && state->render_states[WINED3D_RS_ZWRITEENABLE])
+    if (dsv && state->render_states[WINED3D_RS_ZWRITEENABLE])
     {
-        struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(fb->depth_stencil);
+        struct wined3d_surface *ds = wined3d_rendertarget_view_get_surface(dsv);
         DWORD location = context->render_offscreen ? ds->container->resource.draw_binding : WINED3D_LOCATION_DRAWABLE;
 
-        surface_modify_ds_location(ds, location);
+        wined3d_texture_validate_location(ds->container, dsv->sub_resource_idx, location);
+        wined3d_texture_invalidate_location(ds->container, dsv->sub_resource_idx, ~location);
     }
 
     if ((!gl_info->supported[WINED3D_GL_VERSION_2_0]
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index ad02a20..b4e2025 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -712,6 +712,7 @@ static HRESULT wined3d_surface_depth_blt(struct wined3d_surface *src_surface, DW
     struct wined3d_texture *src_texture = src_surface->container;
     struct wined3d_texture *dst_texture = dst_surface->container;
     struct wined3d_device *device = src_texture->resource.device;
+    unsigned int dst_sub_resource_idx;
 
     if (!fbo_blit_supported(&device->adapter->gl_info, WINED3D_BLIT_OP_DEPTH_BLIT,
             src_rect, src_texture->resource.usage, src_texture->resource.pool, src_texture->resource.format,
@@ -720,7 +721,9 @@ static HRESULT wined3d_surface_depth_blt(struct wined3d_surface *src_surface, DW
 
     surface_depth_blt_fbo(device, src_surface, src_location, src_rect, dst_surface, dst_location, dst_rect);
 
-    surface_modify_ds_location(dst_surface, dst_location);
+    dst_sub_resource_idx = surface_get_sub_resource_idx(dst_surface);
+    wined3d_texture_validate_location(dst_texture, dst_sub_resource_idx, dst_location);
+    wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~dst_location);
 
     return WINED3D_OK;
 }
@@ -2488,18 +2491,6 @@ static HRESULT surface_blt_special(struct wined3d_surface *dst_surface, const RE
     return WINED3DERR_INVALIDCALL;
 }
 
-void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location)
-{
-    struct wined3d_texture *texture = surface->container;
-    unsigned int sub_resource_idx;
-
-    TRACE("surface %p, new location %#x.\n", surface, location);
-
-    sub_resource_idx = surface_get_sub_resource_idx(surface);
-    wined3d_texture_validate_location(texture, sub_resource_idx, location);
-    wined3d_texture_invalidate_location(texture, sub_resource_idx, ~location);
-}
-
 static DWORD resource_access_from_location(DWORD location)
 {
     switch (location)
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index cb704cd..30f6c7d 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -622,7 +622,8 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
         if (ds && (swapchain->desc.flags & WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
                 || ds->container->flags & WINED3D_TEXTURE_DISCARD))
         {
-            surface_modify_ds_location(ds, WINED3D_LOCATION_DISCARDED);
+            wined3d_texture_validate_location(ds->container,
+                    fb->depth_stencil->sub_resource_idx, WINED3D_LOCATION_DISCARDED);
             if (ds == swapchain->device->onscreen_depth_stencil)
             {
                 wined3d_texture_decref(swapchain->device->onscreen_depth_stencil->container);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 31c6c0d..338aef0 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2983,7 +2983,6 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
         struct wined3d_context *context) DECLSPEC_HIDDEN;
 HRESULT surface_load_location(struct wined3d_surface *surface,
         struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
-void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
 void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
         const struct wined3d_surface *rt) DECLSPEC_HIDDEN;
 void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
-- 
2.1.4




More information about the wine-patches mailing list