summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-10-09 07:35:10 -0700
committerGitHub <noreply@github.com>2024-10-09 22:35:10 +0800
commitac6f04c15995061ebe8e0ddf62ecf7eb979afb65 (patch)
treef16f0f01f1f8d0e73ecd774a22f87576f440f8e8 /tests
parentbea1394ad35680940a0b69b9c67efc43764cc194 (diff)
Fix spirv lowering logic around pointer to unsized array. (#5243)
* Fix spirv lowering logic around pointer to unsized array. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/gh-3825.slang10
-rw-r--r--tests/spirv/ptr-unsized-array.slang23
2 files changed, 30 insertions, 3 deletions
diff --git a/tests/bugs/gh-3825.slang b/tests/bugs/gh-3825.slang
index 1feadb588..c7c325864 100644
--- a/tests/bugs/gh-3825.slang
+++ b/tests/bugs/gh-3825.slang
@@ -4,7 +4,7 @@
//TEST:SIMPLE(filecheck=CHECK): -entry fragment -stage fragment -emit-spirv-directly -target spirv-assembly -emit-spirv-directly
struct Descriptors {
uint count;
- uint array[];
+ uint4 array[];
}
struct Context {
@@ -17,7 +17,11 @@ struct Context {
[shader("fragment")]
float4 fragment(): SV_Target
{
- return float4(float(context.descriptors[0].array[0]), 1., 1., 1.);
+ return float4(float(context.descriptors->array[0].x), 1., 1., 1.);
}
-// CHECK: OpDecorate %_ptr_PhysicalStorageBuffer__runtimearr_uint ArrayStride 65535
+// CHECK: OpDecorate %_ptr_PhysicalStorageBuffer_Descriptors_natural ArrayStride 4
+// CHECK: %{{.*}} = OpPtrAccessChain %_ptr_PhysicalStorageBuffer_Descriptors_natural %{{.*}} %int_1
+// CHECK: OpBitcast %ulong
+// CHECK: OpIAdd %ulong %{{.*}} %ulong_4
+// CHECK: OpBitcast %_ptr_PhysicalStorageBuffer \ No newline at end of file
diff --git a/tests/spirv/ptr-unsized-array.slang b/tests/spirv/ptr-unsized-array.slang
new file mode 100644
index 000000000..48added5c
--- /dev/null
+++ b/tests/spirv/ptr-unsized-array.slang
@@ -0,0 +1,23 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+// CHECK: OpPtrAccessChain
+
+struct MeshVertex {
+ float3 Pos;
+ float2 TexCoord;
+};
+struct MeshData {
+ float4x4 ModelMat;
+ MeshVertex Vertices[];
+};
+struct DispatchParams {
+ MeshData* Mesh;
+ float3* Dest;
+};
+
+[vk::push_constant] DispatchParams pc;
+
+[numthreads(64)]
+void ComputeMain(uint tid: SV_DispatchThreadID) {
+ pc.Dest[tid] = pc.Mesh->Vertices[tid].Pos;
+} \ No newline at end of file