Forums - KTX swap Red Channel and Blue Channel in Adreno Texture tool

6 posts / 0 new
Last post
KTX swap Red Channel and Blue Channel in Adreno Texture tool
brucewuu
Join Date: 21 Jun 12
Posts: 2
Posted: Sun, 2012-06-24 23:28

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 . 

  • Up0
  • Down0
Darryl
Join Date: 12 Aug 13
Posts: 3
Posted: Tue, 2013-08-13 13:55

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.

  • Up0
  • Down0
Dave Astle
Profile picture
Join Date: 19 Oct 12
Location: San Diego, CA
Posts: 99
Posted: Tue, 2013-08-13 15:04

This was fixed several releases ago. Are you still seeing it in the latest version of the SDK?

  • Up0
  • Down0
Darryl
Join Date: 12 Aug 13
Posts: 3
Posted: Tue, 2013-08-13 15:10

Hi Dave,

   We are using the Adreno Texture Tool v2.00.00 from the v3.3.3 SDK. 

  • Up0
  • Down0
Darryl
Join Date: 12 Aug 13
Posts: 3
Posted: Wed, 2013-08-14 14:45

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.

  • Up0
  • Down0
khawkins Moderator
Join Date: 29 Nov 12
Location: San Diego, CA
Posts: 62
Posted: Mon, 2013-08-19 13:56

Darryl - thanks for the additional info, that's very helpful. We should be able to get this fixed shortly.

Kevin

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.