From 1acd3d44b1b18d58a5a61ab5a6c1a3d87847ffe8 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Sun, 23 Jul 2017 15:02:41 +0200 Subject: [PATCH] Implement d3d12_device_CreateQueryHeap(). --- libs/vkd3d/command.c | 6 +- libs/vkd3d/device.c | 16 +++-- libs/vkd3d/resource.c | 132 +++++++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 12 ++++ 4 files changed, 159 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index dbf2a827..f2041a5a 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -3431,13 +3431,13 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_signature_SetName(ID3D12CommandSi } static HRESULT STDMETHODCALLTYPE d3d12_command_signature_GetDevice(ID3D12CommandSignature *iface, - REFIID riid, void **device) + REFIID iid, void **device) { struct d3d12_command_signature *signature = impl_from_ID3D12CommandSignature(iface); - TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device); + TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device); - return ID3D12Device_QueryInterface(&signature->device->ID3D12Device_iface, riid, device); + return ID3D12Device_QueryInterface(&signature->device->ID3D12Device_iface, iid, device); } static const struct ID3D12CommandSignatureVtbl d3d12_command_signature_vtbl = diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 8a3afd2a..b95c3d71 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1122,12 +1122,20 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i } static HRESULT STDMETHODCALLTYPE d3d12_device_CreateQueryHeap(ID3D12Device *iface, - const D3D12_QUERY_HEAP_DESC *desc, REFIID riid, void **heap) + const D3D12_QUERY_HEAP_DESC *desc, REFIID iid, void **heap) { - FIXME("iface %p, desc %p, riid %s, heap %p stub!\n", - iface, desc, debugstr_guid(riid), heap); + struct d3d12_device *device = impl_from_ID3D12Device(iface); + struct d3d12_query_heap *object; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, desc %p, iid %s, heap %p.\n", + iface, desc, debugstr_guid(iid), heap); + + if (FAILED(hr = d3d12_query_heap_create(device, &object))) + return hr; + + return return_interface((IUnknown *)&object->ID3D12QueryHeap_iface, + &IID_ID3D12QueryHeap, iid, heap); } static HRESULT STDMETHODCALLTYPE d3d12_device_SetStablePowerState(ID3D12Device *iface, BOOL enable) diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index ef794bcb..7d3de6c4 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -1436,3 +1436,135 @@ HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device, return S_OK; } + +/* ID3D12QueryHeap */ +static inline struct d3d12_query_heap *impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface) +{ + return CONTAINING_RECORD(iface, struct d3d12_query_heap, ID3D12QueryHeap_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_QueryInterface(ID3D12QueryHeap *iface, + REFIID iid, void **out) +{ + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID3D12QueryHeap) + || IsEqualGUID(iid, &IID_ID3D12Pageable) + || IsEqualGUID(iid, &IID_ID3D12DeviceChild) + || IsEqualGUID(iid, &IID_ID3D12Object) + || IsEqualGUID(iid, &IID_IUnknown)) + { + ID3D12QueryHeap_AddRef(iface); + *out = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d12_query_heap_AddRef(ID3D12QueryHeap *iface) +{ + struct d3d12_query_heap *heap = impl_from_ID3D12QueryHeap(iface); + ULONG refcount = InterlockedIncrement(&heap->refcount); + + TRACE("%p increasing refcount to %u.\n", heap, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d12_query_heap_Release(ID3D12QueryHeap *iface) +{ + struct d3d12_query_heap *heap = impl_from_ID3D12QueryHeap(iface); + ULONG refcount = InterlockedDecrement(&heap->refcount); + + TRACE("%p decreasing refcount to %u.\n", heap, refcount); + + if (!refcount) + { + struct d3d12_device *device = heap->device; + + vkd3d_free(heap); + + ID3D12Device_Release(&device->ID3D12Device_iface); + } + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_GetPrivateData(ID3D12QueryHeap *iface, + REFGUID guid, UINT *data_size, void *data) +{ + FIXME("iface %p, guid %s, data_size %p, data %p stub!", iface, debugstr_guid(guid), data_size, data); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetPrivateData(ID3D12QueryHeap *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_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetPrivateDataInterface(ID3D12QueryHeap *iface, + REFGUID guid, const IUnknown *data) +{ + FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_SetName(ID3D12QueryHeap *iface, const WCHAR *name) +{ + FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name)); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_query_heap_GetDevice(ID3D12QueryHeap *iface, + REFIID iid, void **device) +{ + struct d3d12_query_heap *heap = impl_from_ID3D12QueryHeap(iface); + + TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device); + + return ID3D12Device_QueryInterface(&heap->device->ID3D12Device_iface, iid, device); +} + +static const struct ID3D12QueryHeapVtbl d3d12_query_heap_vtbl = +{ + /* IUnknown methods */ + d3d12_query_heap_QueryInterface, + d3d12_query_heap_AddRef, + d3d12_query_heap_Release, + /* ID3D12Object methods */ + d3d12_query_heap_GetPrivateData, + d3d12_query_heap_SetPrivateData, + d3d12_query_heap_SetPrivateDataInterface, + d3d12_query_heap_SetName, + /* ID3D12DeviceChild methods */ + d3d12_query_heap_GetDevice, +}; + +HRESULT d3d12_query_heap_create(struct d3d12_device *device, struct d3d12_query_heap **heap) +{ + struct d3d12_query_heap *object; + + if (!(object = vkd3d_malloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID3D12QueryHeap_iface.lpVtbl = &d3d12_query_heap_vtbl; + object->refcount = 1; + object->device = device; + ID3D12Device_AddRef(&device->ID3D12Device_iface); + + TRACE("Created query heap %p.\n", object); + + *heap = object; + + return S_OK; +} diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 3e4b54cd..7e602db6 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -227,6 +227,18 @@ struct d3d12_descriptor_heap HRESULT d3d12_descriptor_heap_create(struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap) DECLSPEC_HIDDEN; +/* ID3D12QueryHeap */ +struct d3d12_query_heap +{ + ID3D12QueryHeap ID3D12QueryHeap_iface; + LONG refcount; + + struct d3d12_device *device; +}; + +HRESULT d3d12_query_heap_create(struct d3d12_device *device, + struct d3d12_query_heap **heap) DECLSPEC_HIDDEN; + /* ID3D12RootSignature */ struct d3d12_root_signature {