Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong 32 bit float precision error #7

Open
danilw opened this issue Jul 10, 2021 · 0 comments
Open

wrong 32 bit float precision error #7

danilw opened this issue Jul 10, 2021 · 0 comments

Comments

@danilw
Copy link

danilw commented Jul 10, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant