/****************************************************************************** @File PVRTTexture.h @Title PVRTTexture @Version @Version @Copyright Copyright (c) Imagination Technologies Limited. All Rights Reserved. Strictly Confidential. @Platform ANSI compatible @Description Texture loading. ******************************************************************************/ #ifndef _PVRTTEXTURE_H_ #define _PVRTTEXTURE_H_ //ACS: PVRTGlobal.h was dragging in too much stuff (like windows.h & crtdbg.h) // so I split the relevant stuff out into a new file, PVRTTypes.h //#include "PVRTGlobal.h" #include "PVRTTypes.h" /***************************************************************************** * Texture related constants and enumerations. *****************************************************************************/ // V3 Header Identifiers. const PVRTuint32 PVRTEX3_IDENT = 0x03525650; // 'P''V''R'3 const PVRTuint32 PVRTEX3_IDENT_REV = 0x50565203; // If endianness is backwards then PVR3 will read as 3RVP, hence why it is written as an int. //Current version texture identifiers const PVRTuint32 PVRTEX_CURR_IDENT = PVRTEX3_IDENT; const PVRTuint32 PVRTEX_CURR_IDENT_REV = PVRTEX3_IDENT_REV; // PVR Header file flags. Condition if true. If false, opposite is true unless specified. const PVRTuint32 PVRTEX3_FILE_COMPRESSED = (1<<0); // Texture has been file compressed using PVRTexLib (currently unused) const PVRTuint32 PVRTEX3_PREMULTIPLIED = (1<<1); // Texture has been premultiplied by alpha value. // Mip Map level specifier constants. Other levels are specified by 1,2...n const PVRTint32 PVRTEX_TOPMIPLEVEL = 0; const PVRTint32 PVRTEX_ALLMIPLEVELS = -1; //This is a special number used simply to return a total of all MIP levels when dealing with data sizes. //values for each meta data type that we know about. Texture arrays hinge on each surface being identical in all but content, including meta data. //If the meta data varies even slightly then a new texture should be used. It is possible to write your own extension to get around this however. enum EPVRTMetaData { ePVRTMetaDataTextureAtlasCoords=0, ePVRTMetaDataBumpData, ePVRTMetaDataCubeMapOrder, ePVRTMetaDataTextureOrientation, ePVRTMetaDataBorderData, ePVRTMetaDataPadding, ePVRTMetaDataNumMetaDataTypes }; enum EPVRTAxis { ePVRTAxisX = 0, ePVRTAxisY = 1, ePVRTAxisZ = 2 }; enum EPVRTOrientation { ePVRTOrientLeft = 1< class CPVRTMap; /*!*********************************************************************** @Function PVRTGetBitsPerPixel @Input u64PixelFormat A PVR Pixel Format ID. @Return const PVRTuint32 Number of bits per pixel. @Description Returns the number of bits per pixel in a PVR Pixel Format identifier. *************************************************************************/ PVRTuint32 PVRTGetBitsPerPixel(PVRTuint64 u64PixelFormat); /*!*********************************************************************** @Function PVRTGetFormatMinDims @Input u64PixelFormat A PVR Pixel Format ID. @Modified minX Returns the minimum width. @Modified minY Returns the minimum height. @Modified minZ Returns the minimum depth. @Description Gets the minimum dimensions (x,y,z) for a given pixel format. *************************************************************************/ void PVRTGetFormatMinDims(PVRTuint64 u64PixelFormat, PVRTuint32 &minX, PVRTuint32 &minY, PVRTuint32 &minZ); /*!*********************************************************************** @Function PVRTConvertOldTextureHeaderToV3 @Input LegacyHeader Legacy header for conversion. @Modified NewHeader New header to output into. @Modified pMetaData MetaData Map to output into. @Description Converts a legacy texture header (V1 or V2) to a current generation header (V3) *************************************************************************/ void PVRTConvertOldTextureHeaderToV3(const PVR_Texture_Header* LegacyHeader, PVRTextureHeaderV3& NewHeader, CPVRTMap >* pMetaData); /*!*********************************************************************** @Function PVRTMapLegacyTextureEnumToNewFormat @Input OldFormat Legacy Enumeration Value @Modified newType New PixelType identifier. @Modified newCSpace New ColourSpace @Modified newChanType New Channel Type @Modified isPreMult Whether format is pre-multiplied @Description Maps a legacy enumeration value to the new PVR3 style format. *************************************************************************/ void PVRTMapLegacyTextureEnumToNewFormat(PVRTPixelType OldFormat, PVRTuint64& newType, EPVRTColourSpace& newCSpace, EPVRTVariableType& newChanType, bool& isPreMult); /*!*************************************************************************** @Function PVRTTextureLoadTiled @Modified pDst Texture to place the tiled data @Input nWidthDst Width of destination texture @Input nHeightDst Height of destination texture @Input pSrc Texture to tile @Input nWidthSrc Width of source texture @Input nHeightSrc Height of source texture @Input nElementSize Bytes per pixel @Input bTwiddled True if the data is twiddled @Description Needed by PVRTTextureTile() in the various PVRTTextureAPIs *****************************************************************************/ void PVRTTextureLoadTiled( PVRTuint8 * const pDst, const unsigned int nWidthDst, const unsigned int nHeightDst, const PVRTuint8 * const pSrc, const unsigned int nWidthSrc, const unsigned int nHeightSrc, const unsigned int nElementSize, const bool bTwiddled); /*!*************************************************************************** @Function PVRTTextureTwiddle @Output a Twiddled value @Input u Coordinate axis 0 @Input v Coordinate axis 1 @Description Combine a 2D coordinate into a twiddled value *****************************************************************************/ void PVRTTextureTwiddle(unsigned int &a, const unsigned int u, const unsigned int v); /*!*************************************************************************** @Function PVRTTextureDeTwiddle @Output u Coordinate axis 0 @Output v Coordinate axis 1 @Input a Twiddled value @Description Extract 2D coordinates from a twiddled value. *****************************************************************************/ void PVRTTextureDeTwiddle(unsigned int &u, unsigned int &v, const unsigned int a); /*!*********************************************************************** @Function PVRTGetTextureDataSize @Input sTextureHeader Specifies the texture header. @Input iMipLevel Specifies a mip level to check, 'PVRTEX_ALLMIPLEVELS' can be passed to get the size of all MIP levels. @Input bAllSurfaces Size of all surfaces is calculated if true, only a single surface if false. @Input bAllFaces Size of all faces is calculated if true, only a single face if false. @Return PVRTuint32 Size in BYTES of the specified texture area. @Description Gets the size in BYTES of the texture, given various input parameters. User can retrieve the size of either all surfaces or a single surface, all faces or a single face and all MIP-Maps or a single specified MIP level. *************************************************************************/ PVRTuint32 PVRTGetTextureDataSize(PVRTextureHeaderV3 sTextureHeader, PVRTint32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true); #endif /* _PVRTTEXTURE_H_ */ /***************************************************************************** End of file (PVRTTexture.h) *****************************************************************************/