Render frame counter value jumps around
spiralhalo opened this issue ยท 4 comments
Well this is embarrassing.
A few weeks ago I added a render frame counter in a PR (#224). Its purpose is to relay the number of frames since pipeline reload as a uniform, for use by temporal magic (such as TAA).
After the PR was merged, I found this bug while developing with it:
renderframes2.mp4
The frame counter starts with smooth increment of 1 per frame as expected. But after "a while" it starts to jump in steps every other frame.
The exact cause is not yet known. However it's likely to be (terrible) floating point imprecision. As can be seen in the background, the leaves are animating smoothly at all times, meaning the world data is updated each frame as expected. Since the renderFrames
value is updated in world data update, it seems likely that the data got lost in the gpu.
I already tested floating point -> integer precision in Java which should stay precise for a couple hours (still a concerning hack, but less so) but gpu floats are weird, so...
The obvious solution (if the hypothesis for the cause was correct) is to create integer uniforms. WorldData currently only accepts float vectors so it will need something like an integer world data perhaps. I'm not sure if I should make that kind of design decision so I'm opening this issue. (the only other uniform that accepts int is Flags, which the renderFrames
isn't)
ps. Dynamic FPS was once a likely suspect but has since been ruled out.
Fixed in #232
Will probably change to uniform buffer objects with interface blocks in the 1.17 branch. If you want to do this in the 1.16 version it kinda doesn't matter how. (OK to add an int uniform.)
Thanks for the review and greenlight! Excited for the core changes. Will do add int uniform soon in 1.16. By the way, will you keep/rename the configurable-pipeline branch for 1.16? I'm interested in backporting changes until 1.17 is officially released.