ir3: add helper to get the subgroup size

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31731>
This commit is contained in:
Job Noorman 2024-11-29 17:09:16 +01:00 committed by Marge Bot
parent 2e2a36ddb0
commit 0be9ff47b4
3 changed files with 37 additions and 22 deletions

View file

@ -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,

View file

@ -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.
*/

View file

@ -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:
*/