summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/spirv/ptr-empty-struct.slang15
-rw-r--r--tests/spirv/ptr-unsized-array-2.slang25
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/spirv/ptr-empty-struct.slang b/tests/spirv/ptr-empty-struct.slang
new file mode 100644
index 000000000..56148592b
--- /dev/null
+++ b/tests/spirv/ptr-empty-struct.slang
@@ -0,0 +1,15 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK: OpPtrAccessChain
+
+struct EmptyStruct {
+};
+
+[vk::push_constant] EmptyStruct* pc;
+
+RWStructuredBuffer<int> outputBuffer;
+
+[numthreads(64)]
+void ComputeMain(uint tid: SV_DispatchThreadID) {
+ outputBuffer[tid] = ((int*)(pc))[0];
+} \ No newline at end of file
diff --git a/tests/spirv/ptr-unsized-array-2.slang b/tests/spirv/ptr-unsized-array-2.slang
new file mode 100644
index 000000000..ac0911d76
--- /dev/null
+++ b/tests/spirv/ptr-unsized-array-2.slang
@@ -0,0 +1,25 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK-DAG: %[[cbuffer__t:[A-Za-z0-9_]+]] = OpTypeStruct %_ptr_PhysicalStorageBuffer_uint
+// CHECK-DAG: %light_buffer = OpVariable %_ptr_PushConstant_[[cbuffer__t]] PushConstant
+
+// CHECK: OpAccessChain %_ptr_PushConstant
+// CHECK-NEXT: OpLoad
+// CHECK-NEXT: OpBitcast %_ptr_PhysicalStorageBuffer
+
+struct LightBuffer {
+ uint8_t lights[];
+}
+
+[vk::push_constant]
+LightBuffer* light_buffer;
+
+[shader("vertex")]
+float4 vertMain() : SV_Position {
+ return float4(light_buffer.lights[0]);
+}
+
+[shader("fragment")]
+float4 fragMain() : COLOR0 {
+ return float4(1.0);
+} \ No newline at end of file