Domanda

Why is performance boost due to mipmaps? I read somewhere on the net that "when we have 256 x 256 texture data and want to map it to 4x4, then driver will copy only 4x4 mipmap level generated to GPU memory and not 256x 256 data. and sampling will work on 4x4 data copied on GPU memory which will save lot of computations" I just want to know whether it is correct or not?

Also, when glTeximage call happens it uploads texture data in gpu memory which is passed in glteximage call. Then it conflicts with above statement. When we call glgeneratemipmap() does it create all the mipmap levels on CPU side and then later copies all those levels on GPU side?

È stato utile?

Soluzione

Mipmapping boosts performance for two main reasons. The first is because it decreases bandwidth between GPU memory and the texture unit and the second is because it improves caching inside the texture unit.

Imagine you have a distant object with a texture applied to it. With mipmaping the GPU instead of processing, reading and caching a huge texture (level 0) it reads a smaller one. In this scenario the bandwidth reduction is quite obvious.

Bandwidth and caching on mipmaping go hand in hand. Sampling the texture of the distance object most likely will read the texture in a sparse manner. For example read texel x,y and for the next fragment read the x+10,y+10. The x+10,y+10 may be in another cache line. When reading from a smaller texture though the cache misses can be far less.

glTexImageXX creates a single level and uploads the pixel data to the GPU. When calling glGenerateMipmap the driver will allocate GPU memory for the additional levels and most likely it will execute a single or multiple GPU jobs to fill those levels. In some cases it my do the same thing on CPU and then upload the data to GPU.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top