[PATCH 1/7] wined3d: store wined3d_texture and sub_resource_idx in d3d8, d3d9 and ddraw surfaces and volumes

Riccardo Bortolato rikyz619 at gmail.com
Mon Sep 14 06:13:58 CDT 2015


Removed the container_parent from {surface,volume}_created callback since it can now be fetched from within d3dX and ddraw with wined3d_texture_get_parent
---
 dlls/d3d11/device.c        | 16 ++++++++--------
 dlls/d3d8/d3d8_private.h   | 14 ++++++++++----
 dlls/d3d8/device.c         | 21 +++++++++++----------
 dlls/d3d8/surface.c        | 11 +++++++----
 dlls/d3d8/volume.c         |  9 ++++++---
 dlls/d3d9/d3d9_private.h   | 14 ++++++++++----
 dlls/d3d9/device.c         | 21 +++++++++++----------
 dlls/d3d9/surface.c        | 11 +++++++----
 dlls/d3d9/volume.c         |  9 ++++++---
 dlls/ddraw/ddraw.c         | 20 ++++++++++----------
 dlls/ddraw/ddraw_private.h |  7 ++++---
 dlls/ddraw/surface.c       | 12 +++++++-----
 dlls/wined3d/surface.c     |  3 ++-
 dlls/wined3d/volume.c      |  2 +-
 include/wine/wined3d.h     | 10 ++++++----
 15 files changed, 106 insertions(+), 74 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index dcaa49c..5faf44a 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2926,11 +2926,11 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
 }
 
 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_surface *surface, void **parent,
-        const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
-    TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, surface, parent, parent_ops);
+    TRACE("device_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, surface, parent, parent_ops, texture, sub_resource_idx);
 
     *parent = NULL;
     *parent_ops = &d3d10_null_wined3d_parent_ops;
@@ -2939,11 +2939,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,
-        const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
-    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, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, volume, parent, parent_ops, texture, sub_resource_idx);
 
     *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..9b12a49 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -206,10 +206,13 @@ struct d3d8_volume
     struct d3d8_resource resource;
     struct wined3d_volume *wined3d_volume;
     struct d3d8_texture *texture;
+    struct wined3d_texture *wined3d_texture;
+    UINT sub_resource_idx;
 };
 
-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_volume *wined3d_volume,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
 
 struct d3d8_swapchain
 {
@@ -232,11 +235,14 @@ struct d3d8_surface
     IDirect3DDevice8 *parent_device;
     IUnknown *container;
     struct d3d8_texture *texture;
+    struct wined3d_texture *wined3d_texture;
+    UINT sub_resource_idx;
 };
 
 struct wined3d_rendertarget_view *d3d8_surface_get_rendertarget_view(struct d3d8_surface *surface) DECLSPEC_HIDDEN;
-void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
+void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
 struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
 
 struct d3d8_vertexbuffer
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index e899b34..bbd0fd0 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -981,6 +981,7 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
     sub_resource = wined3d_texture_get_sub_resource(texture, 0);
     surface_impl = wined3d_resource_get_parent(sub_resource);
     surface_impl->parent_device = &device->IDirect3DDevice8_iface;
+    surface_impl->wined3d_texture = texture;
     *surface = &surface_impl->IDirect3DSurface8_iface;
     IDirect3DSurface8_AddRef(*surface);
     wined3d_texture_decref(texture);
@@ -2998,18 +2999,18 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
 }
 
 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_surface *surface, void **parent,
-        const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_surface *surface, void **parent,
+        const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
     struct d3d8_surface *d3d_surface;
 
-    TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, surface, parent, parent_ops);
+    TRACE("device_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, surface, parent, parent_ops, texture, sub_resource_idx);
 
     if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
         return E_OUTOFMEMORY;
 
-    surface_init(d3d_surface, container_parent, surface, parent_ops);
+    surface_init(d3d_surface, surface, parent_ops, texture, sub_resource_idx);
     *parent = d3d_surface;
     TRACE("Created surface %p.\n", d3d_surface);
 
@@ -3017,18 +3018,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_volume *volume, void **parent,
+        const struct wined3d_parent_ops **parent_ops, struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
     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, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, volume, parent, parent_ops, texture, sub_resource_idx);
 
     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, volume, parent_ops, texture, sub_resource_idx);
     *parent = d3d_volume;
     TRACE("Created volume %p.\n", d3d_volume);
 
diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c
index 7779a56..437e997 100644
--- a/dlls/d3d8/surface.c
+++ b/dlls/d3d8/surface.c
@@ -292,8 +292,9 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
     surface_wined3d_object_destroyed,
 };
 
-void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
+void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx)
 {
     IDirect3DBaseTexture8 *texture;
 
@@ -302,9 +303,11 @@ void surface_init(struct d3d8_surface *surface, IUnknown *container_parent,
     surface->resource.refcount = 0;
     surface->wined3d_surface = wined3d_surface;
     list_init(&surface->rtv_entry);
-    surface->container = container_parent;
+    surface->container = wined3d_texture_get_parent(wined3d_texture);
+    surface->wined3d_texture = wined3d_texture;
+    surface->sub_resource_idx = sub_resource_idx;
 
-    if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
+    if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
             &IID_IDirect3DBaseTexture8, (void **)&texture)))
     {
         surface->texture = unsafe_impl_from_IDirect3DBaseTexture8(texture);
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c
index d116b16..d66c770 100644
--- a/dlls/d3d8/volume.c
+++ b/dlls/d3d8/volume.c
@@ -201,14 +201,17 @@ 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_volume *wined3d_volume,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx)
 {
     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..d1eebbb 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -193,10 +193,13 @@ struct d3d9_volume
     struct d3d9_resource resource;
     struct wined3d_volume *wined3d_volume;
     struct d3d9_texture *texture;
+    struct wined3d_texture *wined3d_texture;
+    UINT sub_resource_idx;
 };
 
-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_volume *wined3d_volume,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
 
 struct d3d9_swapchain
 {
@@ -220,11 +223,14 @@ struct d3d9_surface
     IUnknown *container;
     struct d3d9_texture *texture;
     BOOL getdc_supported;
+    struct wined3d_texture *wined3d_texture;
+    UINT sub_resource_idx;
 };
 
 struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN;
-void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
+void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
 struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
 
 struct d3d9_vertexbuffer
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 3a0376d..6bab789 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1121,6 +1121,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
     sub_resource = wined3d_texture_get_sub_resource(texture, 0);
     surface_impl = wined3d_resource_get_parent(sub_resource);
     surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface;
+    surface_impl->wined3d_texture = texture;
     *surface = &surface_impl->IDirect3DSurface9_iface;
     IDirect3DSurface9_AddRef(*surface);
 
@@ -3534,18 +3535,18 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
 }
 
 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_surface *surface, void **parent,
-        const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
     struct d3d9_surface *d3d_surface;
 
-    TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, surface, parent, parent_ops);
+    TRACE("device_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, surface, parent, parent_ops, texture, sub_resource_idx);
 
     if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
         return E_OUTOFMEMORY;
 
-    surface_init(d3d_surface, container_parent, surface, parent_ops);
+    surface_init(d3d_surface, surface, parent_ops, texture, sub_resource_idx);
     *parent = d3d_surface;
     TRACE("Created surface %p.\n", d3d_surface);
 
@@ -3553,18 +3554,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_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
     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, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, volume, parent, parent_ops, texture, sub_resource_idx);
 
     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, volume, parent_ops, texture, sub_resource_idx);
     *parent = d3d_volume;
     TRACE("Created volume %p.\n", d3d_volume);
 
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index e5eb11f..47a941c 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -345,8 +345,9 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
     surface_wined3d_object_destroyed,
 };
 
-void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
+void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx)
 {
     struct wined3d_resource_desc desc;
     IDirect3DBaseTexture9 *texture;
@@ -356,9 +357,11 @@ void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
     surface->resource.refcount = 0;
     surface->wined3d_surface = wined3d_surface;
     list_init(&surface->rtv_entry);
-    surface->container = container_parent;
+    surface->container = wined3d_texture_get_parent(wined3d_texture);
+    surface->wined3d_texture = wined3d_texture;
+    surface->sub_resource_idx = sub_resource_idx;
 
-    if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
+    if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
             &IID_IDirect3DBaseTexture9, (void **)&texture)))
     {
         surface->texture = unsafe_impl_from_IDirect3DBaseTexture9(texture);
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index 4b22f20..83eaa7c 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -201,14 +201,17 @@ 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_volume *wined3d_volume,
+        const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx)
 {
     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);
+    volume->wined3d_texture = wined3d_texture;
+    volume->sub_resource_idx = sub_resource_idx;
 
     *parent_ops = &d3d9_volume_wined3d_parent_ops;
 }
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index c94bfee..9cc0d0c 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -4712,17 +4712,17 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa
 }
 
 static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
-        void *container_parent, struct wined3d_surface *surface,
-        void **parent, const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
     struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
     struct ddraw_surface *ddraw_surface;
 
-    TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
-            device_parent, container_parent, surface, parent, parent_ops);
+    TRACE("device_parent %p, surface %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, surface, parent, parent_ops, texture, sub_resource_idx);
 
     /* We have a swapchain or wined3d internal texture. */
-    if (!container_parent || container_parent == ddraw)
+    if (!texture || wined3d_texture_get_parent(texture) == ddraw)
     {
         *parent = NULL;
         *parent_ops = &ddraw_null_wined3d_parent_ops;
@@ -4736,7 +4736,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
         return DDERR_OUTOFVIDEOMEMORY;
     }
 
-    ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops);
+    ddraw_surface_init(ddraw_surface, ddraw, surface, parent_ops, texture, sub_resource_idx);
     *parent = ddraw_surface;
     list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
 
@@ -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,
-        void **parent, const struct wined3d_parent_ops **parent_ops)
+        struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *texture, unsigned int sub_resource_idx)
 {
-    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, volume %p, parent %p, parent_ops %p, texture %p, index %u.\n",
+            device_parent, volume, parent, parent_ops, texture, sub_resource_idx);
 
     *parent = NULL;
     *parent_ops = &ddraw_null_wined3d_parent_ops;
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index bb0a3f8..35cb7ac 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -186,7 +186,7 @@ struct ddraw_surface
     DDSURFACEDESC2          surface_desc;
 
     /* Misc things */
-    UINT                    mipmap_level;
+    UINT                    sub_resource_idx;
 
     /* Clipper objects */
     struct ddraw_clipper *clipper;
@@ -209,8 +209,9 @@ struct ddraw_texture
 HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_desc,
         struct ddraw_surface **surface, IUnknown *outer_unknown, unsigned int version) DECLSPEC_HIDDEN;
 struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
-void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
+void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
+        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
 ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
 HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
         const RECT *rect, BOOL read) DECLSPEC_HIDDEN;
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 6b6ddb9..0654214 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -777,7 +777,6 @@ static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *ifa
              */
 
             TRACE("(%p): Returning surface %p\n", This, surf);
-            TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level);
             *Surface = &surf->IDirectDrawSurface7_iface;
             ddraw_surface7_AddRef(*Surface);
             wined3d_mutex_unlock();
@@ -5101,8 +5100,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu
         struct ddraw_palette *dst_pal, *src_pal;
         DDSURFACEDESC *src_desc, *dst_desc;
 
-        TRACE("Copying surface %p to surface %p (mipmap level %d).\n",
-                src_surface, dst_surface, src_surface->mipmap_level);
+        TRACE("Copying surface %p to surface %p.\n", src_surface, dst_surface);
 
         /* Suppress the ALLOCONLOAD flag */
         dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
@@ -6228,11 +6226,13 @@ fail:
     return hr;
 }
 
-void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
-        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
+void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
+        struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops,
+        struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx)
 {
     DDSURFACEDESC2 *desc = &surface->surface_desc;
     struct wined3d_resource_desc wined3d_desc;
+    struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
     unsigned int version = texture->version;
 
     surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
@@ -6246,6 +6246,8 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru
     surface->iface_count = 1;
     surface->version = version;
     surface->ddraw = ddraw;
+    surface->wined3d_texture = wined3d_texture;
+    surface->sub_resource_idx = sub_resource_idx;
 
     if (version == 7)
     {
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 999423d..4abcd78 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -5395,6 +5395,7 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w
     struct wined3d_surface *object;
     void *parent;
     HRESULT hr;
+    UINT sub_resource_idx = layer * container->level_count + level;
 
     TRACE("container %p, width %u, height %u, format %s, usage %s (%#x), pool %s, "
             "multisample_type %#x, multisample_quality %u, target %#x, level %u, layer %u, flags %#x, surface %p.\n",
@@ -5413,7 +5414,7 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w
     }
 
     if (FAILED(hr = device_parent->ops->surface_created(device_parent,
-            wined3d_texture_get_parent(container), object, &parent, &parent_ops)))
+            object, &parent, &parent_ops, container, sub_resource_idx)))
     {
         WARN("Failed to create surface parent, hr %#x.\n", hr);
         wined3d_surface_destroy(object);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 2daa55e..5582cb0 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -796,7 +796,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)))
+            object, &parent, &parent_ops, container, level)))
     {
         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 ac1e59e..36d875d 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2030,10 +2030,12 @@ struct wined3d_device_parent_ops
     void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
     void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
     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,
-            struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops);
+    HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent,
+            struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops,
+            struct wined3d_texture *texture, unsigned int sub_resource_idx);
+    HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent,
+            struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops,
+            struct wined3d_texture *texture, unsigned int sub_resource_idx);
     HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent,
             const struct wined3d_resource_desc *desc, struct wined3d_texture **texture);
     HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
-- 
1.9.1




More information about the wine-patches mailing list