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

Marek Olšák maraeo at gmail.com
Tue Jan 19 02:58:27 PST 2016


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Jan 19, 2016 at 3:30 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>
> v1 -> v2: use TGSI_MEMBAR defines
> ---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 45 ++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 666b3d8..870991d 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,40 @@ 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(TGSI_MEMBAR_SHADER_BUFFER |
> +                                  TGSI_MEMBAR_ATOMIC_BUFFER |
> +                                  TGSI_MEMBAR_SHADER_IMAGE |
> +                                  TGSI_MEMBAR_SHARED));
> +   else if (!strcmp("__intrinsic_memory_barrier_atomic_counter", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst,
> +               st_src_reg_for_int(TGSI_MEMBAR_ATOMIC_BUFFER));
> +   else if (!strcmp("__intrinsic_memory_barrier_buffer", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst,
> +               st_src_reg_for_int(TGSI_MEMBAR_SHADER_BUFFER));
> +   else if (!strcmp("__intrinsic_memory_barrier_image", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst,
> +               st_src_reg_for_int(TGSI_MEMBAR_SHADER_IMAGE));
> +   else if (!strcmp("__intrinsic_memory_barrier_shared", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst,
> +               st_src_reg_for_int(TGSI_MEMBAR_SHARED));
> +   else if (!strcmp("__intrinsic_group_memory_barrier", callee))
> +      emit_asm(ir, TGSI_OPCODE_MEMBAR, undef_dst,
> +               st_src_reg_for_int(TGSI_MEMBAR_SHADER_BUFFER |
> +                                  TGSI_MEMBAR_ATOMIC_BUFFER |
> +                                  TGSI_MEMBAR_SHADER_IMAGE |
> +                                  TGSI_MEMBAR_SHARED |
> +                                  TGSI_MEMBAR_THREAD_GROUP));
> +   else
> +      assert(!"Unexpected memory barrier intrinsic");
> +}
> +
> +void
>  glsl_to_tgsi_visitor::visit(ir_call *ir)
>  {
>     glsl_to_tgsi_instruction *call_inst;
> @@ -3329,6 +3364,16 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
>        return;
>     }
>
> +   if (!strcmp("__intrinsic_memory_barrier", callee) ||
> +       !strcmp("__intrinsic_memory_barrier_atomic_counter", callee) ||
> +       !strcmp("__intrinsic_memory_barrier_buffer", callee) ||
> +       !strcmp("__intrinsic_memory_barrier_image", callee) ||
> +       !strcmp("__intrinsic_memory_barrier_shared", callee) ||
> +       !strcmp("__intrinsic_group_memory_barrier", callee)) {
> +      visit_membar_intrinsic(ir);
> +      return;
> +   }
> +
>     entry = get_function_signature(sig);
>     /* Process in parameters. */
>     foreach_two_lists(formal_node, &sig->parameters,
> --
> 2.4.10
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list