Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d/state.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 4537e319..c60478be 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1190,6 +1190,18 @@ static void d3d12_pipeline_state_destroy_graphics(struct d3d12_pipeline_state *s } }
+static void d3d12_pipeline_state_uav_counter_cleanup(struct d3d12_pipeline_state *state, struct d3d12_device *device) +{ + const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; + + if (state->vk_set_layout) + VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout, NULL)); + if (state->vk_pipeline_layout) + VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout, NULL)); + + vkd3d_free(state->uav_counters); +} + static ULONG STDMETHODCALLTYPE d3d12_pipeline_state_Release(ID3D12PipelineState *iface) { struct d3d12_pipeline_state *state = impl_from_ID3D12PipelineState(iface); @@ -1209,12 +1221,7 @@ static ULONG STDMETHODCALLTYPE d3d12_pipeline_state_Release(ID3D12PipelineState else if (d3d12_pipeline_state_is_compute(state)) VK_CALL(vkDestroyPipeline(device->vk_device, state->u.compute.vk_pipeline, NULL));
- if (state->vk_set_layout) - VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout, NULL)); - if (state->vk_pipeline_layout) - VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout, NULL)); - - vkd3d_free(state->uav_counters); + d3d12_pipeline_state_uav_counter_cleanup(state, device);
vkd3d_free(state);
@@ -1574,22 +1581,14 @@ static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *st vk_pipeline_layout, &state->u.compute.vk_pipeline))) { WARN("Failed to create Vulkan compute pipeline, hr %#x.\n", hr); - if (state->vk_set_layout) - VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout, NULL)); - if (state->vk_pipeline_layout) - VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout, NULL)); - vkd3d_free(state->uav_counters); + d3d12_pipeline_state_uav_counter_cleanup(state, device); return hr; }
if (FAILED(hr = vkd3d_private_store_init(&state->private_store))) { VK_CALL(vkDestroyPipeline(device->vk_device, state->u.compute.vk_pipeline, NULL)); - if (state->vk_set_layout) - VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout, NULL)); - if (state->vk_pipeline_layout) - VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout, NULL)); - vkd3d_free(state->uav_counters); + d3d12_pipeline_state_uav_counter_cleanup(state, device); return hr; }
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49107 Allows GRID 2019 to run in D3D12 mode.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- v2: Cleanup properly after failure. --- libs/vkd3d/state.c | 24 ++++++++++++------------ tests/d3d12.c | 2 -- 2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index c60478be..8c73b40d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -2273,8 +2273,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s shader_interface.push_constant_buffer_count = root_signature->root_constant_count; shader_interface.combined_samplers = NULL; shader_interface.combined_sampler_count = 0; - shader_interface.uav_counters = NULL; - shader_interface.uav_counter_count = 0;
for (i = 0; i < ARRAY_SIZE(shader_stages); ++i) { @@ -2295,19 +2293,16 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s hr = hresult_from_vkd3d_result(ret); goto fail; } - for (j = 0; j < shader_info.descriptor_count; ++j) + if (FAILED(hr = d3d12_pipeline_state_init_uav_counters(state, + device, root_signature, &shader_info, shader_stages[i].stage))) { - const struct vkd3d_shader_descriptor_info *d = &shader_info.descriptors[j]; - - if (d->type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV - && (d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_COUNTER)) - { - FIXME("UAV counters not implemented for graphics pipelines.\n"); - break; - } + WARN("Failed to create descriptor set layout for UAV counters, hr %#x.\n", hr); + goto fail; } vkd3d_shader_free_scan_descriptor_info(&shader_info);
+ shader_interface.uav_counters = NULL; + shader_interface.uav_counter_count = 0; target_info = NULL; switch (shader_stages[i].stage) { @@ -2333,6 +2328,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s break;
case VK_SHADER_STAGE_FRAGMENT_BIT: + shader_interface.uav_counters = state->uav_counters; + shader_interface.uav_counter_count = state->uav_counter_count; target_info = &ps_target_info; break;
@@ -2528,6 +2525,8 @@ fail: } vkd3d_shader_free_shader_signature(&input_signature);
+ d3d12_pipeline_state_uav_counter_cleanup(state, device); + return hr; }
@@ -2816,7 +2815,8 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta pipeline_desc.pDepthStencilState = &graphics->ds_desc; pipeline_desc.pColorBlendState = &blend_desc; pipeline_desc.pDynamicState = &dynamic_desc; - pipeline_desc.layout = graphics->root_signature->vk_pipeline_layout; + pipeline_desc.layout = state->vk_pipeline_layout ? state->vk_pipeline_layout + : graphics->root_signature->vk_pipeline_layout; pipeline_desc.subpass = 0; pipeline_desc.basePipelineHandle = VK_NULL_HANDLE; pipeline_desc.basePipelineIndex = -1; diff --git a/tests/d3d12.c b/tests/d3d12.c index e418b3c3..47e275cd 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -22481,14 +22481,12 @@ static void test_graphics_uav_counters(void) ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
counter = read_uav_counter(&context, counter_buffer, uav_desc.Buffer.CounterOffsetInBytes); - todo ok(counter == 64, "Got %u, expected 64.\n", counter);
transition_sub_resource_state(command_list, buffer, 0, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); get_buffer_readback_with_command_list(buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list); set_box(&box, 0, 0, 0, uav_desc.Buffer.NumElements, 1, 1); - todo check_readback_data_uint(&rb, &box, 1, 0); release_resource_readback(&rb);
On Tue, 20 Jul 2021 at 05:06, Conor McCarthy cmccarthy@codeweavers.com wrote:
+static void d3d12_pipeline_state_uav_counter_cleanup(struct d3d12_pipeline_state *state, struct d3d12_device *device) +{
- const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
- if (state->vk_set_layout)
VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout, NULL));
- if (state->vk_pipeline_layout)
VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout, NULL));
- vkd3d_free(state->uav_counters);
+}
If that's all UAV counter state (is it?) perhaps it makes sense to group it together in its own structure.