On 19 September 2013 11:36, Steve Miller <dervi...@gmail.com> wrote: > GLSL 1.50 section 4.6.1 (The Invariant Qualifier) says: > To ensure that a particular output variable is invariant, it is > necessary > to use the invariant qualifier. It can either be used to qualify a > previously declared variable as being invariant > invariant gl_Position; // make existing gl_Position be invariant > out vec3 Color; // make existing Color be invariant > invariant Color; > or as part of a declaration when a variable is declared > invariant centroid out vec3 Color; > The invariant qualifier must appear before any interpolation qualifiers > or > storage qualifiers when combined with a declaration. Only variables > output > from a shader (including those that are then input to a subsequent > shader) > can be candidates for invariance. This includes user-defined output > variables > and the built-in output variables. For variables leaving one shader and > coming > into another shader, the invariant keyword has to be used in both > shaders, > or a link error will result. > --- > .../invariant-qualifier-everywhere.shader_test | 83 > +++++++++++++++++++++ > ...fier-everywhere-gs-fs-inconsistency.shader_test | 83 > +++++++++++++++++++++ > ...fier-everywhere-vs-gs-inconsistency.shader_test | 84 > ++++++++++++++++++++++ > 3 files changed, 250 insertions(+) > create mode 100644 > tests/spec/glsl-1.50/execution/invariant-qualifier-everywhere.shader_test > create mode 100644 > tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-gs-fs-inconsistency.shader_test > create mode 100644 > tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-vs-gs-inconsistency.shader_test >
Thanks, Steve. I've made a minor correction and pushed this patch to piglit master. > > diff --git > a/tests/spec/glsl-1.50/execution/invariant-qualifier-everywhere.shader_test > b/tests/spec/glsl-1.50/execution/invariant-qualifier-everywhere.shader_test > new file mode 100644 > index 0000000..3cee960 > --- /dev/null > +++ > b/tests/spec/glsl-1.50/execution/invariant-qualifier-everywhere.shader_test > @@ -0,0 +1,83 @@ > +# Test that invariant qualifier is available to all shaders > +# > +# GLSL 1.50 section 4.6.1 (The Invariant Qualifier) says: > +# To ensure that a particular output variable is invariant, it is > necessary > +# to use the invariant qualifier. It can either be used to qualify a > +# previously declared variable as being invariant > +# invariant gl_Position; // make existing gl_Position be invariant > +# out vec3 Color; // make existing Color be invariant > +# invariant Color; > +# or as part of a declaration when a variable is declared > +# invariant centroid out vec3 Color; > +# The invariant qualifier must appear before any interpolation > qualifiers or > +# storage qualifiers when combined with a declaration. Only variables > output > +# from a shader (including those that are then input to a subsequent > shader) > +# can be candidates for invariance. This includes user-defined output > variables > +# and the built-in output variables. For variables leaving one shader > and coming > +# into another shader, the invariant keyword has to be used in both > shaders, > +# or a link error will result. > +# > +# Test is expected to pass. > + > +[require] > +GL >= 3.2 > +GLSL >= 1.50 > + > +[vertex shader] > +#version 150 > + > +in vec4 vertex; > +invariant out vec4 pos; > +invariant gl_Position; > +invariant out vec4 extra01; > + > +void main() > +{ > + gl_Position = vertex; > + pos = vertex; > +} > + > +[geometry shader] > +#version 150 > + > +layout(triangles) in; > +layout(triangles, max_vertices=3) out; > + > +invariant in vec4 pos[]; > +invariant in vec4 extra01[]; > +invariant out vec4 extra02; > + > + > +void main() > +{ > + for(int i = 0; i < 3; i++) { > + gl_Position = pos[i] * 0.5; > + extra02 = extra01[i] * 0.5; > + EmitVertex(); > + } > + > +} > + > + > +[fragment shader] > +#version 150 > + > +in vec4 extra02; > +invariant extra02; //should be legal according to example > +out vec4 FragColor; > + > +void main() > +{ > + FragColor = vec4(extra02); > +} > + > +[vertex data] > +vertex/float/2 > +-1.0 -1.0 > + 1.0 -1.0 > + 1.0 1.0 > +-1.0 1.0 > + > +[test] > +draw arrays GL_TRIANGLE_FAN 0 4 > +probe all rgba 0.5 0.5 0.5 0.5 > diff --git > a/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-gs-fs-inconsistency.shader_test > b/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-gs-fs-inconsistency.shader_test > new file mode 100644 > index 0000000..6454283 > --- /dev/null > +++ > b/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-gs-fs-inconsistency.shader_test > @@ -0,0 +1,83 @@ > +# Test that invariant qualifier is available to all shaders > +# > +# GLSL 1.50 section 4.6.1 (The Invariant Qualifier) says: > +# To ensure that a particular output variable is invariant, it is > necessary > +# to use the invariant qualifier. It can either be used to qualify a > +# previously declared variable as being invariant > +# invariant gl_Position; // make existing gl_Position be invariant > +# out vec3 Color; // make existing Color be invariant > +# invariant Color; > +# or as part of a declaration when a variable is declared > +# invariant centroid out vec3 Color; > +# The invariant qualifier must appear before any interpolation > qualifiers or > +# storage qualifiers when combined with a declaration. Only variables > output > +# from a shader (including those that are then input to a subsequent > shader) > +# can be candidates for invariance. This includes user-defined output > variables > +# and the built-in output variables. For variables leaving one shader > and coming > +# into another shader, the invariant keyword has to be used in both > shaders, > +# or a link error will result. > +# > +# Test leaves out the required invariant qualifier from the fragment > shader, > +# and produce corresponding link error. > + > +[require] > +GL >= 3.2 > +GLSL >= 1.50 > + > +[vertex shader] > +#version 150 > + > +in vec4 vertex; > +invariant out vec4 pos; > +invariant gl_Position; > +invariant out vec4 extra01; > + > +void main() > +{ > + gl_Position = vertex; > + pos = vertex; > +} > + > +[geometry shader] > +#version 150 > + > +layout(triangles) in; > +layout(triangles, max_vertices=3) out; > + > +invariant in vec4 pos[]; > +invariant in vec4 extra01[]; > +invariant out vec4 extra02; > + > + > +void main() > +{ > + for(int i = 0; i < 3; i++) { > + gl_Position = pos[i] * 0.5; > + extra02 = extra01[i] * 0.5; > + EmitVertex(); > + } > + > +} > + > + > +[fragment shader] > +#version 150 > + > +in vec4 extra02; > +//invariant extra02; //redeclaration left out > +out vec4 FragColor; > + > +void main() > +{ > + FragColor = vec4(extra02); > +} > + > +[vertex data] > +vertex/float/2 > +-1.0 -1.0 > + 1.0 -1.0 > + 1.0 1.0 > +-1.0 1.0 > + > +[test] > +link error > diff --git > a/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-vs-gs-inconsistency.shader_test > b/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-vs-gs-inconsistency.shader_test > new file mode 100644 > index 0000000..56af4f8 > --- /dev/null > +++ > b/tests/spec/glsl-1.50/linker/invariant-qualifier-everywhere-vs-gs-inconsistency.shader_test > @@ -0,0 +1,84 @@ > +# Test that invariant qualifier is available to all shaders > +# > +# GLSL 1.50 section 4.6.1 (The Invariant Qualifier) says: > +# To ensure that a particular output variable is invariant, it is > necessary > +# to use the invariant qualifier. It can either be used to qualify a > +# previously declared variable as being invariant > +# invariant gl_Position; // make existing gl_Position be invariant > +# out vec3 Color; // make existing Color be invariant > +# invariant Color; > +# or as part of a declaration when a variable is declared > +# invariant centroid out vec3 Color; > +# The invariant qualifier must appear before any interpolation > qualifiers or > +# storage qualifiers when combined with a declaration. Only variables > output > +# from a shader (including those that are then input to a subsequent > shader) > +# can be candidates for invariance. This includes user-defined output > variables > +# and the built-in output variables. For variables leaving one shader > and coming > +# into another shader, the invariant keyword has to be used in both > shaders, > +# or a link error will result. > +# > +# Test leaves out the required invariant qualifier from the geometry > shader, > +# and produce corresponding link error. > + > +[require] > +GL >= 3.2 > +GLSL >= 1.50 > + > +[vertex shader] > +#version 150 > + > +in vec4 vertex; > +invariant out vec4 pos; > +invariant gl_Position; > +invariant out vec4 extra01; > + > +void main() > +{ > + gl_Position = vertex; > + pos = vertex; > +} > + > +[geometry shader] > +#version 150 > + > +layout(triangles) in; > +layout(triangles, max_vertices=3) out; > + > +//invariant > +in vec4 pos[]; > +invariant in vec4 extra01[]; > +invariant out vec4 extra02; > + > + > +void main() > +{ > + for(int i = 0; i < 3; i++) { > + gl_Position = pos[i] * 0.5; > + extra02 = extra01[i] * 0.5; > + EmitVertex(); > + } > + > +} > + > + > +[fragment shader] > +#version 150 > + > +in vec4 extra02; > +invariant extra02; //should be legal according to example > +out vec4 FragColor; > + > +void main() > +{ > + FragColor = vec4(extra02); > +} > + > +[vertex data] > +vertex/float/2 > +-1.0 -1.0 > + 1.0 -1.0 > + 1.0 1.0 > +-1.0 1.0 > + > +[test] > +link error > -- > 1.8.3.1 > > _______________________________________________ > Piglit mailing list > Piglit@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/piglit >
_______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit