diff --git a/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_different_global.test b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_different_global.test new file mode 100644 index 000000000..b4bc913b8 --- /dev/null +++ b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_different_global.test @@ -0,0 +1,89 @@ +#--- source.hlsl +// Test that reassigning a local resource to a different global inside a +// conditional branch produces valid output. The branch is always taken +// (tid.x == 0 with numthreads(1,1,1)), so Out resolves to Out1. +// DXC: Error (codegen) — "local resource not guaranteed to map to unique global resource" + +RWByteAddressBuffer In : register(u0); +RWByteAddressBuffer Out0 : register(u1); +RWByteAddressBuffer Out1 : register(u2); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer Out = Out0; + if (tid.x == 0) { + Out = Out1; + } + Out.Store(0, In.Load(0)); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Stride: 4 + Data: [42] + - Name: Out0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: Out1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Out0Check + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: Out1Check + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 +DescriptorSets: + - Resources: + - Name: In + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# DXC codegen error: local resource not guaranteed to map to unique global resource +# XFAIL: DXC + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_from_array.test b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_from_array.test new file mode 100644 index 000000000..ee2fc8b8b --- /dev/null +++ b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_reassign_from_array.test @@ -0,0 +1,93 @@ +#--- source.hlsl +// Test that reassigning a local resource from an unbounded array element +// inside a conditional branch produces valid output. The branch is always +// taken (tid.x == 0), so Out resolves to OutArr[0]. +// DXC: Error (codegen) — "local resource not guaranteed to map to unique global resource" + +RWByteAddressBuffer In : register(u0); +RWByteAddressBuffer Out0 : register(u1); +RWByteAddressBuffer OutArr[] : register(u2); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer Out = Out0; + if (tid.x == 0) { + Out = OutArr[0]; + } + Out.Store(0, In.Load(0)); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Stride: 4 + Data: [42] + - Name: Out0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: OutArr + Format: Int32 + Stride: 4 + ArraySize: 1 + Data: + - [0] + - Name: ExpectedOut0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOutArr + Format: Int32 + Stride: 4 + ArraySize: 1 + Data: + - [42] +Results: + - Result: Out0Check + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: OutArrCheck + Rule: BufferExact + Actual: OutArr + Expected: ExpectedOutArr +DescriptorSets: + - Resources: + - Name: In + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: OutArr + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# DXC codegen error: local resource not guaranteed to map to unique global resource +# XFAIL: DXC + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_single_path_assign.test b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_single_path_assign.test new file mode 100644 index 000000000..c7000f5e1 --- /dev/null +++ b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_conditional_single_path_assign.test @@ -0,0 +1,57 @@ +#--- source.hlsl +// Test that a conditionally initialized local resource works correctly. +// DXC rejects this because it cannot prove the local resource maps to a +// unique global resource through the conditional branch. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer buf; + if (tid.x == 0) + buf = gBuf; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192542 +# XFAIL: DXC && Vulkan + +# Bug: TODO - DXC codegen error: local resource not guaranteed to map to unique global resource +# XFAIL: DXC + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/ClangPass-DXCCodegenError/local_resource_self_assign_uninitialized.test b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_self_assign_uninitialized.test new file mode 100644 index 000000000..ea438b471 --- /dev/null +++ b/test/Feature/LocalResources/ClangPass-DXCCodegenError/local_resource_self_assign_uninitialized.test @@ -0,0 +1,46 @@ +#--- source.hlsl +// Test that self-assignment of an uninitialized local resource compiles. +// NOTE: Runtime behavior is undefined — the handle is never bound to a +// global resource, so the Store operates on an uninitialized handle. +// DXC: Error (codegen) — "local resource not guaranteed to map to unique global resource" + +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer Out; + Out = Out; + Out.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# DXC codegen error: local resource not guaranteed to map to unique global resource +# XFAIL: DXC + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/DXCPass-ClangCodegenError/local_resource_array_dynamic_index.test b/test/Feature/LocalResources/DXCPass-ClangCodegenError/local_resource_array_dynamic_index.test new file mode 100644 index 000000000..97e1b9e63 --- /dev/null +++ b/test/Feature/LocalResources/DXCPass-ClangCodegenError/local_resource_array_dynamic_index.test @@ -0,0 +1,74 @@ +#--- source.hlsl + +// Test that a local resource array can be dynamically indexed at runtime. + +RWByteAddressBuffer gBufArray[4] : register(u0); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer arr[2]; + arr[0] = gBufArray[0]; + arr[1] = gBufArray[1]; + arr[tid.x & 1].Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [42] + - [0] + - [0] + - [0] +Results: + - Result: BufCheck + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedBufArray +DescriptorSets: + - Resources: + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192538 +# Metal is included because it uses the DXIL backend (Metal IR Converter takes +# DXIL as input), so it hits the same DXILLegalizePass assertion as DirectX. +# XFAIL: Clang && (DirectX || Metal) + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && 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/LocalResources/DXCPass-ClangCodegenError/local_resource_array_partial_init.test b/test/Feature/LocalResources/DXCPass-ClangCodegenError/local_resource_array_partial_init.test new file mode 100644 index 000000000..fdf31d828 --- /dev/null +++ b/test/Feature/LocalResources/DXCPass-ClangCodegenError/local_resource_array_partial_init.test @@ -0,0 +1,62 @@ +#--- source.hlsl + +// Test that a local resource array with only some elements initialized +// (others left default) compiles successfully. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer arr[4]; + arr[0] = Out; + arr[1] = Out; + arr[tid.x & 3].Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192538 +# Metal is included because it uses the DXIL backend (Metal IR Converter takes +# DXIL as input), so it hits the same DXILLegalizePass assertion as DirectX. +# XFAIL: Clang && (DirectX || Metal) + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && 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/LocalResources/DXCPass-ClangSemaError/local_resource_const_param.test b/test/Feature/LocalResources/DXCPass-ClangSemaError/local_resource_const_param.test new file mode 100644 index 000000000..c3ab49df8 --- /dev/null +++ b/test/Feature/LocalResources/DXCPass-ClangSemaError/local_resource_const_param.test @@ -0,0 +1,54 @@ +#--- source.hlsl +// Test that a const resource parameter can be read from inside a helper function. +RWByteAddressBuffer gBuf : register(u0); + +void UseConst(const RWByteAddressBuffer buf, out uint val) { + val = buf.Load(0); +} + +[numthreads(1,1,1)] +void main() { + const RWByteAddressBuffer local = gBuf; + gBuf.Store(0, 99); + uint val; + UseConst(local, val); + gBuf.Store(0, val == 99 ? 42 : 0); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192557 +# XFAIL: Clang + +# 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/LocalResources/DXCPass-ClangSemaError/local_resource_volatile.test b/test/Feature/LocalResources/DXCPass-ClangSemaError/local_resource_volatile.test new file mode 100644 index 000000000..c808335ce --- /dev/null +++ b/test/Feature/LocalResources/DXCPass-ClangSemaError/local_resource_volatile.test @@ -0,0 +1,47 @@ +#--- source.hlsl +// Test that a volatile local resource can store through a buffer. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main() { + volatile RWByteAddressBuffer buf = gBuf; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192559 +# XFAIL: Clang + +# 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/LocalResources/expression_init.test b/test/Feature/LocalResources/expression_init.test new file mode 100644 index 000000000..a3d4d52ba --- /dev/null +++ b/test/Feature/LocalResources/expression_init.test @@ -0,0 +1,75 @@ +#--- source.hlsl + +// Test that a local resource variable can be initialized via a ternary +// expression selecting between two global resources. + +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = (true ? gBuf0 : gBuf1); + buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] + - Name: ExpectedBuf1 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: OutCheck + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedOut + - Result: Buf1Check + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8381 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_aggregate_init.test b/test/Feature/LocalResources/local_resource_aggregate_init.test new file mode 100644 index 000000000..a5a38ed1d --- /dev/null +++ b/test/Feature/LocalResources/local_resource_aggregate_init.test @@ -0,0 +1,57 @@ +#--- source.hlsl + +// Test that aggregate (brace) initialization of a struct with a resource +// member works correctly. + +RWByteAddressBuffer Out : register(u0); + +struct ResHolder { RWByteAddressBuffer buf; }; + +[numthreads(1,1,1)] +void main() { + ResHolder h = {Out}; + h.buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8382 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_alias_chain.test b/test/Feature/LocalResources/local_resource_alias_chain.test new file mode 100644 index 000000000..59a4a2e2d --- /dev/null +++ b/test/Feature/LocalResources/local_resource_alias_chain.test @@ -0,0 +1,54 @@ +#--- source.hlsl + +// Test that a chain of local resource aliases (a = global, b = a, c = b) +// correctly propagates the binding through to the final store. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer a = Out; + RWByteAddressBuffer b = a; + RWByteAddressBuffer c = b; + c.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_alias_global.test b/test/Feature/LocalResources/local_resource_alias_global.test new file mode 100644 index 000000000..716e4a6be --- /dev/null +++ b/test/Feature/LocalResources/local_resource_alias_global.test @@ -0,0 +1,51 @@ +#--- source.hlsl + +// Test that a local resource variable can alias a global and store through it. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = Out; + buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_array.test b/test/Feature/LocalResources/local_resource_array.test new file mode 100644 index 000000000..912bf8791 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_array.test @@ -0,0 +1,55 @@ +#--- source.hlsl + +// Test that a basic local resource array works with constant indexing. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer arr[2]; + arr[0] = Out; + arr[0].Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_array_copy.test b/test/Feature/LocalResources/local_resource_array_copy.test new file mode 100644 index 000000000..b8c45f56d --- /dev/null +++ b/test/Feature/LocalResources/local_resource_array_copy.test @@ -0,0 +1,77 @@ +#--- source.hlsl + +// Test that a local resource array can be copied to another local array. + +RWByteAddressBuffer Out : register(u0); +RWByteAddressBuffer Aux : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer src[2]; + src[0] = Out; + src[1] = Aux; + RWByteAddressBuffer dst[2] = src; + dst[0].Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: Aux + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] + - Name: ExpectedAux + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: OutCheck + Rule: BufferExact + Actual: Out + Expected: ExpectedOut + - Result: AuxCheck + Rule: BufferExact + Actual: Aux + Expected: ExpectedAux +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Aux + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192562 +# XFAIL: Clang && Vulkan + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && 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/LocalResources/local_resource_array_size_one.test b/test/Feature/LocalResources/local_resource_array_size_one.test new file mode 100644 index 000000000..09504aa43 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_array_size_one.test @@ -0,0 +1,55 @@ +#--- source.hlsl + +// Test that a local resource array of size 1 works correctly. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer arr[1]; + arr[0] = Out; + arr[0].Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_bindless_array.test b/test/Feature/LocalResources/local_resource_bindless_array.test new file mode 100644 index 000000000..acda4290c --- /dev/null +++ b/test/Feature/LocalResources/local_resource_bindless_array.test @@ -0,0 +1,65 @@ +#--- source.hlsl + +// Test that a local resource can be assigned from a dynamically-indexed +// global resource array (bindless pattern). + +RWByteAddressBuffer gBufArray[4] : register(u0); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer buf = gBufArray[tid.x & 3]; + buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedGBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [42] + - [0] + - [0] + - [0] +Results: + - Result: ArrayCheck + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedGBufArray +DescriptorSets: + - Resources: + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_bindless_selection.test b/test/Feature/LocalResources/local_resource_bindless_selection.test new file mode 100644 index 000000000..c060888e0 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_bindless_selection.test @@ -0,0 +1,67 @@ +#--- source.hlsl + +// Test that a local resource can be reassigned from different elements +// of a global resource array (bindless selection pattern). + +RWByteAddressBuffer gBufArray[4] : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf; + buf = gBufArray[2]; + buf = gBufArray[3]; + buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedGBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [42] +Results: + - Result: ArrayCheck + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedGBufArray +DescriptorSets: + - Resources: + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_block_lifetime.test b/test/Feature/LocalResources/local_resource_block_lifetime.test new file mode 100644 index 000000000..e13a9d428 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_block_lifetime.test @@ -0,0 +1,55 @@ +#--- source.hlsl + +// Test that a local resource assigned inside a nested block scope +// remains valid after the block ends. + +RWByteAddressBuffer Out : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf; + { + buf = Out; + } + buf.Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_chained_call.test b/test/Feature/LocalResources/local_resource_chained_call.test new file mode 100644 index 000000000..4ff4684ee --- /dev/null +++ b/test/Feature/LocalResources/local_resource_chained_call.test @@ -0,0 +1,53 @@ +#--- source.hlsl + +// Test that a method can be called directly on the return value of a +// function that returns a resource (temporary resource lifetime). + +RWByteAddressBuffer Out : register(u0); + +RWByteAddressBuffer GetBuf() { return Out; } + +[numthreads(1,1,1)] +void main() { + GetBuf().Store(0, 42); +} + +//--- pipeline.yaml + +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_comma_init.test b/test/Feature/LocalResources/local_resource_comma_init.test new file mode 100644 index 000000000..ff0797383 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_comma_init.test @@ -0,0 +1,72 @@ +#--- source.hlsl +// Test that a local resource initialized via a comma expression works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = (gBuf0, gBuf1); + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: Out1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: Test1 + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 +DescriptorSets: + - Resources: + - Name: Out0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8383 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_continue_reassign.test b/test/Feature/LocalResources/local_resource_continue_reassign.test new file mode 100644 index 000000000..a6763c0ce --- /dev/null +++ b/test/Feature/LocalResources/local_resource_continue_reassign.test @@ -0,0 +1,77 @@ +#--- source.hlsl +// Test that reassigning a local resource before a continue in a loop works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + for (uint i = 0; i < 4; i++) { + if (i == 2) { + buf = gBuf1; + continue; + } + buf.Store(i * 4, i + 1); + } + buf.Store(0, 99); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0, 0, 0, 0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [1, 2, 0, 0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0, 0, 0, 0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [99, 0, 0, 4] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192542 +# XFAIL: DXC && 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/LocalResources/local_resource_copy_between_locals.test b/test/Feature/LocalResources/local_resource_copy_between_locals.test new file mode 100644 index 000000000..63532b82a --- /dev/null +++ b/test/Feature/LocalResources/local_resource_copy_between_locals.test @@ -0,0 +1,48 @@ +#--- source.hlsl +// Test that copying a local resource to another local variable works correctly. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer a = gBuf; + RWByteAddressBuffer b = a; + b.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out + Expected: ExpectedOut +DescriptorSets: + - Resources: + - Name: Out + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_deep_phi.test b/test/Feature/LocalResources/local_resource_deep_phi.test new file mode 100644 index 000000000..adf3cff6a --- /dev/null +++ b/test/Feature/LocalResources/local_resource_deep_phi.test @@ -0,0 +1,97 @@ +#--- source.hlsl +// Test that a local resource selected through nested if/else (phi merge) works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); +RWByteAddressBuffer gBuf2 : register(u2); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf; + if (true) + buf = false ? gBuf0 : gBuf1; + else + buf = gBuf2; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: Out0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: Out1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut1 + Format: Int32 + Stride: 4 + Data: [42] + - Name: Out2 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut2 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 + - Result: Test1 + Rule: BufferExact + Actual: Out1 + Expected: ExpectedOut1 + - Result: Test2 + Rule: BufferExact + Actual: Out2 + Expected: ExpectedOut2 +DescriptorSets: + - Resources: + - Name: Out0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: Out2 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8381 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_different_types.test b/test/Feature/LocalResources/local_resource_different_types.test new file mode 100644 index 000000000..82b0e6a33 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_different_types.test @@ -0,0 +1,69 @@ +#--- source.hlsl +// Test that two different resource types (RWByteAddressBuffer and RWStructuredBuffer) can coexist in the same function. +RWByteAddressBuffer gBuf : register(u0); +RWStructuredBuffer gSB : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer localBuf = gBuf; + RWStructuredBuffer localSB = gSB; + localBuf.Store(0, 42); + localSB[0] = 99; +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] + - Name: gSB + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGSB + Format: Int32 + Stride: 4 + Data: [99] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf + - Result: Test1 + Rule: BufferExact + Actual: gSB + Expected: ExpectedGSB +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gSB + Kind: RWStructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_do_while_reassign.test b/test/Feature/LocalResources/local_resource_do_while_reassign.test new file mode 100644 index 000000000..7139688a2 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_do_while_reassign.test @@ -0,0 +1,75 @@ +#--- source.hlsl +// Test that reassigning a local resource inside a do-while loop works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + uint i = 0; + do { + buf = gBuf1; + i++; + } while (i < 1); + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_early_return_reassign.test b/test/Feature/LocalResources/local_resource_early_return_reassign.test new file mode 100644 index 000000000..6db44f432 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_early_return_reassign.test @@ -0,0 +1,71 @@ +#--- source.hlsl +// Test that an early return prevents a later reassignment from taking effect. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + if (true) + buf.Store(0, 42); + return; + buf = gBuf1; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [42] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_forward_through_functions.test b/test/Feature/LocalResources/local_resource_forward_through_functions.test new file mode 100644 index 000000000..cd3dc77ca --- /dev/null +++ b/test/Feature/LocalResources/local_resource_forward_through_functions.test @@ -0,0 +1,54 @@ +#--- source.hlsl +// Test that a local resource forwarded through nested function calls works correctly. +RWByteAddressBuffer gBuf : register(u0); + +void Level2(RWByteAddressBuffer buf) { + buf.Store(0, 42); +} +void Level1(RWByteAddressBuffer buf) { + Level2(buf); +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer local = gBuf; + Level1(local); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_from_function_return.test b/test/Feature/LocalResources/local_resource_from_function_return.test new file mode 100644 index 000000000..c84812e87 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_from_function_return.test @@ -0,0 +1,51 @@ +#--- source.hlsl +// Test that a local resource initialized from a function return value works correctly. +RWByteAddressBuffer gBuf : register(u0); + +RWByteAddressBuffer GetBuffer() { + return gBuf; +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = GetBuffer(); + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_if_else_array_elements.test b/test/Feature/LocalResources/local_resource_if_else_array_elements.test new file mode 100644 index 000000000..5895e8ac6 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_if_else_array_elements.test @@ -0,0 +1,73 @@ +#--- source.hlsl +// Test that assigning different elements of the same unbounded global +// resource array in each branch of an if/else produces correct output. +// tid.x == 0 is always true (numthreads(1,1,1)), so OutArr[0] is written. + +RWByteAddressBuffer In : register(u0); +RWByteAddressBuffer OutArr[] : register(u1); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer Out; + if (tid.x == 0) { + Out = OutArr[0]; + } else { + Out = OutArr[1]; + } + Out.Store(0, In.Load(0)); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Stride: 4 + Data: [42] + - Name: OutArr + Format: Int32 + Stride: 4 + ArraySize: 2 + Data: + - [0] + - [0] + - Name: ExpectedOutArr + Format: Int32 + Stride: 4 + ArraySize: 2 + Data: + - [42] + - [0] +Results: + - Result: OutArrCheck + Rule: BufferExact + Actual: OutArr + Expected: ExpectedOutArr +DescriptorSets: + - Resources: + - Name: In + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: OutArr + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_inout_param.test b/test/Feature/LocalResources/local_resource_inout_param.test new file mode 100644 index 000000000..30e0e975d --- /dev/null +++ b/test/Feature/LocalResources/local_resource_inout_param.test @@ -0,0 +1,51 @@ +#--- source.hlsl +// Test that a local resource passed as an inout parameter works correctly. +RWByteAddressBuffer gBuf : register(u0); + +void ReadAndWrite(inout RWByteAddressBuffer buf) { + buf.Store(0, 42); +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer local = gBuf; + ReadAndWrite(local); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_loop_array_index.test b/test/Feature/LocalResources/local_resource_loop_array_index.test new file mode 100644 index 000000000..9d7d78fd6 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_loop_array_index.test @@ -0,0 +1,62 @@ +#--- source.hlsl +// Test that indexing a local resource array inside a loop with compiler-unrollable bounds works correctly. +RWByteAddressBuffer gBufArray[4] : register(u0); + +[numthreads(1,1,1)] +void main() { + for (uint i = 0; i < 4; i++) { + RWByteAddressBuffer buf = gBufArray[i]; + buf.Store(0, 42); + } +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedGBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [42] + - [42] + - [42] + - [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedGBufArray +DescriptorSets: + - Resources: + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_loop_carried.test b/test/Feature/LocalResources/local_resource_loop_carried.test new file mode 100644 index 000000000..5e6dda063 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_loop_carried.test @@ -0,0 +1,85 @@ +#--- source.hlsl +// Test that loop-carried reassignment from global resource array elements works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBufArray[4] : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + for (uint i = 0; i < 3; i++) + buf = gBufArray[i]; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedGBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [42] + - [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedGBufArray +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192542 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_mixed_struct.test b/test/Feature/LocalResources/local_resource_mixed_struct.test new file mode 100644 index 000000000..996d2a35c --- /dev/null +++ b/test/Feature/LocalResources/local_resource_mixed_struct.test @@ -0,0 +1,54 @@ +#--- source.hlsl +// Test that a struct with both a resource member and a scalar member works correctly. +RWByteAddressBuffer gBuf : register(u0); + +struct Node { + RWByteAddressBuffer buf; + uint value; +}; + +[numthreads(1,1,1)] +void main() { + Node n; + n.buf = gBuf; + n.value = 42; + n.buf.Store(0, n.value); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_multi_decl.test b/test/Feature/LocalResources/local_resource_multi_decl.test new file mode 100644 index 000000000..855bec34b --- /dev/null +++ b/test/Feature/LocalResources/local_resource_multi_decl.test @@ -0,0 +1,68 @@ +#--- source.hlsl +// Test that two local resources declared in a single statement work correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer a = gBuf0, b = gBuf1; + a.Store(0, 42); + b.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [42] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_multiple_uses.test b/test/Feature/LocalResources/local_resource_multiple_uses.test new file mode 100644 index 000000000..250aee555 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_multiple_uses.test @@ -0,0 +1,55 @@ +#--- source.hlsl +// Test that the same local resource passed to multiple helper functions works correctly. +RWByteAddressBuffer gBuf : register(u0); + +void HelperA(RWByteAddressBuffer buf) { + buf.Store(0, 42); +} +void HelperB(RWByteAddressBuffer buf) { + buf.Store(0, 42); +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer local = gBuf; + HelperA(local); + HelperB(local); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_nested_blocks_reassign.test b/test/Feature/LocalResources/local_resource_nested_blocks_reassign.test new file mode 100644 index 000000000..2379369e1 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_nested_blocks_reassign.test @@ -0,0 +1,76 @@ +#--- source.hlsl +// Test that reassigning a local resource across nested block scopes works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf; + { + buf = gBuf0; + { + buf = gBuf1; + } + } + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_nested_loops.test b/test/Feature/LocalResources/local_resource_nested_loops.test new file mode 100644 index 000000000..1c1970f27 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_nested_loops.test @@ -0,0 +1,63 @@ +#--- source.hlsl +// Test that indexing a resource array inside nested loops with unrollable bounds works correctly. +RWByteAddressBuffer gBufArray[4] : register(u0); + +[numthreads(1,1,1)] +void main() { + for (uint i = 0; i < 2; i++) + for (uint j = 0; j < 2; j++) { + RWByteAddressBuffer buf = gBufArray[i + j]; + buf.Store(0, 42); + } +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [0] + - [0] + - [0] + - [0] + - Name: ExpectedGBufArray + Format: Int32 + Stride: 4 + ArraySize: 4 + Data: + - [42] + - [42] + - [42] + - [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBufArray + Expected: ExpectedGBufArray +DescriptorSets: + - Resources: + - Name: gBufArray + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/305 +# UNSUPPORTED: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_out_param.test b/test/Feature/LocalResources/local_resource_out_param.test new file mode 100644 index 000000000..d06933f30 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_out_param.test @@ -0,0 +1,52 @@ +#--- source.hlsl +// Test that a local resource assigned via an out parameter works correctly. +RWByteAddressBuffer gBuf : register(u0); + +void WriteThrough(out RWByteAddressBuffer buf) { + buf = gBuf; +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer local; + WriteThrough(local); + local.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_overload.test b/test/Feature/LocalResources/local_resource_overload.test new file mode 100644 index 000000000..fba48ca1c --- /dev/null +++ b/test/Feature/LocalResources/local_resource_overload.test @@ -0,0 +1,76 @@ +#--- source.hlsl +// Test that overloaded functions accepting different resource types work correctly. +RWByteAddressBuffer gBuf : register(u0); +RWStructuredBuffer gSB : register(u1); + +void DoStore(RWByteAddressBuffer buf) { + buf.Store(0, 42); +} +void DoStore(RWStructuredBuffer buf) { + buf[0] = 42; +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer localBuf = gBuf; + RWStructuredBuffer localSB = gSB; + DoStore(localBuf); + DoStore(localSB); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] + - Name: gSB + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGSB + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf + - Result: Test1 + Rule: BufferExact + Actual: gSB + Expected: ExpectedGSB +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gSB + Kind: RWStructuredBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_read_only.test b/test/Feature/LocalResources/local_resource_read_only.test new file mode 100644 index 000000000..a012d3291 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_read_only.test @@ -0,0 +1,60 @@ +#--- source.hlsl +// Test that a local read-only ByteAddressBuffer (SRV) can load data correctly. +ByteAddressBuffer gInput : register(t0); +RWByteAddressBuffer gOutput : register(u1); + +[numthreads(1,1,1)] +void main() { + ByteAddressBuffer local = gInput; + uint val = local.Load(0); + gOutput.Store(0, val); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gInput + Format: Int32 + Stride: 4 + Data: [42] + - Name: gOutput + Format: Int32 + Stride: 4 + FillSize: 4 + - Name: ExpectedGOutput + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gOutput + Expected: ExpectedGOutput +DescriptorSets: + - Resources: + - Name: gInput + Kind: ByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gOutput + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_reassign_different_global.test b/test/Feature/LocalResources/local_resource_reassign_different_global.test new file mode 100644 index 000000000..b6ac251d9 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_reassign_different_global.test @@ -0,0 +1,71 @@ +#--- source.hlsl +// Test that reassigning a local resource from one global to another works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + buf = gBuf1; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_reassign_same_global.test b/test/Feature/LocalResources/local_resource_reassign_same_global.test new file mode 100644 index 000000000..d0d1521a7 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_reassign_same_global.test @@ -0,0 +1,65 @@ +#--- source.hlsl +// Test that reassigning a local resource to the same global it was +// initialized with produces correct output. Both functions verify +// that the resource still resolves to the original global. + +RWByteAddressBuffer In : register(u0); +RWByteAddressBuffer Out0 : register(u1); + +[numthreads(1,1,1)] +void main(uint3 tid : SV_DispatchThreadID) { + RWByteAddressBuffer Out = Out0; + if (tid.x == 0) { + Out = Out0; + } + Out.Store(0, In.Load(0)); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Stride: 4 + Data: [42] + - Name: Out0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedOut0 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Out0Check + Rule: BufferExact + Actual: Out0 + Expected: ExpectedOut0 +DescriptorSets: + - Resources: + - Name: In + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: Out0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_self_assign.test b/test/Feature/LocalResources/local_resource_self_assign.test new file mode 100644 index 000000000..2724dbaa1 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_self_assign.test @@ -0,0 +1,48 @@ +#--- source.hlsl +// Test that self-assignment of a local resource (buf = buf) works correctly. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf; + buf = buf; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_shadow_inner_scope.test b/test/Feature/LocalResources/local_resource_shadow_inner_scope.test new file mode 100644 index 000000000..f5a576fb7 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_shadow_inner_scope.test @@ -0,0 +1,73 @@ +#--- source.hlsl +// Test that an inner-scope variable shadowing an outer resource variable works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + { + RWByteAddressBuffer buf = gBuf1; + buf.Store(0, 42); + } +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_static_ternary_assign.test b/test/Feature/LocalResources/local_resource_static_ternary_assign.test new file mode 100644 index 000000000..39818a4ec --- /dev/null +++ b/test/Feature/LocalResources/local_resource_static_ternary_assign.test @@ -0,0 +1,74 @@ +#--- source.hlsl +// Test that assigning a ternary expression to a static resource variable +// produces valid output. The ternary always resolves to gBuf0 (true branch). +// DXC: Clean with cs_6_0 (folds compile-time ternary). Errors only in lib_6_* +// with -exports ("non const static global resource use is disallowed +// in library exports"). + +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +static RWByteAddressBuffer StaticOut; + +[numthreads(1,1,1)] +void main() { + StaticOut = true ? gBuf0 : gBuf1; + StaticOut.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [42] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Buf0Check + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Buf1Check + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_struct_method.test b/test/Feature/LocalResources/local_resource_struct_method.test new file mode 100644 index 000000000..516c0b2c8 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_struct_method.test @@ -0,0 +1,53 @@ +#--- source.hlsl +// Test that a struct member function can store through a resource member correctly. +RWByteAddressBuffer gBuf : register(u0); + +struct Wrapper { + RWByteAddressBuffer buf; + void DoStore(uint val) { buf.Store(0, val); } +}; + +[numthreads(1,1,1)] +void main() { + Wrapper w; + w.buf = gBuf; + w.DoStore(42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_struct_return.test b/test/Feature/LocalResources/local_resource_struct_return.test new file mode 100644 index 000000000..fd755e494 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_struct_return.test @@ -0,0 +1,55 @@ +#--- source.hlsl +// Test that a function returning a struct with a resource member works correctly. +RWByteAddressBuffer gBuf : register(u0); + +struct ResHolder { RWByteAddressBuffer buf; }; + +ResHolder MakeHolder() { + ResHolder h; + h.buf = gBuf; + return h; +} + +[numthreads(1,1,1)] +void main() { + ResHolder h = MakeHolder(); + h.buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_structured_buffer.test b/test/Feature/LocalResources/local_resource_structured_buffer.test new file mode 100644 index 000000000..bc86b4729 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_structured_buffer.test @@ -0,0 +1,44 @@ +#--- source.hlsl +// Test that a local RWStructuredBuffer with subscript access works correctly. +RWStructuredBuffer gSB : register(u0); + +[numthreads(1,1,1)] +void main() { + RWStructuredBuffer sb = gSB; + sb[0] = 42; +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gSB + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGSB + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gSB + Expected: ExpectedGSB +DescriptorSets: + - Resources: + - Name: gSB + Kind: RWStructuredBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# 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/LocalResources/local_resource_swap.test b/test/Feature/LocalResources/local_resource_swap.test new file mode 100644 index 000000000..6873aef1b --- /dev/null +++ b/test/Feature/LocalResources/local_resource_swap.test @@ -0,0 +1,72 @@ +#--- source.hlsl +// Test that swapping two local resources through a temporary works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer a = gBuf0; + RWByteAddressBuffer b = gBuf1; + RWByteAddressBuffer temp = a; + a = b; + b = temp; + a.Store(0, 1); + b.Store(0, 2); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [2] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [1] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_switch_default.test b/test/Feature/LocalResources/local_resource_switch_default.test new file mode 100644 index 000000000..9b469c771 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_switch_default.test @@ -0,0 +1,94 @@ +#--- source.hlsl +// Test that a switch statement with a default case can select a resource correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); +RWByteAddressBuffer gBuf2 : register(u2); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + switch (0) { + case 0: buf = gBuf1; break; + default: buf = gBuf2; break; + } + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] + - Name: gBuf2 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf2 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 + - Result: Test2 + Rule: BufferExact + Actual: gBuf2 + Expected: ExpectedGBuf2 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: gBuf2 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_switch_fallthrough.test b/test/Feature/LocalResources/local_resource_switch_fallthrough.test new file mode 100644 index 000000000..1a5080d0e --- /dev/null +++ b/test/Feature/LocalResources/local_resource_switch_fallthrough.test @@ -0,0 +1,94 @@ +#--- source.hlsl +// Test that switch fallthrough correctly determines which resource is selected. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); +RWByteAddressBuffer gBuf2 : register(u2); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + switch (0) { + case 0: buf = gBuf1; + case 1: buf = gBuf2; break; + } + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf2 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf2 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 + - Result: Test2 + Rule: BufferExact + Actual: gBuf2 + Expected: ExpectedGBuf2 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: gBuf2 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_switch_reassign.test b/test/Feature/LocalResources/local_resource_switch_reassign.test new file mode 100644 index 000000000..3fad2ec93 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_switch_reassign.test @@ -0,0 +1,94 @@ +#--- source.hlsl +// Test that reassigning a local resource inside a switch case works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); +RWByteAddressBuffer gBuf2 : register(u2); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + switch (1) { + case 1: buf = gBuf1; break; + case 2: buf = gBuf2; break; + } + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] + - Name: gBuf2 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf2 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 + - Result: Test2 + Rule: BufferExact + Actual: gBuf2 + Expected: ExpectedGBuf2 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 + - Name: gBuf2 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 2 + Space: 0 + VulkanBinding: + Binding: 2 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_template_function.test b/test/Feature/LocalResources/local_resource_template_function.test new file mode 100644 index 000000000..eb54bbdc4 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_template_function.test @@ -0,0 +1,52 @@ +#--- source.hlsl +// Test that a template function accepting a resource parameter works correctly. +RWByteAddressBuffer gBuf : register(u0); + +template +void UseResource(T buf) { + buf.Store(0, 42); +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer local = gBuf; + UseResource(local); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_ternary_both_same.test b/test/Feature/LocalResources/local_resource_ternary_both_same.test new file mode 100644 index 000000000..0d3d57a70 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_ternary_both_same.test @@ -0,0 +1,50 @@ +#--- source.hlsl +// Test that a ternary where both branches resolve to the same global +// resource produces correct output. The ternary is trivially resolved +// since both branches are gBuf0. + +RWByteAddressBuffer gBuf0 : register(u0); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer Out = true ? gBuf0 : gBuf0; + Out.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Buf0Check + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_ternary_same_array_elements.test b/test/Feature/LocalResources/local_resource_ternary_same_array_elements.test new file mode 100644 index 000000000..abca6cbee --- /dev/null +++ b/test/Feature/LocalResources/local_resource_ternary_same_array_elements.test @@ -0,0 +1,68 @@ +#--- source.hlsl +// Test that a ternary selecting between different indices of the same +// unbounded global resource array produces correct output. +// The ternary always resolves to OutArr[0] (true branch). + +RWByteAddressBuffer In : register(u0); +RWByteAddressBuffer OutArr[] : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer Out = true ? OutArr[0] : OutArr[1]; + Out.Store(0, In.Load(0)); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: In + Format: Int32 + Stride: 4 + Data: [42] + - Name: OutArr + Format: Int32 + Stride: 4 + ArraySize: 2 + Data: + - [0] + - [0] + - Name: ExpectedOutArr + Format: Int32 + Stride: 4 + ArraySize: 2 + Data: + - [42] + - [0] +Results: + - Result: OutArrCheck + Rule: BufferExact + Actual: OutArr + Expected: ExpectedOutArr +DescriptorSets: + - Resources: + - Name: In + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: OutArr + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_unreachable_reassign.test b/test/Feature/LocalResources/local_resource_unreachable_reassign.test new file mode 100644 index 000000000..3e7fa9f27 --- /dev/null +++ b/test/Feature/LocalResources/local_resource_unreachable_reassign.test @@ -0,0 +1,72 @@ +#--- source.hlsl +// Test that a reassignment after an unconditional return is unreachable. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer buf = gBuf0; + if (true) { + buf.Store(0, 42); + return; + } + buf = gBuf1; + buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [42] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [0] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_resource_with_wave_intrinsic.test b/test/Feature/LocalResources/local_resource_with_wave_intrinsic.test new file mode 100644 index 000000000..5857d919b --- /dev/null +++ b/test/Feature/LocalResources/local_resource_with_wave_intrinsic.test @@ -0,0 +1,48 @@ +#--- source.hlsl +// Test that a local resource used alongside wave intrinsics works correctly. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(8,8,1)] +void main() { + RWByteAddressBuffer buf = gBuf; + uint active = WaveActiveCountBits(true); + buf.Store(0, active > 0 ? 42 : 0); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/local_struct_resource_member.test b/test/Feature/LocalResources/local_struct_resource_member.test new file mode 100644 index 000000000..77f88fba1 --- /dev/null +++ b/test/Feature/LocalResources/local_struct_resource_member.test @@ -0,0 +1,52 @@ +#--- source.hlsl +// Test that a struct with a resource member can be assigned and stored through correctly. +RWByteAddressBuffer gBuf : register(u0); + +struct PassStruct { + RWByteAddressBuffer buf; +}; + +[numthreads(1,1,1)] +void main() { + PassStruct s; + s.buf = gBuf; + s.buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/loop_var.test b/test/Feature/LocalResources/loop_var.test new file mode 100644 index 000000000..3b39f04e4 --- /dev/null +++ b/test/Feature/LocalResources/loop_var.test @@ -0,0 +1,49 @@ +#--- source.hlsl +// Test that a resource declared as a for-loop variable works correctly. +RWByteAddressBuffer gBuf : register(u0); + +[numthreads(1,1,1)] +void main() { + for (RWByteAddressBuffer buf = gBuf; true; ) { + buf.Store(0, 42); + break; + } +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/nested_struct_resource_member.test b/test/Feature/LocalResources/nested_struct_resource_member.test new file mode 100644 index 000000000..7047a32e2 --- /dev/null +++ b/test/Feature/LocalResources/nested_struct_resource_member.test @@ -0,0 +1,51 @@ +#--- source.hlsl +// Test that accessing a resource through a nested struct member works correctly. +RWByteAddressBuffer gBuf : register(u0); + +struct NestedInner { RWByteAddressBuffer buf; }; +struct NestedOuter { NestedInner inner; }; + +[numthreads(1,1,1)] +void main() { + NestedOuter s; + s.inner.buf = gBuf; + s.inner.buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/return_local_resource_initialized.test b/test/Feature/LocalResources/return_local_resource_initialized.test new file mode 100644 index 000000000..022561108 --- /dev/null +++ b/test/Feature/LocalResources/return_local_resource_initialized.test @@ -0,0 +1,52 @@ +#--- source.hlsl +// Test that returning an initialized local resource from a function works correctly. +RWByteAddressBuffer gBuf : register(u0); + +RWByteAddressBuffer GetLocal() { + RWByteAddressBuffer buf = gBuf; + return buf; +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer tmp = GetLocal(); + tmp.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/return_local_resource_uninitialized.test b/test/Feature/LocalResources/return_local_resource_uninitialized.test new file mode 100644 index 000000000..bcc675761 --- /dev/null +++ b/test/Feature/LocalResources/return_local_resource_uninitialized.test @@ -0,0 +1,52 @@ +#--- source.hlsl +// Test that returning an uninitialized local resource compiles and runs without crashing. +RWByteAddressBuffer gBuf : register(u0); + +RWByteAddressBuffer GetUninitialized() { + RWByteAddressBuffer buf; + return buf; +} + +[numthreads(1,1,1)] +void main() { + RWByteAddressBuffer tmp = GetUninitialized(); + gBuf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/struct_array_with_resource_member.test b/test/Feature/LocalResources/struct_array_with_resource_member.test new file mode 100644 index 000000000..c5089f5f8 --- /dev/null +++ b/test/Feature/LocalResources/struct_array_with_resource_member.test @@ -0,0 +1,53 @@ +#--- source.hlsl +// Test that an array of structs with resource members works with constant indexing. +RWByteAddressBuffer gBuf : register(u0); + +struct BufStruct { RWByteAddressBuffer buf; }; + +[numthreads(1,1,1)] +void main() { + BufStruct s[2]; + s[0].buf = gBuf; + s[0].buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/struct_resource_member_reassign.test b/test/Feature/LocalResources/struct_resource_member_reassign.test new file mode 100644 index 000000000..b039a10b8 --- /dev/null +++ b/test/Feature/LocalResources/struct_resource_member_reassign.test @@ -0,0 +1,74 @@ +#--- source.hlsl +// Test that reassigning a struct's resource member to a different global works correctly. +RWByteAddressBuffer gBuf0 : register(u0); +RWByteAddressBuffer gBuf1 : register(u1); + +struct ResHolder { RWByteAddressBuffer buf; }; + +[numthreads(1,1,1)] +void main() { + ResHolder h; + h.buf = gBuf0; + h.buf = gBuf1; + h.buf.Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf0 + Format: Int32 + Stride: 4 + Data: [0] + - Name: gBuf1 + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf1 + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf0 + Expected: ExpectedGBuf0 + - Result: Test1 + Rule: BufferExact + Actual: gBuf1 + Expected: ExpectedGBuf1 +DescriptorSets: + - Resources: + - Name: gBuf0 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 + - Name: gBuf1 + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 1 + Space: 0 + VulkanBinding: + Binding: 1 +... +#--- end + +# Bug: https://github.com/llvm/offload-test-suite/issues/351 +# XFAIL: Metal + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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/LocalResources/struct_with_resource_array_member.test b/test/Feature/LocalResources/struct_with_resource_array_member.test new file mode 100644 index 000000000..ba96fbc71 --- /dev/null +++ b/test/Feature/LocalResources/struct_with_resource_array_member.test @@ -0,0 +1,53 @@ +#--- source.hlsl +// Test that a struct containing a resource array member works with constant indexing. +RWByteAddressBuffer gBuf : register(u0); + +struct S { RWByteAddressBuffer arr[2]; }; + +[numthreads(1,1,1)] +void main() { + S s; + s.arr[0] = gBuf; + s.arr[0].Store(0, 42); +} +//--- pipeline.yaml +--- +Shaders: + - Stage: Compute + Entry: main + DispatchSize: [1, 1, 1] +Buffers: + - Name: gBuf + Format: Int32 + Stride: 4 + Data: [0] + - Name: ExpectedGBuf + Format: Int32 + Stride: 4 + Data: [42] +Results: + - Result: Test0 + Rule: BufferExact + Actual: gBuf + Expected: ExpectedGBuf +DescriptorSets: + - Resources: + - Name: gBuf + Kind: RWByteAddressBuffer + DirectXBinding: + Register: 0 + Space: 0 + VulkanBinding: + Binding: 0 +... +#--- end + +# Bug: https://github.com/microsoft/DirectXShaderCompiler/issues/8379 +# XFAIL: DXC && Vulkan + +# Bug: https://github.com/llvm/llvm-project/issues/192523 +# XFAIL: Clang && 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