From 8e86121b6ce0f2995050ebe112306ded6bc87ca2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 8 May 2024 20:52:36 -0700 Subject: Support `[__ref]` attribute to make `this` pass by reference. (#4139) Fixes #4110. --- tests/spirv/ref-this.slang | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/spirv/ref-this.slang (limited to 'tests') diff --git a/tests/spirv/ref-this.slang b/tests/spirv/ref-this.slang new file mode 100644 index 000000000..5eaa7f3a1 --- /dev/null +++ b/tests/spirv/ref-this.slang @@ -0,0 +1,30 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + +// CHECK: %[[PTR:[0-9a-zA-Z_]+]] = OpAccessChain %_ptr_PhysicalStorageBuffer_uint %{{.*}} %int_0 +// CHECK: %original = OpAtomicIAdd %uint %[[PTR]] %uint_1 %uint_0 %uint_1 + +struct Buf +{ + uint t; + + [__ref] + func tester() + { + uint prev; + InterlockedAdd(t, 1, prev); + } +}; + +struct Push +{ + Buf * b; +}; + +[[vk::push_constant]] Push push; + +[shader("compute")] +[numthreads(1, 1, 1)] +void main() +{ + push.b->tester(); +} \ No newline at end of file -- cgit v1.2.3