From 6e9e9c9f0c708a73b5d4851265d2e36c4adc8d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 3 Jun 2025 10:17:19 -0400 Subject: [PATCH] nir: add shader_info::prev_stage_has_xfb We will use it to skip lowering mediump IO to 16 bits if the previous shader has XFB and mediump XFB doesn't work. Drivers can decide not to lower mediump IO to 16 bits if nir->xfb_info != NULL for the pre-rast stage and if nir->info.prev_stage_has_xfb is true for the FS stage. That way, drivers can lower mediump to 16 bits for all cases except XFB. Reviewed-by: Timothy Arceri Part-of: --- src/compiler/glsl/gl_nir_linker.c | 9 ++++++++- src/compiler/shader_info.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 16191b81972..35c32db1853 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -1302,8 +1302,15 @@ preprocess_shader(const struct gl_constants *consts, unsigned next_stages = shader_program->data->linked_stages & ~BITFIELD_MASK(prog->info.stage + 1); - if (prev_stages) + if (prev_stages) { nir->info.prev_stage = util_last_bit(prev_stages) - 1; + + if (nir->info.stage == MESA_SHADER_FRAGMENT) { + nir->info.prev_stage_has_xfb = + shader_program->TransformFeedback.NumVarying > 0; + } + } + if (next_stages) nir->info.next_stage = u_bit_scan(&next_stages); } diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index 4dfbb90373d..265b84718fe 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -58,6 +58,9 @@ typedef struct shader_info { /* If the shader is linked, this is the next shader, else MESA_SHADER_NONE. */ gl_shader_stage next_stage:8; + /* Whether the previous stage has XFB if the shader is linked (prev_stage != NONE). */ + bool prev_stage_has_xfb; + /* Number of textures used by this shader */ uint8_t num_textures; /* Number of uniform buffers used by this shader */