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) {
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");
}
}
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";
}