blob: b93ca32b43dc7e8412b1516d23f158f9ceeca03d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// TEST:SIMPLE(filecheck=CHECK_GLSL): -entry vertexMain -stage vertex -target glsl
// 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
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_VulkanVertexID)
{
//
// 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;
}
|