Henri Verbeet : wined3d: Pass a texture and sub-resource index to texture2d_create_dc().

Alexandre Julliard julliard at winehq.org
Tue Mar 13 17:10:52 CDT 2018


Module: wine
Branch: master
Commit: a7c0904a10eb30c0fdb59cc67b756cc86bcafe66
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a7c0904a10eb30c0fdb59cc67b756cc86bcafe66

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Mar 13 14:11:03 2018 +0330

wined3d: Pass a texture and sub-resource index to texture2d_create_dc().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/texture.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0abf5ad..07c08d8 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1334,23 +1334,30 @@ void wined3d_texture_set_compatible_renderbuffer(struct wined3d_texture *texture
     checkGLcall("set_compatible_renderbuffer");
 }
 
+struct wined3d_texture_idx
+{
+    struct wined3d_texture *texture;
+    unsigned int sub_resource_idx;
+};
+
 static void texture2d_create_dc(void *object)
 {
-    struct wined3d_surface *surface = object;
+    const struct wined3d_texture_idx *idx = object;
     struct wined3d_context *context = NULL;
     unsigned int sub_resource_idx, level;
     const struct wined3d_format *format;
     unsigned int row_pitch, slice_pitch;
     struct wined3d_texture *texture;
+    struct wined3d_surface *surface;
     struct wined3d_bo_address data;
     D3DKMT_CREATEDCFROMMEMORY desc;
     struct wined3d_device *device;
     NTSTATUS status;
 
-    TRACE("surface %p.\n", surface);
+    TRACE("texture %p, sub_resource_idx %u.\n", idx->texture, idx->sub_resource_idx);
 
-    texture = surface->container;
-    sub_resource_idx = surface_get_sub_resource_idx(surface);
+    texture = idx->texture;
+    sub_resource_idx = idx->sub_resource_idx;
     level = sub_resource_idx % texture->level_count;
     device = texture->resource.device;
 
@@ -1390,10 +1397,11 @@ static void texture2d_create_dc(void *object)
         return;
     }
 
+    surface = texture->sub_resources[sub_resource_idx].u.surface;
     surface->dc = desc.hDc;
     surface->bitmap = desc.hBitmap;
 
-    TRACE("Created DC %p, bitmap %p for surface %p.\n", surface->dc, surface->bitmap, surface);
+    TRACE("Created DC %p, bitmap %p for texture %p, %u.\n", surface->dc, surface->bitmap, texture, sub_resource_idx);
 }
 
 static void texture2d_destroy_dc(void *object)
@@ -1563,7 +1571,9 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
 
     if (create_dib)
     {
-        wined3d_cs_init_object(device->cs, texture2d_create_dc, surface);
+        struct wined3d_texture_idx texture_idx = {texture, 0};
+
+        wined3d_cs_init_object(device->cs, texture2d_create_dc, &texture_idx);
         device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
     }
 
@@ -2377,7 +2387,9 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
 
             if ((desc->usage & WINED3DUSAGE_OWNDC) || (device->wined3d->flags & WINED3D_NO3D))
             {
-                wined3d_cs_init_object(device->cs, texture2d_create_dc, surface);
+                struct wined3d_texture_idx texture_idx = {texture, idx};
+
+                wined3d_cs_init_object(device->cs, texture2d_create_dc, &texture_idx);
                 device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
                 if (!surface->dc)
                 {
@@ -3163,7 +3175,9 @@ HRESULT CDECL wined3d_texture_get_dc(struct wined3d_texture *texture, unsigned i
 
     if (!surface->dc)
     {
-        wined3d_cs_init_object(device->cs, texture2d_create_dc, surface);
+        struct wined3d_texture_idx texture_idx = {texture, sub_resource_idx};
+
+        wined3d_cs_init_object(device->cs, texture2d_create_dc, &texture_idx);
         device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
     }
     if (!surface->dc)




More information about the wine-cvs mailing list