[Mesa-dev] [PATCH 07/10] st/mesa: add support for memory barrier intrinsics

Marek Olšák maraeo at gmail.com
Mon Jan 18 04:31:48 PST 2016


On Mon, Jan 18, 2016 at 6:51 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 32 ++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 602e689..bb519aa 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -451,6 +451,7 @@ public:
>
>     void visit_atomic_counter_intrinsic(ir_call *);
>     void visit_ssbo_intrinsic(ir_call *);
> +   void visit_membar_intrinsic(ir_call *);
>
>     st_src_reg result;
>
> @@ -3299,6 +3300,27 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir)
>  }
>
>  void
> +glsl_to_tgsi_visitor::visit_membar_intrinsic(ir_call *ir)
> +{
> +   const char *callee = ir->callee->function_name();
> +
> +   if (!strcmp("__intrinsic_memory_barrier", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x0f));
> +   else if (!strcmp("__intrinsic_memory_barrier_atomic_counter", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x02));
> +   else if (!strcmp("__intrinsic_memory_barrier_buffer", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x01));
> +   else if (!strcmp("__intrinsic_memory_barrier_image", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x04));
> +   else if (!strcmp("__intrinsic_memory_barrier_shared", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x08));
> +   else if (!strcmp("__intrinsic_group_memory_barrier", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst, st_src_reg_for_int(0x1f));

Can we not use magic numbers here please?

Marek


More information about the mesa-dev mailing list