[Mesa-dev] [PATCH 1/3] glsl: Add a new matching_signature() variant that returns exact/inexact.

Kenneth Graunke kenneth at whitecape.org
Mon Nov 14 17:22:49 PST 2011


On 11/14/2011 10:20 AM, Paul Berry wrote:
> On 11 November 2011 02:56, Kenneth Graunke <kenneth at whitecape.org
> <mailto:kenneth at whitecape.org>> wrote:
> 
>     When matching function signatures across multiple linked shaders, we
>     often want to see if the current shader has _any_ match, but also know
>     whether or not it was exact.  (If not, we may want to keep looking.)
> 
>     This could be done via the existing mechanisms:
> 
>       sig = f->exact_matching_signature(params);
>       if (sig != NULL) {
>          exact = true;
>       } else {
>          sig = f->matching_signature(params);
>          exact = false;
>       }
> 
>     However, this requires walking the list of function signatures twice,
>     which also means walking each signature's formal parameter lists twice.
>     This could be rather expensive.
> 
>     Since matching_signature already internally knows whether a match was
>     exact or not, we can just return it to get that information for free.
> 
>     Signed-off-by: Kenneth Graunke <kenneth at whitecape.org
>     <mailto:kenneth at whitecape.org>>
>     ---
>      src/glsl/ir.h            |    7 +++++++
>      src/glsl/ir_function.cpp |   11 +++++++++++
>      2 files changed, 18 insertions(+), 0 deletions(-)
> 
>     diff --git a/src/glsl/ir.h b/src/glsl/ir.h
>     index 5878c05..6d40913 100644
>     --- a/src/glsl/ir.h
>     +++ b/src/glsl/ir.h
>     @@ -566,6 +566,13 @@ public:
> 
>        /**
>         * Find a signature that matches a set of actual parameters,
>     taking implicit
>     +    * conversions into account.  Also flags whether the match was
>     exact.
>     +    */
>     +   ir_function_signature *matching_signature(const exec_list
>     *actual_param,
>     +                                            bool &match_is_exact);
> 
> 
> 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.

Hah.  I was thinking about doing that, but decided to use
pass-by-reference since it's "the C++ way".  I agree that using a
pointer is clearer, and so does Chad, and I'm pretty sure Eric would to.

So I changed that, re-ran piglit, and pushed this mini-series.  Thanks
for the review.

> In any case, this patch is:
> 
> Reviewed-by: Paul Berry <stereotype441 at gmail.com
> <mailto:stereotype441 at gmail.com>>


More information about the mesa-dev mailing list