d3d9: Volumes are always part of a texture.

This commit is contained in:
Henri Verbeet 2014-08-12 11:11:03 +02:00 committed by Alexandre Julliard
parent 515c1acf29
commit c5e8115ee2
3 changed files with 14 additions and 70 deletions

View File

@ -192,12 +192,11 @@ struct d3d9_volume
IDirect3DVolume9 IDirect3DVolume9_iface; IDirect3DVolume9 IDirect3DVolume9_iface;
struct d3d9_resource resource; struct d3d9_resource resource;
struct wined3d_volume *wined3d_volume; struct wined3d_volume *wined3d_volume;
IUnknown *container; struct d3d9_texture *texture;
IUnknown *forwardReference;
}; };
void volume_init(struct d3d9_volume *volume, struct wined3d_volume *wined3d_volume, void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture,
const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct wined3d_volume *wined3d_volume, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_swapchain struct d3d9_swapchain
{ {

View File

@ -3496,15 +3496,10 @@ static HRESULT CDECL device_parent_volume_created(struct wined3d_device_parent *
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, volume, parent_ops); volume_init(d3d_volume, container_parent, volume, parent_ops);
*parent = d3d_volume; *parent = d3d_volume;
TRACE("Created volume %p.\n", d3d_volume); TRACE("Created volume %p.\n", d3d_volume);
d3d_volume->container = container_parent;
IDirect3DVolume9_Release(&d3d_volume->IDirect3DVolume9_iface);
d3d_volume->forwardReference = container_parent;
return D3D_OK; return D3D_OK;
} }

View File

@ -50,73 +50,30 @@ static HRESULT WINAPI d3d9_volume_QueryInterface(IDirect3DVolume9 *iface, REFIID
static ULONG WINAPI d3d9_volume_AddRef(IDirect3DVolume9 *iface) static ULONG WINAPI d3d9_volume_AddRef(IDirect3DVolume9 *iface)
{ {
struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface);
ULONG refcount;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
TRACE("Forwarding to %p.\n", volume->texture);
if (volume->forwardReference) return IDirect3DBaseTexture9_AddRef(&volume->texture->IDirect3DBaseTexture9_iface);
{
TRACE("Forwarding to %p.\n", volume->forwardReference);
return IUnknown_AddRef(volume->forwardReference);
}
refcount = InterlockedIncrement(&volume->resource.refcount);
TRACE("%p increasing refcount to %u.\n", iface, refcount);
if (refcount == 1)
{
wined3d_mutex_lock();
wined3d_volume_incref(volume->wined3d_volume);
wined3d_mutex_unlock();
}
return refcount;
} }
static ULONG WINAPI d3d9_volume_Release(IDirect3DVolume9 *iface) static ULONG WINAPI d3d9_volume_Release(IDirect3DVolume9 *iface)
{ {
struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface);
ULONG refcount;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
TRACE("Forwarding to %p.\n", volume->texture);
if (volume->forwardReference) return IDirect3DBaseTexture9_Release(&volume->texture->IDirect3DBaseTexture9_iface);
{
TRACE("Forwarding to %p.\n", volume->forwardReference);
return IUnknown_Release(volume->forwardReference);
}
refcount = InterlockedDecrement(&volume->resource.refcount);
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount)
{
wined3d_mutex_lock();
wined3d_volume_decref(volume->wined3d_volume);
wined3d_mutex_unlock();
}
return refcount;
} }
static HRESULT WINAPI d3d9_volume_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device) static HRESULT WINAPI d3d9_volume_GetDevice(IDirect3DVolume9 *iface, IDirect3DDevice9 **device)
{ {
struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface);
IDirect3DResource9 *resource;
HRESULT hr;
TRACE("iface %p, device %p.\n", iface, device); TRACE("iface %p, device %p.\n", iface, device);
hr = IUnknown_QueryInterface(volume->forwardReference, &IID_IDirect3DResource9, (void **)&resource); return IDirect3DBaseTexture9_GetDevice(&volume->texture->IDirect3DBaseTexture9_iface, device);
if (SUCCEEDED(hr))
{
hr = IDirect3DResource9_GetDevice(resource, device);
IDirect3DResource9_Release(resource);
TRACE("Returning device %p.\n", *device);
}
return hr;
} }
static HRESULT WINAPI d3d9_volume_SetPrivateData(IDirect3DVolume9 *iface, REFGUID guid, static HRESULT WINAPI d3d9_volume_SetPrivateData(IDirect3DVolume9 *iface, REFGUID guid,
@ -150,18 +107,10 @@ static HRESULT WINAPI d3d9_volume_FreePrivateData(IDirect3DVolume9 *iface, REFGU
static HRESULT WINAPI d3d9_volume_GetContainer(IDirect3DVolume9 *iface, REFIID riid, void **container) static HRESULT WINAPI d3d9_volume_GetContainer(IDirect3DVolume9 *iface, REFIID riid, void **container)
{ {
struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface);
HRESULT hr;
TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container); TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
if (!volume->container) return IDirect3DBaseTexture9_QueryInterface(&volume->texture->IDirect3DBaseTexture9_iface, riid, container);
return E_NOINTERFACE;
hr = IUnknown_QueryInterface(volume->container, riid, container);
TRACE("Returning %p,\n", *container);
return hr;
} }
static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc) static HRESULT WINAPI d3d9_volume_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc)
@ -252,13 +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 wined3d_volume *wined3d_volume, void volume_init(struct d3d9_volume *volume, struct d3d9_texture *texture,
const struct wined3d_parent_ops **parent_ops) 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);
wined3d_volume_incref(wined3d_volume); volume->resource.refcount = 0;
volume->wined3d_volume = wined3d_volume; volume->wined3d_volume = wined3d_volume;
volume->texture = texture;
*parent_ops = &d3d9_volume_wined3d_parent_ops; *parent_ops = &d3d9_volume_wined3d_parent_ops;
} }