From eb2c3b0b900419385cc00bb3daf60bbd986bc858 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 25 Apr 2022 15:36:59 -0500 Subject: [PATCH] tests: Test depth comparison sampling with cubemap array textures. Signed-off-by: Zebediah Figura Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- tests/d3d12.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 7 deletions(-) diff --git a/tests/d3d12.c b/tests/d3d12.c index c992c6de..015c3122 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -14588,7 +14588,82 @@ static void test_sample_c_lz(void) 0x00000000, 0x0100003e, }; static const D3D12_SHADER_BYTECODE ps_cube = {ps_cube_code, sizeof(ps_cube_code)}; - static const float depth_values[] = {1.0f, 0.0f, 0.5f, 0.6f, 0.4f, 0.1f}; + static const DWORD ps_cube_array_code[] = + { +#if 0 + TextureCubeArray t; + SamplerComparisonState s; + + float ref; + float layer; + + float4 main(float4 position : SV_Position) : SV_Target + { + float2 p; + p.x = position.x / 640.0f; + p.y = position.y / 480.0f; + + float3 coord; + switch ((uint)layer % 6) + { + case 0: + coord = float3(1.0f, p.x, p.y); + break; + case 1: + coord = float3(-1.0f, p.x, p.y); + break; + case 2: + coord = float3(p.x, 1.0f, p.y); + break; + case 3: + coord = float3(p.x, -1.0f, p.y); + break; + case 4: + coord = float3(p.x, p.y, 1.0f); + break; + case 5: + default: + coord = float3(p.x, p.y, -1.0f); + break; + } + + return t.SampleCmpLevelZero(s, float4(coord, (uint)layer / 6), ref); + } +#endif + 0x43425844, 0xafbb850b, 0x724ab414, 0x56cdc3a8, 0x6b9fd1af, 0x00000001, 0x00000360, 0x00000003, + 0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000002c4, 0x00000041, + 0x000000b1, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x0300085a, 0x00106000, + 0x00000000, 0x04005058, 0x00107000, 0x00000000, 0x00005555, 0x04002064, 0x00101032, 0x00000000, + 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x0600001c, 0x00100012, + 0x00000000, 0x0020801a, 0x00000000, 0x00000000, 0x0900004e, 0x00100012, 0x00000000, 0x00100012, + 0x00000001, 0x0010000a, 0x00000000, 0x00004001, 0x00000006, 0x0300004c, 0x0010000a, 0x00000001, + 0x03000006, 0x00004001, 0x00000000, 0x05000036, 0x00100012, 0x00000001, 0x00004001, 0x3f800000, + 0x0a000038, 0x00100062, 0x00000001, 0x00101106, 0x00000000, 0x00004002, 0x00000000, 0x3acccccd, + 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, 0x00000001, 0x05000036, 0x00100012, + 0x00000001, 0x00004001, 0xbf800000, 0x0a000038, 0x00100062, 0x00000001, 0x00101106, 0x00000000, + 0x00004002, 0x00000000, 0x3acccccd, 0x3b088889, 0x00000000, 0x01000002, 0x03000006, 0x00004001, + 0x00000002, 0x0a000038, 0x00100052, 0x00000001, 0x00101106, 0x00000000, 0x00004002, 0x3acccccd, + 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, 0x00000001, 0x00004001, 0x3f800000, + 0x01000002, 0x03000006, 0x00004001, 0x00000003, 0x0a000038, 0x00100052, 0x00000001, 0x00101106, + 0x00000000, 0x00004002, 0x3acccccd, 0x00000000, 0x3b088889, 0x00000000, 0x05000036, 0x00100022, + 0x00000001, 0x00004001, 0xbf800000, 0x01000002, 0x03000006, 0x00004001, 0x00000004, 0x0a000038, + 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, 0x00000000, + 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x01000002, 0x0100000a, + 0x0a000038, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x00004002, 0x3acccccd, 0x3b088889, + 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0xbf800000, 0x01000002, + 0x01000017, 0x05000056, 0x00100082, 0x00000001, 0x0010000a, 0x00000000, 0x0c000047, 0x00100012, + 0x00000000, 0x00100e46, 0x00000001, 0x00107006, 0x00000000, 0x00106000, 0x00000000, 0x0020800a, + 0x00000000, 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps_cube_array = {ps_cube_array_code, sizeof(ps_cube_array_code)}; + static const float depth_values[] = + { + 1.0f, 0.0f, 0.5f, 0.6f, 0.4f, 0.1f, + 0.2f, 0.9f, 0.0f, 1.0f, 0.8f, 0.3f, + }; static const struct { unsigned int layer; @@ -14597,12 +14672,18 @@ static void test_sample_c_lz(void) } tests[] = { - {0, 0.5f, 0.0f}, - {1, 0.5f, 1.0f}, - {2, 0.5f, 0.0f}, - {3, 0.5f, 0.0f}, - {4, 0.5f, 1.0f}, - {5, 0.5f, 1.0f}, + { 0, 0.5f, 0.0f}, + { 1, 0.5f, 1.0f}, + { 2, 0.5f, 0.0f}, + { 3, 0.5f, 0.0f}, + { 4, 0.5f, 1.0f}, + { 5, 0.5f, 1.0f}, + { 6, 0.5f, 1.0f}, + { 7, 0.5f, 0.0f}, + { 8, 0.5f, 1.0f}, + { 9, 0.5f, 0.0f}, + {10, 0.5f, 0.0f}, + {11, 0.5f, 1.0f}, {0, 0.0f, 0.0f}, {1, 0.0f, 0.0f}, @@ -14737,6 +14818,60 @@ static void test_sample_c_lz(void) srv_desc.TextureCube.MipLevels = 2; ID3D12Device_CreateShaderResourceView(context.device, ds.texture, &srv_desc, cpu_handle); + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + if (tests[i].layer >= 6) + continue; + + vkd3d_test_set_context("test %u", i); + + ps_constant.x = tests[i].d_ref; + ps_constant.y = tests[i].layer; + + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, clear_color, 0, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); + ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap); + ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0, + get_gpu_descriptor_handle(&context, heap, 0)); + ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 1, 4, &ps_constant.x, 0); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + /* Avoid testing values affected by seamless cube map filtering. */ + set_rect(&rect, 100, 100, 540, 380); + check_readback_data_float(&rb, &rect, tests[i].expected, 2); + release_resource_readback(&rb); + + reset_command_list(command_list, context.allocator); + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); + } + vkd3d_test_set_context(NULL); + + ID3D12PipelineState_Release(context.pipeline_state); + + /* cube array texture */ + context.pipeline_state = create_pipeline_state(context.device, + context.root_signature, context.render_target_desc.Format, NULL, &ps_cube_array, NULL); + + memset(&srv_desc, 0, sizeof(srv_desc)); + srv_desc.Format = DXGI_FORMAT_R32_FLOAT; + srv_desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srv_desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; + srv_desc.TextureCubeArray.MostDetailedMip = 0; + srv_desc.TextureCubeArray.MipLevels = 2; + srv_desc.TextureCubeArray.First2DArrayFace = 0; + srv_desc.TextureCubeArray.NumCubes = ARRAY_SIZE(depth_values) / 6; + ID3D12Device_CreateShaderResourceView(context.device, ds.texture, &srv_desc, cpu_handle); + for (i = 0; i < ARRAY_SIZE(tests); ++i) { vkd3d_test_set_context("test %u", i);