wine-staging/patches/d3d11-ID3D11Texture1D/0001-d3d11-Add-stub-ID3D11Texture2D-and-ID3D10Texture2D-i.patch

454 lines
15 KiB
Diff
Raw Normal View History

2016-08-31 08:42:50 -07:00
From 9dc913d2ae5fca9a46acc67d896cf317389f7d97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 25 Aug 2016 19:41:15 +0200
Subject: d3d11: Add stub ID3D11Texture2D and ID3D10Texture2D interfaces.
---
dlls/d3d11/d3d11_private.h | 21 +++
dlls/d3d11/device.c | 36 ++++-
dlls/d3d11/texture.c | 340 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 393 insertions(+), 4 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index 4af0faa..6bd7282 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -104,6 +104,27 @@ void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
HRESULT parse_dxbc(const char *data, SIZE_T data_size,
HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN;
+/* ID3D11Texture1D, ID3D10Texture1D */
+struct d3d_texture1d
+{
+ ID3D11Texture1D ID3D11Texture1D_iface;
+ ID3D10Texture1D ID3D10Texture1D_iface;
+ LONG refcount;
+
+ D3D11_TEXTURE1D_DESC desc;
+ ID3D11Device *device;
+};
+
+static inline struct d3d_texture1d *impl_from_ID3D10Texture1D(ID3D10Texture1D *iface)
+{
+ return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
+}
+
+HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
+ const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **texture) DECLSPEC_HIDDEN;
+struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) DECLSPEC_HIDDEN;
+struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) DECLSPEC_HIDDEN;
+
/* ID3D11Texture2D, ID3D10Texture2D */
struct d3d_texture2d
{
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 9a42c8b..8c2aab6 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2106,9 +2106,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface,
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface,
const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture)
{
- FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
+ struct d3d_device *device = impl_from_ID3D11Device(iface);
+ struct d3d_texture1d *object;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
+
+ if (FAILED(hr = d3d_texture1d_create(device, desc, data, &object)))
+ return hr;
+
+ *texture = &object->ID3D11Texture1D_iface;
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface,
@@ -4436,9 +4445,28 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface,
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface,
const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture)
{
- FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture);
+ struct d3d_device *device = impl_from_ID3D10Device(iface);
+ D3D11_TEXTURE1D_DESC d3d11_desc;
+ struct d3d_texture1d *object;
+ HRESULT hr;
- return E_NOTIMPL;
+ TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture);
+
+ d3d11_desc.Width = desc->Width;
+ d3d11_desc.MipLevels = desc->MipLevels;
+ d3d11_desc.ArraySize = desc->ArraySize;
+ d3d11_desc.Format = desc->Format;
+ d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage);
+ d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags);
+ d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags);
+ d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags);
+
+ if (FAILED(hr = d3d_texture1d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object)))
+ return hr;
+
+ *texture = &object->ID3D10Texture1D_iface;
+
+ return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface,
diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c
index d7b2af1..d201b23 100644
--- a/dlls/d3d11/texture.c
+++ b/dlls/d3d11/texture.c
@@ -25,6 +25,346 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
+
+/* ID3D11Texture1D methods */
+
+static inline struct d3d_texture1d *impl_from_ID3D11Texture1D(ID3D11Texture1D *iface)
+{
+ return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface);
+}
+
+static HRESULT STDMETHODCALLTYPE d3d11_texture1d_QueryInterface(ID3D11Texture1D *iface, REFIID riid, void **object)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
+
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ if (IsEqualGUID(riid, &IID_ID3D11Texture1D)
+ || IsEqualGUID(riid, &IID_ID3D11Resource)
+ || IsEqualGUID(riid, &IID_ID3D11DeviceChild)
+ || IsEqualGUID(riid, &IID_IUnknown))
+ {
+ *object = &texture->ID3D11Texture1D_iface;
+ IUnknown_AddRef((IUnknown *)*object);
+ return S_OK;
+ }
+ else if (IsEqualGUID(riid, &IID_ID3D10Texture1D)
+ || IsEqualGUID(riid, &IID_ID3D10Resource)
+ || IsEqualGUID(riid, &IID_ID3D10DeviceChild))
+ {
+ *object = &texture->ID3D10Texture1D_iface;
+ IUnknown_AddRef((IUnknown *)*object);
+ return S_OK;
+ }
+
+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
+
+ *object = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG STDMETHODCALLTYPE d3d11_texture1d_AddRef(ID3D11Texture1D *iface)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
+ ULONG refcount = InterlockedIncrement(&texture->refcount);
+
+ TRACE("%p increasing refcount to %u.\n", texture, refcount);
+
+ if (refcount == 1)
+ {
+ ID3D11Device_AddRef(texture->device);
+ }
+
+ return refcount;
+}
+
+static ULONG STDMETHODCALLTYPE d3d11_texture1d_Release(ID3D11Texture1D *iface)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
+ ULONG refcount = InterlockedDecrement(&texture->refcount);
+
+ TRACE("%p decreasing refcount to %u.\n", texture, refcount);
+
+ if (!refcount)
+ {
+ ID3D11Device *device = texture->device;
+
+ /* Release the device last, it may cause the wined3d device to be
+ * destroyed. */
+ ID3D11Device_Release(device);
+ }
+
+ return refcount;
+}
+
+static void STDMETHODCALLTYPE d3d11_texture1d_GetDevice(ID3D11Texture1D *iface, ID3D11Device **device)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
+
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = texture->device;
+ ID3D11Device_AddRef(*device);
+}
+
+static HRESULT STDMETHODCALLTYPE d3d11_texture1d_GetPrivateData(ID3D11Texture1D *iface,
+ REFGUID guid, UINT *data_size, void *data)
+{
+ FIXME("iface %p, guid %s, data_size %p, data %p: stub.\n", iface, debugstr_guid(guid), data_size, data);
+
+ return E_FAIL;
+}
+
+static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateData(ID3D11Texture1D *iface,
+ REFGUID guid, UINT data_size, const void *data)
+{
+ FIXME("iface %p, guid %s, data_size %u, data %p: stub.\n", iface, debugstr_guid(guid), data_size, data);
+
+ return E_FAIL;
+}
+
+static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateDataInterface(ID3D11Texture1D *iface,
+ REFGUID guid, const IUnknown *data)
+{
+ FIXME("iface %p, guid %s, data %p: stub.\n", iface, debugstr_guid(guid), data);
+
+ return E_FAIL;
+}
+
+static void STDMETHODCALLTYPE d3d11_texture1d_GetType(ID3D11Texture1D *iface,
+ D3D11_RESOURCE_DIMENSION *resource_dimension)
+{
+ TRACE("iface %p, resource_dimension %p.\n", iface, resource_dimension);
+
+ *resource_dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D;
+}
+
+static void STDMETHODCALLTYPE d3d11_texture1d_SetEvictionPriority(ID3D11Texture1D *iface, UINT eviction_priority)
+{
+ FIXME("iface %p, eviction_priority %#x stub!\n", iface, eviction_priority);
+}
+
+static UINT STDMETHODCALLTYPE d3d11_texture1d_GetEvictionPriority(ID3D11Texture1D *iface)
+{
+ FIXME("iface %p stub!\n", iface);
+
+ return 0;
+}
+
+static void STDMETHODCALLTYPE d3d11_texture1d_GetDesc(ID3D11Texture1D *iface, D3D11_TEXTURE1D_DESC *desc)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface);
+
+ FIXME("iface %p, desc %p: semi-stub.\n", iface, desc);
+
+ *desc = texture->desc;
+}
+
+static const struct ID3D11Texture1DVtbl d3d11_texture1d_vtbl =
+{
+ /* IUnknown methods */
+ d3d11_texture1d_QueryInterface,
+ d3d11_texture1d_AddRef,
+ d3d11_texture1d_Release,
+ /* ID3D11DeviceChild methods */
+ d3d11_texture1d_GetDevice,
+ d3d11_texture1d_GetPrivateData,
+ d3d11_texture1d_SetPrivateData,
+ d3d11_texture1d_SetPrivateDataInterface,
+ /* ID3D11Resource methods */
+ d3d11_texture1d_GetType,
+ d3d11_texture1d_SetEvictionPriority,
+ d3d11_texture1d_GetEvictionPriority,
+ /* ID3D11Texture1D methods */
+ d3d11_texture1d_GetDesc,
+};
+
+struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &d3d11_texture1d_vtbl);
+ return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface);
+}
+
+/* IUnknown methods */
+
+static HRESULT STDMETHODCALLTYPE d3d10_texture1d_QueryInterface(ID3D10Texture1D *iface, REFIID riid, void **object)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
+
+ return d3d11_texture1d_QueryInterface(&texture->ID3D11Texture1D_iface, riid, object);
+}
+
+static ULONG STDMETHODCALLTYPE d3d10_texture1d_AddRef(ID3D10Texture1D *iface)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p.\n", iface);
+
+ return d3d11_texture1d_AddRef(&texture->ID3D11Texture1D_iface);
+}
+
+static ULONG STDMETHODCALLTYPE d3d10_texture1d_Release(ID3D10Texture1D *iface)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p.\n", iface);
+
+ return d3d11_texture1d_Release(&texture->ID3D11Texture1D_iface);
+}
+
+/* ID3D10DeviceChild methods */
+
+static void STDMETHODCALLTYPE d3d10_texture1d_GetDevice(ID3D10Texture1D *iface, ID3D10Device **device)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ ID3D11Device_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device);
+}
+
+static HRESULT STDMETHODCALLTYPE d3d10_texture1d_GetPrivateData(ID3D10Texture1D *iface,
+ REFGUID guid, UINT *data_size, void *data)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
+
+ return d3d11_texture1d_GetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data);
+}
+
+static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateData(ID3D10Texture1D *iface,
+ REFGUID guid, UINT data_size, const void *data)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
+
+ return d3d11_texture1d_SetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data);
+}
+
+static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateDataInterface(ID3D10Texture1D *iface,
+ REFGUID guid, const IUnknown *data)
+{
+ struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface);
+
+ TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
+
+ return d3d11_texture1d_SetPrivateDataInterface(&texture->ID3D11Texture1D_iface, guid, data);
+}
+
+/* ID3D10Resource methods */
+
+static void STDMETHODCALLTYPE d3d10_texture1d_GetType(ID3D10Texture1D *iface,
+ D3D10_RESOURCE_DIMENSION *resource_dimension)
+{
+ TRACE("iface %p, resource_dimension %p\n", iface, resource_dimension);
+
+ *resource_dimension = D3D10_RESOURCE_DIMENSION_TEXTURE1D;
+}
+
+static void STDMETHODCALLTYPE d3d10_texture1d_SetEvictionPriority(ID3D10Texture1D *iface, UINT eviction_priority)
+{
+ FIXME("iface %p, eviction_priority %u stub!\n", iface, eviction_priority);
+}
+
+static UINT STDMETHODCALLTYPE d3d10_texture1d_GetEvictionPriority(ID3D10Texture1D *iface)
+{
+ FIXME("iface %p stub!\n", iface);
+
+ return 0;
+}
+
+/* ID3D10Texture1D methods */
+
+static HRESULT STDMETHODCALLTYPE d3d10_texture1d_Map(ID3D10Texture1D *iface, UINT sub_resource_idx,
+ D3D10_MAP map_type, UINT map_flags, void **data)
+{
+ FIXME("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p: stub.\n",
+ iface, sub_resource_idx, map_type, map_flags, data);
+
+ return E_FAIL;
+}
+
+static void STDMETHODCALLTYPE d3d10_texture1d_Unmap(ID3D10Texture1D *iface, UINT sub_resource_idx)
+{
+ FIXME("iface %p, sub_resource_idx %u: stub.\n", iface, sub_resource_idx);
+}
+
+static void STDMETHODCALLTYPE d3d10_texture1d_GetDesc(ID3D10Texture1D *iface, D3D10_TEXTURE1D_DESC *desc)
+{
+ FIXME("iface %p, desc %p: stub\n", iface, desc);
+}
+
+static const struct ID3D10Texture1DVtbl d3d10_texture1d_vtbl =
+{
+ /* IUnknown methods */
+ d3d10_texture1d_QueryInterface,
+ d3d10_texture1d_AddRef,
+ d3d10_texture1d_Release,
+ /* ID3D10DeviceChild methods */
+ d3d10_texture1d_GetDevice,
+ d3d10_texture1d_GetPrivateData,
+ d3d10_texture1d_SetPrivateData,
+ d3d10_texture1d_SetPrivateDataInterface,
+ /* ID3D10Resource methods */
+ d3d10_texture1d_GetType,
+ d3d10_texture1d_SetEvictionPriority,
+ d3d10_texture1d_GetEvictionPriority,
+ /* ID3D10Texture1D methods */
+ d3d10_texture1d_Map,
+ d3d10_texture1d_Unmap,
+ d3d10_texture1d_GetDesc,
+};
+
+struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface)
+{
+ if (!iface)
+ return NULL;
+ assert(iface->lpVtbl == &d3d10_texture1d_vtbl);
+ return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface);
+}
+
+static HRESULT d3d_texture1d_init(struct d3d_texture1d *texture, struct d3d_device *device,
+ const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data)
+{
+ texture->ID3D11Texture1D_iface.lpVtbl = &d3d11_texture1d_vtbl;
+ texture->ID3D10Texture1D_iface.lpVtbl = &d3d10_texture1d_vtbl;
+ texture->refcount = 1;
+ texture->desc = *desc;
+
+ texture->device = &device->ID3D11Device_iface;
+ ID3D11Device_AddRef(texture->device);
+
+ return S_OK;
+}
+
+HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc,
+ const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **texture)
+{
+ struct d3d_texture1d *object;
+ HRESULT hr;
+
+ if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
+ return E_OUTOFMEMORY;
+
+ if (FAILED(hr = d3d_texture1d_init(object, device, desc, data)))
+ {
+ WARN("Failed to initialize texture, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created texture %p.\n", object);
+ *texture = object;
+
+ return S_OK;
+}
+
/* ID3D11Texture2D methods */
static inline struct d3d_texture2d *impl_from_ID3D11Texture2D(ID3D11Texture2D *iface)
--
2.8.1