From: Henri Verbeet hverbeet@codeweavers.com
--- tests/d3d12.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index aaea5e316..e414ca361 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -3045,6 +3045,22 @@ static void test_create_compute_pipeline_state(void) ULONG refcount; HRESULT hr;
+ static const DWORD cs_with_rs[] = + { +#if 0 + [RootSignature("")] + [numthreads(1, 1, 1)] + void main() + { + } +#endif + 0x43425844, 0x215835dd, 0xdcf65f2e, 0x076d1ec0, 0xb1664d2b, 0x00000001, 0x00000098, 0x00000004, + 0x00000030, 0x00000040, 0x00000050, 0x00000078, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000020, 0x00050050, 0x00000008, + 0x0100086a, 0x0400009b, 0x00000001, 0x00000001, 0x00000001, 0x0100003e, 0x30535452, 0x00000018, + 0x00000001, 0x00000000, 0x00000018, 0x00000000, 0x00000018, 0x00000000, + }; + static const char shader_code[] = "[numthreads(1, 1, 1)]\n" "void main() { }\n"; @@ -3111,6 +3127,18 @@ static void test_create_compute_pipeline_state(void) refcount = ID3D12RootSignature_Release(root_signature); ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount);
+ pipeline_state_desc.pRootSignature = NULL; + hr = ID3D12Device_CreateComputePipelineState(device, &pipeline_state_desc, + &IID_ID3D12PipelineState, (void **)&pipeline_state); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + + pipeline_state_desc.CS = shader_bytecode(cs_with_rs, sizeof(cs_with_rs)); + hr = ID3D12Device_CreateComputePipelineState(device, &pipeline_state_desc, + &IID_ID3D12PipelineState, (void **)&pipeline_state); + todo ok(hr == S_OK, "Got hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ID3D12PipelineState_Release(pipeline_state); + refcount = ID3D12Device_Release(device); ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
From: Henri Verbeet hverbeet@codeweavers.com
--- libs/vkd3d/state.c | 28 +++++++++++++++++++++++++--- libs/vkd3d/vkd3d_private.h | 1 + tests/d3d12.c | 5 ++--- 3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 08cc110e8..b8328216a 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2045,6 +2045,9 @@ static ULONG STDMETHODCALLTYPE d3d12_pipeline_state_Release(ID3D12PipelineState
d3d12_pipeline_uav_counter_state_cleanup(&state->uav_counters, device);
+ if (state->implicit_root_signature) + d3d12_root_signature_Release(state->implicit_root_signature); + vkd3d_free(state);
d3d12_device_release(device); @@ -2413,8 +2416,8 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; struct vkd3d_shader_interface_info shader_interface; struct vkd3d_shader_descriptor_offset_info offset_info; - const struct d3d12_root_signature *root_signature; struct vkd3d_shader_spirv_target_info target_info; + struct d3d12_root_signature *root_signature; VkPipelineLayout vk_pipeline_layout; HRESULT hr;
@@ -2425,13 +2428,27 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st
if (!(root_signature = unsafe_impl_from_ID3D12RootSignature(desc->root_signature))) { - WARN("Root signature is NULL.\n"); - return E_INVALIDARG; + TRACE("Root signature is NULL, looking for an embedded signature.\n"); + if (FAILED(hr = d3d12_root_signature_create(device, + desc->cs.pShaderBytecode, desc->cs.BytecodeLength, &root_signature))) + { + WARN("Failed to find an embedded root signature, hr %s.\n", debugstr_hresult(hr)); + return hr; + } + state->implicit_root_signature = &root_signature->ID3D12RootSignature_iface; + } + else + { + state->implicit_root_signature = NULL; }
if (FAILED(hr = d3d12_pipeline_state_find_and_init_uav_counters(state, device, root_signature, &desc->cs, VK_SHADER_STAGE_COMPUTE_BIT))) + { + if (state->implicit_root_signature) + d3d12_root_signature_Release(state->implicit_root_signature); return hr; + }
memset(&target_info, 0, sizeof(target_info)); target_info.type = VKD3D_SHADER_STRUCTURE_TYPE_SPIRV_TARGET_INFO; @@ -2476,6 +2493,8 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st { WARN("Failed to create Vulkan compute pipeline, hr %s.\n", debugstr_hresult(hr)); d3d12_pipeline_uav_counter_state_cleanup(&state->uav_counters, device); + if (state->implicit_root_signature) + d3d12_root_signature_Release(state->implicit_root_signature); return hr; }
@@ -2483,6 +2502,8 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st { VK_CALL(vkDestroyPipeline(device->vk_device, state->u.compute.vk_pipeline, NULL)); d3d12_pipeline_uav_counter_state_cleanup(&state->uav_counters, device); + if (state->implicit_root_signature) + d3d12_root_signature_Release(state->implicit_root_signature); return hr; }
@@ -3484,6 +3505,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s goto fail;
state->vk_bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS; + state->implicit_root_signature = NULL; d3d12_device_add_ref(state->device = device);
return S_OK; diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 91ffa6e98..8de57a336 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1213,6 +1213,7 @@ struct d3d12_pipeline_state
struct d3d12_pipeline_uav_counter_state uav_counters;
+ ID3D12RootSignature *implicit_root_signature; struct d3d12_device *device;
struct vkd3d_private_store private_store; diff --git a/tests/d3d12.c b/tests/d3d12.c index e414ca361..31f57c409 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -3135,9 +3135,8 @@ static void test_create_compute_pipeline_state(void) pipeline_state_desc.CS = shader_bytecode(cs_with_rs, sizeof(cs_with_rs)); hr = ID3D12Device_CreateComputePipelineState(device, &pipeline_state_desc, &IID_ID3D12PipelineState, (void **)&pipeline_state); - todo ok(hr == S_OK, "Got hr %#x.\n", hr); - if (SUCCEEDED(hr)) - ID3D12PipelineState_Release(pipeline_state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ID3D12PipelineState_Release(pipeline_state);
refcount = ID3D12Device_Release(device); ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);