Module: vkd3d Branch: master Commit: 7d6f0f2592a8aedf749c2dff36ea330e9ccb49d1 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/7d6f0f2592a8aedf749c2dff36ea33...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Sep 5 15:39:06 2023 +0200
vkd3d: Implement creating compute pipeline states from shaders with embedded root signatures.
---
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 08cc110e..b8328216 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 91ffa6e9..8de57a33 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 e414ca36..31f57c40 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);