Skip to content

panfrost: fix polygon offset calculation for floating point Z

Eric Smith requested to merge ericsmith/mesa:ericsmith/panfrost-polyoffset into main
panfrost: fix polygon offset calculation for floating point Z

For fixed point Z the offset_units passed to glPolygonOffset
must be scaled by 2, and we do that. However, this scaling is not
needed for floating point output, and actually produces incorrect Z
values. The detailed description of the depth offset is in
e.g. section 13.7.2 of the OpenGL ES 3.2 spec. Note that equation (13.11)
has no factor of 2. That factor is what we get as the minimum
resolvable difference in a 24 bit fixed point format.

After this patch the output Z for a 32 bit floating point depth
buffer exactly match what the software renderer produces, and are extremely
close (off by 1 ULP) to the amdgpu hardware renderer; before the
patch they were significantly different.

Signed-off-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Edited by Eric Smith

Merge request reports