diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-07-12 15:57:54 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-08-06 17:41:04 -0400 |
commit | 878924854196c4a1eb178df198770029937bfa90 (patch) | |
tree | 064acd7b8050700e06236090b5e9b8631169a6e8 /src/gallium | |
parent | 704a6b594877fee52aea5ddd3dbdb7356f74f759 (diff) |
radeonsi: add support for tgsi ATOMDEC_WRAP / ATOMINC_WRAP opcodes
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 23 |
1 files changed, 23 insertions, 0 deletions
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"; } |