[PATCH 1/5] wined3d: Discard texture resources before unloading them in wined3d_texture_destroy_object().

Henri Verbeet hverbeet at codeweavers.com
Thu Jan 20 10:30:53 CST 2022


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/texture.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index a638ec4eeae..34d76249084 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1507,6 +1507,16 @@ static void wined3d_texture_destroy_object(void *object)
         heap_free(texture->dirty_regions);
     }
 
+    /* Discard the contents of resources with CPU access, to avoid downloading
+     * them to SYSMEM on unload. */
+    if (resource->access & WINED3D_RESOURCE_ACCESS_CPU)
+    {
+        for (i = 0; i < sub_count; ++i)
+        {
+            wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_DISCARDED);
+            wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_DISCARDED);
+        }
+    }
     resource->resource_ops->resource_unload(resource);
 }
 
-- 
2.30.2




More information about the wine-devel mailing list