Skip to content

api,operation,rendering,3d_texture_slices createShaderModule does not account for lower subPixelPrecisionBits values #4638

@MareSorin-Alexandru

Description

@MareSorin-Alexandru

The multiple_color_attachments,same_slice_with_diff_mip_levels draws a triangle over a 1 pixel area. This triangle defined in createShaderModule is not large enough to be drawn with certainty in the case that the implementations uses a lower subPixelPrecisionBits value.

        // Triangle is slightly extended so its edge doesn't cut through pixel centers.
        vec2f(-1.0, 1.01),
        vec2f(1.01, -1.0),
        vec2f(-1.0, -1.0),

Specifically for my device where only 6 bits are used for precision, the middle edge of that triangle functionally passes through the pixel center and according to the WebGPU spec, whether it is then drawn is not defined

23.2.5.4. Polygon Rasterization, 5 [...]

disabled
Fragments are associated with pixel centers. That is, all the points with coordinates C, where fract(C) = vector2(0.5, 0.5) in the framebuffer space, enclosed into the polygon, are included. If a pixel center is on the edge of the polygon, whether or not it’s included is not defined.

Note: this becomes a subject of precision for the rasterizer.

A fix would be to extend the triangle corners a bit further to 1.03, 1.03 instead of 1.01, 1.01 as this larger distance from the pixel center would get picked up by the lower-precision implementations.

for 1.01, 1.01, the distance of the line from the pixel center is ~0.007 which is smaller than 1/64 ~=0.015 (6b precision)
for 1.03, 1.03, the distance of the line from the pixel center is ~0.021 which is big enought be distinguished from the pixel center with 6b precision
for 1.09, 1.09, the distance will be big enough to be picked up by implementations using 4 bits for precision: distance ~=0.063 > 1/16 (0.0625)

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