glsl/parser: Handle the early_fragment_tests input layout qualifier.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 12 Feb 2014 16:10:09 +0000 (17:10 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 12 Feb 2014 17:44:05 +0000 (18:44 +0100)
v2: Only allow the early_fragment_tests qualifier in fragment shaders.

Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/glsl_parser.yy
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h

index e43bc4f17bad1aac2273d91ae7781a0f517a3645..2b5061d4c5729d1b1990fced8ff561276fd3a9d9 100644 (file)
@@ -1231,6 +1231,15 @@ layout_qualifier_id:
          }
       }
 
+      /* Layout qualifiers for ARB_shader_image_load_store. */
+      if (state->ARB_shader_image_load_store_enable ||
+          state->is_version(420, 0)) {
+         if (!$$.flags.i &&
+             match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
+            $$.flags.q.early_fragment_tests = 1;
+         }
+      }
+
       if (!$$.flags.i) {
          _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
                           "`%s'", $1);
@@ -2388,6 +2397,13 @@ layout_defaults:
          }
       }
          break;
+      case MESA_SHADER_FRAGMENT:
+         if ($1.flags.q.early_fragment_tests) {
+            state->early_fragment_tests = true;
+         } else {
+            _mesa_glsl_error(& @1, state, "invalid input layout qualifier");
+         }
+         break;
       case MESA_SHADER_COMPUTE: {
          if ($1.flags.q.local_size == 0) {
             _mesa_glsl_error(& @1, state,
@@ -2409,7 +2425,7 @@ layout_defaults:
       default:
          _mesa_glsl_error(& @1, state,
                           "input layout qualifiers only valid in "
-                          "geometry and compute shaders");
+                          "geometry, fragment and compute shaders");
          break;
       }
    }
index 196714f32727537e7bb9262c36af0e87a524c1b9..8bab7a981f2c1718d65b801256df502c9cecf75d 100644 (file)
@@ -197,6 +197,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
    this->gs_input_prim_type = GL_POINTS;
    this->gs_input_size = 0;
    this->out_qualifier = new(this) ast_type_qualifier();
+   this->early_fragment_tests = false;
    memset(this->atomic_counter_offsets, 0,
           sizeof(this->atomic_counter_offsets));
 }
index 2083d555f673c8534203618a1a277fbb195cb460..ba32c086e3a4d135efbfe32c0a290b0099710871 100644 (file)
@@ -395,6 +395,8 @@ struct _mesa_glsl_parse_state {
     */
    unsigned gs_input_size;
 
+   bool early_fragment_tests;
+
    /** Atomic counter offsets by binding */
    unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
 };