ImBuf: no need to use double precision inside IMB_transform #117160

Merged
Aras Pranckevicius merged 1 commits from aras_p/blender:imbuf-no-doubles into main 2024-01-16 13:32:56 +01:00

1 Commits

Author SHA1 Message Date
Aras Pranckevicius cd2d407061 ImBuf: no need to use double precision inside IMB_transform
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
Double precision pixel coordinate interpolation was added in 3a65d2f591
to fix an issue of "wobbly" resulting image at very high scale factors.
But the root cause of that was the fact that the scanline loop was
repeatedly adding the floating point step for each pixel, instead of
doing multiplication by pixel index (repeated floating point additions
can "drift" due to imprecision, whereas multiplications are much more
accurate).

Change all that math back to use single precision floats. I checked the
original issue the commit was fixing, it is still fine. Also added a
gtest to cover this situation: imbuf_transform, nearest_very_large_scale

This makes IMB_transform a tiny bit faster, on Windows/VS2022/Ryzen5950X
scaling an image at 4K resolution:
- Bilinear: 5.92 -> 5.83 ms
- Subsampled3x3: 53.6 -> 52.7 ms
2024-01-16 12:38:56 +02:00