nir: add shader_info::prev_stage

When lowering mediump to 16 bits, this will allow drivers to enable
the lowering only for certain pairs of stages, e.g. a driver can lower
mediump for VS->FS, but not GS->FS.

This could also be useful for other things.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35315>
This commit is contained in:
Marek Olšák 2025-06-01 19:06:32 -04:00 committed by Marge Bot
parent 3649f28771
commit aba7b0831c
3 changed files with 9 additions and 5 deletions

View file

@ -216,9 +216,10 @@ nir_shader_create(void *mem_ctx,
} else {
shader->info.stage = stage;
/* Assume there is no known next stage, this is the case for
* nir_builder_init_simple_shaders for example.
/* Assume there is no known prev/next stage, this is the case for
* nir_builder_init_simple_shader for example.
*/
shader->info.prev_stage = MESA_SHADER_NONE;
shader->info.next_stage = MESA_SHADER_NONE;
}

View file

@ -2623,6 +2623,8 @@ print_shader_info(const struct shader_info *info, FILE *fp)
info->workgroup_size_variable ? " (variable)" : "");
}
if (info->prev_stage != MESA_SHADER_NONE)
fprintf(fp, "prev_stage: %s\n", gl_shader_stage_name(info->prev_stage));
if (info->next_stage != MESA_SHADER_NONE)
fprintf(fp, "next_stage: %s\n", gl_shader_stage_name(info->next_stage));

View file

@ -52,9 +52,10 @@ typedef struct shader_info {
/** The shader stage, such as MESA_SHADER_VERTEX. */
gl_shader_stage stage:8;
/** The shader stage in a non SSO linked program that follows this stage,
* such as MESA_SHADER_FRAGMENT.
*/
/* If the shader is linked, this is the previous shader, else MESA_SHADER_NONE. */
gl_shader_stage prev_stage:8;
/* If the shader is linked, this is the next shader, else MESA_SHADER_NONE. */
gl_shader_stage next_stage:8;
/* Number of textures used by this shader */