glsl: Add support for AMD_conservative_depth to parser
authorChad Versace <chad.versace@intel.com>
Thu, 27 Jan 2011 09:40:14 +0000 (01:40 -0800)
committerChad Versace <chad.versace@intel.com>
Thu, 27 Jan 2011 00:37:44 +0000 (16:37 -0800)
When AMD_conservative_depth is enabled:
* Let 'layout' be a token.
* Extend the production rule of layout_qualifier_id to process the tokens:
   depth_any
   depth_greater
   depth_less
   depth_unchanged

src/glsl/glsl_lexer.lpp
src/glsl/glsl_parser.ypp
src/glsl/glsl_parser_extras.h

index d30759be2b808601c37cefa8986d902ae520ba95..555bc1f885474c707d7baa3d10d2244129fb7703 100644 (file)
@@ -252,6 +252,7 @@ void                return VOID_TOK;
 
 layout         {
                  if ((yyextra->language_version >= 140)
+                     || yyextra->AMD_conservative_depth_enable
                      || yyextra->ARB_explicit_attrib_location_enable
                      || (yyextra->ARB_fragment_coord_conventions_enable)){
                      return LAYOUT_TOK;
index 3982167c4827709585dbeed2ac5cb59e65c160ee..3955648eb6134c59e61ddbaa7bd84538895ee68b 100644 (file)
@@ -1018,7 +1018,8 @@ layout_qualifier_id:
 
           memset(& $$, 0, sizeof($$));
 
-          if (state->ARB_fragment_coord_conventions_enable) {
+          /* Layout qualifiers for ARB_fragment_coord_conventions. */
+          if (!got_one && state->ARB_fragment_coord_conventions_enable) {
              if (strcmp($1, "origin_upper_left") == 0) {
                 got_one = true;
                 $$.flags.q.origin_upper_left = 1;
@@ -1026,19 +1027,41 @@ layout_qualifier_id:
                 got_one = true;
                 $$.flags.q.pixel_center_integer = 1;
              }
+
+             if (got_one && state->ARB_fragment_coord_conventions_warn) {
+                _mesa_glsl_warning(& @1, state,
+                                   "GL_ARB_fragment_coord_conventions layout "
+                                   "identifier `%s' used\n", $1);
+             }
+          }
+
+          /* Layout qualifiers for AMD_conservative_depth. */
+          if (!got_one && state->AMD_conservative_depth_enable) {
+             if (strcmp($1, "depth_any") == 0) {
+                got_one = true;
+                $$.flags.q.depth_any = 1;
+             } else if (strcmp($1, "depth_greater") == 0) {
+                got_one = true;
+                $$.flags.q.depth_greater = 1;
+             } else if (strcmp($1, "depth_less") == 0) {
+                got_one = true;
+                $$.flags.q.depth_less = 1;
+             } else if (strcmp($1, "depth_unchanged") == 0) {
+                got_one = true;
+                $$.flags.q.depth_unchanged = 1;
+             }
+       
+             if (got_one && state->AMD_conservative_depth_warn) {
+                _mesa_glsl_warning(& @1, state,
+                                   "GL_AMD_conservative_depth "
+                                   "layout qualifier `%s' is used\n", $1);
+             }
           }
 
-          /* If the identifier didn't match any known layout identifiers,
-           * emit an error.
-           */
           if (!got_one) {
              _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
                               "`%s'\n", $1);
              YYERROR;
-          } else if (state->ARB_fragment_coord_conventions_warn) {
-             _mesa_glsl_warning(& @1, state,
-                                "GL_ARB_fragment_coord_conventions layout "
-                                "identifier `%s' used\n", $1);
           }
        }
        | IDENTIFIER '=' INTCONSTANT
index 030d27a2627f056c303b564c6fc24f6bb17836c8..92029e2e8dd3ff4471bd1b0995d3fb5c3e57896d 100644 (file)
@@ -144,6 +144,8 @@ struct _mesa_glsl_parse_state {
    unsigned EXT_texture_array_warn:1;
    unsigned ARB_shader_stencil_export_enable:1;
    unsigned ARB_shader_stencil_export_warn:1;
+   unsigned AMD_conservative_depth_enable:1;
+   unsigned AMD_conservative_depth_warn:1;
    /*@}*/
 
    /** Extensions supported by the OpenGL implementation. */