On 11 November 2011 02:56, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
When matching function signatures across multiple linked shaders, we<br>
often want to see if the current shader has _any_ match, but also know<br>
whether or not it was exact. (If not, we may want to keep looking.)<br>
<br>
This could be done via the existing mechanisms:<br>
<br>
sig = f->exact_matching_signature(params);<br>
if (sig != NULL) {<br>
exact = true;<br>
} else {<br>
sig = f->matching_signature(params);<br>
exact = false;<br>
}<br>
<br>
However, this requires walking the list of function signatures twice,<br>
which also means walking each signature's formal parameter lists twice.<br>
This could be rather expensive.<br>
<br>
Since matching_signature already internally knows whether a match was<br>
exact or not, we can just return it to get that information for free.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/glsl/ir.h | 7 +++++++<br>
src/glsl/ir_function.cpp | 11 +++++++++++<br>
2 files changed, 18 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/src/glsl/ir.h b/src/glsl/ir.h<br>
index 5878c05..6d40913 100644<br>
--- a/src/glsl/ir.h<br>
+++ b/src/glsl/ir.h<br>
@@ -566,6 +566,13 @@ public:<br>
<br>
/**<br>
* Find a signature that matches a set of actual parameters, taking implicit<br>
+ * conversions into account. Also flags whether the match was exact.<br>
+ */<br>
+ ir_function_signature *matching_signature(const exec_list *actual_param,<br>
+ bool &match_is_exact);<br></blockquote><div><br>Minor quibble: I'd prefer to make match_is_exact a pointer, so that in the caller, it's obvious that the value of match_is_exact is going to be changed.<br>
<br>In any case, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> <br></div></div>