diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-569.slang | 36 | ||||
| -rw-r--r-- | tests/bugs/gh-569.slang.expected.txt | 4 | ||||
| -rw-r--r-- | tests/compute/multiple-continue-sites.slang | 39 | ||||
| -rw-r--r-- | tests/compute/multiple-continue-sites.slang.expected.txt | 4 |
4 files changed, 83 insertions, 0 deletions
diff --git a/tests/bugs/gh-569.slang b/tests/bugs/gh-569.slang new file mode 100644 index 000000000..fa7525d45 --- /dev/null +++ b/tests/bugs/gh-569.slang @@ -0,0 +1,36 @@ +// gh-569.slang +//TEST(compute):COMPARE_COMPUTE: + +// Test that correct scoping is used in generated HLSL/GLSL, +// even when dominator tree and structured control flow disagree. + +uint test(uint inVal) +{ + uint tmp = inVal; + for(;;) + { + if(tmp < 4) + { + tmp++; + } + else + { + break; + } + } + return tmp + inVal; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<uint> gBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + uint val = tid; + val = test(val); + + gBuffer[tid] = val; +} diff --git a/tests/bugs/gh-569.slang.expected.txt b/tests/bugs/gh-569.slang.expected.txt new file mode 100644 index 000000000..3195a6aa5 --- /dev/null +++ b/tests/bugs/gh-569.slang.expected.txt @@ -0,0 +1,4 @@ +4 +5 +6 +7 diff --git a/tests/compute/multiple-continue-sites.slang b/tests/compute/multiple-continue-sites.slang new file mode 100644 index 000000000..5a5b78d0c --- /dev/null +++ b/tests/compute/multiple-continue-sites.slang @@ -0,0 +1,39 @@ +//TEST(compute):COMPARE_COMPUTE: +//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):dxbinding(0),glbinding(0),out + +// Test that a loop with multiple `continue` sites works. +// +// The current Slang codegen strategy for `continue` ends +// up duplicating the "continue clause" for a `for` loop +// at each `continue` site, so it will stress-test any +// code that assumes a given instruction/block only +// appears once in the region tree. +// + +int test(int inVal) +{ + int ii = inVal; + for(;!(ii & 0x20); ii += 0x10) + { + if(ii == 2) + { + continue; + } + + ii += 0x100; + // there is an implicit `continue` here + } + + return ii; +} + +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = outputBuffer[tid]; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/compute/multiple-continue-sites.slang.expected.txt b/tests/compute/multiple-continue-sites.slang.expected.txt new file mode 100644 index 000000000..6752a80e0 --- /dev/null +++ b/tests/compute/multiple-continue-sites.slang.expected.txt @@ -0,0 +1,4 @@ +220 +221 +122 +223 |
