etnaviv: Improve flatshading

If the shader has flat varyings but API level flatshade is disabled, we
need to switch to flat shading in PA.CONFIG to ensure proper interpolation.

Passes dEQP-GLES3.functional.rasterization.flatshading.* on GC7000.

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Tested-by: Daniel Lang <dalang@gmx.at>
Reviewed-by: Daniel Lang <dalang@gmx.at>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36404>
This commit is contained in:
Christian Gmeiner 2025-07-26 01:06:36 +02:00 committed by Marge Bot
parent 3e9cbea34e
commit 6ba0797a06

View file

@ -258,6 +258,15 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
}
}
/* if shader has flat varyings, switch to flat shading */
for (int idx = 0; idx < link.num_varyings; ++idx) {
if (link.varyings[idx].semantic == VARYING_INTERPOLATION_MODE_FLAT) {
cs->PA_CONFIG &= ~VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH;
cs->PA_CONFIG |= VIVS_PA_CONFIG_SHADE_MODEL_FLAT;
break;
}
}
cs->GL_VARYING_TOTAL_COMPONENTS =
VIVS_GL_VARYING_TOTAL_COMPONENTS_NUM(align(total_components, 2));
memcpy(cs->GL_VARYING_NUM_COMPONENTS, num_components, sizeof(uint32_t) * 2);