diff options
Diffstat (limited to 'tests/bugs')
| -rw-r--r-- | tests/bugs/mutating/mutating-call-in-loop-dce.slang | 39 | ||||
| -rw-r--r-- | tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt | 2 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/bugs/mutating/mutating-call-in-loop-dce.slang b/tests/bugs/mutating/mutating-call-in-loop-dce.slang new file mode 100644 index 000000000..372cb61b0 --- /dev/null +++ b/tests/bugs/mutating/mutating-call-in-loop-dce.slang @@ -0,0 +1,39 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type + +// Confirm that a SideEffectFree mutable method does not get DCE'd when +// it is called from within a loop. + +struct C +{ + int a; + [mutating] + int add() + { + a++; + return a; + } + [mutating] + void init() + { + a = 0; + } +} +int doSomething(C d) +{ + int rs = 0; + for (int i = 0; i < 10; i++) + rs = d.add(); + return rs; +} + +//TEST_INPUT:ubuffer(data=[0], stride=4):out, name outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +{ + int tid = dispatchThreadID.x; + C c; + c.init(); + outputBuffer[tid] = doSomething(c); +}
\ No newline at end of file diff --git a/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt b/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt new file mode 100644 index 000000000..2c29f3f9e --- /dev/null +++ b/tests/bugs/mutating/mutating-call-in-loop-dce.slang.expected.txt @@ -0,0 +1,2 @@ +type: int32_t +10 |
