[PATCH 1/6] wined3d: Don't evict mapped resources in wined3d_device_evict_managed_resources().

Henri Verbeet hverbeet at codeweavers.com
Sun Apr 10 11:09:26 CDT 2016


We would skip evicting the specific mapped sub-resource, but then go on to
evict the texture itself.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/device.c  | 4 ++++
 dlls/wined3d/texture.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 619ad1e..b1d8631 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4503,6 +4503,10 @@ void CDECL wined3d_device_evict_managed_resources(struct wined3d_device *device)
     {
         TRACE("Checking resource %p for eviction.\n", resource);
 
+        /* These are handled by the texture they're part of. */
+        if (resource->type == WINED3D_RTYPE_SURFACE || resource->type == WINED3D_RTYPE_VOLUME)
+            continue;
+
         if (resource->pool == WINED3D_POOL_MANAGED && !resource->map_count)
         {
             TRACE("Evicting %p.\n", resource);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0a89665..393c2f8 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1408,6 +1408,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
         TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
     }
 
+    ++resource->map_count;
     ++sub_resource->resource->map_count;
 
     TRACE("Returning memory %p, row pitch %u, slice pitch %u.\n",
@@ -1473,6 +1474,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso
     }
 
     --sub_resource->resource->map_count;
+    --resource->map_count;
 
     return WINED3D_OK;
 }
@@ -2263,6 +2265,7 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
         context_release(context);
 
     surface->flags |= SFLAG_DCINUSE;
+    ++texture->resource.map_count;
     surface->resource.map_count++;
 
     *dc = surface->hDC;
@@ -2302,6 +2305,7 @@ HRESULT CDECL wined3d_texture_release_dc(struct wined3d_texture *texture, unsign
     }
 
     surface->resource.map_count--;
+    --texture->resource.map_count;
     surface->flags &= ~SFLAG_DCINUSE;
 
     if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY
-- 
2.1.4




More information about the wine-patches mailing list