Skip to content

wrong 32 bit float precision error #7

Open
@danilw

Description

shader code:

#version 450

layout (location = 0) out uvec4 outColor;

void main()
{
    vec2 fragCoord=gl_FragCoord.xy+1000.;
    uint val0 = floatBitsToUint(0.4/(0.1*0.4-0.2*0.3));
    uint val1 = floatBitsToUint(0.4/(0.1*0.4-0.2*(0.3+min(fragCoord.x,0.))));
    uint val2 = floatBitsToUint(0.4/(0.1*(0.4+min(fragCoord.y,0.))-0.2*0.3));
    outColor = uvec4(val0, val1, val2, 0u);
}

Test shadertoy shader.

SPIRV-VM result: (first line float second uint)

-20.000000 -19.999996 -20.000004 0.000000 
3248488448 3248488446 3248488450 0

Expected result: (uint in range +-1 from 3248488448)

-20.000000 -19.999998 -20.000001 0.000000 
3248488448 3248488447 3248488449 0

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions