diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 51bda704a1f..bab5d8faaee 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -486,6 +486,28 @@ ir3_nir_post_finalize(struct ir3_compiler *compiler, nir_shader *s) NIR_PASS_V(s, nir_lower_mediump_io, nir_var_shader_out, 0, false); } + if (s->info.stage == MESA_SHADER_COMPUTE) { + bool progress = false; + NIR_PASS(progress, s, nir_lower_subgroups, &(nir_lower_subgroups_options) { + .subgroup_size = 128, + .ballot_bit_size = 32, + .ballot_components = 4, + .lower_to_scalar = true, + .lower_vote_eq = true, + .lower_subgroup_masks = true, + .lower_read_invocation_to_cond = true, + }); + + progress = false; + NIR_PASS(progress, s, ir3_nir_lower_subgroup_id_cs); + + /* ir3_nir_lower_subgroup_id_cs creates extra compute intrinsics which + * we need to lower again. + */ + if (progress) + NIR_PASS_V(s, nir_lower_compute_system_values, NULL); + } + /* we cannot ensure that ir3_finalize_nir() is only called once, so * we also need to do trig workarounds here: */