GLFFT icon indicating copy to clipboard operation
GLFFT copied to clipboard

A couple improvements - Improved precision, custom intermediate buffers, custom sampling

Open ActuallyaDeviloper opened this issue 4 years ago • 0 comments

I don't know if this project is still maintained, but I want to contribute my changes back.

My changes are grouped into multiple commits.I thought about doing multiple PRs but that seemed more complicated so I decided to group everything here instead. The changes are basically:

  • An option was added to allow using external OpenGL buffers for the intermediate results. These can be quite significant in size for larger FFTs. For example let's say you want do a classical convolution containing both a forward and a backward FFT. If both allocate their own internal storage, up to two additional internal buffers may be allocated, amounting in our case to 512 MB (= 2 Buffers * 4096² Pixel/Buffer * 16 Bytes/Pixel)!
  • An option was added to allow inserting custom sampling code. For post processing applications this allows doing some simple calculations like prefiltering and color space transformations directly without introducing another memory roundtrip.
  • Sometimes half precision floating points were internally used in the case that the output format was only half precision. This is not generally a safe assumption. For example again in the classical case of a convolution filter, you may have an input image with high dynamic range but limited precision such that half precision suffices for it nicely. However the frequency space and during the FFT, very dim and very bright regions are summed which causes precision loss in the dimer regions due to the nature of floats. Because of this the intermediate results cannot really be 16 bit in that case. Whether half precision intermediate buffers are used is controlled by the preexisting fp16 option.
  • Minor changes: Fixed a couple type conversion warnings and added command option to run fewer tests.

I am happy to make adjustments if you have any concerns regarding the changes. I ran the shortend version of the test program.

ActuallyaDeviloper avatar Mar 07 '20 15:03 ActuallyaDeviloper