when I use Adreno Texture Tool in Adreno Sdk 2.3 to convert png image to KTX RGBA Explicit Compressed image , and test it with compresseTexture sample , I found the Red Channel and Blue Channel were swaped , is this the bug of the tool ? or we can fix this in the glFormat .
the ktxLoader is as follows .
UINT8 * LoadKTX(const CHAR * strFileName , UINT32 *pWidth , UINT32 * pHeight , UINT32 * nFormat , UINT32 * nSize)
{
typedef struct KTX_header_t {
UINT8 identifier[12];
UINT32 endianness;
UINT32 glType;
UINT32 glTypeSize;
UINT32 glFormat;
UINT32 glInternalFormat;
UINT32 glBaseInternalFormat;
UINT32 pixelWidth;
UINT32 pixelHeight;
UINT32 pixelDepth;
UINT32 numberOfArrayElements;
UINT32 numberOfFaces;
UINT32 numberOfMipmapLevels;
UINT32 bytesOfKeyValueData;
}KTX_Header;
typedef struct KTX_texinfo_t {
UINT32 textureDemensions;
UINT32 glTarget;
UINT32 compressed;
UINT32 generateMipmaps;
}KTX_Texinfo;
KTX_Header header;
KTX_Texinfo texinfo;
UINT8 * data = NULL;
UINT32 dataSize = 0;
UINT32 texname;
int texnameUser;
UINT32 faceLodSize;
UINT32 faceLodSizeRounded;
UINT32 level;
UINT32 face;
// Read the file
FILE* file = fopen( strFileName, "rb" );
if( NULL == file )
return NULL;
//read the header of ktx file
fread( &header, sizeof(header), 1, file );
//
fseek(file,(long)header.bytesOfKeyValueData,SEEK_CUR);
fread(&faceLodSize,sizeof(faceLodSize),1,file);
faceLodSizeRounded = (faceLodSize + 3) & ~(UINT32)3;
data = (UINT8 *)malloc(faceLodSizeRounded);
fread(data,faceLodSizeRounded,1,file);
*pWidth = header.pixelWidth;
*pHeight= header.pixelHeight;
*nSize = faceLodSizeRounded;
*nFormat = header.glInternalFormat;
return data;
}
thanks very much for your kindly help .
Hi Bruce,
Did you ever figure out what was happening? I have noticed the same RGB to BGR channel swapping behavior. The included tool looked really handy but having to pre-swizzle all of our raw asset textures is not very efficient.
This was fixed several releases ago. Are you still seeing it in the latest version of the SDK?
Hi Dave,
We are using the Adreno Texture Tool v2.00.00 from the v3.3.3 SDK.
To clairify further, I did a quick bit of testing: The Adreno Texture Tool swaps the channels when outputting DDS files as well. It does not appear to be affected by the input file type, 24bit BMP, TGA and JPG nor the compression type ATC, ATCI, ATCA. Loading the DDS texture into the ATI Compressionator v1.50 shows the same channel swapping exhibited in our game.
Darryl - thanks for the additional info, that's very helpful. We should be able to get this fixed shortly.
Kevin