<div dir="ltr">On 17 July 2013 18:24, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Rather than creating a new "binding" field in ir_variable, we reuse<br>
constant_value since the linker code for handling uniform initializers<br>
uses that.<br></blockquote><div><br></div>I'm uncomfortable with this. It's already a bit irregular that we use constant_value for this purpose in handling uniform initializers (since the value of a uniform initializer can be overridden using the GL API, and hence isn't really constant), and we already have some ugly workaround code to deal with that irregularity (see ir_dereference_variable::constant_expression_value(), which has to have a special case to ignore constant_value when looking at a uniform). In point of fact, I'm worried that there may be bugs in opt_constant_variable.cpp, because it doesn't seem to go to any effort to avoid trying to treat uniforms with initializers as constants.<br>
<div><br></div><div>Re-using constant_value for bindings seems even more dangerous, since now the types won't even match.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Since UBOs and samplers can't otherwise have initializers/constant<br>
values, there shouldn't be a conflict.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>><br>
---<br>
src/glsl/ast_to_hir.cpp | 7 +++++--<br>
src/glsl/ir.h | 8 ++++++++<br>
src/glsl/ir_clone.cpp | 1 +<br>
3 files changed, 14 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp<br>
index 4a04b60..f438b6d 100644<br>
--- a/src/glsl/ast_to_hir.cpp<br>
+++ b/src/glsl/ast_to_hir.cpp<br>
@@ -2158,8 +2158,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,<br>
"explicit index requires explicit location\n");<br>
}<br>
<br>
- if (qual->flags.q.explicit_binding)<br>
- validate_binding_qualifier(state, loc, var, qual);<br>
+ if (qual->flags.q.explicit_binding &&<br>
+ validate_binding_qualifier(state, loc, var, qual)) {<br>
+ var->explicit_binding = true;<br>
+ var->constant_value = new(state) ir_constant(qual->binding);<br>
+ }<br>
<br>
/* Does the declaration use the deprecated 'attribute' or 'varying'<br>
* keywords?<br>
diff --git a/src/glsl/ir.h b/src/glsl/ir.h<br>
index 1f0dc09..46bdb38 100644<br>
--- a/src/glsl/ir.h<br>
+++ b/src/glsl/ir.h<br>
@@ -471,6 +471,14 @@ public:<br>
unsigned explicit_index:1;<br>
<br>
/**<br>
+ * Was an initial binding explicitly set in the shader?<br>
+ *<br>
+ * If so, constant_value contains an integer ir_constant representing the<br>
+ * initial binding point.<br>
+ */<br>
+ unsigned explicit_binding:1;<br>
+<br>
+ /**<br>
* Does this variable have an initializer?<br>
*<br>
* This is used by the linker to cross-validiate initializers of global<br>
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp<br>
index 5b42935..535f5ce 100644<br>
--- a/src/glsl/ir_clone.cpp<br>
+++ b/src/glsl/ir_clone.cpp<br>
@@ -55,6 +55,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const<br>
var->pixel_center_integer = this->pixel_center_integer;<br>
var->explicit_location = this->explicit_location;<br>
var->explicit_index = this->explicit_index;<br>
+ var->explicit_binding = this->explicit_binding;<br>
var->has_initializer = this->has_initializer;<br>
var->depth_layout = this->depth_layout;<br>
<span><font color="#888888"><br>
--<br>
1.8.3.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>