From dfdf243f07c977fa59b1a5968ce053bf590f8120 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 26 Mar 2024 17:35:24 -0700 Subject: Support mutable existential parameters. (#3836) * Support mutable existential parameters. * Update test. --- tests/bugs/gh-3818.slang | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/bugs/gh-3818.slang (limited to 'tests') diff --git a/tests/bugs/gh-3818.slang b/tests/bugs/gh-3818.slang new file mode 100644 index 000000000..5b2c4db78 --- /dev/null +++ b/tests/bugs/gh-3818.slang @@ -0,0 +1,47 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-shaderobj -output-using-type + +interface IOperation +{ + [mutating] + void Store(float v); + + float Load(); +}; + +struct TOperationMax : IOperation +{ + float result; + + [mutating] + void Store(float v) + { + result = v; + } + + float Load() + { + return result; + } +}; + +float Run(inout IOperation op, float val) +{ + op.Store(val); + return op.Load(); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer outputBuffer; + +[numthreads(4, 1, 1)] +[shader("compute")] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + TOperationMax opMax; + opMax.result = 0.f; + float val = 2.f; + IOperation op = opMax; + float result = Run(op, val); + // CHECK: 2.0 + outputBuffer[0] = result; +} -- cgit v1.2.3