Skip to content

shader/execution/shader_io/fragment_builtins expects more interpolation precision than specs guarantee #4657

@totalspectrum

Description

@totalspectrum

In the test for perspective interpolation of gl_FragCoord.w only 4 ULP of error is allowed. However, both the Vulkan and OpenGL ES specs only require precision to 1 part in 10^5, and Direct X specifies that:

Post-clipped vertex positions in the rasterizer are snapped to fixed point, to uniformly distribute precision across the RenderTarget area. Many rasterizer operations, including face culling as one example, occur on fixed point snapped positions, while other operations, such as attribute interpolator setup, use positions that have been converted back to floating point from the fixed point snapped positions.

(Direct 3D 11.3 Functional Specification, section 3.2.4 "Fixed Point Integers")

This means that in practice the interpolated and perspective corrected W coordinate may have less than 4 ULP of precision compared to an ideal 32 bit floating point interpolation. It appears that many desktop GPUs do pass the current tests, but lower powered GPUs on phones and embedded systems may not (and indeed I've observed this errors of up to 14 ULP on a Rock 5b SoC).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions