Suppose I have the task of summing 1048576 numbers. Suppose I can also ignore the time involved sending those numbers to the GPU (they don't need to - they can be derived from a simple mathematical formula). Is it possible to sum all those numbers in parallel there?
My attempt: I was going to go with an usual parallel reduction, making the texture 1/4 of its size on each pass, so I'd need log(N)
passes. The problem I am having is that a texture holds Vec4<byte>
values. I am interested in float
values! There is an extension to write Vec4<float>
values, but it doesn't allow reading them back, and they are still Vec4
s!
Does anyone have a solution for that problem? Considering the tricky nature of WebGL, a minimal code demo would be very helpful.