[PATCH 6/7] d3d11: Create dxgi resource object for 3D textures.
Nikolay Sivov
wine at gitlab.winehq.org
Thu Jun 9 02:22:41 CDT 2022
From: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d3d11/d3d11_private.h | 2 +-
dlls/d3d11/tests/d3d11.c | 2 --
dlls/d3d11/texture.c | 70 +++++++++++++++++++++++++++++---------
3 files changed, 55 insertions(+), 19 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index cc236699871..8b3f1ab5717 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -170,7 +170,7 @@ struct d3d_texture3d
ID3D10Texture3D ID3D10Texture3D_iface;
LONG refcount;
- struct wined3d_private_store private_store;
+ IUnknown *dxgi_resource;
struct wined3d_texture *wined3d_texture;
D3D11_TEXTURE3D_DESC desc;
ID3D11Device2 *device;
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 0c741283da5..3628a0bd573 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -3286,9 +3286,7 @@ static void test_texture3d_interfaces(void)
hr = ID3D11Device_CreateTexture3D(device, &desc, NULL, &texture);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_interface(texture, &IID_IDXGISurface, FALSE, FALSE);
- todo_wine
check_interface(texture, &IID_IDXGIResource, TRUE, FALSE);
- todo_wine
test_dxgi_resource(texture);
hr = check_interface(texture, &IID_ID3D10Texture3D, TRUE, TRUE); /* Not available on all Windows versions. */
ID3D11Texture3D_Release(texture);
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index 775b7df43f1..fb4c1cdc597 100644
--- a/dlls/d3d11/texture.c
+++ b/dlls/d3d11/texture.c
@@ -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)
{
struct d3d_texture3d *texture = impl_from_ID3D11Texture3D(iface);
+ HRESULT hr;
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
@@ -1065,10 +1066,15 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_QueryInterface(ID3D11Texture3D
return S_OK;
}
- WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
+ TRACE("Forwarding to dxgi resource.\n");
- *object = NULL;
- return E_NOINTERFACE;
+ if (FAILED(hr = IUnknown_QueryInterface(texture->dxgi_resource, riid, object)))
+ {
+ WARN("%s not implemented, returning %#lx.\n", debugstr_guid(riid), hr);
+ *object = NULL;
+ }
+
+ return hr;
}
static ULONG STDMETHODCALLTYPE d3d11_texture3d_AddRef(ID3D11Texture3D *iface)
@@ -1091,7 +1097,8 @@ static void STDMETHODCALLTYPE d3d_texture3d_wined3d_object_released(void *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);
}
@@ -1129,30 +1136,54 @@ static HRESULT STDMETHODCALLTYPE d3d11_texture3d_GetPrivateData(ID3D11Texture3D
REFGUID guid, UINT *data_size, void *data)
{
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);
- 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,
REFGUID guid, UINT data_size, const void *data)
{
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);
- 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,
REFGUID guid, const IUnknown *data)
{
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);
- 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,
@@ -1251,10 +1282,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D
{
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
- 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);
+ return d3d11_texture3d_GetPrivateData(&texture->ID3D11Texture3D_iface, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D *iface,
@@ -1262,10 +1292,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateData(ID3D10Texture3D
{
struct d3d_texture3d *texture = impl_from_ID3D10Texture3D(iface);
- 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);
+ return d3d11_texture3d_SetPrivateData(&texture->ID3D11Texture3D_iface, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10Texture3D *iface,
@@ -1275,7 +1304,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture3d_SetPrivateDataInterface(ID3D10T
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,
@@ -1413,7 +1442,6 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
texture->ID3D10Texture3D_iface.lpVtbl = &d3d10_texture3d_vtbl;
texture->refcount = 1;
wined3d_mutex_lock();
- wined3d_private_store_init(&texture->private_store);
texture->desc = *desc;
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_3D;
@@ -1439,12 +1467,22 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi
&d3d_texture3d_wined3d_parent_ops, &texture->wined3d_texture)))
{
WARN("Failed to create wined3d texture, hr %#lx.\n", hr);
- wined3d_private_store_cleanup(&texture->private_store);
wined3d_mutex_unlock();
if (hr == WINED3DERR_INVALIDCALL)
hr = E_INVALIDARG;
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();
texture->desc.MipLevels = levels;
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/212
More information about the wine-devel
mailing list