3 #extension GL_3DL_array_objects : enable
\r
6 vec4 Position; // API transform/feedback will use
\93Vertex.Position
\94\r
8 } Coords; // shader will use
\93Coords.Position
\94\r
11 vec4 Color; // API will use
\93Color
\94\r
14 uniform Transform { // API uses
\93Transform[2]
\94 to refer to instance 2
\r
15 mat4 ModelViewMatrix;
\r
16 mat4 ModelViewProjectionMatrix;
\r
17 vec4 a[]; // array will get implicitly sized
\r
21 layout(location = 3) in vec4 normal;
\r
22 layout(location = 6) in vec4 colors[3];
\r
23 layout(location = 9) in mat4 transforms2[2];
\r
25 layout(location = 3) struct S {
\r
31 layout(triangles, invocations = 6) in;
\r
33 layout(lines) in; // legal for Color2, input size is 2, matching Color2
\r
35 layout(triangle_strip, max_vertices = 60) out; // order does not matter
\r
36 layout(max_vertices = 60) out; // redeclaration okay
\r
37 layout(triangle_strip) out; // redeclaration okay
\r
38 //layout(points) out; // error, contradicts triangle_strip
\r
39 //layout(max_vertices = 30) out; // error, contradicts 60
\r
41 layout(stream = 1) out;
\r
43 layout(stream=1) out; // default is now stream 1
\r
44 out vec4 var1; // var1 gets default stream (1)
\r
45 layout(stream=2) out Block1 { // "Block1" belongs to stream 2
\r
46 layout(stream=2) vec4 var2; // redundant block member stream decl
\r
47 layout(stream=3) vec2 var3; // ILLEGAL (must match block stream)
\r
48 vec3 var4; // belongs to stream 2
\r
50 layout(stream=0) out; // default is now stream 0
\r
51 out vec4 var5; // var5 gets default stream (0)
\r
52 out Block2 { // "Block2" gets default stream (0)
\r
55 layout(stream=3) out vec4 var7; // var7 belongs to stream 3
\r
57 layout(shared, column_major) uniform;
\r
58 layout(shared, column_major) buffer;
\r
60 layout(row_major, column_major)
\r
62 layout(shared, row_major) uniform; // default is now shared and row_major
\r
64 layout(std140) uniform Transform2 { // layout of this block is std140
\r
65 mat4 M1; // row_major
\r
66 layout(column_major) mat4 M2; // column major
\r
67 mat3 N1; // row_major
\r
70 layout(column_major) uniform T3 { // shared and column_major
\r
71 mat4 M13; // column_major
\r
72 layout(row_major) mat4 m14; // row major
\r
73 mat3 N12; // column_major
\r
76 // in one compilation unit...
\r
77 layout(binding=3) uniform sampler2D s17; // s bound to unit 3
\r
79 // in another compilation unit...
\r
80 uniform sampler2D s17; // okay, s still bound at 3
\r
82 // in another compilation unit...
\r
83 //layout(binding=4) uniform sampler2D s; // ERROR: contradictory bindings
\r
85 layout (binding = 2, offset = 4) uniform atomic_uint a2;
\r
87 layout (binding = 2) uniform atomic_uint bar;
\r
89 layout (binding = 2, offset = 4) uniform atomic_uint;
\r
91 layout (binding = 2) uniform atomic_uint bar; // offset is 4
\r
92 layout (offset = 8) uniform atomic_uint bar23; // error, no default binding
\r
94 layout (binding=3, offset=4) uniform atomic_uint a2; // offset = 4
\r
95 layout (binding=2) uniform atomic_uint b2; // offset = 0
\r
96 layout (binding=3) uniform atomic_uint c2; // offset = 8
\r
97 layout (binding=2) uniform atomic_uint d2; // offset = 4
\r
99 //layout (offset=4) // error, must include binding
\r
100 //layout (binding=1, offset=0) a; // okay
\r
101 //layout (binding=2, offset=0) b; // okay
\r
102 //layout (binding=1, offset=0) c; // error, offsets must not be shared
\r
103 // // between a and c
\r
104 //layout (binding=1, offset=2) d; // error, overlaps offset 0 of a
\r
106 flat in vec4 gl_FrontColor; // input to geometry shader, no
\93gl_in[]
\94\r
107 flat out vec4 gl_FrontColor; // output from geometry shader
\r
109 invariant gl_Position; // make existing gl_Position be invariant
\r
112 invariant ColorIvn; // make existing Color be invariant
\r
114 invariant centroid out vec3 Color4;
\r
115 precise out vec4 position;
\r
118 precise Color5; // make existing Color be precise
\r
119 in vec4 a, b, c, d;
\r
120 precise out vec4 v;
\r
122 coherent buffer Block {
\r
123 readonly vec4 member1;
\r
128 coherent readonly vec4 member1A;
\r
129 coherent vec4 member2A;
\r
134 vec4 funcA(restrict image2D a) { }
\r
136 vec4 funcB(image2D a) { }
\r
137 layout(rgba32f) uniform image2D img1;
\r
138 layout(rgba32f) coherent uniform image2D img2;
\r
140 float func(float e, float f, float g, float h)
\r
142 return (e*f) + (g*h); // no constraint on order or
\r
143 // operator consistency
\r
146 float func2(float e, float f, float g, float h)
\r
148 precise float result = (e*f) + (g*h); // ensures same precision for
\r
149 // the two multiplies
\r
153 float func3(float i, float j, precise out float k)
\r
155 k = i * i + j; // precise, due to <k> declaration
\r
160 vec3 r = vec3(a * b); // precise, used to compute v.xyz
\r
161 vec3 s = vec3(c * d); // precise, used to compute v.xyz
\r
162 v.xyz = r + s; // precise
\r
163 v.w = (a.w * b.w) + (c.w * d.w); // precise
\r
164 v.x = func(a.x, b.x, c.x, d.x); // values computed in func()
\r
166 v.x = func2(a.x, b.x, c.x, d.x); // precise!
\r
167 func3(a.x * b.x, c.x * d.x, v.x); // precise!
\r
169 funcA(img1); // OK, adding "restrict" is allowed, ERROR, changing formats
\r
170 funcB(img2); // illegal, stripping "coherent" is not, ERROR, changing formats
\r
178 light lightVar = light(3.0, vec3(1.0, 2.0, 3.0));
\r
181 const float c[3] = float[3](5.0, 7.2, 1.1);
\r
182 const float d[3] = float[](5.0, 7.2, 1.1);
\r
185 float a[5] = float[5](g, 1, g, 2.3, g);
\r
188 b = float[3](g, g + 1.0, g + 2.0);
\r
191 vec4 b[2] = { vec4(1.0), vec4(1.0) };
\r
192 vec4[3][2](b, b, b); // constructor
\r
193 vec4[][2](b, b, b); // constructor, valid, size deduced
\r
194 vec4[3][](b, b, b); // compile-time error, invalid type constructed
\r