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 <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32922>
This commit is contained in:
Lucas Stach 2025-01-06 22:00:53 +01:00 committed by Marge Bot
parent 2483d28d0b
commit ca5a9a3861

View file

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