summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-08 18:29:32 -0800
committerGitHub <noreply@github.com>2024-02-08 18:29:32 -0800
commitf44da6cc5c0f211c13bd1eb0743d79c7861ea64e (patch)
tree3ad4edb5e7806c41003280ebf60fd6419a742105 /tests
parenta16f712bb99e426519c9a556b17b54bcc4d1d22d (diff)
Support pointers in SPIRV. (#3561)
* Support pointers in SPIRV. * Fix test. * Enhance test. * Fix test. * Cleanup.
Diffstat (limited to 'tests')
-rw-r--r--tests/spirv/pointer.slang48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/spirv/pointer.slang b/tests/spirv/pointer.slang
new file mode 100644
index 000000000..cb2d56f66
--- /dev/null
+++ b/tests/spirv/pointer.slang
@@ -0,0 +1,48 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry main -stage compute -emit-spirv-directly
+
+
+struct PP
+{
+ int data;
+ int data2;
+}
+struct Data
+{
+ int data;
+ PP* pNext;
+};
+
+void funcThatTakesPointer(PP* p)
+{
+ p.data = 2;
+}
+int* funcThatReturnsPointer(PP* p)
+{
+ return &p.data;
+}
+
+// CHECK: OpEntryPoint
+
+StructuredBuffer<Data> buffer;
+RWStructuredBuffer<int> output;
+void main(int id : SV_DispatchThreadID)
+{
+ output[0] = buffer[0].pNext.data;
+ let pData = &(buffer[0].pNext.data);
+ // CHECK: OpPtrAccessChain
+ int* pData1 = pData + 1;
+ *pData1 = 3;
+ *(int2*)pData = int2(1, 2);
+ pData1[-1] = 2;
+ buffer[0].pNext[1] = {5};
+ // CHECK: OpConvertPtrToU
+ // CHECK: OpINotEqual
+ if (pData1)
+ {
+ *(funcThatReturnsPointer(buffer[0].pNext)) = 4;
+ }
+ if (pData1 > pData)
+ {
+ funcThatTakesPointer(buffer[0].pNext);
+ }
+}