Skip to content

Add depth-z-transformation-precision-check

Tests that gl_FragCoord.z is equal to 0.5f after viewport transformation from gl_Position.z = -0.00000001
gl_FragCoord.z = 0.5f is always result of transformation from gl_Position.z equal to 0.0f with default gl settings

By glspec (13.8.1) z transformation is performed by the next statement: gl_FragCoord.z = (f−n)/2*(z/w)+(n+f)/2 where n and f is a far and near depth range values of viewport

By default for gl near value is 0.0 and far value is 1.0

The IEEE 754 float point standard default behavior for z transformation with gl_Position.z = -0.00000001 is a rounded value of gl_FragCoord.z = 0.5f

CPU and almost all GPUs behavor for such transormation from gl_Position.z = -0.00000001 to gl_FragCoord.z transormation will give us a value = 0.5f

Games with LEQUAL depth function might fails depth test on GPUs with different transformation rounding behavior
Check this issue for details:
mesa!18412 (merged)

This test compares internal 32 bit float point depth buffer values instead of directly extracted gl_FragCoord.z with SSBO buffers to be able to run it
with older gl versions

Edited by Illia Polishchuk

Merge request reports