diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 4afc86bf69d..9db831ad509 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -816,28 +816,8 @@ ir3_nir_post_finalize(struct ir3_shader *shader) * the "real" subgroup size. */ unsigned subgroup_size = 0, max_subgroup_size = 0; - switch (shader->options.api_wavesize) { - case IR3_SINGLE_ONLY: - subgroup_size = max_subgroup_size = compiler->threadsize_base; - break; - case IR3_DOUBLE_ONLY: - subgroup_size = max_subgroup_size = compiler->threadsize_base * 2; - break; - case IR3_SINGLE_OR_DOUBLE: - /* For vertex stages, we know the wavesize will never be doubled. - * Lower subgroup_size here, to avoid having to deal with it when - * translating from NIR. Otherwise use the "real" wavesize obtained as - * a driver param. - */ - if (s->info.stage != MESA_SHADER_COMPUTE && - s->info.stage != MESA_SHADER_FRAGMENT) { - subgroup_size = max_subgroup_size = compiler->threadsize_base; - } else { - subgroup_size = 0; - max_subgroup_size = compiler->threadsize_base * 2; - } - break; - } + ir3_shader_get_subgroup_size(compiler, &shader->options, s->info.stage, + &subgroup_size, &max_subgroup_size); nir_lower_subgroups_options options = { .subgroup_size = subgroup_size, diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index b2f94b9daee..c3d5ede4160 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -990,6 +990,35 @@ ir3_shader_outputs(const struct ir3_shader *so) return so->nir->info.outputs_written; } +void +ir3_shader_get_subgroup_size(const struct ir3_compiler *compiler, + const struct ir3_shader_options *options, + gl_shader_stage stage, unsigned *subgroup_size, + unsigned *max_subgroup_size) +{ + switch (options->api_wavesize) { + case IR3_SINGLE_ONLY: + *subgroup_size = *max_subgroup_size = compiler->threadsize_base; + break; + case IR3_DOUBLE_ONLY: + *subgroup_size = *max_subgroup_size = compiler->threadsize_base * 2; + break; + case IR3_SINGLE_OR_DOUBLE: + /* For vertex stages, we know the wavesize will never be doubled. + * Lower subgroup_size here, to avoid having to deal with it when + * translating from NIR. Otherwise use the "real" wavesize obtained as + * a driver param. + */ + if (stage != MESA_SHADER_COMPUTE && stage != MESA_SHADER_FRAGMENT) { + *subgroup_size = *max_subgroup_size = compiler->threadsize_base; + } else { + *subgroup_size = 0; + *max_subgroup_size = compiler->threadsize_base * 2; + } + break; + } +} + /* Add any missing varyings needed for stream-out. Otherwise varyings not * used by fragment shader will be stripped out. */ diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index 8dd69b7113f..d61043ce26c 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -1075,6 +1075,12 @@ uint64_t ir3_shader_outputs(const struct ir3_shader *so); int ir3_glsl_type_size(const struct glsl_type *type, bool bindless); +void ir3_shader_get_subgroup_size(const struct ir3_compiler *compiler, + const struct ir3_shader_options *options, + gl_shader_stage stage, + unsigned *subgroup_size, + unsigned *max_subgroup_size); + /* * Helper/util: */