From 878924854196c4a1eb178df198770029937bfa90 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 12 Jul 2019 15:57:54 +0200 Subject: [PATCH] radeonsi: add support for tgsi ATOMDEC_WRAP / ATOMINC_WRAP opcodes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- .../drivers/radeonsi/si_shader_tgsi_mem.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index 6fca1d86847..4a4ba43780a 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -827,6 +827,19 @@ static void atomic_emit( args.data[num_data++] = ac_to_integer(&ctx->ac, lp_build_emit_fetch(bld_base, inst, 2, 0)); + + if (inst->Instruction.Opcode == TGSI_OPCODE_ATOMINC_WRAP) { + /* ATOMIC_INC instruction does: + * value = (value + 1) % (data + 1) + * but we want: + * value = (value + 1) % data + * So replace 'data' by 'data - 1'. + */ + args.data[0] = LLVMBuildSub(ctx->ac.builder, + args.data[0], + ctx->ac.i32_1, ""); + } + args.cache_policy = get_cache_policy(ctx, inst, true, false, false); if (inst->Src[0].Register.File == TGSI_FILE_BUFFER) { @@ -902,6 +915,12 @@ static void atomic_emit( case TGSI_OPCODE_ATOMUMAX: args.atomic = ac_atomic_umax; break; case TGSI_OPCODE_ATOMIMIN: args.atomic = ac_atomic_smin; break; case TGSI_OPCODE_ATOMIMAX: args.atomic = ac_atomic_smax; break; + case TGSI_OPCODE_ATOMINC_WRAP: + args.atomic = ac_atomic_inc_wrap; + break; + case TGSI_OPCODE_ATOMDEC_WRAP: + args.atomic = ac_atomic_dec_wrap; + break; default: unreachable("unhandled image atomic"); } } @@ -1821,4 +1840,8 @@ void si_shader_context_init_mem(struct si_shader_context *ctx) bld_base->op_actions[TGSI_OPCODE_ATOMIMIN].intr_name = "smin"; bld_base->op_actions[TGSI_OPCODE_ATOMIMAX].emit = atomic_emit; bld_base->op_actions[TGSI_OPCODE_ATOMIMAX].intr_name = "smax"; + bld_base->op_actions[TGSI_OPCODE_ATOMINC_WRAP].emit = atomic_emit; + bld_base->op_actions[TGSI_OPCODE_ATOMINC_WRAP].intr_name = "inc"; + bld_base->op_actions[TGSI_OPCODE_ATOMDEC_WRAP].emit = atomic_emit; + bld_base->op_actions[TGSI_OPCODE_ATOMDEC_WRAP].intr_name = "dec"; } -- 2.30.2