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

Paul Berry stereotype441 at gmail.com
Sun Sep 8 08:33:06 PDT 2013


On 4 September 2013 15:22, Kenneth Graunke <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.


>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/glsl/ir.cpp | 11 +++++++++++
>  src/glsl/ir.h   |  3 +++
>  2 files changed, 14 insertions(+)
>
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index d9fb808..e9317f8 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -1596,6 +1596,17 @@ ir_function_signature::is_builtin() const
>  }
>
>
> +bool
> +ir_function_signature::is_builtin_available(const _mesa_glsl_parse_state
> *state) const
> +{
> +   if (state == NULL)
> +      return true;
> +
> +   assert(builtin_info != NULL);
> +   return builtin_info(state);
> +}
> +
> +
>  static bool
>  modes_match(unsigned a, unsigned b)
>  {
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index a927e90..bd1c12c 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -686,6 +686,9 @@ public:
>     /** Whether or not this function signature is a built-in. */
>     bool is_builtin() const;
>
> +   /** Whether or not a built-in is available for this shader. */
> +   bool is_builtin_available(const _mesa_glsl_parse_state *state) const;
> +
>     /** Body of instructions in the function. */
>     struct exec_list body;
>
> --
> 1.8.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130908/906e5647/attachment.html>


More information about the mesa-dev mailing list