4 ms·
> Floats are so slooooooooow! Why don't you use fixed-point numbers? On newer computers, there is not much speed difference, but on older computers the speed ga
by dahart 9y ago
> Floats are so slooooooooow! Why don't you use fixed-point numbers? On newer computers, there is not much speed difference, but on older computers the speed gain of using fixed numbers is significant.
This is now even more true than when this article was written, enough that I've been surprised lately and feel like I need to unlearn things I thought I knew about floats and transcendentals. They only cost a handful of clocks now in the worst case, with dependent instructions before and after. Depending on what else is going on, I think you can sometimes get sin & cos for the same cost as 1 add instruction; as long as you have a lot of other independent math nearby and/or memory access. Sin & cos & sqrt are crazy fast on GPUs, when using ShaderToy, for example.
- sp332 9y agoLogarithm too. I had written a fractal program in python, and one optimization for adding up a lot of logarithms was to multiply several values together first, then take the log of the batch. When I converted it to a shadertoy, I found that I could strip out the crufty batching code, converting hundreds of multiplies into logarithms with no noticeable change in performance.