[PATCH 2/5] wined3d: Pass a wined3d_resource_desc structure to device_parent_create_texture_surface().

Henri Verbeet hverbeet at codeweavers.com
Tue Jun 4 02:57:07 CDT 2013


---
 dlls/d3d10core/device.c | 14 +++++++-------
 dlls/d3d8/device.c      | 17 ++++++++---------
 dlls/d3d9/device.c      | 16 ++++++++--------
 dlls/ddraw/ddraw.c      | 13 ++++++-------
 dlls/wined3d/texture.c  | 22 ++++++++++++----------
 include/wine/wined3d.h  |  3 +--
 6 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 0e7fc95..ef898d1 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -1831,17 +1831,17 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
 }
 
 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
-        void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
-        enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
+        void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
+        struct wined3d_surface **surface)
 {
     struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
 
-    TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
-            "\tpool %#x, sub_resource_idx %u, surface %p.\n",
-            device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
+    TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
+            device_parent, container_parent, desc, sub_resource_idx, surface);
 
-    return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
-            WINED3D_MULTISAMPLE_NONE, 0, 0, container_parent, &d3d10_null_wined3d_parent_ops, surface);
+    return wined3d_surface_create(device->wined3d_device, desc->width, desc->height, desc->format,
+            desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality, 0,
+            container_parent, &d3d10_null_wined3d_parent_ops, surface);
 }
 
 static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index a94d3bd..737519f 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2878,24 +2878,23 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
 }
 
 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
-        void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
-        enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
+        void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
+        struct wined3d_surface **surface)
 {
     struct d3d8_device *device = device_from_device_parent(device_parent);
     struct d3d8_surface *d3d_surface;
     BOOL lockable = TRUE;
     HRESULT hr;
 
-    TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
-            "\tpool %#x, sub_resource_idx %u, surface %p.\n",
-            device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
+    TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
+            device_parent, container_parent, desc, sub_resource_idx, surface);
 
-
-    if (pool == WINED3D_POOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC))
+    if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
         lockable = FALSE;
 
-    if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
-            lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
+    if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
+            d3dformat_from_wined3dformat(desc->format), lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface,
+            desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
     {
         WARN("Failed to create surface, hr %#x.\n", hr);
         return hr;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 7b53790..323bce7 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3259,23 +3259,23 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
 }
 
 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
-        void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
-        enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
+        void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
+        struct wined3d_surface **surface)
 {
     struct d3d9_device *device = device_from_device_parent(device_parent);
     struct d3d9_surface *d3d_surface;
     BOOL lockable = TRUE;
     HRESULT hr;
 
-    TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
-            "\tpool %#x, sub_resource_idx %u, surface %p.\n",
-            device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
+    TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
+            device_parent, container_parent, desc, sub_resource_idx, surface);
 
-    if (pool == WINED3D_POOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC))
+    if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
         lockable = FALSE;
 
-    if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
-            lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
+    if (FAILED(hr = d3d9_device_create_surface(device, desc->width, desc->height,
+            d3dformat_from_wined3dformat(desc->format), lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface,
+            desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
     {
         WARN("Failed to create surface, hr %#x.\n", hr);
         return hr;
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 6836d12..84965c1 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -5094,8 +5094,8 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
 }
 
 static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
-        void *container_parent, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
-        enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
+        void *container_parent, const struct wined3d_resource_desc *wined3d_desc, UINT sub_resource_idx,
+        struct wined3d_surface **surface)
 {
     struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
     struct ddraw_surface *tex_root = container_parent;
@@ -5103,9 +5103,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
     struct ddraw_surface *ddraw_surface;
     HRESULT hr;
 
-    TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
-            "\tpool %#x, sub_resource_idx %u, surface %p.\n",
-            device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
+    TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, surface %p.\n",
+            device_parent, container_parent, wined3d_desc, sub_resource_idx, surface);
 
     /* The ddraw root surface is created before the wined3d texture. */
     if (!sub_resource_idx)
@@ -5114,8 +5113,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
         goto done;
     }
 
-    desc.dwWidth = width;
-    desc.dwHeight = height;
+    desc.dwWidth = wined3d_desc->width;
+    desc.dwHeight = wined3d_desc->height;
 
     /* FIXME: Validate that format, usage, pool, etc. really make sense. */
     if (FAILED(hr = ddraw_create_surface(ddraw, &desc, &ddraw_surface, tex_root->version)))
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 2cf125f..e4ef6e8 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -760,8 +760,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
+    struct wined3d_resource_desc desc;
     unsigned int i, j;
-    UINT tmp_w;
     HRESULT hr;
 
     /* TODO: It should only be possible to create textures for formats
@@ -836,7 +836,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
     texture->target = GL_TEXTURE_CUBE_MAP_ARB;
 
     /* Generate all the surfaces. */
-    tmp_w = edge_length;
+    wined3d_resource_get_desc(&texture->resource, &desc);
+    desc.resource_type = WINED3D_RTYPE_SURFACE;
     for (i = 0; i < texture->level_count; ++i)
     {
         /* Create the 6 faces. */
@@ -855,7 +856,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
             struct wined3d_surface *surface;
 
             if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
-                    parent, tmp_w, tmp_w, format_id, usage, pool, idx, &surface)))
+                    parent, &desc, idx, &surface)))
             {
                 FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
                 wined3d_texture_cleanup(texture);
@@ -867,7 +868,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
             texture->sub_resources[idx] = &surface->resource;
             TRACE("Created surface level %u @ %p.\n", i, surface);
         }
-        tmp_w = max(1, tmp_w >> 1);
+        desc.width = max(1, desc.width >> 1);
+        desc.height = desc.width;
     }
 
     return WINED3D_OK;
@@ -879,8 +881,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
+    struct wined3d_resource_desc desc;
     UINT pow2_width, pow2_height;
-    UINT tmp_w, tmp_h;
     unsigned int i;
     HRESULT hr;
 
@@ -1005,15 +1007,15 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
     TRACE("xf(%f) yf(%f)\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
 
     /* Generate all the surfaces. */
-    tmp_w = width;
-    tmp_h = height;
+    wined3d_resource_get_desc(&texture->resource, &desc);
+    desc.resource_type = WINED3D_RTYPE_SURFACE;
     for (i = 0; i < texture->level_count; ++i)
     {
         struct wined3d_surface *surface;
 
         /* Use the callback to create the texture surface. */
         if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
-                parent, tmp_w, tmp_h, format->id, usage, pool, i, &surface)))
+                parent, &desc, i, &surface)))
         {
             FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
             wined3d_texture_cleanup(texture);
@@ -1025,8 +1027,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
         texture->sub_resources[i] = &surface->resource;
         TRACE("Created surface level %u @ %p.\n", i, surface);
         /* Calculate the next mipmap level. */
-        tmp_w = max(1, tmp_w >> 1);
-        tmp_h = max(1, tmp_h >> 1);
+        desc.width = max(1, desc.width >> 1);
+        desc.height = max(1, desc.height >> 1);
     }
 
     return WINED3D_OK;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 27575bb..6f2a51d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1986,8 +1986,7 @@ struct wined3d_device_parent_ops
             enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
             struct wined3d_surface **surface);
     HRESULT (__cdecl *create_texture_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
-            UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
-            UINT sub_resource_idx, struct wined3d_surface **surface);
+            const struct wined3d_resource_desc *desc, UINT sub_resource_idx, struct wined3d_surface **surface);
     HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
             UINT width, UINT height, UINT depth, enum wined3d_format_id format_id, enum wined3d_pool pool, DWORD usage,
             struct wined3d_volume **volume);
-- 
1.8.1.5




More information about the wine-patches mailing list