[PATCH 1/5] wined3d: Store texture user memory pointer per sub resource.

Paul Gofman pgofman at codeweavers.com
Sun Jun 14 13:16:34 CDT 2020


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
 dlls/wined3d/texture.c         | 19 +++++++++++++------
 dlls/wined3d/wined3d_private.h |  3 ++-
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 84020f17c95..5fa79691368 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -735,7 +735,7 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
     }
     if (locations & WINED3D_LOCATION_USER_MEMORY)
     {
-        data->addr = texture->user_memory;
+        data->addr = texture->sub_resources[sub_resource_idx].user_memory;
         data->buffer_object = 0;
         return;
     }
@@ -1416,6 +1416,7 @@ static void wined3d_texture_cleanup_sync(struct wined3d_texture *texture)
 
 ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
 {
+    unsigned int i, sub_resource_count;
     ULONG refcount;
 
     TRACE("texture %p, swapchain %p.\n", texture, texture->swapchain);
@@ -1432,8 +1433,14 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
          * since the application is allowed to free that memory once the
          * texture is destroyed. Note that this implies that
          * the destroy handler can't access that memory either. */
-        if (texture->user_memory)
+        sub_resource_count = texture->layer_count * texture->level_count;
+        for (i = 0; i < sub_resource_count; ++i)
+            if (texture->sub_resources[i].user_memory)
+                break;
+
+        if (i < sub_resource_count)
             wined3d_resource_wait_idle(&texture->resource);
+
         texture->resource.device->adapter->adapter_ops->adapter_destroy_texture(texture);
     }
 
@@ -1872,7 +1879,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
         }
     }
 
-    if ((texture->user_memory = mem))
+    if ((texture->sub_resources[0].user_memory = mem))
     {
         texture->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
         valid_location = WINED3D_LOCATION_USER_MEMORY;
@@ -3126,7 +3133,7 @@ static BOOL wined3d_texture_gl_prepare_location(struct wined3d_texture *texture,
             return wined3d_resource_prepare_sysmem(&texture->resource);
 
         case WINED3D_LOCATION_USER_MEMORY:
-            if (!texture->user_memory)
+            if (!texture->sub_resources[sub_resource_idx].user_memory)
                 ERR("Preparing WINED3D_LOCATION_USER_MEMORY, but texture->user_memory is NULL.\n");
             return TRUE;
 
@@ -4437,7 +4444,7 @@ static BOOL wined3d_texture_no3d_prepare_location(struct wined3d_texture *textur
             return wined3d_resource_prepare_sysmem(&texture->resource);
 
         case WINED3D_LOCATION_USER_MEMORY:
-            if (!texture->user_memory)
+            if (!texture->sub_resources[sub_resource_idx].user_memory)
                 ERR("Preparing WINED3D_LOCATION_USER_MEMORY, but texture->user_memory is NULL.\n");
             return TRUE;
 
@@ -5081,7 +5088,7 @@ static BOOL wined3d_texture_vk_prepare_location(struct wined3d_texture *texture,
             return wined3d_resource_prepare_sysmem(&texture->resource);
 
         case WINED3D_LOCATION_USER_MEMORY:
-            if (!texture->user_memory)
+            if (!texture->sub_resources[sub_resource_idx].user_memory)
                 ERR("Preparing WINED3D_LOCATION_USER_MEMORY, but texture->user_memory is NULL.\n");
             return TRUE;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 17acd4be4d5..dd4d34b08f7 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4060,7 +4060,6 @@ struct wined3d_texture
     DWORD flags;
     DWORD update_map_binding;
 
-    void *user_memory;
     unsigned int row_pitch;
     unsigned int slice_pitch;
 
@@ -4113,6 +4112,8 @@ struct wined3d_texture
         uint32_t map_flags;
         DWORD locations;
         struct wined3d_bo_gl bo;
+
+        void *user_memory;
     } *sub_resources;
 };
 
-- 
2.26.2




More information about the wine-devel mailing list