etnaviv: fix polygon offset disable

If a polygon offset is set via glPolygonOffset, but the functionality
isn't enabled via glEnable(GL_POLYGON_OFFSET_FILL) the offset must not
be taken into account when computing the sample depth. As the Vivante
hardware does not have a separate enable state, the offset units and
scale must both be set to 0 to keep the sample depth unchanged.

Fixes dEQP-GLES2.functional.polygon_offset.default_enable

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/32982>
This commit is contained in:
Lucas Stach 2025-01-10 20:54:10 +01:00 committed by Marge Bot
parent 20b806284a
commit bed748d5f6
3 changed files with 10 additions and 2 deletions

View file

@ -436,7 +436,7 @@ etna_emit_state(struct etna_context *ctx)
}
if (unlikely(dirty & (ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_FRAMEBUFFER))) {
/*00C14*/ EMIT_STATE(SE_DEPTH_BIAS, fui(ctx->rasterizer->offset_units * 2.0f * ctx->framebuffer.depth_mrd));
/*00C14*/ EMIT_STATE(SE_DEPTH_BIAS, fui(etna_rasterizer_state(ctx->rasterizer)->offset_units * ctx->framebuffer.depth_mrd));
}
if (unlikely(dirty & (ETNA_DIRTY_RASTERIZER))) {
/*00C18*/ EMIT_STATE(SE_CONFIG, etna_rasterizer_state(ctx->rasterizer)->SE_CONFIG);

View file

@ -53,7 +53,6 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
COND(VIV_FEATURE(ctx->screen, ETNA_FEATURE_WIDE_LINE), VIVS_PA_CONFIG_WIDE_LINE);
cs->PA_LINE_WIDTH = fui(so->line_width / 2.0f);
cs->PA_POINT_SIZE = fui(so->point_size / 2.0f);
cs->SE_DEPTH_SCALE = fui(so->offset_scale);
cs->SE_CONFIG = COND(so->line_last_pixel, VIVS_SE_CONFIG_LAST_PIXEL_ENABLE);
/* XXX anything else? */
/* XXX bottom_edge_rule */
@ -68,6 +67,14 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
/* point size per vertex adds a vertex shader output */
cs->point_size_per_vertex = so->point_size_per_vertex;
if (so->offset_tri || so->offset_line || so->offset_point) {
cs->SE_DEPTH_SCALE = fui(so->offset_scale);
cs->offset_units = so->offset_units * 2.0f;
} else {
cs->SE_DEPTH_SCALE = fui(0.0f);
cs->offset_units = 0.0f;
}
assert(!so->clip_halfz); /* could be supported with shader magic, actually
D3D z is default on older gc */

View file

@ -38,6 +38,7 @@ struct etna_rasterizer_state {
uint32_t PA_POINT_SIZE;
uint32_t PA_SYSTEM_MODE;
uint32_t SE_DEPTH_SCALE;
float offset_units;
uint32_t SE_CONFIG;
bool point_size_per_vertex;
bool scissor;