PDA

View Full Version : Optimal Texture Transfer Formats and GL_BGRA



Dark Photon
06-20-2017, 01:34 PM
On Windows, on an NVidia GPU, I'm seeing:


glGetInternalformativ( GL_TEXTURE_2D, GL_RGBA8, GL_TEXTURE_IMAGE_FORMAT , 1, &format[0] ); // GL_RGBA
glGetInternalformativ( GL_TEXTURE_2D, GL_RGBA8, GL_TEXTURE_IMAGE_TYPE , 1, &type [0] ); // GL_UNSIGNED_INT_8_8_8_8_REV
glGetInternalformativ( GL_TEXTURE_2D, GL_RGBA8, GL_READ_PIXELS_FORMAT , 1, &format[1] ); // GL_RGBA
glGetInternalformativ( GL_TEXTURE_2D, GL_RGBA8, GL_READ_PIXELS_TYPE , 1, &type [1] ); // GL_UNSIGNED_INT_8_8_8_8_REV


That is, for GL_RGBA8, the driver recommends uploads and downloads using GL_RGBA / GL_UNSIGNED_INT_8_8_8_8_REV.

Does that makes sense to anyone?

I recall repeatedly folks benchmarking and finding that GL_BGRA is the external format to use on Windows (either with GL_UNSIGNED_BYTE or possibly GL_UNSIGNED_INT_8_8_8_8_REV (for instance, in mhagain's post here (https://www.opengl.org/discussion_boards/showthread.php/198787-Updating-textures-per-frame?p=1283599&viewfull=1#post1283599)). Not to mention that NVidia recommends this in their developer literature too.

Correct me if I'm wrong, but the NVidia driver's recommendation (via glGetInternalformativ() (https://www.khronos.org/opengl/wiki/GLAPI/glGetInternalformat)) doesn't match that:



ORDER FORMAT TYPE
-------- ---------- -----------
RGBA RGBA UNSIGNED_BYTE
RGBA RGBA UINT_8_8_8_8_REV <-- NV driver recommends
BGRA BGRA UNSIGNED_BYTE <-- Often recommended
BGRA BGRA UINT_8_8_8_8_REV <-- Sometimes recommended
ABGR RGBA UINT_8_8_8_8
ARGB BGRA UINT_8_8_8_8


Note here that "ORDER" is the memory order on a little-endian machine like x86 (with GL_{PACK,UNPACK}_SWAP_BYTES = FALSE).

mhagain
06-20-2017, 01:53 PM
I believe, and this is without having done any formal testing to back it up, that ever since Microsoft shoved RGBA down the vendors throats in the D3D10 timeframe this is not as important as it used to be.

It's certainly the case however that in my old tests BGRA was primarily optimal on Intel, significantly less so on NV whereas on AMD it didn't matter at all.

Dark Photon
06-20-2017, 03:03 PM
I believe, and this is without having done any formal testing to back it up, that ever since Microsoft shoved RGBA down the vendors throats in the D3D10 timeframe this is not as important as it used to be.

Thanks for the reply. That's a better theory than I had. In this test case, I'm not seeing any better perf with BGRA order than with RGBA order (in fact, RGBA is better).