gl_APPLE_client_storage extension

I’m trying to use the gl_APPLE_client_storage extension for managing texture maps.

Actually i’m doing glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, TRUE);
then doing my glTexImage2D with the texture type GL_UNSIGNED_BYTE and texture format is either ‘GL_RGB’ or ‘GL_RGBA’ (or a compressed texture format). and keep the original texture data from system memory.

Apparently it works fine

But I’ve seen that it is recommended (?) to the use a texture type ‘GL_UNSIGNED_INT_8_8_8_8_REV’ and GL_BGR(A)_EXT

What’s the difference when using this format instead of GL_UNSIGNED_TYPE ?

Is there is a penalty when not using the recommended format or type ?

When using GL_UNSIGNED_INT_8_8_8_8_REV,
Does it means that the texture format is 4x32bit per texel instead of 4x8bit by texel ? (so 4 times bigger ?)

GL_UNSIGNED_INT_8_8_8_8_REV (and GL_UNSIGNED_SHORT_1_5_5_5_REV etc) is a packed type, it still = 32 bits.

The reason this is preferred over RGBA, UNSIGNED_BYTE is that the internal texture layout on all Mac GPUs is ARGB (== BGRA if you account for the PC/Mac endian difference.) If your CPU-side texel data is RGBA format, the GL has to swap the alpha around whenever it pages in, which is slow. Note that NSImage gives you pixels in RGBA format.

Keeping everything in ARGB format from start to end is much faster. QuickTime GWorlds can be ARGB.

This is covered in the Texture Range sample code along with two other steps needed for fast texture updates. The fourth step that isn’t mentioned there is that your texture rowbytes must be a multiple of 32.

Yes i’ve seen that example but it was only covering the ‘32bit’ texel format.

  • So if a texture was defined for being used in GL_RGBA, GL_UNSIGNED_BYTE,
    Converts the texel format (bswap32 on each texel) and set to GL_BGRA_EXT and GL_UNSIGNED_INT_8_8_8_8_REV

What about ‘24 bit’ GL_RGB, does it better to be converts back to GL_BGRA_EXT and use the same trick, although this will
increase the size by 25% or just do the BGR conversion (GL_RGB->GL_BGR) with keep the type ‘GL_UNSIGNED_BYTE’

What about compressed textures (GL_COMPRESSED_RGBA_S3TC_DXT?_EXT) does it avantageous to use glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, TRUE);
or don’t use it ?

It’s not bswap, since it’s only moving the A around the RGB.

But, those are all good questions. I think the answers will depend on what video card you have, because the supported internal texture formats vary by card. They’re also not very well documented, so you’ll probably have to figure out which formats are fastest by experimentation on a per-card basis.

For example, Radeons have an A8 format so in theory that upload should be fast. But GF’s prior to the 6800 don’t have an internal A8 format, they have to convert to L8A8, which will be slow. I think that all cards have internal RGB8 and RGB5 formats, but I’m not sure about that. Whether that format is fast uploading probably depends on other things, like the rowbytes being a DMA-friendly multiple of 32.

The S3TC formats, I’ve never used in combination with client storage. It seems to me that it wouldn’t be useful; client storage is intended to eliminate the overhead of the copy between your app RAM and GL, and the primary benefit of this (for me, anyway) is animated textures which are continually updated. Nobody continually updates S3TC textures (the runtime compressor is slow and very low quality.)

But, good question. I’ll try reworking some of my texture caching to see how it affects S3TC…

It could be interesting to have a list of the internal format supported by each video cards, and a small utility (like a ‘benchmark’) in order to test each texture format.

It would be useful for knowing which are the best texture format for dynamic textures.

For static textures, I think I will stay away from APPLE_client_storage, letting the driver converts to the most optimized format.

Btw, for pixel buffers, which are sort of dynamic textures, what is the best format ? I’m using GL_RGBA with aglCreatePBuffer (or CGLCreatePBuffer in fullscreen).
It should be GL_BGRA ?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.