I need to compute the average of the contents of a 32x32 RGB32F render target texture. I have tried two methods:
MethodCPU: use glReadPixels over the FBO and do the computations on the CPU. Cost: glReadPixels + 1024-iterations loop.
MethodGPU: use glGenerateMipmapEXT to compute the mipmap on the GPU and fetch the 1x1 mipmap for the value which will contain the average of all texels (works fine).
The problem I have is that MethodGPU is 2~3 times slower than MethodCPU. I thought my GPU-based approach would outpeform the CPU-based one, but I doesn’t seem to be true.
My questions are:
1- Which is the fastest way of generating mipmaps for a texture attached as a render target to a FBO?
2- Which is the fastest way of computing the average value of a texture?