forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for multi-dim arrays and unbounded arrays (microsoft#5532)
I added at test for unbounded arrays. This case works, so no code changes were required. I also added a test for multi-dimensional arrays. This case is not handled allowed in Vulkan, so I chose to issue an error. If we need to support it, we could try improve it later by transforming the array into a single dimensional array. See https://gitlab.khronos.org/spirv/SPIR-V/-/issues/743 and https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#interfaces-resources-setandbinding.
- Loading branch information
Showing
5 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tools/clang/test/CodeGenSPIRV/type.rwstructured-buffer.array.multidim.counter.error.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %dxc -T ps_6_6 -E main -fvk-allow-rwstructuredbuffer-arrays | ||
|
||
struct PSInput | ||
{ | ||
uint idx : COLOR; | ||
}; | ||
|
||
RWStructuredBuffer<uint> g_rwbuffer[2][3] : register(u0, space2); | ||
|
||
float4 main(PSInput input) : SV_TARGET | ||
{ | ||
g_rwbuffer[1][input.idx].IncrementCounter(); | ||
return g_rwbuffer[input.idx][input.idx][0]; | ||
} | ||
|
||
// CHECK: :8:26: error: Multi-dimensional arrays of RW/append/consume structured buffers are unsupported in Vulkan | ||
// CHECK: RWStructuredBuffer<uint> g_rwbuffer[2][3] : register(u0, space2); |
30 changes: 30 additions & 0 deletions
30
tools/clang/test/CodeGenSPIRV/type.rwstructured-buffer.array.unbounded.counter.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: %dxc -T ps_6_6 -E main -fvk-allow-rwstructuredbuffer-arrays | ||
|
||
struct PSInput | ||
{ | ||
uint idx : COLOR; | ||
}; | ||
|
||
// CHECK: OpDecorate %g_rwbuffer DescriptorSet 2 | ||
// CHECK: OpDecorate %g_rwbuffer Binding 0 | ||
// CHECK: OpDecorate %counter_var_g_rwbuffer DescriptorSet 2 | ||
// CHECK: OpDecorate %counter_var_g_rwbuffer Binding 1 | ||
|
||
// CHECK: %g_rwbuffer = OpVariable %_ptr_Uniform__runtimearr_type_RWStructuredBuffer_uint Uniform | ||
// CHECK: %counter_var_g_rwbuffer = OpVariable %_ptr_Uniform__runtimearr_type_ACSBuffer_counter Uniform | ||
RWStructuredBuffer<uint> g_rwbuffer[] : register(u0, space2); | ||
|
||
float4 main(PSInput input) : SV_TARGET | ||
{ | ||
// Correctly increment the counter. | ||
// CHECK: [[ac1:%\w+]] = OpAccessChain %_ptr_Uniform_type_ACSBuffer_counter %counter_var_g_rwbuffer {{%\d+}} | ||
// CHECK: [[ac2:%\w+]] = OpAccessChain %_ptr_Uniform_int [[ac1]] %uint_0 | ||
// CHECK: OpAtomicIAdd %int [[ac2]] %uint_1 %uint_0 %int_1 | ||
g_rwbuffer[input.idx].IncrementCounter(); | ||
|
||
// Correctly access the buffer. | ||
// CHECK: [[ac1:%\w+]] = OpAccessChain %_ptr_Uniform_type_RWStructuredBuffer_uint %g_rwbuffer {{%\d+}} | ||
// CHECK: [[ac2:%\w+]] = OpAccessChain %_ptr_Uniform_uint [[ac1]] %int_0 %uint_0 | ||
// CHECK: OpLoad %uint [[ac2]] | ||
return g_rwbuffer[input.idx][0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters