v3d,v3dv: fix depth bias for v3d 7.x

In v3d 7.x we don't need to scale up depth bias for D16 buffers.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25450>
This commit is contained in:
Iago Toral Quiroga 2023-02-08 09:04:02 +01:00 committed by Marge Bot
parent cd8afef9f1
commit 8a69888803
3 changed files with 7 additions and 2 deletions

View file

@ -1499,8 +1499,10 @@ v3dX(cmd_buffer_emit_depth_bias)(struct v3dv_cmd_buffer *cmd_buffer)
cl_emit(&job->bcl, DEPTH_OFFSET, bias) {
bias.depth_offset_factor = dynamic->depth_bias.slope_factor;
bias.depth_offset_units = dynamic->depth_bias.constant_factor;
#if V3D_VERSION <= 42
if (pipeline->depth_bias.is_z16)
bias.depth_offset_units *= 256.0f;
#endif
bias.limit = dynamic->depth_bias.depth_bias_clamp;
}

View file

@ -559,7 +559,8 @@ v3dX(emit_state)(struct pipe_context *pctx)
if (v3d->dirty & V3D_DIRTY_RASTERIZER &&
v3d->rasterizer->base.offset_tri) {
if (job->zsbuf &&
if (v3d->screen->devinfo.ver <= 42 &&
job->zsbuf &&
job->zsbuf->format == PIPE_FORMAT_Z16_UNORM) {
cl_emit_prepacked_sized(&job->bcl,
v3d->rasterizer->depth_offset_z16,

View file

@ -111,9 +111,10 @@ v3d_create_rasterizer_state(struct pipe_context *pctx,
#endif
}
/* The HW treats polygon offset units based on a Z24 buffer, so we
/* V3d 4.x treats polygon offset units based on a Z24 buffer, so we
* need to scale up offset_units if we're only Z16.
*/
#if V3D_VERSION <= 42
v3dx_pack(&so->depth_offset_z16, DEPTH_OFFSET, depth) {
depth.depth_offset_factor = cso->offset_scale;
depth.depth_offset_units = cso->offset_units * 256.0;
@ -121,6 +122,7 @@ v3d_create_rasterizer_state(struct pipe_context *pctx,
depth.limit = cso->offset_clamp;
#endif
}
#endif
return so;
}