etnaviv: fix polygon offset for 24bpp depth buffers
Currently we scale the polygon offset units with a fixed factor, matching the MRD (minimal resolvable distance) for a 16bpp depth buffer. This wastes a lot of precision when a 24bpp depth buffer is used. Apply the correct MRD scale, depending on the format of the currently bound depth buffer. Fixes piglit spec@!opengl 1.4@gl-1.4-polygon-offset. 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/32756>
This commit is contained in:
@@ -430,11 +430,14 @@ etna_emit_state(struct etna_context *ctx)
|
||||
/*00C0C*/ EMIT_STATE_FIXP(SE_SCISSOR_BOTTOM, (ctx->clipping.maxy << 16) + ETNA_SE_SCISSOR_MARGIN_BOTTOM);
|
||||
}
|
||||
if (unlikely(dirty & (ETNA_DIRTY_RASTERIZER))) {
|
||||
struct etna_rasterizer_state *rasterizer = etna_rasterizer_state(ctx->rasterizer);
|
||||
/*00C10*/ EMIT_STATE(SE_DEPTH_SCALE, etna_rasterizer_state(ctx->rasterizer)->SE_DEPTH_SCALE);
|
||||
|
||||
/*00C10*/ EMIT_STATE(SE_DEPTH_SCALE, rasterizer->SE_DEPTH_SCALE);
|
||||
/*00C14*/ EMIT_STATE(SE_DEPTH_BIAS, rasterizer->SE_DEPTH_BIAS);
|
||||
/*00C18*/ EMIT_STATE(SE_CONFIG, rasterizer->SE_CONFIG);
|
||||
}
|
||||
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));
|
||||
}
|
||||
if (unlikely(dirty & (ETNA_DIRTY_RASTERIZER))) {
|
||||
/*00C18*/ EMIT_STATE(SE_CONFIG, etna_rasterizer_state(ctx->rasterizer)->SE_CONFIG);
|
||||
}
|
||||
if (unlikely(dirty & (ETNA_DIRTY_SCISSOR_CLIP))) {
|
||||
/*00C20*/ EMIT_STATE_FIXP(SE_CLIP_RIGHT, (ctx->clipping.maxx << 16) + ETNA_SE_CLIP_MARGIN_RIGHT);
|
||||
|
||||
@@ -180,6 +180,7 @@ struct compiled_framebuffer_state {
|
||||
uint32_t PE_DEPTH_STRIDE;
|
||||
uint32_t PE_HDEPTH_CONTROL;
|
||||
uint32_t PE_DEPTH_NORMALIZE;
|
||||
float depth_mrd;
|
||||
struct etna_reloc PE_COLOR_ADDR;
|
||||
struct etna_reloc PE_PIPE_COLOR_ADDR[ETNA_MAX_PIXELPIPES];
|
||||
uint32_t PE_COLOR_STRIDE;
|
||||
|
||||
@@ -54,7 +54,6 @@ etna_rasterizer_state_create(struct pipe_context *pctx,
|
||||
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_DEPTH_BIAS = fui((so->offset_units / 65535.0f) * 2.0f);
|
||||
cs->SE_CONFIG = COND(so->line_last_pixel, VIVS_SE_CONFIG_LAST_PIXEL_ENABLE);
|
||||
/* XXX anything else? */
|
||||
/* XXX bottom_edge_rule */
|
||||
|
||||
@@ -38,7 +38,6 @@ struct etna_rasterizer_state {
|
||||
uint32_t PA_POINT_SIZE;
|
||||
uint32_t PA_SYSTEM_MODE;
|
||||
uint32_t SE_DEPTH_SCALE;
|
||||
uint32_t SE_DEPTH_BIAS;
|
||||
uint32_t SE_CONFIG;
|
||||
bool point_size_per_vertex;
|
||||
bool scissor;
|
||||
|
||||
@@ -352,6 +352,8 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
|
||||
if (depth_bits == 16)
|
||||
target_16bpp = true;
|
||||
|
||||
cs->depth_mrd = util_get_depth_format_mrd(util_format_description(zsbuf->base.format));
|
||||
|
||||
cs->PE_DEPTH_CONFIG =
|
||||
depth_format |
|
||||
COND(depth_supertiled, VIVS_PE_DEPTH_CONFIG_SUPER_TILED) |
|
||||
@@ -397,6 +399,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
|
||||
|
||||
nr_samples_depth = zsbuf->base.texture->nr_samples;
|
||||
} else {
|
||||
cs->depth_mrd = 0.0f;
|
||||
cs->PE_DEPTH_CONFIG = VIVS_PE_DEPTH_CONFIG_DEPTH_MODE_NONE;
|
||||
cs->PE_DEPTH_ADDR.bo = NULL;
|
||||
cs->PE_DEPTH_STRIDE = 0;
|
||||
|
||||
Reference in New Issue
Block a user