This currently fails if the shader loads from the UAV, because it causes vkd3d-shader to specify the R32ui format instead of Unknown.
Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- v2: Make the load/store test independent of the store test. --- tests/d3d12.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index ec5cfb20..57e072e4 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -20947,6 +20947,56 @@ static void test_typed_buffer_uav(void) 0x00000000, 0x0002100a, 0x00004001, 0x00000020, 0x0002400a, 0x0a0000a4, 0x0011e0f2, 0x00000000, 0x00100006, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x0100003e, }; + static const DWORD cs_vec4_code[] = + { +#if 0 + RWBuffer<float4> buffer; + + [numthreads(8, 1, 1)] + void main(uint3 group_id : SV_groupID, uint group_index : SV_GroupIndex) + { + uint global_index = 8 * group_id.x + group_index; + buffer[global_index] = float4(0.5f, 0.625f, 0.75f, 1.0f); + } +#endif + 0x43425844, 0x37e9fa91, 0x11ca38f4, 0x9d4a70b7, 0x4fd05c45, 0x00000001, 0x000000e0, 0x00000003, + 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x0000008c, 0x00050050, 0x00000023, 0x0100086a, + 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0200005f, 0x00024000, 0x0200005f, 0x00021012, + 0x02000068, 0x00000001, 0x0400009b, 0x00000008, 0x00000001, 0x00000001, 0x07000023, 0x00100012, + 0x00000000, 0x0002100a, 0x00004001, 0x00000008, 0x0002400a, 0x0a0000a4, 0x0011e0f2, 0x00000000, + 0x00100006, 0x00000000, 0x00004002, 0x3f000000, 0x3f200000, 0x3f400000, 0x3f800000, 0x0100003e, + }; + static const DWORD cs_vec4_load_code[] = + { + /* Compiled with /Od */ +#if 0 + RWBuffer<float4> buffer; + + [numthreads(4, 1, 1)] + void main(uint3 group_id : SV_groupID, uint group_index : SV_GroupIndex) + { + uint global_index = 8 * group_id.x + group_index * 2u; + buffer[global_index] = float4(0.5f, 0.625f, 0.75f, 1.0f); + buffer[global_index + 1] = buffer[global_index]; + } +#endif + 0x43425844, 0x0b7914da, 0x7379094c, 0xa3567660, 0xeb9df127, 0x00000001, 0x000001b0, 0x00000004, + 0x00000030, 0x00000040, 0x00000050, 0x000001a0, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, + 0x4e47534f, 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000148, 0x00050050, 0x00000052, + 0x0100886a, 0x0400089c, 0x0011e000, 0x00000000, 0x00005555, 0x0200005f, 0x00024000, 0x0200005f, + 0x00021012, 0x02000068, 0x00000002, 0x0400009b, 0x00000004, 0x00000001, 0x00000001, 0x05000036, + 0x00100012, 0x00000000, 0x00004001, 0x00000008, 0x07000026, 0x0000d000, 0x00100012, 0x00000000, + 0x0010000a, 0x00000000, 0x0002100a, 0x07000026, 0x0000d000, 0x00100022, 0x00000000, 0x0002400a, + 0x00004001, 0x00000002, 0x0700001e, 0x00100012, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, + 0x00000000, 0x0a0000a4, 0x0011e0f2, 0x00000000, 0x00100006, 0x00000000, 0x00004002, 0x3f000000, + 0x3f200000, 0x3f400000, 0x3f800000, 0x05000036, 0x00100022, 0x00000000, 0x00004001, 0x00000001, + 0x0700001e, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x890000a3, + 0x80000042, 0x00155543, 0x001000f2, 0x00000001, 0x00100006, 0x00000000, 0x0011ee46, 0x00000000, + 0x070000a4, 0x0011e0f2, 0x00000000, 0x00100556, 0x00000000, 0x00100e46, 0x00000001, 0x0100003e, + 0x30494653, 0x00000008, 0x00000800, 0x00000000, + }; + static const struct vec4 expected = {0.5f, 0.625f, 0.75f, 1.0f};
if (!init_compute_test_context(&context)) return; @@ -21004,6 +21054,48 @@ static void test_typed_buffer_uav(void) check_readback_data_float(&rb.rb, NULL, 0.5f, 0); release_resource_readback(&rb);
+ reset_command_list(command_list, context.allocator); + transition_sub_resource_state(command_list, resource, 0, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + ID3D12PipelineState_Release(pipeline_state); + pipeline_state = create_compute_pipeline_state(device, root_signature, + shader_bytecode(cs_vec4_code, sizeof(cs_vec4_code))); + + uav_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + uav_desc.Buffer.NumElements = 16; + ID3D12Device_CreateUnorderedAccessView(device, resource, NULL, &uav_desc, cpu_descriptor_handle); + + ID3D12GraphicsCommandList_SetPipelineState(command_list, pipeline_state); + ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature); + ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list, 0, gpu_descriptor_handle); + ID3D12GraphicsCommandList_Dispatch(command_list, 2, 1, 1); + + transition_sub_resource_state(command_list, resource, 0, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_buffer_readback_with_command_list(resource, uav_desc.Format, &rb, queue, command_list); + check_readback_data_vec4(&rb.rb, NULL, &expected, 0); + release_resource_readback(&rb); + + reset_command_list(command_list, context.allocator); + transition_sub_resource_state(command_list, resource, 0, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + ID3D12PipelineState_Release(pipeline_state); + pipeline_state = create_compute_pipeline_state(device, root_signature, + shader_bytecode(cs_vec4_load_code, sizeof(cs_vec4_load_code))); + + ID3D12GraphicsCommandList_SetPipelineState(command_list, pipeline_state); + ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature); + ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list, 0, gpu_descriptor_handle); + ID3D12GraphicsCommandList_Dispatch(command_list, 2, 1, 1); + + transition_sub_resource_state(command_list, resource, 0, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_buffer_readback_with_command_list(resource, uav_desc.Format, &rb, queue, command_list); + todo check_readback_data_vec4(&rb.rb, NULL, &expected, 0); + release_resource_readback(&rb); + ID3D12Resource_Release(resource); ID3D12RootSignature_Release(root_signature); ID3D12PipelineState_Release(pipeline_state);
On Mon, 11 Jul 2022 at 16:27, Conor McCarthy cmccarthy@codeweavers.com wrote:
- get_buffer_readback_with_command_list(resource, uav_desc.Format, &rb, queue, command_list);
- check_readback_data_vec4(&rb.rb, NULL, &expected, 0);
- release_resource_readback(&rb);
- reset_command_list(command_list, context.allocator);
- transition_sub_resource_state(command_list, resource, 0,
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
- ID3D12PipelineState_Release(pipeline_state);
- pipeline_state = create_compute_pipeline_state(device, root_signature,
shader_bytecode(cs_vec4_load_code, sizeof(cs_vec4_load_code)));
- ID3D12GraphicsCommandList_SetPipelineState(command_list, pipeline_state);
- ID3D12GraphicsCommandList_SetComputeRootSignature(command_list, root_signature);
- ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(command_list, 0, gpu_descriptor_handle);
- ID3D12GraphicsCommandList_Dispatch(command_list, 2, 1, 1);
- transition_sub_resource_state(command_list, resource, 0,
D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE);
- get_buffer_readback_with_command_list(resource, uav_desc.Format, &rb, queue, command_list);
- todo check_readback_data_vec4(&rb.rb, NULL, &expected, 0);
- release_resource_readback(&rb);
I think still has the same issue as the previous v2; if for one reason or another the Dispatch() command is not executed, the test would succeed, because the expected value here is the same as for the preceding test, and we never clear or reinitialise the output buffer between them. The easiest way around that is likely to simply use different expected values for the two tests.