Mesa (master): glsl: throw error when using invariant(all) in a fragment shader

Tapani Pälli tpalli at kemper.freedesktop.org
Wed Dec 3 06:58:25 UTC 2014


Module: Mesa
Branch: master
Commit: 636db35c35d4420a308629cead3287c57458644d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=636db35c35d4420a308629cead3287c57458644d

Author: Tapani Pälli <tapani.palli at intel.com>
Date:   Tue Nov  4 14:20:15 2014 +0200

glsl: throw error when using invariant(all) in a fragment shader

Note that some of the GLSL specifications explicitly state this as
compile error, some simply state that 'it is an error'.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>

---

 src/glsl/glsl_parser.yy |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 6160e26..6a55a4e 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -331,7 +331,18 @@ pragma_statement:
    | PRAGMA_OPTIMIZE_OFF EOL
    | PRAGMA_INVARIANT_ALL EOL
    {
-      if (!state->is_version(120, 100)) {
+      /* Pragma invariant(all) cannot be used in a fragment shader.
+       *
+       * Page 27 of the GLSL 1.20 spec, Page 53 of the GLSL ES 3.00 spec:
+       *
+       *     "It is an error to use this pragma in a fragment shader."
+       */
+      if (state->is_version(120, 300) &&
+          state->stage == MESA_SHADER_FRAGMENT) {
+         _mesa_glsl_error(& @1, state,
+                          "pragma `invariant(all)' cannot be used "
+                          "in a fragment shader.");
+      } else if (!state->is_version(120, 100)) {
          _mesa_glsl_warning(& @1, state,
                             "pragma `invariant(all)' not supported in %s "
                             "(GLSL ES 1.00 or GLSL 1.20 required)",




More information about the mesa-commit mailing list