zink: Fix depth.
Fixes some depth related test failures listed here: #6243 (closed)
Details of the problem:
-
Vulkan spec chapter 28.10.1. Depth Clamping and Range Adjustment says that the driver should ignore
minDepth
/maxDepth
whendepthClampEnable == false
. Zink mixes up depth clipping and depth clamping. It doesn't always enable depth clamping which means that the depth range in the viewport was not actually respected. - Also, when
gl_FragmentDepth
is not in the[0; 1]
range anddepthClampEnable == false
then the depth value is undefined according to the VK spec. Some of the failing tests hit this undefined behaviour here. - Note that the undefined behaviour allows the Vulkan driver to clamp the depth to
[0; 1]
(and some drivers do), which make it appear as if Zink were working properly. However, if there were any OpenGL tests which set a different depth range than[0; 1]
usingglDepthRange
then these would still fail.
The solution I propose here is this:
- Set
depthClampEnable
to alwaystrue
in Zink, to ensure the Vulkan driver always respects the viewportminDepth
/maxDepth
settings. - Make depth clipping independent of depth clamping, use
VK_EXT_depth_clip_enable
for depth clipping. - Finally, there is also a fix to the Gallium blitter to make sure that the viewport transform it sets doesn't disturb the depth range. (Previously,
maxDepth
was0.0
in some blits, which was again at the mercy of Vulkan undefined behaviour and would be borken now that depth clamping is always enabled.)