llvmpipe: clamp z to 0..1 range when using polygon offset
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 18 Aug 2021 09:00:33 +0000 (11:00 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 24 Aug 2021 07:36:31 +0000 (07:36 +0000)
commit856533366928300bbad8949675b1c165ccb39605
tree51640db719ff91b7c78ebe633bbb255663a6c12c
parent63138c42c5631ecf5d3c8eb3e39e33cac91df4f1
llvmpipe: clamp z to 0..1 range when using polygon offset

The OpenGL 4.6 compatibility spec, section 14.6.5 (Depth Offset) says
the following:

> For fixed-point depth buffers, fragment depth values are always
> limited to the range [0,1] by clamping after offset addition is
> performed. Fragment depth values are clamped even when the depth
> buffer uses a floating-point representation.

So we need to properly clamp the result here.

This fixes the following dEQP failures, that the CI has missed:

- dEQP-GLES3.functional.polygon_offset.default_result_depth_clamp
- dEQP-GLES3.functional.polygon_offset.default_factor_1_slope
- dEQP-GLES3.functional.polygon_offset.fixed24_result_depth_clamp
- dEQP-GLES3.functional.polygon_offset.fixed24_factor_1_slope

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12442>
src/gallium/drivers/llvmpipe/lp_bld_interp.c