[Mesa-dev] [PATCH 04/21] glsl: Add a method to tell whether a built-in is available.

Kenneth Graunke kenneth at whitecape.org
Sun Sep 8 22:12:41 PDT 2013


On 09/08/2013 08:33 AM, Paul Berry wrote:
> On 4 September 2013 15:22, Kenneth Graunke <kenneth at whitecape.org
> <mailto:kenneth at whitecape.org>> wrote:
>
>     We can simply call the stored predicate function.
>
>     In the case where we don't have a _mesa_glsl_parse_state pointer, it
>     doesn't much matter whether we return true or false.
>
>
> 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.
>
> 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.

Returning true (not filtering out anything) is definitely safest.  I 
never actually tried returning false, so I actually don't know if it 
works or not.

I've added the following comment:

/* We can't call the predicate without a state pointer, so just say that
  * the signature is available.  Code that needs this filtering passes a
  * valid state pointer; later code can safely skip the filtering.
  */

--Ken


More information about the mesa-dev mailing list