Merge pull request #2891 from dneto0/hlsl-namespace
[platform/upstream/glslang.git] / Test / 440.frag
1 #version 440\r
2 \r
3 // Note 'location'-only tests for enhanced layouts are in 330.frag\r
4 // Generic 'component' tests are in 440.vert\r
5 \r
6 // a consumes components 2 and 3 of location 4\r
7 layout(location = 4, component = 2) in vec2 a; \r
8 \r
9 // b consumes component 1 of location 4\r
10 layout(location = 4, component = 1) in float b; \r
11 layout(location = 4, component = 2) in vec2 h;  // ERROR, component overlap not okay for fragment in\r
12 \r
13 layout(location = 3, component = 2) in vec3 c;  // ERROR: c overflows components 2 and 3\r
14 \r
15 // e consumes beginning (components 0, 1 and 2) of each of 6 slots\r
16 layout(location = 20, component = 0) in vec3 e[6];\r
17 \r
18 // f consumes last component of the same 6 slots \r
19 layout(location = 20, component = 3) in float f[6];\r
20 \r
21 layout(location = 30, component = 3) out int be;\r
22 layout(location = 30, component = 0) out vec3 bf;  // ERROR, not the same basic type\r
23 \r
24 writeonly uniform;          // ERROR\r
25 readonly in;                // ERROR\r
26 flat out;                   // ERROR\r
27 mediump uniform;\r
28 \r
29 layout(offset=12) uniform;  // ERROR\r
30 layout(offset=12) in;       // ERROR\r
31 layout(offset=12) out;      // ERROR\r
32 \r
33 layout(align=16) uniform;   // ERROR\r
34 layout(align=16) in;        // ERROR\r
35 layout(align=16) out;       // ERROR\r
36 \r
37 layout(offset=12) uniform  ubl1 { int a; } inst1;  // ERROR\r
38 layout(offset=12)      in inbl2 { int a; } inst2;  // ERROR\r
39 layout(offset=12)     out inbl3 { int a; } inst3;  // ERROR\r
40 \r
41 layout(align=16, std140) uniform  ubl4 { int a; } inst4;\r
42 layout(align=16) uniform  ubl8 { int a; } inst8;  // ERROR, no packing\r
43 layout(align=16)      in inbl5 { int a; } inst5;  // ERROR\r
44 layout(align=16)     out inbl6 { int a; } inst6;  // ERROR\r
45 \r
46 layout(offset=12) uniform vec4 v1;  // ERROR\r
47 layout(offset=12)      in vec4 v2;  // ERROR\r
48 layout(offset=12)     out vec4 v3;  // ERROR\r
49 \r
50 layout(align=16) uniform vec4 v4;   // ERROR\r
51 layout(align=16)      in vec4 v5;   // ERROR\r
52 layout(align=16)     out vec4 v6;   // ERROR\r
53 \r
54 layout(std140) in;                  // ERROR\r
55 layout(std140) uniform vec4 v7;     // ERROR\r
56 \r
57 layout(align=48) uniform ubl7 {          // ERROR, not power of 2\r
58     layout(offset=12, align=4) float f;  // ERROR, no packing\r
59 } inst7;\r
60 \r
61 in ibl10 {\r
62     layout(offset=12) float f;  // ERROR\r
63     layout(align=4) float g;    // ERROR\r
64 } inst10;\r
65 \r
66 layout(std430) uniform;\r
67 \r
68 layout(align=32) uniform ubl9 {\r
69     float e;\r
70     layout(offset=12, align=4) float f;\r
71     layout(offset=20) float g;\r
72     float h;\r
73 } inst9;\r
74 \r
75 uniform ubl11 {\r
76     layout(offset=12, align=4) float f;\r
77     float g;\r
78 } inst11;\r
79 \r
80 layout(std140) uniform block {\r
81                         vec4   a;     // a takes offsets 0-15\r
82     layout(offset = 32) vec3   b;     // b takes offsets 32-43\r
83     layout(offset = 40) vec2   c;     // ERROR, lies within previous member\r
84     layout(align = 6)   double g;     // ERROR, 6 is not a power of 2\r
85     layout(offset=68)   double h;     // ERROR, offset not aligned\r
86 } specExampleErrors;\r
87 \r
88 layout(std140) uniform block2 {\r
89                         vec4   a;     // a takes offsets 0-15\r
90     layout(offset = 32) vec3   b;     // b takes offsets 32-43\r
91     layout(offset = 48) vec2   d;     // d takes offsets 48-55\r
92     layout(align = 16)  float  e;     // e takes offsets 64-67\r
93     layout(align = 2)   double f;     // f takes offsets 72-79\r
94     layout(offset = 80) float  h;     // h takes offsets 80-83\r
95     layout(align = 64)  dvec3  i;     // i takes offsets 128-151\r
96     layout(offset = 164, align = 8) float  j;     // j takes offsets 168-171\r
97 } specExample;\r
98 \r
99 layout(std430) buffer block430 {\r
100                         vec4   a;     // a takes offsets 0-15\r
101     layout(offset = 32) vec3   b;     // b takes offsets 32-43\r
102     layout(offset = 40) vec2   c;     // ERROR, lies within previous member\r
103     layout(align = 6)   double g;     // ERROR, 6 is not a power of 2\r
104     layout(offset=68)   double h;     // ERROR, offset not aligned\r
105     layout(align = 0)   double i;     // ERROR, 0 not a power of 2\r
106 } specExampleErrors430;\r
107 \r
108 layout(std430) buffer block2430 {\r
109                         vec4   a;     // a takes offsets 0-15\r
110     layout(offset = 32) vec3   b;     // b takes offsets 32-43\r
111     layout(offset = 48) vec2   d;     // d takes offsets 48-55\r
112     layout(align = 16)  float  e;     // e takes offsets 64-67\r
113     layout(align = 2)   double f;     // f takes offsets 72-79\r
114     layout(offset = 80) float  h;     // h takes offsets 80-83\r
115     layout(align = 64)  dvec3  i;     // i takes offsets 128-151\r
116     layout(offset = 164, align = 8) float  j;     // j takes offsets 168-171\r
117 } specExample430;\r
118 \r
119 layout(std430, align = 128) buffer block24300 {\r
120     vec4   a;\r
121     vec3   b;\r
122     vec2   d;\r
123     float  e;\r
124     double f;\r
125     float  h;\r
126     dvec3  i;\r
127 } specExample4300;\r
128 \r
129 layout(std430, align = 128) buffer block24301 {\r
130     vec4   a;\r
131     vec3   b;\r
132     vec2   d;\r
133     layout(offset=388) float  e;\r
134     layout(align=8) double f;\r
135     float  h;\r
136     dvec3  i;\r
137 } specExample4301;\r
138 \r
139 int aconst[gl_MaxTransformFeedbackBuffers];\r
140 int bconst[gl_MaxTransformFeedbackInterleavedComponents];\r
141 \r
142 sample in vec3 sampInArray[4];\r
143 \r
144 void interp()\r
145 {\r
146     interpolateAtCentroid(sampInArray[2].xy);\r
147     interpolateAtSample(sampInArray[2].x.x, 2);\r
148 }\r
149 \r
150 int layer()\r
151 {\r
152     return gl_Layer;\r
153 }\r
154 \r
155 // The std140 layout qualifier should NOT propagate all the way down to\r
156 // the vec3. It is unnecessary and it breaks downstream AST consumers,\r
157 // notably LunarGlass.\r
158 \r
159 struct PointLight_t\r
160 {\r
161     vec3 vPositionWs ;\r
162 } ;\r
163 \r
164 layout( std140, row_major ) uniform PerViewLightData_t\r
165 {\r
166 \r
167     PointLight_t g_pointLightData [ 128 ] ;\r
168 } ;\r