Commit 204126ec authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11: Create dxgi resource object for 3D textures.

parent 9b220b80
...@@ -170,7 +170,7 @@ struct d3d_texture3d ...@@ -170,7 +170,7 @@ struct d3d_texture3d
ID3D10Texture3D ID3D10Texture3D_iface; ID3D10Texture3D ID3D10Texture3D_iface;
LONG refcount; LONG refcount;
struct wined3d_private_store private_store; IUnknown *dxgi_resource;
struct wined3d_texture *wined3d_texture; struct wined3d_texture *wined3d_texture;
D3D11_TEXTURE3D_DESC desc; D3D11_TEXTURE3D_DESC desc;
ID3D11Device2 *device; ID3D11Device2 *device;
......
...@@ -3286,9 +3286,7 @@ static void test_texture3d_interfaces(void) ...@@ -3286,9 +3286,7 @@ static void test_texture3d_interfaces(void)
hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture); hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE); check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE); check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
todo_wine
test_dxgi_resource(texture); test_dxgi_resource(texture);
hr = check_interface(texture, &IID_ID3D10Texture3D, TRUE, TRUE); /* Not available on all Windows versions. */ hr = check_interface(texture, &IID_ID3D10Texture3D, TRUE, TRUE); /* Not available on all Windows versions. */
ID3D11Texture3D_Release(texture); ID3D11Texture3D_Release(texture);
...@@ -1044,6 +1044,7 @@ static inline struct d3d_texture3d *impl_from_ID3D11Texture3D(ID3D11Texture3D *i ...@@ -1044,6 +1044,7 @@ static inline struct d3d_texture3d *impl_from_ID3D11Texture3D(ID3D11Texture3D *i
static HRESULT STDMETHODCALLTYPE d3d11_texture3d_QueryInterface(ID3D11Texture3D *iface, REFIID riid, void **object) static HRESULT STDMETHODCALLTYPE d3d11_texture3d_QueryInterface(ID3D11Texture3D *iface, REFIID riid, void **object)
{ {
struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface);
HRESULT hr;
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
...@@ -1065,10 +1066,15 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_QueryInterface(ID3D11Texture3D ...@@ -1065,10 +1066,15 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_QueryInterface(ID3D11Texture3D
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); TRACE("Forwarding to dxgi resource.\n");
*object = NULL; if (FAILED(hr = IUnknown_QueryInterface(texture->dxgi_resource, riid, object)))
return E_NOINTERFACE; {
WARN("%s not implemented, returning %#lx.\n", debugstr_guid(riid), hr);
*object = NULL;
}
return hr;
} }
static ULONG STDMETHODCALLTYPE d3d11_texture3d_AddRef(ID3D11Texture3D *iface) static ULONG STDMETHODCALLTYPE d3d11_texture3d_AddRef(ID3D11Texture3D *iface)
...@@ -1091,7 +1097,8 @@ static void STDMETHODCALLTYPE d3d_texture3d_wined3d_object_released(void *parent ...@@ -1091,7 +1097,8 @@ static void STDMETHODCALLTYPE d3d_texture3d_wined3d_object_released(void *parent
{ {
struct d3d_texture3d *texture = parent; struct d3d_texture3d *texture = parent;
wined3d_private_store_cleanup(&texture->private_store); if (texture->dxgi_resource)
IUnknown_Release(texture->dxgi_resource);
heap_free(parent); heap_free(parent);
} }
...@@ -1129,30 +1136,54 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_GetPrivateData(ID3D11Texture3D ...@@ -1129,30 +1136,54 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_GetPrivateData(ID3D11Texture3D
REFGUID guid, UINT *data_size, void *data) REFGUID guid, UINT *data_size, void *data)
{ {
struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface);
IDXGIResource *dxgi_resource;
HRESULT hr;
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return d3d_get_private_data(&texture->private_store, guid, data_size, data); if (SUCCEEDED(hr = IUnknown_QueryInterface(texture->dxgi_resource, &IID_IDXGIResource, (void **)&dxgi_resource)))
{
hr = IDXGIResource_GetPrivateData(dxgi_resource, guid, data_size, data);
IDXGIResource_Release(dxgi_resource);
}
return hr;
} }
static HRESULT STDMETHODCALLTYPE d3d11_texture3d_SetPrivateData(ID3D11Texture3D *iface, static HRESULT STDMETHODCALLTYPE d3d11_texture3d_SetPrivateData(ID3D11Texture3D *iface,
REFGUID guid, UINT data_size, const void *data) REFGUID guid, UINT data_size, const void *data)
{ {
struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface);
IDXGIResource *dxgi_resource;
HRESULT hr;
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return d3d_set_private_data(&texture->private_store, guid, data_size, data); if (SUCCEEDED(hr = IUnknown_QueryInterface(texture->dxgi_resource, &IID_IDXGIResource, (void **)&dxgi_resource)))
{
hr = IDXGIResource_SetPrivateData(dxgi_resource, guid, data_size, data);
IDXGIResource_Release(dxgi_resource);
}
return hr;
} }
static HRESULT STDMETHODCALLTYPE d3d11_texture3d_SetPrivateDataInterface(ID3D11Texture3D *iface, static HRESULT STDMETHODCALLTYPE d3d11_texture3d_SetPrivateDataInterface(ID3D11Texture3D *iface,
REFGUID guid, const IUnknown *data) REFGUID guid, const IUnknown *data)
{ {
struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface);
IDXGIResource *dxgi_resource;
HRESULT hr;
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return d3d_set_private_data_interface(&texture->private_store, guid, data); if (SUCCEEDED(hr = IUnknown_QueryInterface(texture->dxgi_resource, &IID_IDXGIResource, (void **)&dxgi_resource)))
{
hr = IDXGIResource_SetPrivateDataInterface(dxgi_resource, guid, data);
IDXGIResource_Release(dxgi_resource);
}
return hr;
} }
static void STDMETHODCALLTYPE d3d11_texture3d_GetType(ID3D11Texture3D *iface, static void STDMETHODCALLTYPE d3d11_texture3d_GetType(ID3D11Texture3D *iface,
...@@ -1251,10 +1282,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D ...@@ -1251,10 +1282,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D
{ {
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
iface, debugstr_guid(guid), data_size, data);
return d3d_get_private_data(&texture->private_store, guid, data_size, data); return d3d11_texture3d_GetPrivateData(&texture->ID3D11Texture3D_iface, guid, data_size, data);
} }
static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D *iface, static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D *iface,
...@@ -1262,10 +1292,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D ...@@ -1262,10 +1292,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D
{ {
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
iface, debugstr_guid(guid), data_size, data);
return d3d_set_private_data(&texture->private_store, guid, data_size, data); return d3d11_texture3d_SetPrivateData(&texture->ID3D11Texture3D_iface, guid, data_size, data);
} }
static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10Texture3D *iface, static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10Texture3D *iface,
...@@ -1275,7 +1304,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10T ...@@ -1275,7 +1304,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10T
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return d3d_set_private_data_interface(&texture->private_store, guid, data); return d3d11_texture3d_SetPrivateDataInterface(&texture->ID3D11Texture3D_iface, guid, data);
} }
static void STDMETHODCALLTYPE d3d10_texture3d_GetType(ID3D10Texture3D *iface, static void STDMETHODCALLTYPE d3d10_texture3d_GetType(ID3D10Texture3D *iface,
...@@ -1413,7 +1442,6 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi ...@@ -1413,7 +1442,6 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
texture->ID3D10Texture3D_iface.lpVtbl = &d3d10_texture3d_vtbl; texture->ID3D10Texture3D_iface.lpVtbl = &d3d10_texture3d_vtbl;
texture->refcount = 1; texture->refcount = 1;
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_private_store_init(&texture->private_store);
texture->desc = *desc; texture->desc = *desc;
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_3D; wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_3D;
...@@ -1439,12 +1467,22 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi ...@@ -1439,12 +1467,22 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
&d3d_texture3d_wined3d_parent_ops, &texture->wined3d_texture))) &d3d_texture3d_wined3d_parent_ops, &texture->wined3d_texture)))
{ {
WARN("Failed to create wined3d texture, hr %#lx.\n", hr); WARN("Failed to create wined3d texture, hr %#lx.\n", hr);
wined3d_private_store_cleanup(&texture->private_store);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (hr == WINED3DERR_INVALIDCALL) if (hr == WINED3DERR_INVALIDCALL)
hr = E_INVALIDARG; hr = E_INVALIDARG;
return hr; return hr;
} }
hr = d3d_device_create_dxgi_resource((IUnknown *)&device->ID3D10Device1_iface,
wined3d_texture_get_resource(texture->wined3d_texture), (IUnknown *)&texture->ID3D10Texture3D_iface,
FALSE, &texture->dxgi_resource);
if (FAILED(hr))
{
ERR("Failed to create DXGI resource, returning %#.lx\n", hr);
wined3d_texture_decref(texture->wined3d_texture);
wined3d_mutex_unlock();
return hr;
}
wined3d_mutex_unlock(); wined3d_mutex_unlock();
texture->desc.MipLevels = levels; texture->desc.MipLevels = levels;
......
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