diff options
| author | Darren Wihandi <65404740+fairywreath@users.noreply.github.com> | 2025-04-13 11:09:01 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-13 17:09:01 +0000 |
| commit | b9af45ff3f2288e2aa325c1d910544e368eb9538 (patch) | |
| tree | d53fab6b46b88a475cba770f6a98315e1b248f87 /tests/spirv | |
| parent | 28006e36d92f7709f7c5ad84d50d1c5584c42508 (diff) | |
Fix pointer field/member access for GLSL (#6798)
* Fix pointer field access for GLSL
* Add test
* Fix SPIRV test
* add spirv via glsl test
Diffstat (limited to 'tests/spirv')
| -rw-r--r-- | tests/spirv/pointer-2.slang | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/spirv/pointer-2.slang b/tests/spirv/pointer-2.slang new file mode 100644 index 000000000..201d97001 --- /dev/null +++ b/tests/spirv/pointer-2.slang @@ -0,0 +1,76 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV): -entry vertexMain -stage vertex -emit-spirv-directly -target spirv +//TEST:SIMPLE(filecheck=CHECK_SPV_VIA_GLSL): -entry vertexMain -stage vertex -emit-spirv-via-glsl -target spirv +//TEST:SIMPLE(filecheck=CHECK_GLSL): -entry vertexMain -stage vertex -target glsl + +struct Inner1 +{ + float4 position; + Inner2* inner; +} + +struct Inner2 +{ + float4 position; +} + +struct Vertex +{ + float4 position; + Inner1* inner; +} + +struct VSOutput +{ + float4 position : SV_Position; +} + +struct PushConstants +{ + float a; + Vertex* verts; +}; + +[[vk::push_constant]] +PushConstants pushConstants; + +ConstantBuffer<PushConstants> constantBuffer; + +// CHECK_SPV: OpEntryPoint +// CHECK_SPV: OpTypePointer PhysicalStorageBuffer +// CHECK_SPV: OpPtrAccessChain + +// CHECK_SPV_VIA_GLSL: Glslang +// CHECK_SPV_VIA_GLSL: OpEntryPoint +// CHECK_SPV_VIA_GLSL: OpTypePointer PhysicalStorageBuffer + +[shader("vertex")] +VSOutput vertexMain(int vertexIndex: SV_VertexID) +{ + // + // Test field access chains. + // + + // CHECK_GLSL: (((((pushConstants_0.verts_0 + gl_VertexIndex)._data.inner_1) + 1)._data.inner_0) + 5)._data.position_0 + let position1 = pushConstants.verts[vertexIndex].inner[1].inner[5].position; + + // CHECK_GLSL: (((((constantBuffer_0.verts_0 + 7)._data.inner_1) + 3)._data.inner_0) + 4)._data.position_0 + let position2 = constantBuffer.verts[7].inner[3].inner[4].position; + + // CHECK_GLSL: (((constantBuffer_0.verts_0 + gl_VertexIndex)._data.inner_1) + 12)._data.position_1 + let position3 = constantBuffer.verts[vertexIndex].inner[12].position; + + // + // Test accesing from a variable. + // + + // CHECK_GLSL: ((((pushConstants_0.verts_0 + 8)._data.inner_1 + 6)._data.inner_0))._data.position_0 + let vertex = pushConstants.verts[8]; + let position4 = vertex.inner[6].inner.position; + + VSOutput output; + output.position = position1 + position2 + position3 + position4; + output.position *= pushConstants.a; + + return output; +} + |
