From: Riccardo Bortolato Subject: [PATCH 01/12] wined3d: store wined3d_texture and sub_resource_idx in d3dX volumes Message-Id: <1442996856-32611-1-git-send-email-rikyz619@gmail.com> Date: Wed, 23 Sep 2015 10:27:25 +0200 also removed the wined3d_volume member from the d3dX_volume structs as it is now useless --- dlls/d3d11/device.c | 8 ++++---- dlls/d3d8/d3d8_private.h | 7 ++++--- dlls/d3d8/device.c | 10 +++++----- dlls/d3d8/volume.c | 27 ++++++++++++++++++--------- dlls/d3d9/d3d9_private.h | 7 ++++--- dlls/d3d9/device.c | 10 +++++----- dlls/d3d9/volume.c | 27 ++++++++++++++++++--------- dlls/ddraw/ddraw.c | 6 +++--- dlls/wined3d/volume.c | 2 +- include/wine/wined3d.h | 5 +++-- 10 files changed, 65 insertions(+), 44 deletions(-) diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 65524d3..8e50918 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -2941,11 +2941,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_texture* wined3d_texture, unsigned int sub_resource_idx, + 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, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", + device_parent, wined3d_texture, sub_resource_idx, 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..ab6a3d4 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -204,12 +204,13 @@ struct d3d8_volume { IDirect3DVolume8 IDirect3DVolume8_iface; struct d3d8_resource resource; - struct wined3d_volume *wined3d_volume; + struct wined3d_texture *wined3d_texture; + unsigned int sub_resource_idx; 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, 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..0eebd8d 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, + 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, parent %p, parent_ops %p.\n", + device_parent, wined3d_texture, sub_resource_idx, 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, 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 d116b16..cba06bc 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -116,13 +116,13 @@ static HRESULT WINAPI d3d8_volume_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DES { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); struct wined3d_resource_desc wined3d_desc; - struct wined3d_resource *wined3d_resource; + struct wined3d_resource *sub_resource; TRACE("iface %p, desc %p.\n", iface, desc); wined3d_mutex_lock(); - wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume); - wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_resource_get_desc(sub_resource, &wined3d_desc); wined3d_mutex_unlock(); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); @@ -141,6 +141,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); + struct wined3d_resource *sub_resource; + struct wined3d_volume *wined3d_volume; struct wined3d_map_desc map_desc; HRESULT hr; @@ -148,7 +150,9 @@ 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); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_volume = wined3d_volume_from_resource(sub_resource); + hr = wined3d_volume_map(wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; @@ -161,12 +165,16 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); + struct wined3d_resource *sub_resource; + struct wined3d_volume *wined3d_volume; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - hr = wined3d_volume_unmap(volume->wined3d_volume); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_volume = wined3d_volume_from_resource(sub_resource); + hr = wined3d_volume_unmap(wined3d_volume); wined3d_mutex_unlock(); return hr; @@ -201,14 +209,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, 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..ea0d3e6 100644 --- a/dlls/d3d9/d3d9_private.h +++ b/dlls/d3d9/d3d9_private.h @@ -191,12 +191,13 @@ struct d3d9_volume { IDirect3DVolume9 IDirect3DVolume9_iface; struct d3d9_resource resource; - struct wined3d_volume *wined3d_volume; + struct wined3d_texture *wined3d_texture; + unsigned int sub_resource_idx; 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, 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..608c341 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, - const struct wined3d_parent_ops **parent_ops) + struct wined3d_texture* wined3d_texture, unsigned int sub_resource_idx, + 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, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", + device_parent, wined3d_texture, sub_resource_idx, 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, 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..4c258b9 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -117,13 +117,13 @@ static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DES { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); struct wined3d_resource_desc wined3d_desc; - struct wined3d_resource *wined3d_resource; + struct wined3d_resource *sub_resource; TRACE("iface %p, desc %p.\n", iface, desc); wined3d_mutex_lock(); - wined3d_resource = wined3d_volume_get_resource(volume->wined3d_volume); - wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_resource_get_desc(sub_resource, &wined3d_desc); wined3d_mutex_unlock(); desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); @@ -141,6 +141,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); + struct wined3d_resource *sub_resource; + struct wined3d_volume *wined3d_volume; struct wined3d_map_desc map_desc; HRESULT hr; @@ -148,7 +150,9 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, iface, locked_box, box, flags); wined3d_mutex_lock(); - hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_volume = wined3d_volume_from_resource(sub_resource); + hr = wined3d_volume_map(wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; @@ -161,12 +165,16 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, static HRESULT WINAPI d3d9_volume_UnlockBox(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); + struct wined3d_resource *sub_resource; + struct wined3d_volume *wined3d_volume; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - hr = wined3d_volume_unmap(volume->wined3d_volume); + sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); + wined3d_volume = wined3d_volume_from_resource(sub_resource); + hr = wined3d_volume_unmap(wined3d_volume); wined3d_mutex_unlock(); return hr; @@ -201,14 +209,15 @@ 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, 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); + 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..0aaccd8 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, 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, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", + device_parent, wined3d_texture, sub_resource_idx, 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 2daa55e..934245d 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))) + container, level, &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 ac1e59e..995f31f 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2032,8 +2032,9 @@ 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, - struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops); + HRESULT (__cdecl *volume_created)(struct wined3d_device_parent *device_parent, + struct wined3d_texture *texture, unsigned int sub_resource_idx, + 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); HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent, -- 1.9.1