[v2 03/10] wined3d: pass wined3d_texture and sub_resource idx to device_volume_created callback

Riccardo Bortolato rikyz619 at gmail.com
Tue Oct 6 02:26:11 CDT 2015


Store wined3d_texture and sub_resource in d3d8_volume.
Updated the d3d8_volume_LockBox to make use of wined3d_texture_map.
Also updated d3d9, d3d11, ddraw callbacks accordingly
---
 dlls/d3d11/device.c      |  6 +++---
 dlls/d3d8/d3d8_private.h |  6 ++++--
 dlls/d3d8/device.c       | 10 +++++-----
 dlls/d3d8/volume.c       | 12 +++++++-----
 dlls/d3d9/d3d9_private.h |  4 ++--
 dlls/d3d9/device.c       |  8 ++++----
 dlls/d3d9/volume.c       |  6 +++---
 dlls/ddraw/ddraw.c       |  6 +++---
 dlls/wined3d/volume.c    |  2 +-
 include/wine/wined3d.h   |  3 ++-
 10 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index f56d3a9..40ad407 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2950,11 +2950,11 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
 }
 
 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_volume *volume, void **parent,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_volume *volume, void **parent,
         const struct wined3d_parent_ops **parent_ops)
 {
-    TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, volume, parent, parent_ops);
+    TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
+            device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
 
     *parent = NULL;
     *parent_ops = &d3d10_null_wined3d_parent_ops;
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 6283c8d..aec4831 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -204,12 +204,14 @@ struct d3d8_volume
 {
     IDirect3DVolume8 IDirect3DVolume8_iface;
     struct d3d8_resource resource;
+    struct wined3d_texture *wined3d_texture;
+    unsigned int sub_resource_idx;
     struct wined3d_volume *wined3d_volume;
     struct d3d8_texture *texture;
 };
 
-void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture,
-        struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
+void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture,
+        unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
 
 struct d3d8_swapchain
 {
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index e899b34..a7539de 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -3017,18 +3017,18 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
 }
 
 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_volume *volume, void **parent,
-        const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
+        struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops)
 {
     struct d3d8_volume *d3d_volume;
 
-    TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, volume, parent, parent_ops);
+    TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
+            device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
 
     if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
         return E_OUTOFMEMORY;
 
-    volume_init(d3d_volume, container_parent, volume, parent_ops);
+    volume_init(d3d_volume, wined3d_texture, sub_resource_idx, volume, parent_ops);
     *parent = d3d_volume;
     TRACE("Created volume %p.\n", d3d_volume);
 
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c
index 077ec72..ee70a5f 100644
--- a/dlls/d3d8/volume.c
+++ b/dlls/d3d8/volume.c
@@ -148,7 +148,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
             iface, locked_box, box, flags);
 
     wined3d_mutex_lock();
-    hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags);
+    hr = wined3d_texture_map(volume->wined3d_texture, volume->sub_resource_idx,
+            &map_desc, (const struct wined3d_box *)box, flags);
     wined3d_mutex_unlock();
 
     locked_box->RowPitch = map_desc.row_pitch;
@@ -201,14 +202,15 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
     volume_wined3d_object_destroyed,
 };
 
-void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture,
-        struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
+void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture,
+        unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
 {
     volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
     d3d8_resource_init(&volume->resource);
     volume->resource.refcount = 0;
-    volume->wined3d_volume = wined3d_volume;
-    volume->texture = texture;
+    volume->texture = wined3d_texture_get_parent(wined3d_texture);
+    volume->wined3d_texture = wined3d_texture;
+    volume->sub_resource_idx = sub_resource_idx;
 
     *parent_ops = &d3d8_volume_wined3d_parent_ops;
 }
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index d12805f..a1b824b 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -195,8 +195,8 @@ struct d3d9_volume
     struct d3d9_texture *texture;
 };
 
-void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture,
-        struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
+void volume_init(struct d3d9_volume *volume, struct wined3d_texture *wined3d_texture,
+        unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
 
 struct d3d9_swapchain
 {
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 3a0376d..5568cc8 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3553,18 +3553,18 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
 }
 
 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_volume *volume, void **parent,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_volume *volume, void **parent,
         const struct wined3d_parent_ops **parent_ops)
 {
     struct d3d9_volume *d3d_volume;
 
-    TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, volume, parent, parent_ops);
+    TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
+            device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
 
     if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
         return E_OUTOFMEMORY;
 
-    volume_init(d3d_volume, container_parent, volume, parent_ops);
+    volume_init(d3d_volume, wined3d_texture, sub_resource_idx, volume, parent_ops);
     *parent = d3d_volume;
     TRACE("Created volume %p.\n", d3d_volume);
 
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index 4b22f20..603fb6e 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -201,14 +201,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
     volume_wined3d_object_destroyed,
 };
 
-void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture,
-        struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
+void volume_init(struct d3d9_volume *volume, struct wined3d_texture *wined3d_texture,
+        unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
 {
     volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl;
     d3d9_resource_init(&volume->resource);
     volume->resource.refcount = 0;
     volume->wined3d_volume = wined3d_volume;
-    volume->texture = texture;
+    volume->texture = wined3d_texture_get_parent(wined3d_texture);
 
     *parent_ops = &d3d9_volume_wined3d_parent_ops;
 }
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index c94bfee..aef9963 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -4746,11 +4746,11 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
 }
 
 static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_volume *volume,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_volume *volume,
         void **parent, const struct wined3d_parent_ops **parent_ops)
 {
-    TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, volume, parent, parent_ops);
+    TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
+            device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
 
     *parent = NULL;
     *parent_ops = &ddraw_null_wined3d_parent_ops;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 45a2fee..099927c 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -791,7 +791,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi
     }
 
     if (FAILED(hr = device_parent->ops->volume_created(device_parent,
-            wined3d_texture_get_parent(container), object, &parent, &parent_ops)))
+            container, level, object, &parent, &parent_ops)))
     {
         WARN("Failed to create volume parent, hr %#x.\n", hr);
         wined3d_volume_destroy(object);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 7dc51ae..c9448df 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2032,7 +2032,8 @@ struct wined3d_device_parent_ops
     void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate);
     HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent,
             struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops);
-    HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent, void *container_parent,
+    HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent,
+            struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
             struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops);
     HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent,
             const struct wined3d_resource_desc *desc, struct wined3d_texture **texture);
-- 
1.9.1




More information about the wine-patches mailing list