[PATCH 3/5] wined3d: Discard depth stencils on unload.

Stefan Dösinger stefan at codeweavers.com
Sat Nov 21 18:00:59 CST 2015


This fixes the depth stencil part of bug 39536.

Doing so is equivalent of setting WINED3D_LOCATION_DISCARDED when
creating new depth stencil surfaces. It will only happen on the implicit
depth stencil.

Being discarded is necessary for surface_load_ds_location to properly
allocate the surface. This is arguably a bug on its own, but fixing this
is too invasive during the code freeze IMO. (At some point we want to
get rid of the special depth buffer handling in load_location, although
there may be more fine grained improvements to fix allocation or handle
multisampled surfaces in the copy codepaths in this function. We'll
also want depth buffer locking somewhen.)

Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
 dlls/wined3d/surface.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 6a93de4..a8f7179 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1149,10 +1149,18 @@ static void surface_unload(struct wined3d_resource *resource)
          * but we can't set the sysmem INDRAWABLE because when we're rendering the swapchain
          * or the depth stencil into an FBO the texture or render buffer will be removed
          * and all flags get lost */
-        surface_prepare_system_memory(surface);
-        memset(surface->resource.heap_memory, 0, surface->resource.size);
-        surface_validate_location(surface, WINED3D_LOCATION_SYSMEM);
-        surface_invalidate_location(surface, ~WINED3D_LOCATION_SYSMEM);
+        if (resource->usage & WINED3DUSAGE_DEPTHSTENCIL)
+        {
+            surface_validate_location(surface, WINED3D_LOCATION_DISCARDED);
+            surface_invalidate_location(surface, ~WINED3D_LOCATION_DISCARDED);
+        }
+        else
+        {
+            surface_prepare_system_memory(surface);
+            memset(surface->resource.heap_memory, 0, surface->resource.size);
+            surface_validate_location(surface, WINED3D_LOCATION_SYSMEM);
+            surface_invalidate_location(surface, ~WINED3D_LOCATION_SYSMEM);
+        }
 
         /* We also get here when the ddraw swapchain is destroyed, for example
          * for a mode switch. In this case this surface won't necessarily be
-- 
2.4.10




More information about the wine-patches mailing list