diff options
| author | Yong He <yonghe@outlook.com> | 2024-07-10 16:17:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 16:17:10 -0700 |
| commit | 746d47bb491e0b97e35ab373b4b78d33b9a61164 (patch) | |
| tree | 74e0936472d911d8c6c561ca4b21e800306c5f51 /tests | |
| parent | 82f308ca692878bfe9844b86629c6536b4cd0f0a (diff) | |
Specialize address space during spirv legalization. (#4600)
* Specialize address space during spirv legalization.
* Fix.
* Fix building doc.
* Fix cmake.
* Update assert.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/spirv/address-space-specialize.slang | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/spirv/address-space-specialize.slang b/tests/spirv/address-space-specialize.slang new file mode 100644 index 000000000..e2b48489a --- /dev/null +++ b/tests/spirv/address-space-specialize.slang @@ -0,0 +1,33 @@ +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry main -stage compute -emit-spirv-directly -O0 + +// Test that we can pass arguments in different address space to an `inout` parameter, and have +// the callee specialized to the address space of the argument. +// If successful, we should generate SPIRV that passes validation. + +static int gArray0[2]; +groupshared int gArray1[2]; + +// CHECK: %array = OpFunctionParameter %_ptr_Private__arr_int_int_2 +// CHECK: %array_0 = OpFunctionParameter %_ptr_Workgroup__arr_int_int_2 + +void modify(inout int array[2]) +{ + array[0] = 1; + array[1] = 2; +} + +void atomicOp(inout int array[2]) +{ + InterlockedAdd(array[0], 1); +} + +RWStructuredBuffer<int> output; + +[numthreads(1,1,1)] +void main() +{ + modify(gArray0); + modify(gArray1); + atomicOp(gArray1); + output[0] = gArray0[0] + gArray1[1]; +} |
