diff options
| author | Yong He <yonghe@outlook.com> | 2023-12-13 15:15:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-13 15:15:19 -0800 |
| commit | 3979660d4fe1fd6c1f1d9b8956e96817e17c3f4e (patch) | |
| tree | a1777fc23e2983c5dbe630d39e529c798953484c /tests | |
| parent | 1406aa2bc9e398e5e5565ba9c6adbb780c29fee1 (diff) | |
Fix GLSL static initialization bug. (#3409)
* Fix GLSL static initialization bug.
Fixes #3408.
* Update comment.
* Fold global var initializer as an expression if possible.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/gh-2959.slang | 16 | ||||
| -rw-r--r-- | tests/bugs/gh-3408.slang | 21 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/bugs/gh-2959.slang b/tests/bugs/gh-2959.slang new file mode 100644 index 000000000..b478fa938 --- /dev/null +++ b/tests/bugs/gh-2959.slang @@ -0,0 +1,16 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +static uint g_values[2] = { 0, 1 }; + +[numthreads(2, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + outputBuffer[tid] = g_values[tid]; + // BUF: 0 + // BUF: 1 +} diff --git a/tests/bugs/gh-3408.slang b/tests/bugs/gh-3408.slang new file mode 100644 index 000000000..a24befe91 --- /dev/null +++ b/tests/bugs/gh-3408.slang @@ -0,0 +1,21 @@ +//TEST:SIMPLE(filecheck=CHECK): -entry computeMain -stage compute -target glsl +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj -vk + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK-NOT: {{\b}}if{{\b}} + + int tid = dispatchThreadID.x; + + static int a[] = { 1, 2 }; + + outputBuffer[dispatchThreadID.x] = a[tid & 1]; + // BUF: 1 + // BUF: 2 + // BUF: 1 + // BUF: 2 +} |
