compiler/nir: add a divergence analysis option for non-uniform workgroup id

The V3D hardware allows us to pack multiple workgroups together to avoid
wasting execution lanes in shader cores.

For example, if we dispatch 16 workgroups with a local size of 1 element, we
can pack all 16 workgroups in a single 16-wide dispatch where each lane
executes a different workgroup, instead of 16 1-wide dispatches.

When we do this, we don't have a uniform workgroup id any more.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10541>
This commit is contained in:
Iago Toral Quiroga 2021-04-29 11:10:32 +02:00 committed by Marge Bot
parent caf9fb1a10
commit aebb47b7d1
2 changed files with 6 additions and 1 deletions

View File

@ -3126,6 +3126,7 @@ typedef enum {
nir_divergence_single_patch_per_tes_subgroup = (1 << 2),
nir_divergence_view_index_uniform = (1 << 3),
nir_divergence_single_frag_shading_rate_per_subgroup = (1 << 4),
nir_divergence_multiple_workgroup_per_compute_subgroup = (1 << 5),
} nir_divergence_options;
typedef struct nir_shader_compiler_options {

View File

@ -101,7 +101,6 @@ visit_intrinsic(nir_shader *shader, nir_intrinsic_instr *instr)
case nir_intrinsic_vote_ieq:
case nir_intrinsic_load_push_constant:
case nir_intrinsic_load_work_dim:
case nir_intrinsic_load_work_group_id:
case nir_intrinsic_load_num_work_groups:
case nir_intrinsic_load_local_group_size:
case nir_intrinsic_load_subgroup_id:
@ -233,6 +232,11 @@ visit_intrinsic(nir_shader *shader, nir_intrinsic_instr *instr)
assert(stage == MESA_SHADER_TESS_CTRL);
break;
case nir_intrinsic_load_work_group_id:
assert(stage == MESA_SHADER_COMPUTE);
is_divergent |= (options & nir_divergence_multiple_workgroup_per_compute_subgroup);
break;
/* Clustered reductions are uniform if cluster_size == subgroup_size or
* the source is uniform and the operation is invariant.
* Inclusive scans are uniform if