diff options
| -rw-r--r-- | source/slang/slang-emit.cpp | 1 | ||||
| -rw-r--r-- | tests/wgsl/global-call.slang | 20 | ||||
| -rw-r--r-- | tests/wgsl/global-call.slang.expected.txt | 4 |
3 files changed, 25 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 176cd0558..4fee5c440 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -1471,6 +1471,7 @@ Result linkAndOptimizeIR( default: break; case CodeGenTarget::GLSL: + case CodeGenTarget::WGSL: moveGlobalVarInitializationToEntryPoints(irModule); break; // For SPIR-V to SROA across 2 entry-points a value must not be a global diff --git a/tests/wgsl/global-call.slang b/tests/wgsl/global-call.slang new file mode 100644 index 000000000..7b67f2139 --- /dev/null +++ b/tests/wgsl/global-call.slang @@ -0,0 +1,20 @@ +//TEST(compute):COMPARE_COMPUTE:-shaderobj + +//TEST_INPUT:ubuffer(data=[3 7 8 10], stride=4):name=inputBuffer +RWStructuredBuffer<uint> inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +uint f(uint a) +{ + return a*inputBuffer[0]; +} + +static uint b = f(2); + +[numthreads(1,1,1)] +void computeMain() +{ + outputBuffer[0] = b; +}
\ No newline at end of file diff --git a/tests/wgsl/global-call.slang.expected.txt b/tests/wgsl/global-call.slang.expected.txt new file mode 100644 index 000000000..e20d75ba3 --- /dev/null +++ b/tests/wgsl/global-call.slang.expected.txt @@ -0,0 +1,4 @@ +6 +0 +0 +0 |
