intel/compiler: Lower Task/Mesh local_invocation_{id,index}

The Invocation index is provided by the payload, so we can skip the
usual math done to get to it.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13661>
This commit is contained in:
Caio Oliveira 2021-10-29 12:48:54 -07:00 committed by Marge Bot
parent db23c41537
commit 171bdd2ec6
2 changed files with 24 additions and 0 deletions

View File

@ -255,7 +255,23 @@ fs_visitor::nir_emit_task_mesh_intrinsic(const fs_builder &bld,
{
assert(stage == MESA_SHADER_MESH || stage == MESA_SHADER_TASK);
fs_reg dest;
if (nir_intrinsic_infos[instr->intrinsic].has_dest)
dest = get_nir_dest(instr->dest);
switch (instr->intrinsic) {
case nir_intrinsic_load_local_invocation_index:
case nir_intrinsic_load_local_invocation_id:
/* Local_ID.X is given by the HW in the shader payload. */
dest = retype(dest, BRW_REGISTER_TYPE_UD);
bld.MOV(dest, retype(brw_vec8_grf(1, 0), BRW_REGISTER_TYPE_UW));
/* Task/Mesh only use one dimension. */
if (instr->intrinsic == nir_intrinsic_load_local_invocation_id) {
bld.MOV(offset(dest, bld, 1), brw_imm_uw(0));
bld.MOV(offset(dest, bld, 2), brw_imm_uw(0));
}
break;
default:
nir_emit_cs_intrinsic(bld, instr);
break;

View File

@ -68,6 +68,14 @@ lower_cs_intrinsics_convert_block(struct lower_intrinsics_state *state,
case nir_intrinsic_load_local_invocation_index:
case nir_intrinsic_load_local_invocation_id: {
if (nir->info.stage == MESA_SHADER_TASK ||
nir->info.stage == MESA_SHADER_MESH) {
/* Will be lowered by nir_emit_task_mesh_intrinsic() using
* information from the payload.
*/
continue;
}
/* First time we are using those, so let's calculate them. */
if (!local_index) {
assert(!local_id);