radv,aco: add support for packed threadID VGPRs on GFX11

Thread ID are packed in one VGPR with 10 bits each.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16369>
This commit is contained in:
Samuel Pitoiset
2022-05-04 21:35:58 +02:00
committed by Marge Bot
parent 52952f51cd
commit 432cde7f00
2 changed files with 19 additions and 2 deletions

View File

@@ -8178,7 +8178,21 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* instr)
} }
case nir_intrinsic_load_local_invocation_id: { case nir_intrinsic_load_local_invocation_id: {
Temp dst = get_ssa_temp(ctx, &instr->dest.ssa); Temp dst = get_ssa_temp(ctx, &instr->dest.ssa);
bld.copy(Definition(dst), Operand(get_arg(ctx, ctx->args->ac.local_invocation_ids))); if (ctx->options->chip_class >= GFX11) {
Temp local_ids[3];
/* Thread IDs are packed in VGPR0, 10 bits per component. */
for (uint32_t i = 0; i < 3; i++) {
local_ids[i] = bld.vop3(aco_opcode::v_bfe_u32, bld.def(v1),
get_arg(ctx, ctx->args->ac.local_invocation_ids),
Operand::c32(i * 10u), Operand::c32(10u));
}
bld.pseudo(aco_opcode::p_create_vector, Definition(dst), local_ids[0], local_ids[1],
local_ids[2]);
} else {
bld.copy(Definition(dst), Operand(get_arg(ctx, ctx->args->ac.local_invocation_ids)));
}
emit_split_vector(ctx, dst, 3); emit_split_vector(ctx, dst, 3);
break; break;
} }

View File

@@ -597,7 +597,10 @@ radv_declare_shader_args(enum chip_class chip_class, const struct radv_pipeline_
ac_add_arg(&args->ac, AC_ARG_SGPR, 1, AC_ARG_INT, &args->ac.scratch_offset); ac_add_arg(&args->ac, AC_ARG_SGPR, 1, AC_ARG_INT, &args->ac.scratch_offset);
} }
ac_add_arg(&args->ac, AC_ARG_VGPR, 3, AC_ARG_INT, &args->ac.local_invocation_ids); if (chip_class >= GFX11)
ac_add_arg(&args->ac, AC_ARG_VGPR, 1, AC_ARG_INT, &args->ac.local_invocation_ids);
else
ac_add_arg(&args->ac, AC_ARG_VGPR, 3, AC_ARG_INT, &args->ac.local_invocation_ids);
break; break;
case MESA_SHADER_VERTEX: case MESA_SHADER_VERTEX:
/* NGG is handled by the GS case */ /* NGG is handled by the GS case */