(I'm doing this in Apple Metal, but I think the question applies to OpenGL and DirectX too. Code examples from Metal or OpenGL are highly welcome.)
I have one texture smallTex whose size is a multiple of the size of another texture bigTex.
For example, smallTex has dimensions 32x32 and bigTex has 128x128.
I need to downsample the contents of bigTex into smallTex so that every pixel in smallTex contains the average values of the corresponding pixels in bigTex.
First I thought I could create a fragment shader which samples from bigTex and renders to smallTex. However, this way I would lose much information, since the sampling reads from at most four pixels and interpolates between them.
What I need is real downsampling, where every pixel in the source has the same influence on the result.
I read that this could be done using mipmaps (which essentially are downsampled copies of the original texture). But then I would have to enable mipmapping on bigTex, which will have a negative performance impact since I'm doing many rendering (compute) steps on bigTex, which would result in a lot of work for the GPU to update the mipmaps.
What I need is a direct GPU command to downsample the texture.
Is that possible? Any hints?