[Mesa-dev] [PATCH] ac/nir: add support for all intrinsics. (v2)

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Thu Nov 9 01:19:37 UTC 2017


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Thu, Nov 9, 2017 at 2:12 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This is derived from tgsi/radeonsi code from the GLSL intrinsics.
>
> This should pre-fix radv for the upcoming spirv patches.
>
> v2: actually use wait_cnt, sleep deprived dad time! (Bas)
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/amd/common/ac_nir_to_llvm.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index 2ae656693fc..f922b32bf7b 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3654,6 +3654,31 @@ static void emit_waitcnt(struct nir_to_llvm_context *ctx,
>                            ctx->ac.voidt, args, 1, 0);
>  }
>
> +static void emit_membar(struct nir_to_llvm_context *ctx,
> +                       const nir_intrinsic_instr *instr)
> +{
> +       unsigned waitcnt = NOOP_WAITCNT;
> +
> +       switch (instr->intrinsic) {
> +       case nir_intrinsic_memory_barrier:
> +       case nir_intrinsic_group_memory_barrier:
> +               waitcnt &= VM_CNT & LGKM_CNT;
> +               break;
> +       case nir_intrinsic_memory_barrier_atomic_counter:
> +       case nir_intrinsic_memory_barrier_buffer:
> +       case nir_intrinsic_memory_barrier_image:
> +               waitcnt &= VM_CNT;
> +               break;
> +       case nir_intrinsic_memory_barrier_shared:
> +               waitcnt &= LGKM_CNT;
> +               break;
> +       default:
> +               break;
> +       }
> +       if (waitcnt != NOOP_WAITCNT)
> +               emit_waitcnt(ctx, waitcnt);
> +}
> +
>  static void emit_barrier(struct nir_to_llvm_context *ctx)
>  {
>         /* SI only (thanks to a hw bug workaround):
> @@ -4144,7 +4169,12 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
>                 emit_discard_if(ctx, instr);
>                 break;
>         case nir_intrinsic_memory_barrier:
> -               emit_waitcnt(ctx->nctx, VM_CNT);
> +       case nir_intrinsic_group_memory_barrier:
> +       case nir_intrinsic_memory_barrier_atomic_counter:
> +       case nir_intrinsic_memory_barrier_buffer:
> +       case nir_intrinsic_memory_barrier_image:
> +       case nir_intrinsic_memory_barrier_shared:
> +               emit_membar(ctx->nctx, instr);
>                 break;
>         case nir_intrinsic_barrier:
>                 emit_barrier(ctx->nctx);
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list