Merge pull request #427 from wesleygriffin/master
[platform/upstream/glslang.git] / Test / 440.vert
1 #version 440\r
2 \r
3 // Note 'location' tests for enhanced layouts are in 330.frag\r
4 \r
5 layout(location = 2, component = 2) in vec2 a; \r
6 layout(location = 2, component = 1) in float b; \r
7 \r
8 layout(location = 3, component = 2) in vec3 c;      // ERROR: c overflows components 2 and 3\r
9 \r
10 layout(location = 0, component = 3) in float d[4]; \r
11 \r
12 layout(location = 4, component = 0) in vec3 e[5];\r
13 layout(location = 4, component = 3) in float f[5];\r
14 \r
15 layout(location = 9, component = 4) in float g[6];   // ERROR, component too big\r
16 \r
17 layout(location = 4, component = 2) in vec2 h;       // component overlap okay for vertex in\r
18 \r
19 layout(location = 3, component = 2) out vec2 i;\r
20 layout(location = 3, component = 0) out vec2 j;\r
21 \r
22 layout(location = 4, component = 2) out vec2 k;\r
23 layout(location = 4, component = 2) out vec2 m;      // ERROR, component overlap\r
24 \r
25 layout(location = 2, component = 2) out vec2 n;\r
26 layout(location = 2, component = 0) out vec3 p;      // ERROR, component overlap\r
27 \r
28 layout(location = 10, component = 3) out float q[6]; \r
29 layout(location = 10, component = 0) out vec3 r[6];\r
30 \r
31 layout(location = 15, component = 3) out float s;    // ERROR, overlap\r
32 layout(location = 10, component = 1) out float t;    // ERROR, overlap\r
33 \r
34 layout(location = 20, component = 2) out float u;\r
35 layout(location = 20, component = 0) out float v;\r
36 layout(location = 20, component = 3) out float w;\r
37 layout(location = 20, component = 1) out vec2 x;     // ERROR, overlap\r
38 \r
39 layout(location = 30, component = 3) out vec2 y;     // ERROR, goes to component 4\r
40 layout(location = 31, component = 1) out vec4 z;     // ERROR, goes to component 4\r
41 \r
42 layout(location = 32, component = 1) out mat4 ba;               // ERROR\r
43 layout(location = 33, component = 1) out struct S {int a;} Ss;  // ERROR\r
44 layout(location = 34, component = 1) out bn { int a;} bb;       // ERROR\r
45 \r
46 layout(component = 1) out float bc;    // ERROR, no location\r
47 \r
48 out blockname {\r
49     layout(location = 40, component = 2) out float u;\r
50     layout(location = 40, component = 0) out float v;\r
51     layout(location = 40, component = 3) out float w;\r
52     layout(location = 40, component = 1) out vec2 x;     // ERROR, overlap\r
53 \r
54     layout(location = 41, component = 3) out vec2 y;     // ERROR, goes to component 4\r
55     layout(location = 42, component = 1) out vec4 z;     // ERROR, goes to component 4\r
56 \r
57     layout(location = 42, component = 1) out mat4 ba;    // ERROR\r
58     layout(location = 43, component = 1) out S Ss;       // ERROR\r
59 } bd;\r
60 \r
61 layout(location = 1, component = 1) out;                 // ERROR, no global setting\r
62 \r
63 layout(location = 50, component = 3) out int be;\r
64 layout(location = 50, component = 0) out vec3 bf;\r
65 \r
66 layout(location = 51, component = 1) out double dfo;     // ERROR, odd component\r
67 layout(location = 52, component = 2) out dvec2 dvo;      // ERROR, overflow\r
68 layout(location = 53) out double dfo2;\r
69 layout(location = 53, component = 2) out vec2 ffv2;      // okay, fits\r
70 layout(location = 54) out dvec4 dvec4out;                // uses up location 55 too\r
71 layout(location = 55) out float overf;                   // ERROR, collides with previous dvec4\r
72 layout(location = 56, component = 1) out vec2 df2o;\r
73 layout(location = 56, component = 3) out float sf2o;\r
74 layout(location = 57, component = 2) out vec2 dv3o;\r
75 layout(location = 57, component = 3) out float sf4o;     // ERROR, overlapping component\r
76 layout(location=58) out flat dvec3 dv3o2;                // uses part of location 59\r
77 layout(location=59, component=2) out flat double dfo3;   // okay, fits\r
78 layout(location=59, component=0) out flat double dfo4;   // ERROR, overlaps the dvec3 in starting in 58\r
79 \r
80 out bblck1 {\r
81     vec4 bbv;\r
82 } bbinst1;\r
83 \r
84 out bblck2 {\r
85     layout(xfb_offset=64) vec4 bbv;\r
86 } bbinst2;\r
87 \r
88 layout(xfb_buffer = 3, xfb_stride = 64) out;  // default buffer is 3\r
89 \r
90 out bblck3 {\r
91     layout(xfb_offset=16) vec4 bbv;  // in xfb_buffer 3\r
92 } bbinst3;\r
93 \r
94 uniform ubblck3 {\r
95     layout(xfb_offset=16) vec4 bbv;  // ERROR, not in a uniform\r
96 } ubbinst3;\r
97 \r
98 layout(xfb_buffer=2, xfb_offset=48, xfb_stride=80) out vec4 bg;\r
99 layout(              xfb_offset=32, xfb_stride=64) out vec4 bh;\r
100 \r
101 layout(xfb_offset=48) out; // ERROR\r
102 \r
103 layout(xfb_stride=80, xfb_buffer=2, xfb_offset=16) out bblck4 {\r
104     vec4 bbv1;\r
105     vec4 bbv2;\r
106 } bbinst4;\r
107 \r
108 out bblck5 {\r
109     layout(xfb_offset=0) vec4 bbv1;\r
110     layout(xfb_stride=64, xfb_buffer=3, xfb_offset=48) vec4 bbv2;\r
111     layout(xfb_buffer=2) vec4 bbv3;                               // ERROR, wrong buffer\r
112 } bbinst5;\r
113 \r
114 out layout(xfb_buffer=2) bblck6 {\r
115     layout(xfb_offset=0) vec4 bbv1;\r
116     layout(xfb_stride=64, xfb_buffer=3, xfb_offset=32) vec4 bbv2; // ERROR, overlap 32 from bh, and buffer contradiction\r
117     layout(xfb_buffer=2, xfb_offset=0) vec4 bbv3;                 // ERROR, overlap 0 from bbinst5\r
118     layout(xfb_buffer=2) vec4 bbv5;\r
119     layout(xfb_offset=24) float bbf6;                             // ERROR, overlap 24 from bbv1 in bbinst4\r
120 } bbinst6;\r
121 \r
122 layout(xfb_stride=48) out;                   // ERROR, stride of buffer 3\r
123 \r
124 layout(xfb_buffer=1) out;  // default buffer is 1\r
125 layout(xfb_offset=4) out float bj;\r
126 layout(xfb_offset=0) out ivec2 bk;           // ERROR, overlap 4\r
127 \r
128 layout(xfb_buffer=3, xfb_stride=48) out;     // ERROR, stride of buffer 3 (default is now 3)\r
129 layout(xfb_stride=48) out float bl;          // ERROR, stride of buffer 3\r
130 \r
131 layout(xfb_stride=48) out bblck7 {           // ERROR, stride of buffer 3\r
132     layout(xfb_stride=64) vec4 bbv1;\r
133     layout(xfb_stride=32) vec4 bbv2;         // ERROR, stride of buffer 3\r
134 } bbinst7;\r
135 \r
136 struct S5 {\r
137     int i;    // 4 bytes plus 4 byte hole\r
138     double d; // 8 bytes\r
139     float f;  // 4 bytes\r
140 };  // total size = 20\r
141 \r
142 struct T {\r
143     bool b;   // 4 plus 4 byte hole\r
144     S5 s;     // 20 \r
145     vec2 v2;  // 8\r
146 };  // total size = 36\r
147 \r
148 out layout(xfb_buffer=0, xfb_offset=0, xfb_stride=92) bblck8 {  // ERROR, stride not multiple of 8\r
149     bool b;    // offset 0\r
150     T t;       // offset 8, size 40\r
151     int i;     // offset 40 + 4 = 48\r
152     mat3x3 m3; // offset 52\r
153     float f;   // offset 52 + 9*4 = 88\r
154     float g;   // ERROR, overflow stride\r
155 } bbinst8;\r
156 \r
157 out layout(xfb_buffer=4) bblck9 {\r
158     layout(xfb_offset=1) bool b;     // ERROR\r
159     layout(xfb_offset=12) T t;       // ERROR\r
160     layout(xfb_offset=52) mat3x3 m3; // non-multiple of 8 okay\r
161     layout(xfb_offset=90) int i;     // ERROR\r
162     layout(xfb_offset=98) double d;  // ERROR\r
163     layout(xfb_offset=108) S s;      // non-multiple of 8 okay\r
164 } bbinst9;\r
165 \r
166 layout(xfb_buffer=5, xfb_stride=6) out;     // link ERROR, stride not multiple of 4\r
167 layout(xfb_offset=0) out float bm;\r
168 \r
169 layout(xfb_buffer=6, xfb_stride=2000) out;  // ERROR, stride too big\r
170 \r
171 out layout(xfb_buffer=7, xfb_offset=0) bblck10 {  // link ERROR, implicit stride too big\r
172     dmat4x4 m1;\r
173     dmat4x4 m2;\r
174     float f;\r
175 } bbinst10;\r
176 \r
177 int drawParamsBad()\r
178 {\r
179     return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB; // ERROR, extension not requested\r
180 }\r
181 \r
182 #extension GL_ARB_shader_draw_parameters: enable\r
183 \r
184 int drawParams()\r
185 {\r
186     return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB;\r
187     gl_BaseVertexARB = 3;       // ERROR, can't write to shader 'in'\r
188     gl_BaseInstanceARB = 3;     // ERROR, can't write to shader 'in'\r
189     gl_DrawIDARB = 3;           // ERROR, can't write to shader 'in'\r
190     glBaseInstanceARB;          // ERROR, not defined\r
191 }\r