OpenGL: why square textures take up less memory

Question: Why is the number of pixels occupying significantly less video memory if they are stored in a square texture than in a long rectangular texture?

Example: I create 360 ​​4x16384 textures using the glTexImage2D command. The internal format is GL_RGBA. Video memory: 1328 MB.

If I create 360 ​​256x256 textures with the same data, the memory usage is less than 100 MB.

Using the integrated Intel HD4000 GPU.

+7
opengl
source share
1 answer

It’s not that the texture is rectangular. This is because one of the sizes is extremely small.

To select texels from textures in an optimal way, the hardware will use what is called swizzling. The general idea is that it will restructure the bytes in the texture, so that pixels that are adjacent to each other in 2 dimensions will also be neighbors in memory. But this requires that the texture has a certain minimum size in both dimensions.

Now, texture filtering equipment can ignore this minimum size and only receive pixels from the actual texture size. But this additional storage still exists, taking up space without any useful purpose.

Given what you see, there is a good chance that Intel swizzling hardware has a minimum base size of 32 or 64 pixels.

OpenGL doesn't have much to discover this inconsistency other than what you did here.

+6
source share

All Articles