vkd3d: Add support for UAV counters in pixel shaders.

Allows GRID (2019) to run in D3D12 mode.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49107
Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2021-07-24 00:02:43 +10:00 committed by Alexandre Julliard
parent 640b914bfb
commit 8860c4d077
2 changed files with 12 additions and 14 deletions

View File

@ -2268,8 +2268,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.push_constant_buffer_count = root_signature->root_constant_count;
shader_interface.combined_samplers = NULL; shader_interface.combined_samplers = NULL;
shader_interface.combined_sampler_count = 0; 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) for (i = 0; i < ARRAY_SIZE(shader_stages); ++i)
{ {
@ -2290,19 +2288,16 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
hr = hresult_from_vkd3d_result(ret); hr = hresult_from_vkd3d_result(ret);
goto fail; 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]; WARN("Failed to create descriptor set layout for UAV counters, hr %#x.\n", hr);
goto fail;
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;
}
} }
vkd3d_shader_free_scan_descriptor_info(&shader_info); vkd3d_shader_free_scan_descriptor_info(&shader_info);
shader_interface.uav_counters = NULL;
shader_interface.uav_counter_count = 0;
target_info = NULL; target_info = NULL;
switch (shader_stages[i].stage) switch (shader_stages[i].stage)
{ {
@ -2328,6 +2323,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
break; break;
case VK_SHADER_STAGE_FRAGMENT_BIT: case VK_SHADER_STAGE_FRAGMENT_BIT:
shader_interface.uav_counters = state->uav_counters.bindings;
shader_interface.uav_counter_count = state->uav_counters.binding_count;
target_info = &ps_target_info; target_info = &ps_target_info;
break; break;
@ -2523,6 +2520,8 @@ fail:
} }
vkd3d_shader_free_shader_signature(&input_signature); vkd3d_shader_free_shader_signature(&input_signature);
d3d12_pipeline_uav_counter_state_cleanup(&state->uav_counters, device);
return hr; return hr;
} }
@ -2811,7 +2810,8 @@ VkPipeline d3d12_pipeline_state_get_or_create_pipeline(struct d3d12_pipeline_sta
pipeline_desc.pDepthStencilState = &graphics->ds_desc; pipeline_desc.pDepthStencilState = &graphics->ds_desc;
pipeline_desc.pColorBlendState = &blend_desc; pipeline_desc.pColorBlendState = &blend_desc;
pipeline_desc.pDynamicState = &dynamic_desc; pipeline_desc.pDynamicState = &dynamic_desc;
pipeline_desc.layout = graphics->root_signature->vk_pipeline_layout; pipeline_desc.layout = state->uav_counters.vk_pipeline_layout ? state->uav_counters.vk_pipeline_layout
: graphics->root_signature->vk_pipeline_layout;
pipeline_desc.subpass = 0; pipeline_desc.subpass = 0;
pipeline_desc.basePipelineHandle = VK_NULL_HANDLE; pipeline_desc.basePipelineHandle = VK_NULL_HANDLE;
pipeline_desc.basePipelineIndex = -1; pipeline_desc.basePipelineIndex = -1;

View File

@ -22481,14 +22481,12 @@ static void test_graphics_uav_counters(void)
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
counter = read_uav_counter(&context, counter_buffer, uav_desc.Buffer.CounterOffsetInBytes); counter = read_uav_counter(&context, counter_buffer, uav_desc.Buffer.CounterOffsetInBytes);
todo
ok(counter == 64, "Got %u, expected 64.\n", counter); ok(counter == 64, "Got %u, expected 64.\n", counter);
transition_sub_resource_state(command_list, buffer, 0, transition_sub_resource_state(command_list, buffer, 0,
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); 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); 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); set_box(&box, 0, 0, 0, uav_desc.Buffer.NumElements, 1, 1);
todo
check_readback_data_uint(&rb, &box, 1, 0); check_readback_data_uint(&rb, &box, 1, 0);
release_resource_readback(&rb); release_resource_readback(&rb);