<div dir="ltr">On 4 September 2013 15:22, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We can simply call the stored predicate function.<br>
<br>
In the case where we don't have a _mesa_glsl_parse_state pointer, it<br>
doesn't much matter whether we return true or false.<br></blockquote><div><br></div><div>Can you elaborate on this?  I dug through the code and it looks like the only cases where this code is reachable with state == NULL come from the linker.  But I don't understand enough about what happens to built-ins during linking to see why it doesn't matter whether we return true or false.<br>
<br>Also, it would be nice if you could put the explanation in a comment next to "if (state == NULL) return true;" rather than in the commit message, so that future maintainers don't have to do a "git blame" to understand why you're returning true.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/glsl/ir.cpp | 11 +++++++++++<br>
 src/glsl/ir.h   |  3 +++<br>
 2 files changed, 14 insertions(+)<br>
<br>
diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp<br>
index d9fb808..e9317f8 100644<br>
--- a/src/glsl/ir.cpp<br>
+++ b/src/glsl/ir.cpp<br>
@@ -1596,6 +1596,17 @@ ir_function_signature::is_builtin() const<br>
 }<br>
<br>
<br>
+bool<br>
+ir_function_signature::is_builtin_available(const _mesa_glsl_parse_state *state) const<br>
+{<br>
+   if (state == NULL)<br>
+      return true;<br>
+<br>
+   assert(builtin_info != NULL);<br>
+   return builtin_info(state);<br>
+}<br>
+<br>
+<br>
 static bool<br>
 modes_match(unsigned a, unsigned b)<br>
 {<br>
diff --git a/src/glsl/ir.h b/src/glsl/ir.h<br>
index a927e90..bd1c12c 100644<br>
--- a/src/glsl/ir.h<br>
+++ b/src/glsl/ir.h<br>
@@ -686,6 +686,9 @@ public:<br>
    /** Whether or not this function signature is a built-in. */<br>
    bool is_builtin() const;<br>
<br>
+   /** Whether or not a built-in is available for this shader. */<br>
+   bool is_builtin_available(const _mesa_glsl_parse_state *state) const;<br>
+<br>
    /** Body of instructions in the function. */<br>
    struct exec_list body;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">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>