llvmpipe: Improve depth bias rounding workaround

Multiplying by 2 is too conservative to pass depth bias control CTS.

Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26282>
This commit is contained in:
Konstantin Seurer 2023-11-19 22:05:35 +01:00 committed by Marge Bot
parent 84f581c659
commit b30bebf38e

View file

@ -797,11 +797,17 @@ lp_make_setup_variant_key(const struct llvmpipe_context *lp,
*/
key->floating_point_depth = lp->floating_point_depth && !lp->rasterizer->offset_units_unscaled;
if (lp->floating_point_depth || lp->rasterizer->offset_units_unscaled) {
key->pgon_offset_units = (float) lp->rasterizer->offset_units;
} else {
key->pgon_offset_units = (float) lp->rasterizer->offset_units;
if (lp->rasterizer->offset_units != 0 && !lp->floating_point_depth &&
!lp->rasterizer->offset_units_unscaled) {
/* Ensure correct rounding if a unorm format is used. */
float adjustment =
lp->floating_point_depth
? 0
: (lp->rasterizer->offset_units > 0 ? 0.5 : -0.5);
key->pgon_offset_units =
(float) (lp->rasterizer->offset_units * lp->mrd * 2);
(float) ((lp->rasterizer->offset_units + adjustment) * lp->mrd);
}
key->pgon_offset_scale = lp->rasterizer->offset_scale;