Commit 9621737c authored by Riccardo Bortolato's avatar Riccardo Bortolato Committed by Alexandre Julliard

wined3d: Pass wined3d_texture and sub_resource idx to device_volume_created callback.

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. Signed-off-by: 's avatarHenri Verbeet <hverbeet@codeweavers.com>
parent eac95d30
...@@ -2966,11 +2966,11 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -2966,11 +2966,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, 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) const struct wined3d_parent_ops **parent_ops)
{ {
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops); device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
*parent = NULL; *parent = NULL;
*parent_ops = &d3d10_null_wined3d_parent_ops; *parent_ops = &d3d10_null_wined3d_parent_ops;
......
...@@ -204,12 +204,14 @@ struct d3d8_volume ...@@ -204,12 +204,14 @@ struct d3d8_volume
{ {
IDirect3DVolume8 IDirect3DVolume8_iface; IDirect3DVolume8 IDirect3DVolume8_iface;
struct d3d8_resource resource; struct d3d8_resource resource;
struct wined3d_texture *wined3d_texture;
unsigned int sub_resource_idx;
struct wined3d_volume *wined3d_volume; struct wined3d_volume *wined3d_volume;
struct d3d8_texture *texture; struct d3d8_texture *texture;
}; };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture,
struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d8_swapchain struct d3d8_swapchain
{ {
......
...@@ -3018,18 +3018,18 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -3018,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, 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,
const struct wined3d_parent_ops **parent_ops) struct wined3d_volume *volume, void **parent, const struct wined3d_parent_ops **parent_ops)
{ {
struct d3d8_volume *d3d_volume; struct d3d8_volume *d3d_volume;
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops); device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
return E_OUTOFMEMORY; 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; *parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume); TRACE("Created volume %p.\n", d3d_volume);
......
...@@ -148,7 +148,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, ...@@ -148,7 +148,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface,
iface, locked_box, box, flags); iface, locked_box, box, flags);
wined3d_mutex_lock(); 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(); wined3d_mutex_unlock();
locked_box->RowPitch = map_desc.row_pitch; locked_box->RowPitch = map_desc.row_pitch;
...@@ -201,14 +202,16 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = ...@@ -201,14 +202,16 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
volume_wined3d_object_destroyed, volume_wined3d_object_destroyed,
}; };
void volume_init(struct d3d8_volume *volume, struct d3d8_texture *texture, void volume_init(struct d3d8_volume *volume, struct wined3d_texture *wined3d_texture,
struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
{ {
volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl; volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
d3d8_resource_init(&volume->resource); d3d8_resource_init(&volume->resource);
volume->resource.refcount = 0; volume->resource.refcount = 0;
volume->wined3d_volume = wined3d_volume; 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; *parent_ops = &d3d8_volume_wined3d_parent_ops;
} }
...@@ -195,8 +195,8 @@ struct d3d9_volume ...@@ -195,8 +195,8 @@ struct d3d9_volume
struct d3d9_texture *texture; struct d3d9_texture *texture;
}; };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, void volume_init(struct d3d9_volume *volume, struct wined3d_texture *wined3d_texture,
struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_swapchain struct d3d9_swapchain
{ {
......
...@@ -3553,18 +3553,18 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -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, 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) const struct wined3d_parent_ops **parent_ops)
{ {
struct d3d9_volume *d3d_volume; struct d3d9_volume *d3d_volume;
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops); device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume)))) if (!(d3d_volume = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_volume))))
return E_OUTOFMEMORY; 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; *parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume); TRACE("Created volume %p.\n", d3d_volume);
......
...@@ -201,14 +201,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = ...@@ -201,14 +201,14 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
volume_wined3d_object_destroyed, volume_wined3d_object_destroyed,
}; };
void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture, void volume_init(struct d3d9_volume *volume, struct wined3d_texture *wined3d_texture,
struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) unsigned int sub_resource_idx, struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops)
{ {
volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl; volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl;
d3d9_resource_init(&volume->resource); d3d9_resource_init(&volume->resource);
volume->resource.refcount = 0; volume->resource.refcount = 0;
volume->wined3d_volume = wined3d_volume; volume->wined3d_volume = wined3d_volume;
volume->texture = texture; volume->texture = wined3d_texture_get_parent(wined3d_texture);
*parent_ops = &d3d9_volume_wined3d_parent_ops; *parent_ops = &d3d9_volume_wined3d_parent_ops;
} }
...@@ -4746,11 +4746,11 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -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, 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) void **parent, const struct wined3d_parent_ops **parent_ops)
{ {
TRACE("device_parent %p, container_parent %p, volume %p, parent %p, parent_ops %p.\n", TRACE("device_parent %p, texture %p, sub_resource_idx %u, volume %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, volume, parent, parent_ops); device_parent, wined3d_texture, sub_resource_idx, volume, parent, parent_ops);
*parent = NULL; *parent = NULL;
*parent_ops = &ddraw_null_wined3d_parent_ops; *parent_ops = &ddraw_null_wined3d_parent_ops;
......
...@@ -791,7 +791,7 @@ HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wi ...@@ -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, 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); WARN("Failed to create volume parent, hr %#x.\n", hr);
wined3d_volume_destroy(object); wined3d_volume_destroy(object);
......
...@@ -2032,7 +2032,8 @@ struct wined3d_device_parent_ops ...@@ -2032,7 +2032,8 @@ struct wined3d_device_parent_ops
void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate); void (__cdecl *activate)(struct wined3d_device_parent *device_parent, BOOL activate);
HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent, 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); 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); 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, HRESULT (__cdecl *create_swapchain_texture)(struct wined3d_device_parent *device_parent, void *parent,
const struct wined3d_resource_desc *desc, struct wined3d_texture **texture); const struct wined3d_resource_desc *desc, struct wined3d_texture **texture);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment