[Mesa-dev] [PATCH v2 02/11] glsl: Add builtin barrier() function

Kenneth Graunke kenneth at whitecape.org
Mon Apr 27 19:27:45 PDT 2015


On Saturday, April 25, 2015 09:45:51 PM Jordan Justen wrote:
> From: Chris Forbes <chrisf at ijw.co.nz>
> 
> [jordan.l.justen at intel.com: Add CS support]
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> Reviewed-by: Ben Widawsky <ben at bwidawsk.net>
> ---
>  src/glsl/builtin_functions.cpp | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
> index 524b8d6..778470d 100644
> --- a/src/glsl/builtin_functions.cpp
> +++ b/src/glsl/builtin_functions.cpp
> @@ -99,6 +99,18 @@ gs_only(const _mesa_glsl_parse_state *state)
>  }
>  
>  static bool
> +tcs_only(const _mesa_glsl_parse_state *state)
> +{
> +   return false; /* TODO: state->stage == MESA_SHADER_TESS_CTRL; */
> +}
> +
> +static bool
> +cs_only(const _mesa_glsl_parse_state *state)
> +{
> +   return state->stage == MESA_SHADER_COMPUTE;
> +}
> +
> +static bool
>  v110(const _mesa_glsl_parse_state *state)
>  {
>     return !state->es_shader;
> @@ -387,6 +399,12 @@ fp64(const _mesa_glsl_parse_state *state)
>     return state->has_double();
>  }
>  
> +static bool
> +barrier_supported(const _mesa_glsl_parse_state *state)
> +{
> +   return tcs_only(state) || cs_only(state);
> +}
> +

I'd probably drop the cs_only/tcs_only functions unless you're going to
use them as a built-in predicate directly.

Writing this as:

static bool
barrier_supported(const _mesa_glsl_parse_state *state)
{
    return state->stage == MESA_SHADER_COMPUTE;
    /* TODO: || stage->state == MESA_SHADER_TESS_CTRL; */
}

seems simpler to me.

With that change, (or either way I guess),
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150427/31aa3d0e/attachment.sig>


More information about the mesa-dev mailing list