From ca5a9a38612a00c8404a31d7da0b34ac4df9c4eb Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Mon, 6 Jan 2025 22:00:53 +0100 Subject: [PATCH] etnaviv: fix flatshading color varyings must be properly annoted, so they don't get interpolated when the rasterizer is configured for flatshading. For whatever reason the etnaviv NIR compiler failed to do so from its inception. Signed-off-by: Lucas Stach Reviewed-by: Christian Gmeiner Part-of: --- src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index 5ac9653bf97..cff4f07ae91 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -1382,7 +1382,8 @@ etna_link_shader(struct etna_shader_link_info *info, const struct etna_shader_inout *fsio = &fs->infile.reg[idx]; const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio); struct etna_varying *varying; - bool interpolate_always = true; + bool varying_is_color = fsio->slot == VARYING_SLOT_COL0 || + fsio->slot == VARYING_SLOT_COL1; assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings)); @@ -1392,13 +1393,17 @@ etna_link_shader(struct etna_shader_link_info *info, varying = &info->varyings[fsio->reg - 1]; varying->num_components = fsio->num_components; - if (!interpolate_always) /* colors affected by flat shading */ + if (varying_is_color) /* colors affected by flat shading */ varying->pa_attributes = 0x200; else /* texture coord or other bypasses flat shading */ varying->pa_attributes = 0x2f1; - for (int i = 0; i < 4; i++) - varying->use[i] = VARYING_COMPONENT_USE_GENERIC; + for (int i = 0; i < 4; i++) { + if (varying_is_color) + varying->use[i] = VARYING_COMPONENT_USE_COLOR; + else + varying->use[i] = VARYING_COMPONENT_USE_GENERIC; + } /* point/tex coord is an input to the PS without matching VS output, * so it gets a varying slot without being assigned a VS register.