[PATCH 1/5] wined3d: Pass a wined3d_resource_desc structure to wined3d_texture_create_3d().

Henri Verbeet hverbeet at codeweavers.com
Thu Jun 6 03:51:46 CDT 2013


---
 dlls/d3d10core/texture.c  | 18 ++++++++++---
 dlls/d3d8/texture.c       | 17 ++++++++++---
 dlls/d3d9/texture.c       | 17 ++++++++++---
 dlls/wined3d/texture.c    | 65 ++++++++++++++++++-----------------------------
 dlls/wined3d/wined3d.spec |  2 +-
 include/wine/wined3d.h    |  5 ++--
 6 files changed, 70 insertions(+), 54 deletions(-)

diff --git a/dlls/d3d10core/texture.c b/dlls/d3d10core/texture.c
index f2aa13a..d5e2bf8 100644
--- a/dlls/d3d10core/texture.c
+++ b/dlls/d3d10core/texture.c
@@ -475,6 +475,7 @@ static const struct wined3d_parent_ops d3d10_texture3d_wined3d_parent_ops =
 HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_device *device,
         const D3D10_TEXTURE3D_DESC *desc)
 {
+    struct wined3d_resource_desc wined3d_desc;
     HRESULT hr;
 
     texture->ID3D10Texture3D_iface.lpVtbl = &d3d10_texture3d_vtbl;
@@ -483,10 +484,19 @@ HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_devic
 
     FIXME("Implement DXGI<->wined3d usage conversion.\n");
 
-    hr = wined3d_texture_create_3d(device->wined3d_device, desc->Width, desc->Height, desc->Depth,
-            desc->MipLevels, desc->Usage, wined3dformat_from_dxgi_format(desc->Format), WINED3D_POOL_DEFAULT,
-            texture, &d3d10_texture3d_wined3d_parent_ops, &texture->wined3d_texture);
-    if (FAILED(hr))
+    wined3d_desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE;
+    wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format);
+    wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
+    wined3d_desc.multisample_quality = 0;
+    wined3d_desc.usage = desc->Usage;
+    wined3d_desc.pool = WINED3D_POOL_DEFAULT;
+    wined3d_desc.width = desc->Width;
+    wined3d_desc.height = desc->Height;
+    wined3d_desc.depth = desc->Depth;
+    wined3d_desc.size = 0;
+
+    if (FAILED(hr = wined3d_texture_create_3d(device->wined3d_device, &wined3d_desc, desc->MipLevels,
+            texture, &d3d10_texture3d_wined3d_parent_ops, &texture->wined3d_texture)))
     {
         WARN("Failed to create wined3d texture, hr %#x.\n", hr);
         return hr;
diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c
index 3309080..a4dcd4d 100644
--- a/dlls/d3d8/texture.c
+++ b/dlls/d3d8/texture.c
@@ -1257,15 +1257,26 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic
 HRESULT volumetexture_init(struct d3d8_texture *texture, struct d3d8_device *device,
         UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
 {
+    struct wined3d_resource_desc desc;
     HRESULT hr;
 
     texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DVolumeTexture8_Vtbl;
     texture->refcount = 1;
 
+    desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE;
+    desc.format = wined3dformat_from_d3dformat(format);
+    desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
+    desc.multisample_quality = 0;
+    desc.usage = usage & WINED3DUSAGE_MASK;
+    desc.pool = pool;
+    desc.width = width;
+    desc.height = height;
+    desc.depth = depth;
+    desc.size = 0;
+
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
-            usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
-            &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
+    hr = wined3d_texture_create_3d(device->wined3d_device, &desc, levels,
+            texture, &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
     if (FAILED(hr))
     {
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index 36b9655..6add792 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -1381,15 +1381,26 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
 HRESULT volumetexture_init(struct d3d9_texture *texture, struct d3d9_device *device,
         UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
 {
+    struct wined3d_resource_desc desc;
     HRESULT hr;
 
     texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_3d_vtbl;
     texture->refcount = 1;
 
+    desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE;
+    desc.format = wined3dformat_from_d3dformat(format);
+    desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
+    desc.multisample_quality = 0;
+    desc.usage = usage & WINED3DUSAGE_MASK;
+    desc.pool = pool;
+    desc.width = width;
+    desc.height = height;
+    desc.depth = depth;
+    desc.size = 0;
+
     wined3d_mutex_lock();
-    hr = wined3d_texture_create_3d(device->wined3d_device, width, height, depth, levels,
-            usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(format), pool, texture,
-            &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
+    hr = wined3d_texture_create_3d(device->wined3d_device, &desc, levels,
+            texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
     wined3d_mutex_unlock();
     if (FAILED(hr))
     {
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index e8482c3..459af86 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1153,19 +1153,17 @@ static const struct wined3d_resource_ops texture3d_resource_ops =
     texture3d_unload,
 };
 
-static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, UINT height,
-        UINT depth, UINT levels, struct wined3d_device *device, DWORD usage, enum wined3d_format_id format_id,
-        enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops)
+static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
+        UINT levels, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
 {
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
-    struct wined3d_resource_desc desc;
     UINT tmp_w, tmp_h, tmp_d;
     unsigned int i;
     HRESULT hr;
 
     /* TODO: It should only be possible to create textures for formats
      * that are reported as supported. */
-    if (WINED3DFMT_UNKNOWN >= format_id)
+    if (WINED3DFMT_UNKNOWN >= desc->format)
     {
         WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
         return WINED3DERR_INVALIDCALL;
@@ -1178,7 +1176,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
     }
 
     /* Calculate levels for mip mapping. */
-    if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
+    if (desc->usage & WINED3DUSAGE_AUTOGENMIPMAP)
     {
         if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
         {
@@ -1196,7 +1194,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
     }
     else if (!levels)
     {
-        levels = wined3d_log2i(max(max(width, height), depth)) + 1;
+        levels = wined3d_log2i(max(max(desc->width, desc->height), desc->depth)) + 1;
         TRACE("Calculated levels = %u.\n", levels);
     }
 
@@ -1204,40 +1202,32 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
     {
         UINT pow2_w, pow2_h, pow2_d;
         pow2_w = 1;
-        while (pow2_w < width) pow2_w <<= 1;
+        while (pow2_w < desc->width)
+            pow2_w <<= 1;
         pow2_h = 1;
-        while (pow2_h < height) pow2_h <<= 1;
+        while (pow2_h < desc->height)
+            pow2_h <<= 1;
         pow2_d = 1;
-        while (pow2_d < depth) pow2_d <<= 1;
+        while (pow2_d < desc->depth)
+            pow2_d <<= 1;
 
-        if (pow2_w != width || pow2_h != height || pow2_d != depth)
+        if (pow2_w != desc->width || pow2_h != desc->height || pow2_d != desc->depth)
         {
-            if (pool == WINED3D_POOL_SCRATCH)
+            if (desc->pool == WINED3D_POOL_SCRATCH)
             {
                 WARN("Creating a scratch NPOT volume texture despite lack of HW support.\n");
             }
             else
             {
-                WARN("Attempted to create a NPOT volume texture (%u,%u,%u) without GL support.\n",
-                        width, height, depth);
+                WARN("Attempted to create a NPOT volume texture (%u, %u, %u) without GL support.\n",
+                        desc->width, desc->height, desc->depth);
                 return WINED3DERR_INVALIDCALL;
             }
         }
     }
 
-    desc.resource_type = WINED3D_RTYPE_VOLUME_TEXTURE;
-    desc.format = format_id;
-    desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
-    desc.multisample_quality = 0;
-    desc.usage = usage;
-    desc.pool = pool;
-    desc.width = width;
-    desc.height = height;
-    desc.depth = depth;
-    desc.size = 0;
-
     if (FAILED(hr = wined3d_texture_init(texture, &texture3d_ops, 1, levels,
-            &desc, device, parent, parent_ops, &texture3d_resource_ops)))
+            desc, device, parent, parent_ops, &texture3d_resource_ops)))
     {
         WARN("Failed to initialize texture, returning %#x.\n", hr);
         return hr;
@@ -1250,9 +1240,9 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
     texture->target = GL_TEXTURE_3D;
 
     /* Generate all the surfaces. */
-    tmp_w = width;
-    tmp_h = height;
-    tmp_d = depth;
+    tmp_w = desc->width;
+    tmp_h = desc->height;
+    tmp_d = desc->depth;
 
     for (i = 0; i < texture->level_count; ++i)
     {
@@ -1260,7 +1250,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, UINT width, U
 
         /* Create the volume. */
         hr = device->device_parent->ops->create_volume(device->device_parent, parent,
-                tmp_w, tmp_h, tmp_d, format_id, pool, usage, &volume);
+                tmp_w, tmp_h, tmp_d, desc->format, desc->pool, desc->usage, &volume);
         if (FAILED(hr))
         {
             ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
@@ -1311,17 +1301,14 @@ HRESULT CDECL wined3d_texture_create_2d(struct wined3d_device *device, const str
     return WINED3D_OK;
 }
 
-HRESULT CDECL wined3d_texture_create_3d(struct wined3d_device *device, UINT width, UINT height, UINT depth,
-        UINT level_count, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
-        const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
+HRESULT CDECL wined3d_texture_create_3d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
+        UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
 {
     struct wined3d_texture *object;
     HRESULT hr;
 
-    TRACE("device %p, width %u, height %u, depth %u, level_count %u, usage %#x\n",
-            device, width, height, depth, level_count, usage);
-    TRACE("format %s, pool %#x, parent %p, parent_ops %p, texture %p.\n",
-            debug_d3dformat(format_id), pool, parent, parent_ops, texture);
+    TRACE("device %p, desc %p, level_count %u, parent %p, parent_ops %p, texture %p.\n",
+            device, desc, level_count, parent, parent_ops, texture);
 
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
     if (!object)
@@ -1330,9 +1317,7 @@ HRESULT CDECL wined3d_texture_create_3d(struct wined3d_device *device, UINT widt
         return WINED3DERR_OUTOFVIDEOMEMORY;
     }
 
-    hr = volumetexture_init(object, width, height, depth, level_count,
-            device, usage, format_id, pool, parent, parent_ops);
-    if (FAILED(hr))
+    if (FAILED(hr = volumetexture_init(object, desc, level_count, device, parent, parent_ops)))
     {
         WARN("Failed to initialize volumetexture, returning %#x\n", hr);
         HeapFree(GetProcessHeap(), 0, object);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 3e42ace..3b20d0c 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -252,7 +252,7 @@
 
 @ cdecl wined3d_texture_add_dirty_region(ptr long ptr)
 @ cdecl wined3d_texture_create_2d(ptr ptr long ptr ptr ptr)
-@ cdecl wined3d_texture_create_3d(ptr long long long long long long long ptr ptr ptr)
+@ cdecl wined3d_texture_create_3d(ptr ptr long ptr ptr ptr)
 @ cdecl wined3d_texture_create_cube(ptr ptr long ptr ptr ptr)
 @ cdecl wined3d_texture_decref(ptr)
 @ cdecl wined3d_texture_generate_mipmaps(ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 9eab617..247d215 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2373,9 +2373,8 @@ HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture
         UINT layer, const struct wined3d_box *dirty_region);
 HRESULT __cdecl wined3d_texture_create_2d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
         UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
-HRESULT __cdecl wined3d_texture_create_3d(struct wined3d_device *device, UINT width, UINT height, UINT depth,
-        UINT level_count, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
-        const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
+HRESULT __cdecl wined3d_texture_create_3d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
+        UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
 HRESULT __cdecl wined3d_texture_create_cube(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
         UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
 ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
-- 
1.8.1.5




More information about the wine-patches mailing list