diff options
| author | Yong He <yonghe@outlook.com> | 2024-05-08 20:52:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-08 20:52:36 -0700 |
| commit | 8e86121b6ce0f2995050ebe112306ded6bc87ca2 (patch) | |
| tree | 5c7f03ec9a144fa4d38eba67d563aefaaa1f4f9a /tests/spirv | |
| parent | 448e21adac9ec260d7854076a686bd506bb371ec (diff) | |
Support `[__ref]` attribute to make `this` pass by reference. (#4139)
Fixes #4110.
Diffstat (limited to 'tests/spirv')
| -rw-r--r-- | tests/spirv/ref-this.slang | 30 |
1 files changed, 30 insertions, 0 deletions
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 |
