1617a3babSopenharmony_ci#version 440
2617a3babSopenharmony_ci
3617a3babSopenharmony_ci// Note 'location' tests for enhanced layouts are in 330.frag
4617a3babSopenharmony_ci
5617a3babSopenharmony_cilayout(location = 2, component = 2) in vec2 a; 
6617a3babSopenharmony_cilayout(location = 2, component = 1) in float b; 
7617a3babSopenharmony_ci
8617a3babSopenharmony_cilayout(location = 3, component = 2) in vec3 c;      // ERROR: c overflows components 2 and 3
9617a3babSopenharmony_ci
10617a3babSopenharmony_cilayout(location = 0, component = 3) in float d[4]; 
11617a3babSopenharmony_ci
12617a3babSopenharmony_cilayout(location = 4, component = 0) in vec3 e[5];
13617a3babSopenharmony_cilayout(location = 4, component = 3) in float f[5];
14617a3babSopenharmony_ci
15617a3babSopenharmony_cilayout(location = 9, component = 4) in float g[6];   // ERROR, component too big
16617a3babSopenharmony_ci
17617a3babSopenharmony_cilayout(location = 4, component = 2) in vec2 h;       // component overlap okay for vertex in
18617a3babSopenharmony_ci
19617a3babSopenharmony_cilayout(location = 3, component = 2) out vec2 i;
20617a3babSopenharmony_cilayout(location = 3, component = 0) out vec2 j;
21617a3babSopenharmony_ci
22617a3babSopenharmony_cilayout(location = 4, component = 2) out vec2 k;
23617a3babSopenharmony_cilayout(location = 4, component = 2) out vec2 m;      // ERROR, component overlap
24617a3babSopenharmony_ci
25617a3babSopenharmony_cilayout(location = 2, component = 2) out vec2 n;
26617a3babSopenharmony_cilayout(location = 2, component = 0) out vec3 p;      // ERROR, component overlap
27617a3babSopenharmony_ci
28617a3babSopenharmony_cilayout(location = 10, component = 3) out float q[6]; 
29617a3babSopenharmony_cilayout(location = 10, component = 0) out vec3 r[6];
30617a3babSopenharmony_ci
31617a3babSopenharmony_cilayout(location = 15, component = 3) out float s;    // ERROR, overlap
32617a3babSopenharmony_cilayout(location = 10, component = 1) out float t;    // ERROR, overlap
33617a3babSopenharmony_ci
34617a3babSopenharmony_cilayout(location = 20, component = 2) out float u;
35617a3babSopenharmony_cilayout(location = 20, component = 0) out float v;
36617a3babSopenharmony_cilayout(location = 20, component = 3) out float w;
37617a3babSopenharmony_cilayout(location = 20, component = 1) out vec2 x;     // ERROR, overlap
38617a3babSopenharmony_ci
39617a3babSopenharmony_cilayout(location = 30, component = 3) out vec2 y;     // ERROR, goes to component 4
40617a3babSopenharmony_cilayout(location = 31, component = 1) out vec4 z;     // ERROR, goes to component 4
41617a3babSopenharmony_ci
42617a3babSopenharmony_cilayout(location = 32, component = 1) out mat4 ba;               // ERROR
43617a3babSopenharmony_cilayout(location = 33, component = 1) out struct S {int a;} Ss;  // ERROR
44617a3babSopenharmony_cilayout(location = 34, component = 1) out bn { int a;} bb;       // ERROR
45617a3babSopenharmony_ci
46617a3babSopenharmony_cilayout(component = 1) out float bc;    // ERROR, no location
47617a3babSopenharmony_ci
48617a3babSopenharmony_ciout blockname {
49617a3babSopenharmony_ci    layout(location = 40, component = 2) out float u;
50617a3babSopenharmony_ci    layout(location = 40, component = 0) out float v;
51617a3babSopenharmony_ci    layout(location = 40, component = 3) out float w;
52617a3babSopenharmony_ci    layout(location = 40, component = 1) out vec2 x;     // ERROR, overlap
53617a3babSopenharmony_ci
54617a3babSopenharmony_ci    layout(location = 41, component = 3) out vec2 y;     // ERROR, goes to component 4
55617a3babSopenharmony_ci    layout(location = 42, component = 1) out vec4 z;     // ERROR, goes to component 4
56617a3babSopenharmony_ci
57617a3babSopenharmony_ci    layout(location = 42, component = 1) out mat4 ba;    // ERROR
58617a3babSopenharmony_ci    layout(location = 43, component = 1) out S Ss;       // ERROR
59617a3babSopenharmony_ci} bd;
60617a3babSopenharmony_ci
61617a3babSopenharmony_cilayout(location = 1, component = 1) out;                 // ERROR, no global setting
62617a3babSopenharmony_ci
63617a3babSopenharmony_cilayout(location = 50, component = 3) out int be;
64617a3babSopenharmony_cilayout(location = 50, component = 0) out vec3 bf;
65617a3babSopenharmony_ci
66617a3babSopenharmony_cilayout(location = 51, component = 1) out double dfo;     // ERROR, odd component
67617a3babSopenharmony_cilayout(location = 52, component = 2) out dvec2 dvo;      // ERROR, overflow
68617a3babSopenharmony_cilayout(location = 53) out double dfo2;
69617a3babSopenharmony_cilayout(location = 53, component = 2) out vec2 ffv2;      // okay, fits
70617a3babSopenharmony_cilayout(location = 54) out dvec4 dvec4out;                // uses up location 55 too
71617a3babSopenharmony_cilayout(location = 55) out float overf;                   // ERROR, collides with previous dvec4
72617a3babSopenharmony_cilayout(location = 56, component = 1) out vec2 df2o;
73617a3babSopenharmony_cilayout(location = 56, component = 3) out float sf2o;
74617a3babSopenharmony_cilayout(location = 57, component = 2) out vec2 dv3o;
75617a3babSopenharmony_cilayout(location = 57, component = 3) out float sf4o;     // ERROR, overlapping component
76617a3babSopenharmony_cilayout(location=58) out flat dvec3 dv3o2;                // uses part of location 59
77617a3babSopenharmony_cilayout(location=59, component=2) out flat double dfo3;   // okay, fits
78617a3babSopenharmony_cilayout(location=59, component=0) out flat double dfo4;   // ERROR, overlaps the dvec3 in starting in 58
79617a3babSopenharmony_ci
80617a3babSopenharmony_ciout bblck1 {
81617a3babSopenharmony_ci    vec4 bbv;
82617a3babSopenharmony_ci} bbinst1;
83617a3babSopenharmony_ci
84617a3babSopenharmony_ciout bblck2 {
85617a3babSopenharmony_ci    layout(xfb_offset=64) vec4 bbv;
86617a3babSopenharmony_ci} bbinst2;
87617a3babSopenharmony_ci
88617a3babSopenharmony_cilayout(xfb_buffer = 3, xfb_stride = 64) out;  // default buffer is 3
89617a3babSopenharmony_ci
90617a3babSopenharmony_ciout bblck3 {
91617a3babSopenharmony_ci    layout(xfb_offset=16) vec4 bbv;  // in xfb_buffer 3
92617a3babSopenharmony_ci} bbinst3;
93617a3babSopenharmony_ci
94617a3babSopenharmony_ciuniform ubblck3 {
95617a3babSopenharmony_ci    layout(xfb_offset=16) vec4 bbv;  // ERROR, not in a uniform
96617a3babSopenharmony_ci} ubbinst3;
97617a3babSopenharmony_ci
98617a3babSopenharmony_cilayout(xfb_buffer=2, xfb_offset=48, xfb_stride=80) out vec4 bg;
99617a3babSopenharmony_cilayout(              xfb_offset=32, xfb_stride=64) out vec4 bh;
100617a3babSopenharmony_ci
101617a3babSopenharmony_cilayout(xfb_offset=48) out; // ERROR
102617a3babSopenharmony_ci
103617a3babSopenharmony_cilayout(xfb_stride=80, xfb_buffer=2, xfb_offset=16) out bblck4 {
104617a3babSopenharmony_ci    vec4 bbv1;
105617a3babSopenharmony_ci    vec4 bbv2;
106617a3babSopenharmony_ci} bbinst4;
107617a3babSopenharmony_ci
108617a3babSopenharmony_ciout bblck5 {
109617a3babSopenharmony_ci    layout(xfb_offset=0) vec4 bbv1;
110617a3babSopenharmony_ci    layout(xfb_stride=64, xfb_buffer=3, xfb_offset=48) vec4 bbv2;
111617a3babSopenharmony_ci    layout(xfb_buffer=2) vec4 bbv3;                               // ERROR, wrong buffer
112617a3babSopenharmony_ci} bbinst5;
113617a3babSopenharmony_ci
114617a3babSopenharmony_ciout layout(xfb_buffer=2) bblck6 {
115617a3babSopenharmony_ci    layout(xfb_offset=0) vec4 bbv1;
116617a3babSopenharmony_ci    layout(xfb_stride=64, xfb_buffer=3, xfb_offset=32) vec4 bbv2; // ERROR, overlap 32 from bh, and buffer contradiction
117617a3babSopenharmony_ci    layout(xfb_buffer=2, xfb_offset=0) vec4 bbv3;                 // ERROR, overlap 0 from bbinst5
118617a3babSopenharmony_ci    layout(xfb_buffer=2) vec4 bbv5;
119617a3babSopenharmony_ci    layout(xfb_offset=24) float bbf6;                             // ERROR, overlap 24 from bbv1 in bbinst4
120617a3babSopenharmony_ci} bbinst6;
121617a3babSopenharmony_ci
122617a3babSopenharmony_cilayout(xfb_stride=48) out;                   // ERROR, stride of buffer 3
123617a3babSopenharmony_ci
124617a3babSopenharmony_cilayout(xfb_buffer=1) out;  // default buffer is 1
125617a3babSopenharmony_cilayout(xfb_offset=4) out float bj;
126617a3babSopenharmony_cilayout(xfb_offset=0) out ivec2 bk;           // ERROR, overlap 4
127617a3babSopenharmony_ci
128617a3babSopenharmony_cilayout(xfb_buffer=3, xfb_stride=48) out;     // ERROR, stride of buffer 3 (default is now 3)
129617a3babSopenharmony_cilayout(xfb_stride=48) out float bl;          // ERROR, stride of buffer 3
130617a3babSopenharmony_ci
131617a3babSopenharmony_cilayout(xfb_stride=48) out bblck7 {           // ERROR, stride of buffer 3
132617a3babSopenharmony_ci    layout(xfb_stride=64) vec4 bbv1;
133617a3babSopenharmony_ci    layout(xfb_stride=32) vec4 bbv2;         // ERROR, stride of buffer 3
134617a3babSopenharmony_ci} bbinst7;
135617a3babSopenharmony_ci
136617a3babSopenharmony_cistruct S5 {
137617a3babSopenharmony_ci    int i;    // 4 bytes plus 4 byte hole
138617a3babSopenharmony_ci    double d; // 8 bytes
139617a3babSopenharmony_ci    float f;  // 4 bytes
140617a3babSopenharmony_ci};  // total size = 20
141617a3babSopenharmony_ci
142617a3babSopenharmony_cistruct T {
143617a3babSopenharmony_ci    bool b;   // 4 plus 4 byte hole
144617a3babSopenharmony_ci    S5 s;     // 20 
145617a3babSopenharmony_ci    vec2 v2;  // 8
146617a3babSopenharmony_ci};  // total size = 36
147617a3babSopenharmony_ci
148617a3babSopenharmony_ciout layout(xfb_buffer=0, xfb_offset=0, xfb_stride=92) bblck8 {  // ERROR, stride not multiple of 8
149617a3babSopenharmony_ci    bool b;    // offset 0
150617a3babSopenharmony_ci    T t;       // offset 8, size 40
151617a3babSopenharmony_ci    int i;     // offset 40 + 4 = 48
152617a3babSopenharmony_ci    mat3x3 m3; // offset 52
153617a3babSopenharmony_ci    float f;   // offset 52 + 9*4 = 88
154617a3babSopenharmony_ci    float g;   // ERROR, overflow stride
155617a3babSopenharmony_ci} bbinst8;
156617a3babSopenharmony_ci
157617a3babSopenharmony_ciout layout(xfb_buffer=4) bblck9 {
158617a3babSopenharmony_ci    layout(xfb_offset=1) bool b;     // ERROR
159617a3babSopenharmony_ci    layout(xfb_offset=12) T t;       // ERROR
160617a3babSopenharmony_ci    layout(xfb_offset=52) mat3x3 m3; // non-multiple of 8 okay
161617a3babSopenharmony_ci    layout(xfb_offset=90) int i;     // ERROR
162617a3babSopenharmony_ci    layout(xfb_offset=98) double d;  // ERROR
163617a3babSopenharmony_ci    layout(xfb_offset=108) S s;      // non-multiple of 8 okay
164617a3babSopenharmony_ci} bbinst9;
165617a3babSopenharmony_ci
166617a3babSopenharmony_cilayout(xfb_buffer=5, xfb_stride=6) out;     // link ERROR, stride not multiple of 4
167617a3babSopenharmony_cilayout(xfb_offset=0) out float bm;
168617a3babSopenharmony_ci
169617a3babSopenharmony_cilayout(xfb_buffer=6, xfb_stride=2000) out;  // ERROR, stride too big
170617a3babSopenharmony_ci
171617a3babSopenharmony_ciout layout(xfb_buffer=7, xfb_offset=0) bblck10 {  // link ERROR, implicit stride too big
172617a3babSopenharmony_ci    dmat4x4 m1;
173617a3babSopenharmony_ci    dmat4x4 m2;
174617a3babSopenharmony_ci    float f;
175617a3babSopenharmony_ci} bbinst10;
176617a3babSopenharmony_ci
177617a3babSopenharmony_cilayout(xfb_buffer = 3) out;
178617a3babSopenharmony_cilayout(xfb_offset = 32) out gl_PerVertex {
179617a3babSopenharmony_ci    layout(xfb_buffer = 2) float gl_PointSize; // ERROR, change in xfb_buffer
180617a3babSopenharmony_ci    vec4 gl_Position;
181617a3babSopenharmony_ci};
182617a3babSopenharmony_ci
183617a3babSopenharmony_ciint drawParamsBad()
184617a3babSopenharmony_ci{
185617a3babSopenharmony_ci    return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB; // ERROR, extension not requested
186617a3babSopenharmony_ci}
187617a3babSopenharmony_ci
188617a3babSopenharmony_ci#extension GL_ARB_shader_draw_parameters: enable
189617a3babSopenharmony_ci
190617a3babSopenharmony_ciint drawParams()
191617a3babSopenharmony_ci{
192617a3babSopenharmony_ci    return gl_BaseVertexARB + gl_BaseInstanceARB + gl_DrawIDARB;
193617a3babSopenharmony_ci    gl_BaseVertexARB = 3;       // ERROR, can't write to shader 'in'
194617a3babSopenharmony_ci    gl_BaseInstanceARB = 3;     // ERROR, can't write to shader 'in'
195617a3babSopenharmony_ci    gl_DrawIDARB = 3;           // ERROR, can't write to shader 'in'
196617a3babSopenharmony_ci    glBaseInstanceARB;          // ERROR, not defined
197617a3babSopenharmony_ci}
198