Skip to content

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

Open

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).

Activity

  1. kainino0x commented on Jun 5, 2026

    @kainino0x
    Collaborator

    Thanks for the report - when writing the tests we defaulted to being "optimistic" about precision with the intent to increase the threshold it when we found issues on real devices. Would you be willing to look into increasing it to something that either should pass theoretically, or passes on the devices you've tried?

  2. dneto0 commented on Oct 5, 2026

    @dneto0
    Contributor

    +1 thanks for the report.

    Search suggests the Rock 5b SoC has a "Arm Mali-G610 MP4"

  3. fooishbar commented on Oct 7, 2026

    @fooishbar

    Right, that's Mali v10, though it's common to essentially all Mali. We can come up with a list of what to expect across various GPU families that we have in Mesa (which is all of them), though realistically the future-proof baseline would be what Vulkan demands. If DX has more stringent demands, those would be met by most but by no means all GPUs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions