Detecting Alpha Channel with PVRTexTool's DDS Output

I am using PVRTexTool (commandline) to generate a DDS file with specified PVRTC formats (PVRTC1_4 , PVRTC1_4_RGB, etc.). I am having difficulty parsing the generated DDS header in my loader to determine which OpenGL internal format should be used, particularly between the RGBA and RGB formats (GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG vs. GL_COMPRESSED_RGB4_PVRTC_4BPPV1_IMG).



I would expect to read in the internal format for OpenGL by parsing the fourCC from the DDS header. When reading in the generated DDS header, it seems that regardless if PVRTC1_4 or PVRTC1_4_RGB is specified, the same fourCC is generated for each. The only difference in fourCC’s used is between 2bpp and 4bpp. I also don’t see other flags being set in the DDS header that would help me parse out this information (e.g. dwAlphaBitDepth isn’t set).





How can I correctly parse the generated DDS header from PVRTexTool to determine whether or not I should specify the RGB or RGBA internal format for OpenGL?

Hi Sw7,



Unfortunately we never considered setting an alpha flag in a DDS file for the different file types - our DirectX implementations make no distinction between RGBA and RGB PVRTC textures - because regions of both are permitted in either case - the decode has to handle both regardless.



This is now also true for our OpenGL ES implementation - I believe there used to be an optimisation for our MBX hardware when not supporting alpha, but if you’re on Series5 (SGX) it won’t make a difference - just upload it as RGBA, as this works as a catch all.



So there’s nothing in the DDS header at present which would signify one or the other, though I can certainly add something to a future version of our DDS export code - I’ll have a look into it. I’ll probably do it by adding the “ALPHA_PIXELS” flag. If you need this information from a application point of view, I can’t really make any suggestions at present beyond considering making the switch to PVR files, otherwise you’re probably going to have to enumerate it yourself some other way I’m afraid.



Regards,

Tobias

Thanks for the response,



If I’m understanding this correctly, with newer hardware (SGX), there’s no need to distinguish between the OpenGL ES internal format of RGB vs. RGBA for optimization or correctness purposes? If that’s the case, then I think we should be okay with how it is currently.

Hi Sw7,



That is correct, yes. I’ll add the flag for a future release anyway though because it seems like a good idea :slight_smile:



Thanks,

Tobias

Great, thanks for your help!