[Mesa-dev] [PATCH 06/10] glsl: Add support for AMD_conservative_depth to bison file

Chad Versace chad.versace at intel.com
Sat Oct 23 11:22:26 PDT 2010


Add support for AMD_conservative_depth by extending the production rule of
layout_qualifier_id to process the additional layout qualifier tokens enabled
by the extension.
---
 src/glsl/glsl_parser.ypp |   64 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/src/glsl/glsl_parser.ypp b/src/glsl/glsl_parser.ypp
index 97f7b32..2161200 100644
--- a/src/glsl/glsl_parser.ypp
+++ b/src/glsl/glsl_parser.ypp
@@ -50,6 +50,24 @@ layout_qualifier_id__ARB_fragment_coord_conventions_enable(
    const char *token1,
    YYLTYPE *token1_location);
 
+/**
+ * \brief Helper function for prodution rule of 'layout_qualifier_id'.
+ *
+ * If extension 'AMD_conservative_depth' is enabled and \c token1 is
+ * a layout qualifer added by that extension, then process the token and
+ * return true. Else, return false.
+ *
+ * This function should be used only within the production rule of
+ * 'layout_qualifier_id'.
+ */
+static bool
+layout_qualifier_id__AMD_conservative_depth(
+   _mesa_glsl_parse_state *state,
+   ast_type_qualifier *lhs,
+   YYLTYPE *lhs_location,
+   const char *token1,
+   YYLTYPE *token1_location);
+
 %}
 
 %pure-parser
@@ -1024,8 +1042,14 @@ layout_qualifier_id:
 
 	   memset(& $$, 0, sizeof($$));
 
-           got_one = layout_qualifier_id__ARB_fragment_coord_conventions_enable(
-              state, & $$, & @$, $1, & @1);
+           if (!got_one) {
+              got_one = layout_qualifier_id__ARB_fragment_coord_conventions_enable(
+                    state, & $$, & @$, $1, & @1);
+           }
+           if (!got_one) {
+              got_one = layout_qualifier_id__AMD_conservative_depth(
+                    state, & $$, & @$, $1, & @1);
+           }
 
 	   /* If the identifier didn't match any known layout identifiers,
 	    * emit an error.
@@ -1667,3 +1691,39 @@ layout_qualifier_id__ARB_fragment_coord_conventions_enable(
 
    return found;
 }
+
+static bool
+layout_qualifier_id__AMD_conservative_depth(
+   _mesa_glsl_parse_state *state,
+   ast_type_qualifier *lhs,
+   YYLTYPE *lhs_location,
+   const char *token1,
+   YYLTYPE *token1_location)
+{
+   // found: Indicates if a layout qualifier has been found.
+   bool found = false;
+
+   if (!state->AMD_conservative_depth_enable)
+      return false;
+
+   if (strcmp(token1, "depth_any") == 0) {
+      found = true;
+      lhs->flags.q.depth_any = 1;
+   } else if (strcmp(token1, "depth_greater") == 0) {
+      found = true;
+      lhs->flags.q.depth_greater = 1;
+   } else if (strcmp(token1, "depth_less") == 0) {
+      found = true;
+      lhs->flags.q.depth_less = 1;
+   } else if (strcmp(token1, "depth_unchanged") == 0) {
+      found = true;
+      lhs->flags.q.depth_unchanged = 1;
+   }
+
+   if (found && state->AMD_conservative_depth_warn) {
+      _mesa_glsl_warning(token1_location, state, "GL_AMD_conservative_depth "
+         "layout identifier `%s' used\n", token1);
+   }
+
+   return found;
+}
-- 
1.7.1



More information about the mesa-dev mailing list