From 5b5cffcf849c80e933586d42c77e65d036cc3ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 10 Oct 2017 16:01:35 +0200 Subject: [PATCH] libs/vkd3d: Implement creating root signature from bytecode. --- libs/vkd3d/device.c | 9 +-------- libs/vkd3d/state.c | 26 ++++++++++++++++++++++---- libs/vkd3d/vkd3d_private.h | 4 ++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index c3ce4836..c54f7d8d 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -1273,14 +1273,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateRootSignature(ID3D12Device * if (node_mask && node_mask != 1) FIXME("Ignoring node mask 0x%08x.\n", node_mask); - if (bytecode_length != ~(SIZE_T)0) - { - 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))) + if (FAILED(hr = d3d12_root_signature_create(device, bytecode, bytecode_length, &object))) return hr; return return_interface((IUnknown *)&object->ID3D12RootSignature_iface, diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 921e1ea2..ad385991 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1001,15 +1001,33 @@ fail: } HRESULT d3d12_root_signature_create(struct d3d12_device *device, - const D3D12_ROOT_SIGNATURE_DESC *desc, struct d3d12_root_signature **root_signature) + const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature) { + const struct vkd3d_shader_code dxbc = {bytecode, bytecode_length}; + D3D12_ROOT_SIGNATURE_DESC root_signature_desc; struct d3d12_root_signature *object; HRESULT hr; - if (!(object = vkd3d_malloc(sizeof(*object)))) - return E_OUTOFMEMORY; + if (bytecode_length == ~(SIZE_T)0) + { + root_signature_desc = *(const D3D12_ROOT_SIGNATURE_DESC *)bytecode; + } + else if (FAILED(hr = vkd3d_shader_parse_root_signature(&dxbc, &root_signature_desc))) + { + WARN("Failed to parse root signature, hr %#x.\n", hr); + return hr; + } - if (FAILED(hr = d3d12_root_signature_init(object, device, desc))) + if (!(object = vkd3d_malloc(sizeof(*object)))) + { + vkd3d_shader_free_root_signature(&root_signature_desc); + return E_OUTOFMEMORY; + } + + hr = d3d12_root_signature_init(object, device, &root_signature_desc); + if (bytecode_length != ~(SIZE_T)0) + vkd3d_shader_free_root_signature(&root_signature_desc); + if (FAILED(hr)) { vkd3d_free(object); return hr; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 32c55382..1988bbd9 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -394,8 +394,8 @@ struct d3d12_root_signature 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; +HRESULT d3d12_root_signature_create(struct d3d12_device *device, const void *bytecode, + size_t bytecode_length, struct d3d12_root_signature **root_signature) DECLSPEC_HIDDEN; struct d3d12_root_signature *unsafe_impl_from_ID3D12RootSignature(ID3D12RootSignature *iface) DECLSPEC_HIDDEN; struct d3d12_graphics_pipeline_state