diff --git a/test/Feature/ResourceArrays/multi-dim-array-subset.test b/test/Feature/ResourceArrays/multi-dim-array-subset.test new file mode 100644 index 00000000..c01e1db4 --- /dev/null +++ b/test/Feature/ResourceArrays/multi-dim-array-subset.test @@ -0,0 +1,81 @@ +#--- source.hlsl + +// Verify handling of subsets of multi-dimensional resource arrays +// used in a function argument. + +RWStructuredBuffer In[4][2] : register(u0); +RWStructuredBuffer Out : register(u0, space1); + +float foo(RWStructuredBuffer A[2], uint Index) { + return A[0][Index] + A[1][Index]; +} + +[numthreads(4,1,1)] +void main(uint GI : SV_GroupIndex) { + for (int i = 0; i < 4; i++) { + Out[i] = foo(In[i], i); + } +} + +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: BufIn + Format: Float32 + ArraySize: 8 + Data: + - [ 1.0, 2.0, 3.0, 4.0 ] + - [ 0.1, 0.2, 0.3, 0.4 ] + - [ 5.0, 6.0, 7.0, 8.0 ] + - [ 0.5, 0.6, 0.7, 0.8 ] + - [ 10.0, 11.0, 12.0, 13.0 ] + - [ 0.10, 0.11, 0.12, 0.13 ] + - [ 14.0, 15.0, 16.0, 17.0 ] + - [ 0.14, 0.15, 0.16, 0.17 ] + + - Name: BufOut + Format: Float32 + ZeroInitSize: 16 + + - Name: ExpectedOut + Format: Float32 + Data: [ 1.1, 6.6, 12.12, 17.17 ] + +Results: + - Result: BufOut + Rule: BufferFloatULP + ULPT: 1 # Float addition should be within 1 ULP on all hardware. + Actual: BufOut + Expected: ExpectedOut + +DescriptorSets: + - Resources: + - Name: BufIn + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + - Name: BufOut + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 1 +... +#--- end + +# Bug https://github.com/llvm/llvm-project/issues/160937 +# XFAIL: Clang + +# Vulkan does not support multi-dimensional resource arrays +# UNSUPPORTED: Vulkan + +# Resource arrays are not yet supported on Metal +# UNSUPPORTED: Metal + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/ResourceArrays/multi-dim-unbounded-array.test b/test/Feature/ResourceArrays/multi-dim-unbounded-array.test new file mode 100644 index 00000000..06b97333 --- /dev/null +++ b/test/Feature/ResourceArrays/multi-dim-unbounded-array.test @@ -0,0 +1,68 @@ +#--- source.hlsl + +// Verify handling of unbounded multi-dimensional resource array. + +RWStructuredBuffer Buf[][2] : register(u0); + +[numthreads(4,2,1)] +void main(uint3 GTI : SV_GroupThreadID, uint GI : SV_GroupIndex) { + for (int i = 0; i < 4; i++) { + Buf[1][0][i] = Buf[0][0][i] + Buf[0][1][i]; + Buf[1][1][i] = Buf[0][0][i] * Buf[0][1][i]; + Buf[0][0][i] += Buf[0][1][i]; + } +} + +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Buf + Format: Int32 + ArraySize: 4 + Data: + - [ 0, 1, 2, 3 ] + - [ 1, 2, 3, 4 ] + - [ 2, 3, 4, 5 ] + - [ 3, 4, 5, 6 ] + + - Name: ExpectedBuf + Format: Int32 + ArraySize: 4 + Data: + - [ 1, 3, 5, 7 ] + - [ 1, 2, 3, 4 ] + - [ 1, 3, 5, 7 ] + - [ 0, 2, 6, 12 ] + +Results: + - Result: Buf + Rule: BufferExact + Actual: Buf + Expected: ExpectedBuf + +DescriptorSets: + - Resources: + - Name: Buf + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 +... +#--- end + +# Bug https://github.com/llvm/llvm-project/issues/159679 +# XFAIL: Clang + +# Resource arrays are not yet supported on Metal +# UNSUPPORTED: Metal + +# Vulkan does not support multi-dimensional resource arrays +# UNSUPPORTED: Vulkan + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o diff --git a/test/Feature/ResourceArrays/unbounded-array.test b/test/Feature/ResourceArrays/unbounded-array.test new file mode 100644 index 00000000..1af42207 --- /dev/null +++ b/test/Feature/ResourceArrays/unbounded-array.test @@ -0,0 +1,65 @@ +#--- source.hlsl + +// Verify handling of unbounded resource array. + +[[vk::binding(0)]] +RWBuffer Buf[] : register(u0); + +[numthreads(4,2,1)] +void main(uint GI : SV_GroupIndex) { + for (int i = 0; i < 4; i++) { + Buf[1][i] = Buf[0][i] * 2; + Buf[2][i] = Buf[0][i] + Buf[1][i]; + } +} + +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Buf + Format: Int32 + ArraySize: 3 + Data: + - [ 1, 2, 3, 4 ] + - [ 0, 0, 0, 0 ] + - [ 0, 0, 0, 0 ] + + - Name: ExpectedBuf + Format: Int32 + ArraySize: 3 + Data: + - [ 1, 2, 3, 4 ] + - [ 2, 4, 6, 8 ] + - [ 3, 6, 9, 12 ] + +Results: + - Result: Buf + Rule: BufferExact + Actual: Buf + Expected: ExpectedBuf + +DescriptorSets: + - Resources: + - Name: Buf + Kind: RWBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug https://github.com/llvm/llvm-project/issues/159679 +# XFAIL: Clang && DirectX + +# Resource arrays are not yet supported on Metal +# UNSUPPORTED: Metal + +# RUN: split-file %s %t +# RUN: %dxc_target -T cs_6_0 -Fo %t.o %t/source.hlsl +# RUN: %offloader %t/pipeline.yaml %t.o