[Mesa-dev] [PATCH 05/11] glsl: Propagate explicit binding information from AST to IR.

Kenneth Graunke kenneth at whitecape.org
Wed Jul 17 18:24:05 PDT 2013


Rather than creating a new "binding" field in ir_variable, we reuse
constant_value since the linker code for handling uniform initializers
uses that.

Since UBOs and samplers can't otherwise have initializers/constant
values, there shouldn't be a conflict.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ast_to_hir.cpp | 7 +++++--
 src/glsl/ir.h           | 8 ++++++++
 src/glsl/ir_clone.cpp   | 1 +
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 4a04b60..f438b6d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2158,8 +2158,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
 			  "explicit index requires explicit location\n");
    }
 
-   if (qual->flags.q.explicit_binding)
-      validate_binding_qualifier(state, loc, var, qual);
+   if (qual->flags.q.explicit_binding &&
+       validate_binding_qualifier(state, loc, var, qual)) {
+      var->explicit_binding = true;
+      var->constant_value = new(state) ir_constant(qual->binding);
+   }
 
    /* Does the declaration use the deprecated 'attribute' or 'varying'
     * keywords?
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 1f0dc09..46bdb38 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -471,6 +471,14 @@ public:
    unsigned explicit_index:1;
 
    /**
+    * Was an initial binding explicitly set in the shader?
+    *
+    * If so, constant_value contains an integer ir_constant representing the
+    * initial binding point.
+    */
+   unsigned explicit_binding:1;
+
+   /**
     * Does this variable have an initializer?
     *
     * This is used by the linker to cross-validiate initializers of global
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 5b42935..535f5ce 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -55,6 +55,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
    var->pixel_center_integer = this->pixel_center_integer;
    var->explicit_location = this->explicit_location;
    var->explicit_index = this->explicit_index;
+   var->explicit_binding = this->explicit_binding;
    var->has_initializer = this->has_initializer;
    var->depth_layout = this->depth_layout;
 
-- 
1.8.3.2



More information about the mesa-dev mailing list