On Tue, 2015-11-17 at 21:55 -0800, Jordan Justen wrote:
> When an atomic function is called, we need to check to see if it is
> for an SSBO variable before lowering it to the SSBO specific intrinsic
> function.
> 
> v2:
>  * is_in_buffer_block => is_in_shader_storage_block (Iago)
> 
> Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com>
> Cc: Samuel Iglesias Gonsalvez <sigles...@igalia.com>
> Cc: Iago Toral Quiroga <ito...@igalia.com>
> Reviewed-by: Iago Toral Quiroga <ito...@igalia.com>
> ---
>  src/glsl/lower_ubo_reference.cpp | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/glsl/lower_ubo_reference.cpp 
> b/src/glsl/lower_ubo_reference.cpp
> index 915db6c..667a80e 100644
> --- a/src/glsl/lower_ubo_reference.cpp
> +++ b/src/glsl/lower_ubo_reference.cpp
> @@ -862,6 +862,20 @@ 
> lower_ubo_reference_visitor::lower_ssbo_atomic_intrinsic(ir_call *ir)
>  ir_call *
>  lower_ubo_reference_visitor::check_for_ssbo_atomic_intrinsic(ir_call *ir)
>  {
> +   exec_list& params = ir->actual_parameters;
> +
> +   if (params.length() < 2)
> +      return ir;

It is not very relevant but if we really want to return early if the
number of parameters does not match any of the atomic functions then we
should also check if they are > 3.

Either way:
Reviewed-by: Iago Toral Quiroga <ito...@igalia.com>

> +   ir_rvalue *rvalue =
> +      ((ir_instruction *) params.get_head())->as_rvalue();
> +   if (!rvalue)
> +      return ir;
> +
> +   ir_variable *var = rvalue->variable_referenced();
> +   if (!var || !var->is_in_shader_storage_block())
> +      return ir;
> +
>     const char *callee = ir->callee_name();
>     if (!strcmp("__intrinsic_atomic_add", callee) ||
>         !strcmp("__intrinsic_atomic_min", callee) ||


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to