Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading