[Mesa-dev] [PATCH 5/5] ac/nir: add nir_intrinsic_{load, store}_shared support
Marek Olšák
maraeo at gmail.com
Mon Feb 12 16:44:05 UTC 2018
For the series:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Fri, Feb 9, 2018 at 2:48 AM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> ---
> src/amd/common/ac_nir_to_llvm.c | 46 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
> index db692919ce..c69aaed7ed 100644
> --- a/src/amd/common/ac_nir_to_llvm.c
> +++ b/src/amd/common/ac_nir_to_llvm.c
> @@ -3918,6 +3918,46 @@ visit_load_local_invocation_index(struct nir_to_llvm_context *ctx)
> return LLVMBuildAdd(ctx->builder, result, thread_id, "");
> }
>
> +static LLVMValueRef
> +visit_load_shared(struct ac_nir_context *ctx,
> + const nir_intrinsic_instr *instr)
> +{
> + LLVMValueRef values[4], derived_ptr, index, ret;
> +
> + LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[0]);
> +
> + for (int chan = 0; chan < instr->num_components; chan++) {
> + index = LLVMConstInt(ctx->ac.i32, chan, 0);
> + derived_ptr = LLVMBuildGEP(ctx->ac.builder, ptr, &index, 1, "");
> + values[chan] = LLVMBuildLoad(ctx->ac.builder, derived_ptr, "");
> + }
> +
> + ret = ac_build_gather_values(&ctx->ac, values, instr->num_components);
> + return LLVMBuildBitCast(ctx->ac.builder, ret, get_def_type(ctx, &instr->dest.ssa), "");
> +}
> +
> +static void
> +visit_store_shared(struct ac_nir_context *ctx,
> + const nir_intrinsic_instr *instr)
> +{
> + LLVMValueRef derived_ptr, data,index;
> + LLVMBuilderRef builder = ctx->ac.builder;
> +
> + LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[1]);
> + LLVMValueRef src = get_src(ctx, instr->src[0]);
> +
> + int writemask = nir_intrinsic_write_mask(instr);
> + for (int chan = 0; chan < 4; chan++) {
> + if (!(writemask & (1 << chan))) {
> + continue;
> + }
> + data = ac_llvm_extract_elem(&ctx->ac, src, chan);
> + index = LLVMConstInt(ctx->ac.i32, chan, 0);
> + derived_ptr = LLVMBuildGEP(builder, ptr, &index, 1, "");
> + LLVMBuildStore(builder, data, derived_ptr);
> + }
> +}
> +
> static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx,
> const nir_intrinsic_instr *instr,
> LLVMValueRef ptr)
> @@ -4440,6 +4480,12 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
> case nir_intrinsic_store_var:
> visit_store_var(ctx, instr);
> break;
> + case nir_intrinsic_load_shared:
> + result = visit_load_shared(ctx, instr);
> + break;
> + case nir_intrinsic_store_shared:
> + visit_store_shared(ctx, instr);
> + break;
> case nir_intrinsic_image_load:
> result = visit_image_load(ctx, instr);
> break;
> --
> 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