GPU precision never 0, but it can be 0 - v1.2

Danil
2 min readMay 27, 2023

--

Look below for link with example shaders

Short and important information about GPU floats:

When you debug and comparing two results and data to calculate those results were equal, but source of data is different — result may be different for both cases.

New shaders for this “bug”, screenshots on shadertoy page:

https://www.shadertoy.com/view/dldXR4 —minimal version, also remove normalize to see float pattern.

https://www.shadertoy.com/view/Dl3Szn — same as above but large example, it shows how “precompiler” can change behavior and behavior of precompiler if different.

I mention this before in Float precision on GPU, bugs/features — GPU precision never 0, but it can be 0.

I think pointing this important information again, even as a note for myself — can be helpful.

Story:

Recently I was debugging TAA in this shader — and had two versions of reprojection and camera logic, and was “debugging/comparing” my reprojection-camera-logic to be sure I did everything correctly.

And my logic returned “it is equal” result when I calculated from static data, when other reprojection-camera logic return “noise that not everywhere equal” — I was expecting “equal result” but “noise” seems more correct because its dynamic TAA and pixel shift may result this “noise”, same as on test shaders I linked above.

I was very confused by “equal” result and thought — I somehow/somewhere did mistake with pixel jittering. I recalculated everything by hands to be sure it is correct, and it was.

Then I found this “old-known-bug” I listed above:
My shader return “equal result” because I use different camera calculation that “restore needed data from local data”.
When other camera-logic were “loading camera data from external memory” — that lead to different result compare to my.

That all, have fun.

--

--

Danil
Danil

No responses yet