From 083a58767a98a216409680de2dfa34a72bb230b2 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 26 Jan 2024 16:32:30 -0600 Subject: [PATCH] tests: Test HLSL unbounded array syntax. Change the shader in test_unbounded_samplers() to also test a nested array. Note that the changed shader compiles to the same bytecode. --- Makefile.am | 1 + tests/d3d12.c | 16 ++++++++------- tests/hlsl/unbounded-array-5.1.shader_test | 23 ++++++++++++++++++++++ tests/shader_runner.c | 1 + 4 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 tests/hlsl/unbounded-array-5.1.shader_test diff --git a/Makefile.am b/Makefile.am index 68e8642e..39b04150 100644 --- a/Makefile.am +++ b/Makefile.am @@ -214,6 +214,7 @@ vkd3d_shader_tests = \ tests/hlsl/uav-rwbyteaddressbuffer.shader_test \ tests/hlsl/uav-rwstructuredbuffer.shader_test \ tests/hlsl/uav-rwtexture.shader_test \ + tests/hlsl/unbounded-array-5.1.shader_test \ tests/hlsl/uniform-parameters.shader_test \ tests/hlsl/uniform-semantics.shader_test \ tests/hlsl/vector-indexing-uniform.shader_test \ diff --git a/tests/d3d12.c b/tests/d3d12.c index b8d20a58..ccebf510 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -37211,14 +37211,15 @@ static void test_unbounded_samplers(void) { #if 0 Texture2D t1 : register(t1, space1); - SamplerState s1[] : register(s1, space1); + SamplerState s1[][2] : register(s1, space1); RWByteAddressBuffer u1 : register(u1, space1); [numthreads(64, 1, 1)] void main(uint id : SV_DispatchThreadID) { - /* Should alternate between wrap (address 0.1), or clamp (address 1.0). */ - uint value = t1.SampleLevel(s1[NonUniformResourceIndex(id)], float2(1.1, 1.1), 0.0); + /* wrap yields address 0.1; clamp yields address 1.0. + * Samplers alternate (wrap, wrap), (clamp, wrap), (wrap, clamp), (clamp, clamp). */ + uint value = t1.SampleLevel(s1[NonUniformResourceIndex(id / 2)][NonUniformResourceIndex(id % 2)], float2(1.1, 1.1), 0.0); u1.Store(4 * id, value); } #endif @@ -37236,7 +37237,7 @@ static void test_unbounded_samplers(void) 0x00000001, 0x0010001a, 0x00000000, 0x0010000a, 0x00000000, 0x0100003e, }; - static const float texture_data[] = {10.0f, 100.0f, 100.0f, 100.0f}; + static const float texture_data[] = {10.0f, 11.0f, 12.0f, 13.0f}; if (!init_compute_test_context(&context)) return; @@ -37294,8 +37295,9 @@ static void test_unbounded_samplers(void) { memset(&sampler_desc, 0, sizeof(sampler_desc)); sampler_desc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - sampler_desc.AddressU = sampler_desc.AddressV = sampler_desc.AddressW - = (i & 1) ? D3D12_TEXTURE_ADDRESS_MODE_CLAMP : D3D12_TEXTURE_ADDRESS_MODE_WRAP; + sampler_desc.AddressU = (i & 1) ? D3D12_TEXTURE_ADDRESS_MODE_CLAMP : D3D12_TEXTURE_ADDRESS_MODE_WRAP; + sampler_desc.AddressV = (i & 2) ? D3D12_TEXTURE_ADDRESS_MODE_CLAMP : D3D12_TEXTURE_ADDRESS_MODE_WRAP; + sampler_desc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; ID3D12Device_CreateSampler(device, &sampler_desc, get_cpu_descriptor_handle(&context, sampler_heap, i)); } @@ -37313,7 +37315,7 @@ static void test_unbounded_samplers(void) for (i = 0; i < 64; ++i) { unsigned int value = get_readback_uint(&rb.rb, i, 0, 0); - unsigned int expected = (i & 1) ? 100 : 10; + unsigned int expected = 10 + (i % 4); ok(value == expected, "Got %u, expected %u at %u.\n", value, expected, i); } release_resource_readback(&rb); diff --git a/tests/hlsl/unbounded-array-5.1.shader_test b/tests/hlsl/unbounded-array-5.1.shader_test new file mode 100644 index 00000000..e648e009 --- /dev/null +++ b/tests/hlsl/unbounded-array-5.1.shader_test @@ -0,0 +1,23 @@ +[require] +shader model >= 5.1 +options: unbounded-descriptor-arrays + +[pixel shader fail] +SamplerState s[][]; + +float4 main() : sv_target +{ + return 0; +} + +[pixel shader fail] +SamplerState s[2][]; +float4 main() : sv_target {return 0;} + +[pixel shader fail] +float f[]; +float4 main() : sv_target {return 0;} + +[pixel shader fail todo] +STRING s[]; +float4 main() : sv_target {return 0;} diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 5eafbcbe..f800ded3 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -311,6 +311,7 @@ static void parse_require_directive(struct shader_runner *runner, const char *li { D3DCOMPILE_PACK_MATRIX_ROW_MAJOR, "row-major" }, { D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR, "column-major" }, { D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY, "backcompat" }, + { D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES, "unbounded-descriptor-arrays" }, }; runner->compile_options = 0;