[Mesa-dev] [PATCH 08/10] glsl: Add support for AMD_conservative_depth in ast-to-hir

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


Extend the following functions to support the type qualifiers added by the
extension:
  - apply_type_qualifier_to_variable()
  - ast_declarator_list::hir()
---
 src/glsl/ast_to_hir.cpp |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 15e1afc..6e80e96 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1813,6 +1813,31 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
       }
    }
 
+   // Layout qualifiers enabled by AMD_conservative_depth.
+   var->depth_any = qual->flags.q.depth_any;
+   var->depth_greater = qual->flags.q.depth_greater;
+   var->depth_less = qual->flags.q.depth_less;
+   var->depth_unchanged = qual->flags.q.depth_unchanged;
+   {
+       int count = var->depth_any
+               + var->depth_greater
+               + var->depth_less
+               + var->depth_unchanged;
+       if (count > 0 && !state->AMD_conservative_depth_enable) {
+           _mesa_glsl_error(loc, state,
+                   "Extension GL_AMD_conservative_depth must be enabled to "
+                   "use depth layout qualifiers");
+       } else if (count > 0 && strcmp(var->name, "gl_FragDepth") != 0) {
+           _mesa_glsl_error(loc, state,
+                   "depth layout qualifiers can be applied only to "
+                    "gl_FragDepth");
+       } else if (count > 1 && strcmp(var->name, "gl_FragDepth") == 0) {
+           _mesa_glsl_error(loc, state,
+                   "At most one depth layout qualifier can be applied to "
+                   "gl_FragDepth");
+       }
+   }
+
    if (var->type->is_array() && state->language_version != 110) {
       var->array_lvalue = true;
    }
@@ -2219,6 +2244,16 @@ ast_declarator_list::hir(exec_list *instructions,
 	     */
 	    earlier->origin_upper_left = var->origin_upper_left;
 	    earlier->pixel_center_integer = var->pixel_center_integer;
+	 } else if (state->AMD_conservative_depth_enable
+	            && strcmp(var->name, "gl_FragDepth") == 0
+	            && earlier->type == var->type
+	            && earlier->mode == var->mode) {
+	     /* Allow redeclaration of gl_FragDepth for AMD_conservative_depth
+	      * qualifiers. */
+	     earlier->depth_any = var->depth_any;
+	     earlier->depth_greater = var->depth_greater;
+	     earlier->depth_less = var->depth_less;
+	     earlier->depth_unchanged = var->depth_unchanged;
 	 } else {
 	    YYLTYPE loc = this->get_location();
 	    _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier);
-- 
1.7.1



More information about the mesa-dev mailing list