1 # Test that invariant qualifier is available to all shaders
3 # GLSL 1.50 section 4.6.1 (The Invariant Qualifier) says:
4 # To ensure that a particular output variable is invariant, it is necessary
5 # to use the invariant qualifier. It can either be used to qualify a
6 # previously declared variable as being invariant
7 # invariant gl_Position; // make existing gl_Position be invariant
8 # out vec3 Color; // make existing Color be invariant
10 # or as part of a declaration when a variable is declared
11 # invariant centroid out vec3 Color;
12 # The invariant qualifier must appear before any interpolation qualifiers or
13 # storage qualifiers when combined with a declaration. Only variables output
14 # from a shader (including those that are then input to a subsequent shader)
15 # can be candidates for invariance. This includes user-defined output variables
16 # and the built-in output variables. For variables leaving one shader and coming
17 # into another shader, the invariant keyword has to be used in both shaders,
18 # or a link error will result.
20 # Test leaves out the required invariant qualifier from the fragment shader,
21 # and produce corresponding link error.
31 invariant out vec4 pos;
32 invariant gl_Position;
33 invariant out vec4 extra01;
45 layout(triangle_strip, max_vertices=3) out;
47 invariant in vec4 pos[];
48 invariant in vec4 extra01[];
49 invariant out vec4 extra02;
54 for(int i = 0; i < 3; i++) {
55 gl_Position = pos[i] * 0.5;
56 extra02 = extra01[i] * 0.5;
67 //invariant extra02; //redeclaration left out
72 FragColor = vec4(extra02);