diff options
Diffstat (limited to 'tests/compute')
| -rw-r--r-- | tests/compute/bound-check-zero-index.slang | 56 | ||||
| -rw-r--r-- | tests/compute/bound-check-zero-index.slang.expected.txt | 8 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/compute/bound-check-zero-index.slang b/tests/compute/bound-check-zero-index.slang new file mode 100644 index 000000000..e8244886e --- /dev/null +++ b/tests/compute/bound-check-zero-index.slang @@ -0,0 +1,56 @@ +// bound-check-zero-index.slang + +// Check 'zero indexing' bound check feature, supported by CPU and CUDA + +// Currently zero index bound checking doesn't appear to be working properly for CUDA. +//TEST(compute):COMPARE_COMPUTE:-cuda -shaderobj -Xslang... -DSLANG_ENABLE_BOUND_ZERO_INDEX -X. +//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -Xslang... -DSLANG_ENABLE_BOUND_ZERO_INDEX -X. + +//TEST_INPUT:ubuffer(data=[1 2 3 4]):name=byteAddressBuffer +ByteAddressBuffer byteAddressBuffer; + +//TEST_INPUT:ubuffer(data=[0x10 0x20 0x30 0x40]):name=rwByteAddressBuffer +RWByteAddressBuffer rwByteAddressBuffer; + +//TEST_INPUT:ubuffer(data=[0x100 0x200 0x300 0x400], stride=4):name=structuredBuffer +StructuredBuffer<int> structuredBuffer; + +//TEST_INPUT:ubuffer(data=[0x1000 0x2000 0x3000 0x4000], stride=4):name=rwStructuredBuffer +RWStructuredBuffer<int> rwStructuredBuffer; + +//TEST_INPUT:ubuffer(data=[-1 -1 -1 -1], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +//TEST_INPUT:ubuffer(data=[-1 -1 -1 -1], stride=4):out,name=outputBuffer2 +RWStructuredBuffer<int> outputBuffer2; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + + int fixedArray[3] = { 2, 5, 9}; + + int total = 0; + total += byteAddressBuffer.Load<int>(tid * 4); + total += byteAddressBuffer.Load<int>(-tid * 4); + + total += rwByteAddressBuffer.Load<int>(tid * 4); + total += rwByteAddressBuffer.Load<int>(-tid * 4); + + total += structuredBuffer[tid]; + total += structuredBuffer[-tid]; + + total += rwStructuredBuffer[tid]; + total += rwStructuredBuffer[-tid]; + + total += fixedArray[tid]; + total += fixedArray[-tid]; + + outputBuffer[tid] = total; + + // NOTE! Different threads could access this if being performed in parallel. + // So undeterministic if we write to same index (because out of range) when running in parallel + // By just adding one, all indices should be hit once + outputBuffer2[tid + 1] = total; +}
\ No newline at end of file diff --git a/tests/compute/bound-check-zero-index.slang.expected.txt b/tests/compute/bound-check-zero-index.slang.expected.txt new file mode 100644 index 000000000..21f89147e --- /dev/null +++ b/tests/compute/bound-check-zero-index.slang.expected.txt @@ -0,0 +1,8 @@ +2226 +333A +444F +5559 +5559 +2226 +333A +444F |
