01-24-2014, 06:37 PM
I had a Heureka moment last night. If I remember correctly, it is possible to templatize functions not only on type, but also on an integer value, right? This might make the cCubicNoise::GenerateX() functions faster - if they had the array dimensions as template parameters, rather than regular parameters, the compiler would be able to make much more optimizations, such as unrolling the loop and perhaps even vectorizing the calculation, if it's smart enough. We're using a small set of dimensions anyway - usually only a 5x5 array.
It might be interesting to implement at least a 2D generator in this way and compare its performance with the current approach, whether we get any substantial difference on, let's say, a million 5x5 arrays generated. The NoiseTest project should be able to measure this, when modified.
Another set of functions quite likely to benefit from such an optimization would be the the linear upscaling functions ($/src/LinearUpscale.h), used heavily in the generator. Again, a test confirming this would be nice, and it doesn't require the tiresome decoupling.
It might be interesting to implement at least a 2D generator in this way and compare its performance with the current approach, whether we get any substantial difference on, let's say, a million 5x5 arrays generated. The NoiseTest project should be able to measure this, when modified.
Another set of functions quite likely to benefit from such an optimization would be the the linear upscaling functions ($/src/LinearUpscale.h), used heavily in the generator. Again, a test confirming this would be nice, and it doesn't require the tiresome decoupling.