From aec10bd68204aaf011c84a0db19c258b619cb4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Mon, 26 Sep 2016 11:13:30 +0200 Subject: [PATCH] libs/vkd3d: Add ID3D12RootSignature interface stub. --- Makefile.am | 1 + libs/vkd3d/device.c | 20 ++++- libs/vkd3d/state.c | 162 +++++++++++++++++++++++++++++++++++++ libs/vkd3d/vkd3d_private.h | 12 +++ 4 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 libs/vkd3d/state.c diff --git a/Makefile.am b/Makefile.am index bb67a62d..add794dc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ libvkd3d_la_SOURCES = \ libs/vkd3d/debug.c \ libs/vkd3d/device.c \ libs/vkd3d/resource.c \ + libs/vkd3d/state.c \ libs/vkd3d/utils.c \ libs/vkd3d/vkd3d_main.c diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index 75054aa9..ea04be49 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -662,11 +662,29 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateRootSignature(ID3D12Device * UINT node_mask, const void *bytecode, SIZE_T bytecode_length, REFIID riid, void **root_signature) { + struct d3d12_device *device = impl_from_ID3D12Device(iface); + struct d3d12_root_signature *object; + HRESULT hr; + FIXME("iface %p, node_mask 0x%08x, bytecode %p, bytecode_length %lu, " "riid %s, root_signature %p stub!\n", iface, node_mask, bytecode, bytecode_length, debugstr_guid(riid), root_signature); - return E_NOTIMPL; + if (node_mask && node_mask != 1) + FIXME("Ignoring node mask 0x%08x.\n", node_mask); + + if (bytecode_length != ~0u) + { + FIXME("Root signature byte code not supported.\n"); + return E_NOTIMPL; + } + + if (FAILED(hr = d3d12_root_signature_create(device, + (const D3D12_ROOT_SIGNATURE_DESC *)bytecode, &object))) + return hr; + + return return_interface((IUnknown *)&object->ID3D12RootSignature_iface, + &IID_ID3D12RootSignature, riid, root_signature); } static void STDMETHODCALLTYPE d3d12_device_CreateConstantBufferView(ID3D12Device *iface, diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c new file mode 100644 index 00000000..89606589 --- /dev/null +++ b/libs/vkd3d/state.c @@ -0,0 +1,162 @@ +/* + * Copyright 2016 Józef Kucia for CodeWeavers + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "vkd3d_private.h" + +/* ID3D12RootSignature */ +static inline struct d3d12_root_signature *impl_from_ID3D12RootSignature(ID3D12RootSignature *iface) +{ + return CONTAINING_RECORD(iface, struct d3d12_root_signature, ID3D12RootSignature_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d12_root_signature_QueryInterface(ID3D12RootSignature *iface, + REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D12RootSignature) + || IsEqualGUID(riid, &IID_ID3D12DeviceChild) + || IsEqualGUID(riid, &IID_ID3D12Object) + || IsEqualGUID(riid, &IID_IUnknown)) + { + ID3D12RootSignature_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d12_root_signature_AddRef(ID3D12RootSignature *iface) +{ + struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface); + ULONG refcount = InterlockedIncrement(&root_signature->refcount); + + TRACE("%p increasing refcount to %u.\n", root_signature, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d12_root_signature_Release(ID3D12RootSignature *iface) +{ + struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface); + ULONG refcount = InterlockedDecrement(&root_signature->refcount); + + TRACE("%p decreasing refcount to %u.\n", root_signature, refcount); + + if (!refcount) + { + struct d3d12_device *device = root_signature->device; + + vkd3d_free(root_signature); + + ID3D12Device_Release(&device->ID3D12Device_iface); + } + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetPrivateData(ID3D12RootSignature *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_root_signature_SetPrivateData(ID3D12RootSignature *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_root_signature_SetPrivateDataInterface(ID3D12RootSignature *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_root_signature_SetName(ID3D12RootSignature *iface, const WCHAR *name) +{ + FIXME("iface %p, name %s stub!\n", iface, debugstr_w(name)); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_root_signature_GetDevice(ID3D12RootSignature *iface, + REFIID riid, void **device) +{ + struct d3d12_root_signature *root_signature = impl_from_ID3D12RootSignature(iface); + + TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device); + + return ID3D12Device_QueryInterface(&root_signature->device->ID3D12Device_iface, riid, device); +} + +static const struct ID3D12RootSignatureVtbl d3d12_root_signature_vtbl = +{ + /* IUnknown methods */ + d3d12_root_signature_QueryInterface, + d3d12_root_signature_AddRef, + d3d12_root_signature_Release, + /* ID3D12Object methods */ + d3d12_root_signature_GetPrivateData, + d3d12_root_signature_SetPrivateData, + d3d12_root_signature_SetPrivateDataInterface, + d3d12_root_signature_SetName, + /* ID3D12DeviceChild methods */ + d3d12_root_signature_GetDevice, +}; + +static void d3d12_root_signature_init(struct d3d12_root_signature *root_signature, + struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC *desc) +{ + root_signature->ID3D12RootSignature_iface.lpVtbl = &d3d12_root_signature_vtbl; + root_signature->refcount = 1; + + root_signature->device = device; + ID3D12Device_AddRef(&device->ID3D12Device_iface); +} + +HRESULT d3d12_root_signature_create(struct d3d12_device *device, + const D3D12_ROOT_SIGNATURE_DESC *desc, struct d3d12_root_signature **root_signature) +{ + struct d3d12_root_signature *object; + + if (!(object = vkd3d_malloc(sizeof(*object)))) + return E_OUTOFMEMORY; + + d3d12_root_signature_init(object, device, desc); + + TRACE("Created root signature %p.\n", object); + + *root_signature = object; + + return S_OK; +} diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index cabf2ba5..c525d3cd 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -70,6 +70,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; +/* ID3D12RootSignature */ +struct d3d12_root_signature +{ + ID3D12RootSignature ID3D12RootSignature_iface; + ULONG refcount; + + struct d3d12_device *device; +}; + +HRESULT d3d12_root_signature_create(struct d3d12_device *device, + const D3D12_ROOT_SIGNATURE_DESC *desc, struct d3d12_root_signature **root_signature) DECLSPEC_HIDDEN; + /* ID3D12CommandAllocator */ struct d3d12_command_allocator {