diff --git a/deps/PVRTT/Include/PVRTexLib.h b/deps/PVRTT/Include/PVRTexLib.h new file mode 100755 index 0000000000..1c927606cb --- /dev/null +++ b/deps/PVRTT/Include/PVRTexLib.h @@ -0,0 +1,1414 @@ +#pragma once + +#ifndef PVR_DLL +#if defined(PVRTEXLIB_EXPORT) +#if defined(_MSC_VER) +#define PVR_DLL __declspec(dllexport) +#else +#define PVR_DLL __attribute__((visibility("default"))) +#endif +#elif defined(_MSC_VER) && defined(PVRTEXLIB_IMPORT) // To use the PVRTexLib .dll on Windows, define PVRTEXLIB_IMPORT +#define PVR_DLL __declspec(dllimport) +#else +#define PVR_DLL +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#include "PVRTexLibDefines.h" +#include "PVRTextureVersion.h" + +typedef void* PVRTexLib_PVRTextureHeader; +typedef const void* PVRTexLib_CPVRTextureHeader; +typedef void* PVRTexLib_PVRTexture; +typedef const void* PVRTexLib_CPVRTexture; + +/*!*********************************************************************** + @struct PVRHeader_CreateParams + @brief Structure containing various texture header parameters for + PVRTexLib_CreateTextureHeader(). +*************************************************************************/ +struct PVRHeader_CreateParams +{ + PVRTuint64 pixelFormat; ///< pixel format + PVRTuint32 width; ///< texture width + PVRTuint32 height; ///< texture height + PVRTuint32 depth; ///< texture depth + PVRTuint32 numMipMaps; ///< number of MIP maps + PVRTuint32 numArrayMembers; ///< number of array members + PVRTuint32 numFaces; ///< number of faces + PVRTexLibColourSpace colourSpace; ///< colour space + PVRTexLibVariableType channelType; ///< channel type + bool preMultiplied; ///< has the RGB been pre-multiplied by the alpha? +}; + +/*!*********************************************************************** + @struct PVRTexLib_Orientation + @brief Structure containing a textures orientation in each axis. +*************************************************************************/ +struct PVRTexLib_Orientation +{ + PVRTexLibOrientation x; ///< X axis orientation + PVRTexLibOrientation y; ///< Y axis orientation + PVRTexLibOrientation z; ///< Z axis orientation +}; + +/*!*********************************************************************** + @struct PVRTexLib_OpenGLFormat + @brief Structure containing a OpenGL[ES] format. +*************************************************************************/ +struct PVRTexLib_OpenGLFormat +{ + PVRTuint32 internalFormat; ///< GL internal format + PVRTuint32 format; ///< GL format + PVRTuint32 type; ///< GL type +}; + +typedef PVRTexLib_OpenGLFormat PVRTexLib_OpenGLESFormat; + +/*!*********************************************************************** + @struct PVRTexLib_MetaDataBlock + @brief Structure containing a block of meta data for a texture. +*************************************************************************/ +struct PVRTexLib_MetaDataBlock +{ + PVRTuint32 DevFOURCC; ///< A 4cc descriptor of the data type's creator. Values starting with 'PVR' are reserved for PVRTexLib. + PVRTuint32 u32Key; ///< A unique value identifying the data type, and thus how to read it. For example PVRTexLibMetaData. + PVRTuint32 u32DataSize; ///< Size of 'Data' in bytes. + PVRTuint8* Data; ///< Meta data bytes +}; + +#define PVRTEXLIB_SIZEOF_METADATABLOCK(BLOCK) offsetof(PVRTexLib_MetaDataBlock, Data) + BLOCK.u32DataSize; + +/*!*********************************************************************** + @struct PVRTexLib_TranscoderOptions + @brief Structure containing the transcoder options for + PVRTexLib_TranscodeTexture(). +*************************************************************************/ +#pragma pack(push,4) +struct PVRTexLib_TranscoderOptions +{ + PVRTuint32 sizeofStruct; ///< For versioning - sizeof(PVRTexLib_TranscoderOptions) + PVRTuint64 pixelFormat; ///< Pixel format type + PVRTexLibVariableType channelType[4U]; ///< Per-channel variable type. + PVRTexLibColourSpace colourspace; ///< Colour space + PVRTexLibCompressorQuality quality; ///< Compression quality for PVRTC, ASTC, ETC, BASISU and IMGIC, higher quality usually requires more processing time. + bool doDither; ///< Apply dithering to lower precision formats. + float maxRange; ///< Max range value for RGB[M|D] encoding + PVRTuint32 maxThreads; ///< Max number of threads to use for transcoding, if set to 0 PVRTexLib will use all available cores. +}; +#pragma pack(pop) + +/*!*********************************************************************** + @struct PVRTexLib_ErrorMetrics + @brief Structure containing the resulting error metrics computed by: + PVRTexLib_MaxDifference(), + PVRTexLib_MeanError(), + PVRTexLib_MeanSquaredError(), + PVRTexLib_RootMeanSquaredError(), + PVRTexLib_StandardDeviation(), + PVRTexLib_PeakSignalToNoiseRatio(). +*************************************************************************/ +struct PVRTexLib_ErrorMetrics +{ + struct + { + PVRTexLibChannelName name; ///< Channel name. PVRTLCN_NoChannel indicates invalid entry. + double value; ///< Value for this channel. + } channels[4U]; ///< Per-channel metrics, not all entries have to be valid. + + double allChannels; ///< Value for all channels. + double rgbChannels; ///< Value for RGB channels. +}; + +/*!*********************************************************************** + @brief Sets up default texture header parameters. + @param[in,out] result Default header attributes. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetDefaultTextureHeaderParams(PVRHeader_CreateParams* result); + +/*!*********************************************************************** + @brief Creates a new texture header using the supplied + header parameters. + @param[in] attribs The header attributes + @return A handle to a new texture header. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTextureHeader PVRTexLib_CreateTextureHeader(const PVRHeader_CreateParams* attribs); + +/*!*********************************************************************** + @brief Creates a new texture header from a PVRV3 structure. + Optionally supply meta data. + @param[in] header PVRTextureHeaderV3 structure to create from. + @param[in] metaDataCount Number of items in metaData, can be 0. + @param[in] metaData Array of meta data blocks, can be null. + @return A handle to a new texture header. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTextureHeader PVRTexLib_CreateTextureHeaderFromHeader(const PVRTextureHeaderV3* header, PVRTuint32 metaDataCount, PVRTexLib_MetaDataBlock* metaData); + +/*!*********************************************************************** + @brief Creates a new texture header by copying values from a + previously allocated texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return A handle to a new texture header. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTextureHeader PVRTexLib_CopyTextureHeader(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Free a previously allocated texture header. + @param[in] header Handle to a PVRTexLib_PVRTextureHeader. +*************************************************************************/ +PVR_DLL void PVRTexLib_DestroyTextureHeader(PVRTexLib_PVRTextureHeader header); + +/*!************************************************************************ + @brief Low level texture creation function. + Creates a PVRTextureHeaderV3 structure, + including room for the specified texture, in memory. + @param[in] width Width of the texture in pixels + @param[in] height Height of the texture in pixels + @param[in] depth Number of Z layers + @param[in] wMin Minimum width of a texture level + @param[in] hMin Minimum height of a texture level + @param[in] dMin Minimum depth of a texture level + @param[in] nBPP Bits per pixel + @param[in] bMIPMap Create memory for MIP-map levels also? + @param[in] pfnAllocCallback Memory allocation callback function. + @return Allocated texture memory. free()d by caller. +**************************************************************************/ +PVR_DLL PVRTextureHeaderV3* PVRTexLib_TextureCreateRaw( + PVRTuint32 width, + PVRTuint32 height, + PVRTuint32 depth, + PVRTuint32 wMin, + PVRTuint32 hMin, + PVRTuint32 dMin, + PVRTuint32 nBPP, + bool bMIPMap, + void* (pfnAllocCallback)(PVRTuint64 allocSize)); + +/*!*************************************************************************** + @brief Low level texture creation function. + Load blocks of data from pSrc into pDst. + @param[in] pDst Texture to place the tiled data + @param[in] widthDst Width of destination texture + @param[in] heightDst Height of destination texture + @param[in] pSrc Texture to tile + @param[in] widthSrc Width of source texture + @param[in] heightSrc Height of source texture + @param[in] elementSize Bytes per pixel + @param[in] twiddled True if the data is twiddled +*****************************************************************************/ +PVR_DLL void PVRTexLib_TextureLoadTiled( + PVRTuint8* pDst, + PVRTuint32 widthDst, + PVRTuint32 heightDst, + PVRTuint8* pSrc, + PVRTuint32 widthSrc, + PVRTuint32 heightSrc, + PVRTuint32 elementSize, + bool twiddled); + +/*!*********************************************************************** + @brief Gets the number of bits per pixel for the specified texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Number of bits per pixel. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureBitsPerPixel(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the number of bits per pixel for the specified pixel format. + @param u64PixelFormat A PVR pixel format ID. + @return Number of bits per pixel. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetFormatBitsPerPixel(PVRTuint64 u64PixelFormat); + +/*!*********************************************************************** + @brief Gets the number of channels for the specified texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return For uncompressed formats the number of channels between 1 and 4. + For compressed formats 0 +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureChannelCount(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the channel type for the specified texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return PVRTexLibVariableType enum. +*************************************************************************/ +PVR_DLL PVRTexLibVariableType PVRTexLib_GetTextureChannelType(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the colour space for the specified texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return PVRTexLibColourSpace enum. +*************************************************************************/ +PVR_DLL PVRTexLibColourSpace PVRTexLib_GetTextureColourSpace(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the width of the user specified MIP-Map level for the + texture + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] uiMipLevel MIP level that user is interested in. + @return Width of the specified MIP-Map level. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureWidth(PVRTexLib_CPVRTextureHeader header, PVRTuint32 mipLevel); + +/*!*********************************************************************** + @brief Gets the height of the user specified MIP-Map + level for the texture + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] uiMipLevel MIP level that user is interested in. + @return Height of the specified MIP-Map level. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureHeight(PVRTexLib_CPVRTextureHeader header, PVRTuint32 mipLevel); + +/*!*********************************************************************** + @brief Gets the depth of the user specified MIP-Map + level for the texture + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] uiMipLevel MIP level that user is interested in. + @return Depth of the specified MIP-Map level. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureDepth(PVRTexLib_CPVRTextureHeader header, PVRTuint32 mipLevel); + +/*!*********************************************************************** + @brief Gets the size in PIXELS of the texture, given various input + parameters. User can retrieve the total 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. All of these + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] iMipLevel Specifies a MIP level to check, + 'PVRTEX_ALLMIPLEVELS' can be passed to get + the size of all MIP levels. + @param[in] bAllSurfaces Size of all surfaces is calculated if true, + only a single surface if false. + @param[in] bAllFaces Size of all faces is calculated if true, + only a single face if false. + @return Size in PIXELS of the specified texture area. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureSize(PVRTexLib_CPVRTextureHeader header, PVRTint32 mipLevel, bool allSurfaces, bool allFaces); + +/*!*********************************************************************** + @brief 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. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] iMipLevel Specifies a mip level to check, + 'PVRTEX_ALLMIPLEVELS' can be passed to get + the size of all MIP levels. + @param[in] bAllSurfaces Size of all surfaces is calculated if true, + only a single surface if false. + @param[in] bAllFaces Size of all faces is calculated if true, + only a single face if false. + @return Size in BYTES of the specified texture area. +*************************************************************************/ +PVR_DLL PVRTuint64 PVRTexLib_GetTextureDataSize(PVRTexLib_CPVRTextureHeader header, PVRTint32 mipLevel, bool allSurfaces, bool allFaces); + +/*!*********************************************************************** + @brief Gets the data orientation for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] result Pointer to a PVRTexLib_Orientation structure. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureOrientation(PVRTexLib_CPVRTextureHeader header, PVRTexLib_Orientation* result); + +/*!*********************************************************************** + @brief Gets the OpenGL equivalent format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] result Pointer to a PVRTexLib_OpenGLFormat structure. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureOpenGLFormat(PVRTexLib_CPVRTextureHeader header, PVRTexLib_OpenGLFormat* result); + +/*!*********************************************************************** + @brief Gets the OpenGLES equivalent format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] result Pointer to a PVRTexLib_OpenGLESFormat structure. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureOpenGLESFormat(PVRTexLib_CPVRTextureHeader header, PVRTexLib_OpenGLESFormat* result); + +/*!*********************************************************************** + @brief Gets the Vulkan equivalent format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return A VkFormat enum value. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureVulkanFormat(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the Direct3D equivalent format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return A D3DFORMAT enum value. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureD3DFormat(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the DXGI equivalent format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return A DXGI_FORMAT enum value. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureDXGIFormat(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the minimum dimensions (x,y,z) + for the textures pixel format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] minX Returns the minimum width. + @param[in,out] minY Returns the minimum height. + @param[in,out] minZ Returns the minimum depth. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureFormatMinDims(PVRTexLib_CPVRTextureHeader header, PVRTuint32* minX, PVRTuint32* minY, PVRTuint32* minZ); + +/*!*********************************************************************** + @brief Gets the minimum dimensions (x,y,z) + for the textures pixel format. + @param[in] u64PixelFormat A PVR Pixel Format ID. + @param[in,out] minX Returns the minimum width. + @param[in,out] minY Returns the minimum height. + @param[in,out] minZ Returns the minimum depth. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetPixelFormatMinDims(PVRTuint64 ui64Format, PVRTuint32* minX, PVRTuint32* minY, PVRTuint32* minZ); + +/*!*********************************************************************** + @brief Returns the total size of the meta data stored in the header. + This includes the size of all information stored in all MetaDataBlocks. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Size, in bytes, of the meta data stored in the header. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureMetaDataSize(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Returns whether or not the texture's colour has been + pre-multiplied by the alpha values. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return True if texture is premultiplied. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GetTextureIsPreMultiplied(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Returns whether or not the texture is compressed using + PVRTexLib's FILE compression - this is independent of + any texture compression. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return True if it is file compressed. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GetTextureIsFileCompressed(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Returns whether or not the texture is a bump map. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return True if it is a bump map. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GetTextureIsBumpMap(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the bump map scaling value for this texture. + If the texture is not a bump map, 0.0f is returned. If the + texture is a bump map but no meta data is stored to + specify its scale, then 1.0f is returned. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Returns the bump map scale value as a float. +*************************************************************************/ +PVR_DLL float PVRTexLib_GetTextureBumpMapScale(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Works out the number of possible texture atlas members in + the texture based on the width, height, depth and data size. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return The number of sub textures defined by meta data. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetNumTextureAtlasMembers(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Returns a pointer to the texture atlas data. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] count Number of floats in the returned data set. + @return A pointer directly to the texture atlas data. NULL if + the texture does not have atlas data. +*************************************************************************/ +PVR_DLL const float* PVRTexLib_GetTextureAtlasData(PVRTexLib_CPVRTextureHeader header, PVRTuint32* count); + +/*!*********************************************************************** + @brief Gets the number of MIP-Map levels stored in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Number of MIP-Map levels in this texture. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureNumMipMapLevels(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the number of faces stored in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Number of faces in this texture. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureNumFaces(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the number of array members stored in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return Number of array members in this texture. +*************************************************************************/ +PVR_DLL PVRTuint32 PVRTexLib_GetTextureNumArrayMembers(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Gets the cube map face order. + cubeOrder string will be in the form "ZzXxYy" with capitals + representing positive and lower case letters representing + negative. I.e. Z=Z-Positive, z=Z-Negative. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] cubeOrder Null terminated cube map order string. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureCubeMapOrder(PVRTexLib_CPVRTextureHeader header, char cubeOrder[7]); + +/*!*********************************************************************** + @brief Gets the bump map channel order relative to rgba. + For example, an RGB texture with bumps mapped to XYZ returns + 'xyz'. A BGR texture with bumps in the order ZYX will also + return 'xyz' as the mapping is the same: R=X, G=Y, B=Z. + If the letter 'h' is present in the string, it means that + the height map has been stored here. + Other characters are possible if the bump map was created + manually, but PVRTexLib will ignore these characters. They + are returned simply for completeness. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] Null terminated bump map order string relative to rgba. +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureBumpMapOrder(PVRTexLib_CPVRTextureHeader header, char bumpOrder[5]); + +/*!*********************************************************************** + @brief Gets the 64-bit pixel type ID of the texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return 64-bit pixel type ID. +*************************************************************************/ +PVR_DLL PVRTuint64 PVRTexLib_GetTexturePixelFormat(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Checks whether the pixel format of the texture is packed. + E.g. R5G6B5, R11G11B10, R4G4B4A4 etc. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @return True if the texture format is packed, false otherwise. +*************************************************************************/ +PVR_DLL bool PVRTexLib_TextureHasPackedChannelData(PVRTexLib_CPVRTextureHeader header); + +/*!*********************************************************************** + @brief Sets the variable type for the channels in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] type A PVRTexLibVariableType enum. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureChannelType(PVRTexLib_PVRTextureHeader header, PVRTexLibVariableType type); + +/*!*********************************************************************** + @brief Sets the colour space for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] colourSpace A PVRTexLibColourSpace enum. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureColourSpace(PVRTexLib_PVRTextureHeader header, PVRTexLibColourSpace colourSpace); + +/*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the D3D format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] d3dFormat A D3DFORMAT enum. + @return True if successful. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureD3DFormat(PVRTexLib_PVRTextureHeader header, PVRTuint32 d3dFormat); + +/*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the DXGI format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] dxgiFormat A DXGI_FORMAT enum. + @return True if successful. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureDXGIFormat(PVRTexLib_PVRTextureHeader header, PVRTuint32 dxgiFormat); + +/*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the OpenGL format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] oglFormat The OpenGL format. + @return True if successful. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureOGLFormat(PVRTexLib_PVRTextureHeader header, const PVRTexLib_OpenGLFormat* oglFormat); + +/*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the OpenGLES format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] oglesFormat The OpenGLES format. + @return True if successful. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureOGLESFormat(PVRTexLib_PVRTextureHeader header, const PVRTexLib_OpenGLESFormat* oglesFormat); + +/*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the OpenGLES format. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] vulkanFormat A VkFormat enum. + @return True if successful. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureVulkanFormat(PVRTexLib_PVRTextureHeader header, PVRTuint32 vulkanFormat); + +/*!*********************************************************************** + @brief Sets the pixel format for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] format The format of the pixel. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTexturePixelFormat(PVRTexLib_PVRTextureHeader header, PVRTuint64 format); + +/*!*********************************************************************** + @brief Sets the texture width. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] width The new width. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureWidth(PVRTexLib_PVRTextureHeader header, PVRTuint32 width); + +/*!*********************************************************************** + @brief Sets the texture height. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] height The new height. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureHeight(PVRTexLib_PVRTextureHeader header, PVRTuint32 height); + +/*!*********************************************************************** + @brief Sets the texture depth. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] depth The new depth. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureDepth(PVRTexLib_PVRTextureHeader header, PVRTuint32 depth); + +/*!*********************************************************************** + @brief Sets the number of array members in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] newNumMembers The new number of array members. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureNumArrayMembers(PVRTexLib_PVRTextureHeader header, PVRTuint32 numMembers); + +/*!*********************************************************************** + @brief Sets the number of MIP-Map levels in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] numMIPLevels New number of MIP-Map levels. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureNumMIPLevels(PVRTexLib_PVRTextureHeader header, PVRTuint32 numMIPLevels); + +/*!*********************************************************************** + @brief Sets the number of faces stored in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] numFaces New number of faces for this texture. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureNumFaces(PVRTexLib_PVRTextureHeader header, PVRTuint32 numFaces); + +/*!*********************************************************************** + @brief Sets the data orientation for a given axis in this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] orientation Pointer to a PVRTexLib_Orientation struct. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureOrientation(PVRTexLib_PVRTextureHeader header, const PVRTexLib_Orientation* orientation); + +/*!*********************************************************************** + @brief Sets whether or not the texture is compressed using + PVRTexLib's FILE compression - this is independent of + any texture compression. Currently unsupported. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] isFileCompressed Sets the file compression to true or false. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureIsFileCompressed(PVRTexLib_PVRTextureHeader header, bool isFileCompressed); + +/*!*********************************************************************** + @brief Sets whether or not the texture's colour has been + pre-multiplied by the alpha values. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] isPreMultiplied Sets if texture is premultiplied. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureIsPreMultiplied(PVRTexLib_PVRTextureHeader header, bool isPreMultiplied); + +/*!*********************************************************************** + @brief Obtains the border size in each dimension for this texture. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in,out] borderWidth Border width + @param[in,out] borderHeight Border height + @param[in,out] borderDepth Border depth +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureBorder(PVRTexLib_CPVRTextureHeader header, + PVRTuint32* borderWidth, + PVRTuint32* borderHeight, + PVRTuint32* borderDepth); + +/*!*********************************************************************** + @brief Returns a copy of a block of meta data from the texture. + If the meta data doesn't exist, a block with a data size + of 0 will be returned. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] DevFOURCC Four character descriptor representing the + creator of the meta data + @param[in] u32Key Key value representing the type of meta data stored + @param[in,out] dataBlock returned meta block data + @param[in] pfnAllocCallback Memory allocation callback function. + @return True if the meta data block was found. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GetMetaDataBlock( + PVRTexLib_CPVRTextureHeader header, + PVRTuint32 devFOURCC, + PVRTuint32 key, + PVRTexLib_MetaDataBlock* dataBlock, + void* (pfnAllocCallback)(PVRTuint32 allocSize)); + +/*!*********************************************************************** + @brief Returns whether or not the specified meta data exists as + part of this texture header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] DevFOURCC Four character descriptor representing the + creator of the meta data + @param[in] u32Key Key value representing the type of meta data stored + @return True if the specified meta data bock exists +*************************************************************************/ +PVR_DLL bool PVRTexLib_TextureHasMetaData(PVRTexLib_CPVRTextureHeader header, PVRTuint32 devFOURCC, PVRTuint32 key); + +/*!*********************************************************************** + @brief Sets a texture's bump map data. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] bumpScale Floating point "height" value to scale the bump map. + @param[in] bumpOrder Up to 4 character string, with values x,y,z,h in + some combination. Not all values need to be present. + Denotes channel order; x,y,z refer to the + corresponding axes, h indicates presence of the + original height map. It is possible to have only some + of these values rather than all. For example if 'h' + is present alone it will be considered a height map. + The values should be presented in RGBA order, regardless + of the texture format, so a zyxh order in a bgra texture + should still be passed as 'xyzh'. Capitals are allowed. + Any character stored here that is not one of x,y,z,h + or a NULL character will be ignored when PVRTexLib + reads the data, but will be preserved. This is useful + if you wish to define a custom data channel for instance. + In these instances PVRTexLib will assume it is simply + colour data. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureBumpMap(PVRTexLib_PVRTextureHeader header, float bumpScale, const char* bumpOrder); + +/*!*********************************************************************** + @brief Sets the texture atlas coordinate meta data for later display. + It is up to the user to make sure that this texture atlas + data actually makes sense in the context of the header. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] atlasData Pointer to an array of atlas data. + @param[in] dataSize Number of floats in atlasData. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureAtlas(PVRTexLib_PVRTextureHeader header, const float* atlasData, PVRTuint32 dataSize); + +/*!*********************************************************************** + @brief Sets the texture's face ordering. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] cubeMapOrder Up to 6 character string, with values + x,X,y,Y,z,Z in some combination. Not all + values need to be present. Denotes face + order; Capitals refer to positive axis + positions and small letters refer to + negative axis positions. E.g. x=X-Negative, + X=X-Positive. It is possible to have only + some of these values rather than all, as + long as they are NULL terminated. + NB: Values past the 6th character are not read. +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureCubeMapOrder(PVRTexLib_PVRTextureHeader header, const char* cubeMapOrder); + +/*!*********************************************************************** + @brief Sets a texture's border size data. This value is subtracted + from the current texture height/width/depth to get the valid + texture data. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] borderWidth Border width + @param[in] borderHeight Border height + @param[in] borderDepth Border depth +*************************************************************************/ +PVR_DLL void PVRTexLib_SetTextureBorder(PVRTexLib_PVRTextureHeader header, PVRTuint32 borderWidth, PVRTuint32 borderHeight, PVRTuint32 borderDepth); + +/*!*********************************************************************** + @brief Adds an arbitrary piece of meta data. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] dataBlock Meta data block to be added. +*************************************************************************/ +PVR_DLL void PVRTexLib_AddMetaData(PVRTexLib_PVRTextureHeader header, const PVRTexLib_MetaDataBlock* dataBlock); + +/*!*********************************************************************** + @brief Removes a specified piece of meta data, if it exists. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] DevFOURCC Four character descriptor representing the + creator of the meta data + @param[in] u32Key Key value representing the type of meta data stored. +*************************************************************************/ +PVR_DLL void PVRTexLib_RemoveMetaData(PVRTexLib_PVRTextureHeader header, PVRTuint32 devFOURCC, PVRTuint32 key); + +/*!*********************************************************************** + @brief Creates a new texture based on a texture header, + and optionally copies the supplied texture data. + @param[in] header A handle to a previously allocated PVRTexLib_PVRTextureHeader. + @param[in] data Texture data (may be NULL) + @return A new texture handle. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTexture PVRTexLib_CreateTexture(PVRTexLib_CPVRTextureHeader header, const void* data); + +/*!*********************************************************************** + @brief Creates a copy of the supplied texture. + @param[in] texture A handle to a PVRTexLib_PVRTexture to copy from. + @return A new texture handle. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTexture PVRTexLib_CopyTexture(PVRTexLib_CPVRTexture texture); + +/*!*********************************************************************** + @brief Creates a new texture, moving the contents of the + supplied texture into the new texture. + @param[in] texture A handle to a PVRTexLib_PVRTexture to move from. + @return A new texture handle. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTexture PVRTexLib_MoveTexture(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Free a texture. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. +*************************************************************************/ +PVR_DLL void PVRTexLib_DestroyTexture(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Creates a new texture from a file. + Accepted file formats are: PVR, KTX, KTX2, ASTC, DDS, BASIS, + PNG, JPEG, BMP, TGA, GIF, HDR, EXR, PSD, PPM, PGM and PIC + @param[in] filePath File path to the texture to load from. + @return A new texture handle OR NULL on failure. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTexture PVRTexLib_CreateTextureFromFile(const char* filePath); + +/*!*********************************************************************** + @brief Creates a new texture from a pointer that includes a header + structure, meta data and texture data as laid out in a file. + This functionality is primarily for user-defined file loading. + Header may be any version of pvr. + @param[in] data Pointer to texture data + @return A new texture handle OR NULL on failure. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTexture PVRTexLib_CreateTextureFromData(const void* data); + +/*!*********************************************************************** + @brief Returns a pointer to the texture's data. + The data offset is calculated using the parameters below. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel Offset to MIP Map levels + @param[in] arrayMember Offset to array members + @param[in] faceNumber Offset to face numbers + @param[in] ZSlice Offset to Z slice (3D textures only) + @return Pointer into the texture data OR NULL on failure. +*************************************************************************/ +PVR_DLL void* PVRTexLib_GetTextureDataPtr(PVRTexLib_PVRTexture texture, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 faceNumber, + PVRTuint32 ZSlice); + +/*!*********************************************************************** + @brief Returns a const pointer to the texture's data. + The data offset is calculated using the parameters below. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel Offset to MIP Map levels + @param[in] arrayMember Offset to array members + @param[in] faceNumber Offset to face numbers + @param[in] ZSlice Offset to Z slice (3D textures only) + @return Pointer into the texture data OR NULL on failure. +*************************************************************************/ +PVR_DLL const void* PVRTexLib_GetTextureDataConstPtr( + PVRTexLib_CPVRTexture texture, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 faceNumber, + PVRTuint32 ZSlice); + +/*!*********************************************************************** + @brief Returns a read only texture header. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return PVRTexLib_PVRTextureHeader handle. +*************************************************************************/ +PVR_DLL PVRTexLib_CPVRTextureHeader PVRTexLib_GetTextureHeader(PVRTexLib_CPVRTexture texture); + +/*!*********************************************************************** + @brief Gets a write-able handle to the texture header. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return PVRTexLib_PVRTextureHeader handle. +*************************************************************************/ +PVR_DLL PVRTexLib_PVRTextureHeader PVRTexLib_GetTextureHeaderW(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Pads the texture data to a boundary value equal to "padding". + For example setting padding=8 will align the start of the + texture data to an 8 byte boundary. + NB: This should be called immediately before saving as + the value is worked out based on the current meta data size. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] padding Padding boundary value +*************************************************************************/ +PVR_DLL void PVRTexLib_AddPaddingMetaData(PVRTexLib_PVRTexture texture, PVRTuint32 padding); + +/*!*********************************************************************** + @brief Saves the texture to a given file path. + File type will be determined by the extension present in the string. + Valid extensions are: PVR, KTX, KTX2, ASTC, DDS, BASIS and h + If no extension is present the PVR format will be selected. + Unsupported formats will result in failure. + ASTC files only support ASTC texture formats. + BASIS files only support Basis Universal texture formats. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] filepath File path to write to + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SaveTextureToFile(PVRTexLib_CPVRTexture texture, const char* filePath); + +/*!*********************************************************************** + @brief Similar to PVRTexLib_SaveTextureToFile, but redirects + the data to a memory buffer instead of a file. + Caller is responsible for de-allocating memory. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] fileType File container type to wrap the texture data with. + @param[in] privateData Pointer to a user supplied allocation context. + PVRTexLib will pass this into pfnRealloc when a [re]allocation + is required. + @param[out] outSize Size, in bytes, of the resulting 'file'/data. + @param[in] pfnRealloc Callback function to reallocate memory on-demand. + Return NULL to indicate allocation failure. + @return True if the method succeeds. + N.B This function may allocate even if it fails. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SaveTextureToMemory( + PVRTexLib_CPVRTexture texture, + PVRTexLibFileContainerType fileType, + void* privateData, + PVRTuint64* outSize, + PVRTuint8*(pfnRealloc)(void* privateData, PVRTuint64 allocSize)); + +/*!*********************************************************************** + @brief Writes out a single surface to a given image file. + @details File type is determined by the extension present in the filepath string. + Supported file types are PNG, JPG, BMP, TGA and HDR. + If no extension is present then the PNG format will be selected. + Unsupported formats will result in failure. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] filepath Path to write the image file. + @param[in] MIPLevel Mip level. + @param[in] arrayMember Array index. + @param[in] face Face index. + @param[in] ZSlice Z index. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SaveSurfaceToImageFile( + PVRTexLib_CPVRTexture texture, + const char* filePath, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 ZSlice); + +/*!*********************************************************************** + @brief Saves the texture to a file, stripping any + extensions specified and appending .pvr. This function is + for legacy support only and saves out to PVR Version 2 file. + The target api must be specified in order to save to this format. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] filepath File path to write to + @param[in] api Target API + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SaveTextureToLegacyPVRFile(PVRTexLib_PVRTexture texture, const char* filePath, PVRTexLibLegacyApi api); + +/*!*********************************************************************** + @brief Queries the texture object to determine if there are multiple + texture objects associated with the handle. This may be the + case after loading certain file types such as EXR, since EXR + files may contain several images/layers with unique pixel formats. + In these cases PVRTexLib will group all images with the same + pixel format into a single PVRTexLib_PVRTexture object, where + each PVRTexLib_PVRTexture can contain multiple array surfaces. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return True if texture contains more than one PVRTexLib_PVRTexture. +*************************************************************************/ +PVR_DLL bool PVRTexLib_IsTextureMultiPart(PVRTexLib_CPVRTexture texture); + +/*!*********************************************************************** + @brief Retrieves (and moves ownership of) the PVRTexLib_PVRTexture handles + stored within a multi-part texture and stores them in 'outTextures'. + Call this function with 'outTextures' == NULL to populate count + and then allocate an appropriately sized array. Handles returned + in 'outTextures' should be de-allocated as normal via + PVRTexLib_DestroyTexture. After calling this function, subsequent + calls to PVRTexLib_IsTextureMultiPart on the same handle will + return false. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] outTextures Array of PVRTexLib_PVRTexture handles to be populated. + All returned handles are independent of each other and 'inTexture'. + @param[out] count The number of parts held by inTexture +*************************************************************************/ +PVR_DLL void PVRTexLib_GetTextureParts(PVRTexLib_PVRTexture inTexture, void** outTextures, PVRTuint32 *count); + +/*!*********************************************************************** + @brief Resizes the texture to new specified dimensions. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] newWidth New width + @param[in] newHeight New height + @param[in] newDepth New depth + @param[in] resizeMode Filtering mode + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_ResizeTexture( + PVRTexLib_PVRTexture texture, + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTexLibResizeMode resizeMode); + +/*!*********************************************************************** + @brief Resizes the canvas of a texture to new specified dimensions. + Offset area is filled with transparent black colour. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] u32NewWidth New width + @param[in] u32NewHeight New height + @param[in] u32NewDepth New depth + @param[in] i32XOffset X Offset value from the top left corner + @param[in] i32YOffset Y Offset value from the top left corner + @param[in] i32ZOffset Z Offset value from the top left corner + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_ResizeTextureCanvas( + PVRTexLib_PVRTexture texture, + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTint32 xOffset, + PVRTint32 yOffset, + PVRTint32 zOffset); + +/*!*********************************************************************** + @brief Rotates a texture by 90 degrees around the given axis. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] rotationAxis Rotation axis + @param[in] forward Direction of rotation; true = clockwise, false = anti-clockwise + @return True if the method succeeds or not. +*************************************************************************/ +PVR_DLL bool PVRTexLib_RotateTexture(PVRTexLib_PVRTexture texture, PVRTexLibAxis rotationAxis, bool forward); + +/*!*********************************************************************** + @brief Flips a texture on a given axis. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] flipDirection Flip direction + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_FlipTexture(PVRTexLib_PVRTexture texture, PVRTexLibAxis flipDirection); + +/*!*********************************************************************** + @brief Adds a user specified border to the texture. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] borderX X border + @param[in] borderY Y border + @param[in] borderZ Z border + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_BorderTexture(PVRTexLib_PVRTexture texture, PVRTuint32 borderX, PVRTuint32 borderY, PVRTuint32 borderZ); + +/*!*********************************************************************** + @brief Pre-multiplies a texture's colours by its alpha values. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_PreMultiplyAlpha(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Allows a texture's colours to run into any fully transparent areas. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_Bleed(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Sets the specified number of channels to values specified in pValues. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] numChannelSets Number of channels to set + @param[in] channels Channels to set + @param[in] pValues uint32 values to set channels to + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureChannels( + PVRTexLib_PVRTexture texture, + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const PVRTuint32* pValues); + +/*!*********************************************************************** + @brief Sets the specified number of channels to values specified in float pValues. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] numChannelSets Number of channels to set + @param[in] channels Channels to set + @param[in] pValues float values to set channels to + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_SetTextureChannelsFloat( + PVRTexLib_PVRTexture texture, + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const float* pValues); + +/*!*********************************************************************** + @brief Copies the specified channels from textureSource + into textureDestination. textureSource is not modified so it + is possible to use the same texture as both input and output. + When using the same texture as source and destination, channels + are preserved between swaps e.g. copying Red to Green and then + Green to Red will result in the two channels trading places + correctly. Channels in eChannels are set to the value of the channels + in eChannelSource. + @param[in] textureDestination A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureSource A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] uiNumChannelCopies Number of channels to copy + @param[in] destinationChannels Channels to set + @param[in] sourceChannels Source channels to copy from + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_CopyTextureChannels( + PVRTexLib_PVRTexture textureDestination, + PVRTexLib_CPVRTexture textureSource, + PVRTuint32 numChannelCopies, + const PVRTexLibChannelName* destinationChannels, + const PVRTexLibChannelName* sourceChannels); + +/*!*********************************************************************** + @brief Generates a Normal Map from a given height map. + Assumes the red channel has the height values. + By default outputs to red/green/blue = x/y/z, + this can be overridden by specifying a channel + order in channelOrder. The channels specified + will output to red/green/blue/alpha in that order. + So "xyzh" maps x to red, y to green, z to blue + and h to alpha. 'h' is used to specify that the + original height map data should be preserved in + the given channel. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] fScale Scale factor + @param[in] channelOrder Channel order + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GenerateNormalMap(PVRTexLib_PVRTexture texture, float fScale, const char* channelOrder); + +/*!*********************************************************************** + @brief Generates MIPMap chain for a texture. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] filterMode Filter mode + @param[in] mipMapsToDo Number of levels of MIPMap chain to create. + Use PVRTEX_ALLMIPLEVELS to create a full mip chain. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GenerateMIPMaps(PVRTexLib_PVRTexture texture, PVRTexLibResizeMode filterMode, PVRTint32 mipMapsToDo); + +/*!*********************************************************************** + @brief Colours a texture's MIPMap levels with different colours + for debugging purposes. MIP levels are coloured in the + following repeating pattern: Red, Green, Blue, Cyan, + Magenta and Yellow + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_ColourMIPMaps(PVRTexLib_PVRTexture texture); + +/*!*********************************************************************** + @brief Transcodes a texture from its original format into the specified format. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] transcoderOptions struct containing transcoder options. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_TranscodeTexture(PVRTexLib_PVRTexture texture, const PVRTexLib_TranscoderOptions& transcoderOptions); + +/*!*********************************************************************** + @brief A convenience function to decompresses a texture into the most + appropriate format based on the textures 'compressed' format, + for example a PVRTC compressed texture may decompress to RGB888 + or RGBA8888. This function may also be used to 'decompress' + packed formats into something easier to manipulate for example + RGB565 will be decompressed to RGB888. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] maxThreads The maximum number of threads to use for decompression, + if set to 0 PVRTexLib will use all available cores. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_Decompress(PVRTexLib_PVRTexture texture, PVRTuint32 maxThreads); + +/*!*********************************************************************** + @brief Creates a cubemap with six faces from an equirectangular + projected texture. The input must have an aspect ratio of 2:1, + i.e. the width must be exactly twice the height. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] filterMode Filtering mode to apply when sampling the source texture. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_EquiRectToCubeMap(PVRTexLib_PVRTexture texture, PVRTexLibResizeMode filter); + +/*!*********************************************************************** + @brief Generates a mipmapped diffuse irradiance texture from a cubemap + environment map, to be used primarily with physically based + rendering (PBR) techniques. + The input must be a cubemap, the width must equal height, + and the depth must equal 1. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] sampleCount The number of samples to use when generating + the diffuse map. + @param[in] mapSize Output dimensions, in pixels. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GenerateDiffuseIrradianceCubeMap(PVRTexLib_PVRTexture texture, PVRTuint32 sampleCount, PVRTuint32 mapSize); + +/*!*********************************************************************** + @brief Generates a prefiltered specular irradiance texture from a + cubemap environment map, to be used primarily with physically + based rendering (PBR) techniques. + Each Mip level of the specular map is blurred by a roughness + value between 0 and 1. + The input must be a cubemap, the width must equal height, + and the depth must equal 1. + @param[in] texture A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] sampleCount The number of samples to use when generating + the specular map. + @param[in] mapSize Output dimensions, in pixels. + @param[in] numMipLevelsToDiscard The number of Mip levels to be discarded + from the bottom of the Mip chain. + @param[in] zeroRoughnessIsExternal False to include a roughness of zero + when generating the prefiltered environment map. + True to omit a rougness of zero, implying that the user + will supply roughness zero from the environment texture. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_GeneratePreFilteredSpecularCubeMap( + PVRTexLib_PVRTexture texture, + PVRTuint32 sampleCount, + PVRTuint32 mapSize, + PVRTuint32 numMipLevelsToDiscard, + bool zeroRoughnessIsExternal); + +/*!*********************************************************************** + @brief Computes the maximum difference between two given input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_MaxDifference( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the mean error between two given input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_MeanError( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the mean squared error (MSE) between two given input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_MeanSquaredError( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the root mean squared error (RMSE) between two given + input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_RootMeanSquaredError( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the standard deviation between two given input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_StandardDeviation( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the PSNR between two given input textures. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both input textures. Both textures must have the + same dimensions. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @param[out] metrics Structure containing the resulting values. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_PeakSignalToNoiseRatio( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice, + PVRTexLib_ErrorMetrics* metrics); + +/*!*********************************************************************** + @brief Computes the the [mode] delta per channel between two given + input textures. Both textures must have the same dimensions and + may not be compressed. The function will only compare common + channels i.e. if 'LHS' has RGB while 'RHS' has RGBA channels, + then only the RGB channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[out] textureResult PVRTexLib_PVRTexture that will contain the result on success. + @param[in] multiplier The factor to multiply the deltas to highlight differences, + generally a value between 1 and 10. + @param[in] mode The clamping mode to use, currently supports absolute and signed. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_ColourDiff( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTexLib_PVRTexture* textureResult, + float multiplier, + PVRTexLibColourDiffMode mode); + +/*!*********************************************************************** + @brief Computes the total absolute pixel difference between two given + input textures and modulates the output based on the tolerance + value supplied. Deltas of zero will appear black while pixels + with deltas greater than or equal to the threshold are set to + red and finally deltas less than the tolerance are set to blue. + Both textures must have the same dimensions and may not be + compressed. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[out] textureResult PVRTexLib_PVRTexture that will contain the result on success. + @param[in] tolerance The cut-off value to compare the pixel delta to. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_ToleranceDiff( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTexLib_PVRTexture* textureResult, + float tolerance); + +/*!*********************************************************************** + @brief Blend each channel of the input textures using the blend factor + as a weighting of the first texture against the second. + Both textures must have the same dimensions and may not be + compressed. The function will only blend common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be blended. + @param[in] textureLHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[in] textureRHS A handle to a previously allocated PVRTexLib_PVRTexture. + @param[out] textureResult PVRTexLib_PVRTexture that will contain the result on success. + @param[in] blendFactor The blend weight to use in the blend equation: + (LHS_delta * BF) + (RHS_delta * (1 - BF)). The value is clamped + between 0 and 1. + @return True if the method succeeds. +*************************************************************************/ +PVR_DLL bool PVRTexLib_BlendDiff( + PVRTexLib_CPVRTexture textureLHS, + PVRTexLib_CPVRTexture textureRHS, + PVRTexLib_PVRTexture* textureResult, + float blendFactor); + +#ifdef __cplusplus +} +#endif + +/***************************************************************************** +End of file (PVRTexLib.h) +*****************************************************************************/ \ No newline at end of file diff --git a/deps/PVRTT/Include/PVRTexLib.hpp b/deps/PVRTT/Include/PVRTexLib.hpp new file mode 100755 index 0000000000..449fa8e8e1 --- /dev/null +++ b/deps/PVRTT/Include/PVRTexLib.hpp @@ -0,0 +1,2657 @@ +/*!*********************************************************************** + @file PVRTexLib.hpp + @copyright Copyright (c) Imagination Technologies Limited. + @brief C++ wrapper around PVRTexLib's C interface. +*************************************************************************/ +#pragma once + +#include "PVRTexLib.h" +#include +#include +#include +#include +#include +#include + +namespace pvrtexlib +{ + struct MetaDataBlock + { + PVRTuint32 DevFOURCC; ///< A 4cc descriptor of the data type's creator. Values equating to values between 'P' 'V' 'R' 0 and 'P' 'V' 'R' 255 will be used by our headers. + PVRTuint32 u32Key; ///< A DWORD (enum value) identifying the data type, and thus how to read it. + PVRTuint32 u32DataSize; ///< Size of the Data member. + std::unique_ptr Data; ///< Meta data bytes + + MetaDataBlock() + : DevFOURCC(PVRTEX_CURR_IDENT) + , u32Key() + , u32DataSize() + , Data() + {} + }; + + /*!*********************************************************************** + @brief Texture header methods. + @details Setters & getters for pixel type, channel type and colour space. + Size retrieval and dimension manipulation. Setters & getters for + texture meta data. + *************************************************************************/ + class PVRTextureHeader + { + public: + /*!*********************************************************************** + @brief Creates a new texture header with default parameters. + @param[in] params PVRHeader_CreateParams + @return A new PVRTextureHeader + *************************************************************************/ + inline PVRTextureHeader(); + + /*!*********************************************************************** + @brief Creates a new texture header using the supplied parameters. + @param[in] params PVRHeader_CreateParams + @return A new PVRTextureHeader + *************************************************************************/ + inline PVRTextureHeader(const PVRHeader_CreateParams* params); + + /*!*********************************************************************** + @brief Creates a new texture header using the supplied parameters. + @param[in] pixelFormat texture format + @param[in] width texture width in pixels + @param[in] height texture height in pixels + @param[in] depth texture depth + @param[in] numMipMaps number of MIP map levels + @param[in] numArrayMembers number of array members + @param[in] numFaces number of faces + @param[in] colourSpace colour space + @param[in] channelType channel type + @param[in] preMultiplied texture's colour has been pre-multiplied by the alpha values? + @return A new PVRTextureHeader + *************************************************************************/ + inline PVRTextureHeader( + PVRTuint64 pixelFormat, + PVRTuint32 width, + PVRTuint32 height, + PVRTuint32 depth = 1U, + PVRTuint32 numMipMaps = 1U, + PVRTuint32 numArrayMembers = 1U, + PVRTuint32 numFaces = 1U, + PVRTexLibColourSpace colourSpace = PVRTexLibColourSpace::PVRTLCS_sRGB, + PVRTexLibVariableType channelType = PVRTexLibVariableType::PVRTLVT_UnsignedByteNorm, + bool preMultiplied = false); + + /*!*********************************************************************** + @brief Creates a new texture header from a PVRTextureHeader + @param[in] rhs Texture header to copy + @return A new PVRTextureHeader + *************************************************************************/ + inline PVRTextureHeader(const PVRTextureHeader& rhs); + + /*!*********************************************************************** + @brief Creates a new texture, moving the contents of the + supplied texture into the new texture. + @param[in] texture A PVRTextureHeader to move from. + @return A new PVRTextureHeader. + *************************************************************************/ + inline PVRTextureHeader(PVRTextureHeader&& rhs) noexcept; + + /*!*********************************************************************** + @brief Copies the contents of another texture header into this one. + @param[in] rhs PVRTextureHeader to copy + @return This texture header. + *************************************************************************/ + inline PVRTextureHeader& operator=(const PVRTextureHeader& rhs); + + /*!*********************************************************************** + @brief Moves ownership of texture header data to this object. + @param[in] rhs PVRTextureHeader to move + @return This texture header. + *************************************************************************/ + inline PVRTextureHeader& operator=(PVRTextureHeader&& rhs) noexcept; + + /*!*********************************************************************** + @brief Deconstructor for PVRTextureHeader. + *************************************************************************/ + inline virtual ~PVRTextureHeader(); + + /*!*********************************************************************** + @brief Gets the number of bits per pixel for this texture header. + @return Number of bits per pixel. + *************************************************************************/ + inline PVRTuint32 GetTextureBitsPerPixel() const; + + /*!*********************************************************************** + @brief Gets the number of bits per pixel for the specified pixel format. + @param u64PixelFormat A PVR pixel format ID. + @return Number of bits per pixel. + *************************************************************************/ + static inline PVRTuint32 GetTextureBitsPerPixel(PVRTuint64 u64PixelFormat); + + /*!*********************************************************************** + @brief Gets the number of channels for this texture header. + @return For uncompressed formats the number of channels between 1 and 4. + For compressed formats 0 + *************************************************************************/ + inline PVRTuint32 GetTextureChannelCount() const; + + /*!*********************************************************************** + @brief Gets the channel type for this texture header. + @return PVRTexLibVariableType enum. + *************************************************************************/ + inline PVRTexLibVariableType GetTextureChannelType() const; + + /*!*********************************************************************** + @brief Gets the colour space for this texture header. + @return PVRTexLibColourSpace enum. + *************************************************************************/ + inline PVRTexLibColourSpace GetColourSpace() const; + + /*!*********************************************************************** + @brief Gets the width of the user specified MIP-Map level for the + texture + @param[in] uiMipLevel MIP level that user is interested in. + @return Width of the specified MIP-Map level. + *************************************************************************/ + inline PVRTuint32 GetTextureWidth(PVRTuint32 mipLevel = 0U) const; + + /*!*********************************************************************** + @brief Gets the height of the user specified MIP-Map + level for the texture + @param[in] uiMipLevel MIP level that user is interested in. + @return Height of the specified MIP-Map level. + *************************************************************************/ + inline PVRTuint32 GetTextureHeight(PVRTuint32 mipLevel = 0U) const; + + /*!*********************************************************************** + @brief Gets the depth of the user specified MIP-Map + level for the texture + @param[in] uiMipLevel MIP level that user is interested in. + @return Depth of the specified MIP-Map level. + *************************************************************************/ + inline PVRTuint32 GetTextureDepth(PVRTuint32 mipLevel = 0U) const; + + /*!*********************************************************************** + @brief Gets the size in PIXELS of the texture, given various input + parameters. User can retrieve the total 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. + @param[in] iMipLevel Specifies a MIP level to check, + 'PVRTEX_ALLMIPLEVELS' can be passed to get + the size of all MIP levels. + @param[in] bAllSurfaces Size of all surfaces is calculated if true, + only a single surface if false. + @param[in] bAllFaces Size of all faces is calculated if true, + only a single face if false. + @return Size in PIXELS of the specified texture area. + *************************************************************************/ + inline PVRTuint32 GetTextureSize(PVRTint32 mipLevel = PVRTEX_ALLMIPLEVELS, bool allSurfaces = true, bool allFaces = true) const; + + /*!*********************************************************************** + @brief 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. + @param[in] iMipLevel Specifies a mip level to check, + 'PVRTEX_ALLMIPLEVELS' can be passed to get + the size of all MIP levels. + @param[in] bAllSurfaces Size of all surfaces is calculated if true, + only a single surface if false. + @param[in] bAllFaces Size of all faces is calculated if true, + only a single face if false. + @return Size in BYTES of the specified texture area. + *************************************************************************/ + inline PVRTuint64 GetTextureDataSize(PVRTint32 mipLevel = PVRTEX_ALLMIPLEVELS, bool allSurfaces = true, bool allFaces = true) const; + + /*!*********************************************************************** + @brief Gets the data orientation for this texture. + @param[in,out] result Pointer to a PVRTexLib_Orientation structure. + *************************************************************************/ + inline void GetTextureOrientation(PVRTexLib_Orientation& result) const; + + /*!*********************************************************************** + @brief Gets the OpenGL equivalent format for this texture. + @param[in,out] result Pointer to a PVRTexLib_OpenGLFormat structure. + *************************************************************************/ + inline void GetTextureOpenGLFormat(PVRTexLib_OpenGLFormat& result) const; + + /*!*********************************************************************** + @brief Gets the OpenGLES equivalent format for this texture. + @param[in,out] result Pointer to a PVRTexLib_OpenGLESFormat structure. + *************************************************************************/ + inline void GetTextureOpenGLESFormat(PVRTexLib_OpenGLESFormat& result) const; + + /*!*********************************************************************** + @brief Gets the Vulkan equivalent format for this texture. + @return A VkFormat enum value. + *************************************************************************/ + inline PVRTuint32 GetTextureVulkanFormat() const; + + /*!*********************************************************************** + @brief Gets the Direct3D equivalent format for this texture. + @return A D3DFORMAT enum value. + *************************************************************************/ + inline PVRTuint32 GetTextureD3DFormat() const; + + /*!*********************************************************************** + @brief Gets the DXGI equivalent format for this texture. + @return A DXGI_FORMAT enum value. + *************************************************************************/ + inline PVRTuint32 GetTextureDXGIFormat() const; + + /*!*********************************************************************** + @brief Gets the minimum dimensions (x,y,z) + for the textures pixel format. + @param[in,out] minX Returns the minimum width. + @param[in,out] minY Returns the minimum height. + @param[in,out] minZ Returns the minimum depth. + *************************************************************************/ + inline void GetTextureFormatMinDims(PVRTuint32& minX, PVRTuint32& minY, PVRTuint32& minZ) const; + + /*!*********************************************************************** + @brief Gets the minimum dimensions (x,y,z) + for a given pixel format. + @param[in] u64PixelFormat A PVR Pixel Format ID. + @param[in,out] minX Returns the minimum width. + @param[in,out] minY Returns the minimum height. + @param[in,out] minZ Returns the minimum depth. + *************************************************************************/ + static inline void GetPixelFormatMinDims(PVRTuint64 ui64Format, PVRTuint32& minX, PVRTuint32& minY, PVRTuint32& minZ); + + /*!*********************************************************************** + @brief Returns the total size of the meta data stored in the header. + This includes the size of all information stored in all MetaDataBlocks. + @return Size, in bytes, of the meta data stored in the header. + *************************************************************************/ + inline PVRTuint32 GetTextureMetaDataSize() const; + + /*!*********************************************************************** + @brief Returns whether or not the texture's colour has been + pre-multiplied by the alpha values. + @return True if texture is premultiplied. + *************************************************************************/ + inline bool GetTextureIsPreMultiplied() const; + + /*!*********************************************************************** + @brief Returns whether or not the texture is compressed using + PVRTexLib's FILE compression - this is independent of + any texture compression. + @return True if it is file compressed. + *************************************************************************/ + inline bool GetTextureIsFileCompressed() const; + + /*!*********************************************************************** + @brief Returns whether or not the texture is a bump map. + @return True if it is a bump map. + *************************************************************************/ + inline bool GetTextureIsBumpMap() const; + + /*!*********************************************************************** + @brief Gets the bump map scaling value for this texture. + If the texture is not a bump map, 0.0f is returned. If the + texture is a bump map but no meta data is stored to + specify its scale, then 1.0f is returned. + @return Returns the bump map scale value as a float. + *************************************************************************/ + inline float GetTextureBumpMapScale() const; + + /*!*********************************************************************** + @brief Works out the number of possible texture atlas members in + the texture based on the width, height, depth and data size. + @return The number of sub textures defined by meta data. + *************************************************************************/ + inline PVRTuint32 GetNumTextureAtlasMembers() const; + + /*!*********************************************************************** + @brief Returns a pointer to the texture atlas data. + @param[in,out] count Number of floats in the returned data set. + @return A pointer directly to the texture atlas data. NULL if + the texture does not have atlas data. + *************************************************************************/ + inline const float* GetTextureAtlasData(PVRTuint32& count) const; + + /*!*********************************************************************** + @brief Gets the number of MIP-Map levels stored in this texture. + @return Number of MIP-Map levels in this texture. + *************************************************************************/ + inline PVRTuint32 GetTextureNumMipMapLevels() const; + + /*!*********************************************************************** + @brief Gets the number of faces stored in this texture. + @return Number of faces in this texture. + *************************************************************************/ + inline PVRTuint32 GetTextureNumFaces() const; + + /*!*********************************************************************** + @brief Gets the number of array members stored in this texture. + @return Number of array members in this texture. + *************************************************************************/ + inline PVRTuint32 GetTextureNumArrayMembers() const; + + /*!*********************************************************************** + @brief Gets the cube map face order. + cubeOrder string will be in the form "ZzXxYy" with capitals + representing positive and lower case letters representing + negative. I.e. Z=Z-Positive, z=Z-Negative. + @return Null terminated cube map order string. + *************************************************************************/ + inline std::string GetTextureCubeMapOrder() const; + + /*!*********************************************************************** + @brief Gets the bump map channel order relative to RGBA. + For example, an RGB texture with bumps mapped to XYZ returns + 'xyz'. A BGR texture with bumps in the order ZYX will also + return 'xyz' as the mapping is the same: R=X, G=Y, B=Z. + If the letter 'h' is present in the string, it means that + the height map has been stored here. + Other characters are possible if the bump map was created + manually, but PVRTexLib will ignore these characters. They + are returned simply for completeness. + @return Null terminated bump map order string relative to RGBA. + *************************************************************************/ + inline std::string GetTextureBumpMapOrder() const; + + /*!*********************************************************************** + @brief Gets the 64-bit pixel type ID of the texture. + @return 64-bit pixel type ID. + *************************************************************************/ + inline PVRTuint64 GetTexturePixelFormat() const; + + /*!*********************************************************************** + @brief Checks whether this textures pixel format is packed. + E.g. R5G6B5, R11G11B10, R4G4B4A4 etc. + @return True if the texture format is packed, false otherwise. + *************************************************************************/ + inline bool TextureHasPackedChannelData() const; + + /*!*********************************************************************** + @brief Checks whether this textures pixel format is compressed. + E.g. PVRTC, ETC, ASTC etc. + @return True if the texture format is compressed, false otherwise. + *************************************************************************/ + inline bool IsPixelFormatCompressed() const; + + /*!*********************************************************************** + @brief Sets the variable type for the channels in this texture. + @param[in] type A PVRTexLibVariableType enum. + *************************************************************************/ + inline void SetTextureChannelType(PVRTexLibVariableType type); + + /*!*********************************************************************** + @brief Sets the colour space for this texture. + @param[in] colourSpace A PVRTexLibColourSpace enum. + *************************************************************************/ + inline void SetTextureColourSpace(PVRTexLibColourSpace colourSpace); + + /*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the D3D format. + @param[in] d3dFormat A D3DFORMAT enum. + @return True if successful. + *************************************************************************/ + inline bool SetTextureD3DFormat(PVRTuint32 d3dFormat); + + /*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the DXGI format. + @param[in] dxgiFormat A DXGI_FORMAT enum. + @return True if successful. + *************************************************************************/ + inline bool SetTextureDXGIFormat(PVRTuint32 dxgiFormat); + + /*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the OpenGL format. + @param[in] oglFormat The OpenGL format. + @return True if successful. + *************************************************************************/ + inline bool SetTextureOGLFormat(const PVRTexLib_OpenGLFormat& oglFormat); + + /*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the OpenGLES format. + @param[in] oglesFormat The OpenGLES format. + @return True if successful. + *************************************************************************/ + inline bool SetTextureOGLESFormat(const PVRTexLib_OpenGLESFormat& oglesFormat); + + /*!*********************************************************************** + @brief Sets the format of the texture to PVRTexLib's internal + representation of the Vulkan format. + @param[in] vulkanFormat A VkFormat enum. + @return True if successful. + *************************************************************************/ + inline bool SetTextureVulkanFormat(PVRTuint32 vulkanFormat); + + /*!*********************************************************************** + @brief Sets the pixel format for this texture. + @param[in] format The format of the pixel. + *************************************************************************/ + inline void SetTexturePixelFormat(PVRTuint64 format); + + /*!*********************************************************************** + @brief Sets the texture width. + @param[in] width The new width. + *************************************************************************/ + inline void SetTextureWidth(PVRTuint32 width); + + /*!*********************************************************************** + @brief Sets the texture height. + @param[in] height The new height. + *************************************************************************/ + inline void SetTextureHeight(PVRTuint32 height); + + /*!*********************************************************************** + @brief Sets the texture depth. + @param[in] depth The new depth. + *************************************************************************/ + inline void SetTextureDepth(PVRTuint32 depth); + + /*!*********************************************************************** + @brief Sets the number of array members in this texture. + @param[in] newNumMembers The new number of array members. + *************************************************************************/ + inline void SetTextureNumArrayMembers(PVRTuint32 numMembers); + + /*!*********************************************************************** + @brief Sets the number of MIP-Map levels in this texture. + @param[in] numMIPLevels New number of MIP-Map levels. + *************************************************************************/ + inline void SetTextureNumMIPLevels(PVRTuint32 numMIPLevels); + + /*!*********************************************************************** + @brief Sets the number of faces stored in this texture. + @param[in] numFaces New number of faces for this texture. + *************************************************************************/ + inline void SetTextureNumFaces(PVRTuint32 numFaces); + + /*!*********************************************************************** + @brief Sets the data orientation for a given axis in this texture. + @param[in] orientation Pointer to a PVRTexLib_Orientation structure. + *************************************************************************/ + inline void SetTextureOrientation(const PVRTexLib_Orientation& orientation); + + /*!*********************************************************************** + @brief Sets whether or not the texture is compressed using + PVRTexLib's FILE compression - this is independent of + any texture compression. Currently unsupported. + @param[in] isFileCompressed Sets the file compression to true or false. + *************************************************************************/ + inline void SetTextureIsFileCompressed(bool isFileCompressed); + + /*!*********************************************************************** + @brief Sets whether or not the texture's colour has been + pre-multiplied by the alpha values. + @param[in] isPreMultiplied Sets if texture is premultiplied. + *************************************************************************/ + inline void SetTextureIsPreMultiplied(bool isPreMultiplied); + + /*!*********************************************************************** + @brief Obtains the border size in each dimension for this texture. + @param[in,out] borderWidth Border width + @param[in,out] borderHeight Border height + @param[in,out] borderDepth Border depth + *************************************************************************/ + inline void GetTextureBorder(PVRTuint32& borderWidth, PVRTuint32& borderHeight, PVRTuint32& borderDepth) const; + + /*!*********************************************************************** + @brief Returns a copy of a block of meta data from the texture. + If the meta data doesn't exist, a block with a data size + of 0 will be returned. + @param[in] key Value representing the type of meta data stored + @param[in,out] dataBlock returned meta block data + @param[in] devFOURCC Four character descriptor representing the + creator of the meta data + @return True if the meta data block was found. False otherwise. + *************************************************************************/ + inline bool GetMetaDataBlock(PVRTuint32 key, MetaDataBlock& dataBlock, PVRTuint32 devFOURCC = PVRTEX_CURR_IDENT) const; + + /*!*********************************************************************** + @brief Returns whether or not the specified meta data exists as + part of this texture header. + @param[in] u32Key Key value representing the type of meta data stored + @param[in] DevFOURCC Four character descriptor representing the + creator of the meta data + @return True if the specified meta data bock exists + *************************************************************************/ + inline bool TextureHasMetaData(PVRTuint32 key, PVRTuint32 devFOURCC = PVRTEX_CURR_IDENT) const; + + /*!*********************************************************************** + @brief Sets a texture's bump map data. + @param[in] bumpScale Floating point "height" value to scale the bump map. + @param[in] bumpOrder Up to 4 character string, with values x,y,z,h in + some combination. Not all values need to be present. + Denotes channel order; x,y,z refer to the + corresponding axes, h indicates presence of the + original height map. It is possible to have only some + of these values rather than all. For example if 'h' + is present alone it will be considered a height map. + The values should be presented in RGBA order, regardless + of the texture format, so a zyxh order in a bgra texture + should still be passed as 'xyzh'. Capitals are allowed. + Any character stored here that is not one of x,y,z,h + or a NULL character will be ignored when PVRTexLib + reads the data, but will be preserved. This is useful + if you wish to define a custom data channel for instance. + In these instances PVRTexLib will assume it is simply + colour data. + *************************************************************************/ + inline void SetTextureBumpMap(float bumpScale, const std::string& bumpOrder); + + /*!*********************************************************************** + @brief Sets the texture atlas coordinate meta data for later display. + It is up to the user to make sure that this texture atlas + data actually makes sense in the context of the header. + @param[in] atlasData Pointer to an array of atlas data. + @param[in] dataSize Number of floats in atlasData. + *************************************************************************/ + inline void SetTextureAtlas(const float* atlasData, PVRTuint32 dataSize); + + /*!*********************************************************************** + @brief Sets the texture's face ordering. + @param[in] cubeMapOrder Up to 6 character string, with values + x,X,y,Y,z,Z in some combination. Not all + values need to be present. Denotes face + order; Capitals refer to positive axis + positions and small letters refer to + negative axis positions. E.g. x=X-Negative, + X=X-Positive. It is possible to have only + some of these values rather than all, as + long as they are NULL terminated. + NB: Values past the 6th character are not read. + *************************************************************************/ + inline void SetTextureCubeMapOrder(const std::string& cubeMapOrder); + + /*!*********************************************************************** + @brief Sets a texture's border size data. This value is subtracted + from the current texture height/width/depth to get the valid + texture data. + @param[in] borderWidth Border width + @param[in] borderHeight Border height + @param[in] borderDepth Border depth + *************************************************************************/ + inline void SetTextureBorder(PVRTuint32 borderWidth, PVRTuint32 borderHeight, PVRTuint32 borderDepth); + + /*!*********************************************************************** + @brief Adds an arbitrary piece of meta data. + @param[in] dataBlock Meta data block to be added. + *************************************************************************/ + inline void AddMetaData(const MetaDataBlock& dataBlock); + + /*!*********************************************************************** + @brief Adds an arbitrary piece of meta data. + @param[in] dataBlock Meta data block to be added. + *************************************************************************/ + inline void AddMetaData(const PVRTexLib_MetaDataBlock& dataBlock); + + /*!*********************************************************************** + @brief Removes a specified piece of meta data, if it exists. + @param[in] u32Key Key value representing the type of meta data stored. + @param[in] DevFOURCC Four character descriptor representing the + creator of the meta data + *************************************************************************/ + inline void RemoveMetaData(PVRTuint32 key, PVRTuint32 devFOURCC = PVRTEX_CURR_IDENT); + + protected: + inline PVRTextureHeader(bool); + static inline PVRTexLib_CPVRTextureHeader GetHeader(const PVRTextureHeader& header); + PVRTexLib_PVRTextureHeader m_hTextureHeader; + }; + + /*!*********************************************************************** + @brief Texture loading, saving and manipulation. + @details Methods to load and save texture data to various container + and image file formats such as; PVR, KTX, Basis, PNG, JPG and HDR. + Methods for image manipulation operations such as; compressing, + transcoding, resizing and generating MIP chains & normal maps etc. + Also allows for direct data access. + *************************************************************************/ + class PVRTexture : public PVRTextureHeader + { + public: + /*!*********************************************************************** + @brief Default constructor. + @return A new texture object. + *************************************************************************/ + inline PVRTexture(); + + /*!*********************************************************************** + @brief Creates a new texture based on a texture header, + and optionally copies the supplied texture data. + @param[in] header A PVRTextureHeader. + @param[in] data Texture data (may be NULL) + @return A new texture object. + *************************************************************************/ + inline PVRTexture(const PVRTextureHeader& header, const void *textureData); + + /*!*********************************************************************** + @brief Creates a new texture from a file. + Accepted file formats are: PVR, KTX, KTX2, ASTC, DDS, BASIS, + PNG, JPEG, BMP, TGA, GIF, HDR, EXR, PSD, PPM, PGM and PIC + @param[in] filePath File path to a texture to load from. + @return A new texture object. + *************************************************************************/ + inline PVRTexture(const std::string& filePath); + + /*!*********************************************************************** + @brief Creates a new texture from a file. + Accepted file formats are: PVR, KTX, KTX2, ASTC, DDS, BASIS, + PNG, JPEG, BMP, TGA, GIF, HDR, EXR, PSD, PPM, PGM and PIC + @param[in] filePath File path to a texture to load from. + @return A new texture object. + *************************************************************************/ + inline PVRTexture(const char* filePath); + + /*!*********************************************************************** + @brief Creates a new texture from a pointer that includes a header + structure, meta data and texture data as laid out in a file. + This functionality is primarily for user-defined file loading. + Header may be any version of PVR. + @param[in] data Pointer to texture data + @return A new texture object. + *************************************************************************/ + inline explicit PVRTexture(const void* data); + + /*!*********************************************************************** + @brief Creates a copy of the supplied texture. + @param[in] texture A PVRTexture to copy from. + @return A new texture object. + *************************************************************************/ + inline PVRTexture(const PVRTexture& rhs); + + /*!*********************************************************************** + @brief Creates a new texture, moving the contents of the + supplied texture into the new texture. + @param[in] texture A PVRTexture to move from. + @return A new texture object. + *************************************************************************/ + inline PVRTexture(PVRTexture&& rhs) noexcept; + + /*!*********************************************************************** + @brief Copies the contents of another texture into this one. + @param[in] rhs Texture to copy + @return This texture. + *************************************************************************/ + inline PVRTexture& operator=(const PVRTexture& rhs); + + /*!*********************************************************************** + @brief Moves ownership of texture data to this object. + @param[in] rhs Texture to move + @return This texture. + *************************************************************************/ + inline PVRTexture& operator=(PVRTexture&& rhs) noexcept; + + /*!*********************************************************************** + @brief Deconstructor for PVRTexture. + *************************************************************************/ + inline ~PVRTexture(); + + /*!*********************************************************************** + @brief Returns a pointer to the texture's data. + The data offset is calculated using the parameters below. + @param[in] MIPLevel Offset to MIP Map levels + @param[in] arrayMember Offset to array members + @param[in] faceNumber Offset to face numbers + @param[in] ZSlice Offset to Z slice (3D textures only) + @return Pointer into the texture data OR NULL on failure. + *************************************************************************/ + inline void* GetTextureDataPointer( + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 faceNumber = 0U, + PVRTuint32 ZSlice = 0U); + + /*!*********************************************************************** + @brief Returns a constant pointer to the texture's data. + The data offset is calculated using the parameters below. + @param[in] MIPLevel Offset to MIP Map levels + @param[in] arrayMember Offset to array members + @param[in] faceNumber Offset to face numbers + @param[in] ZSlice Offset to Z slice (3D textures only) + @return Pointer into the texture data OR NULL on failure. + *************************************************************************/ + inline const void* GetTextureDataPointer( + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 faceNumber = 0U, + PVRTuint32 ZSlice = 0U) const; + + /*!*********************************************************************** + @brief Pads the texture data to a boundary value equal to "padding". + For example setting padding=8 will align the start of the + texture data to an 8 byte boundary. + NB: This should be called immediately before saving as + the value is worked out based on the current meta data size. + @param[in] padding Padding boundary value + *************************************************************************/ + inline void AddPaddingMetaData(PVRTuint32 padding); + + /*!*********************************************************************** + @brief Saves the texture to a given file path. + File type will be determined by the extension present in the string. + Valid extensions are: PVR, KTX, KTX2, ASTC, DDS, BASIS and h + If no extension is present the PVR format will be selected. + Unsupported formats will result in failure. + ASTC files only support ASTC texture formats. + BASIS files only support Basis Universal texture formats. + @param[in] filepath File path to write to + @return True if the method succeeds. + *************************************************************************/ + inline bool SaveToFile(const std::string& filePath) const; + + /*!*********************************************************************** + @brief Saves the texture to a file, stripping any + extensions specified and appending .pvr. This function is + for legacy support only and saves out to PVR Version 2 file. + The target api must be specified in order to save to this format. + @param[in] filepath File path to write to + @param[in] api Target API + @return True if the method succeeds. + *************************************************************************/ + inline bool SaveToFile(const std::string& filePath, PVRTexLibLegacyApi api) const; + + /*!*********************************************************************** + @brief Similar to SaveToFile, but redirects the data to a memory + buffer instead of a file. + The caller is responsible for de-allocating memory. + @param[in] fileType File container type to wrap the texture data with. + @param[in] privateData Pointer to a user supplied allocation context. + PVRTexLib will pass this into pfnRealloc when a [re]allocation + is required. + @param[out] outSize Size, in bytes, of the resulting 'file'/data. + @param[in] pfnRealloc Callback function to reallocate memory on-demand. + Return NULL to indicate allocation failure. + @return True if the method succeeds. + N.B This function may allocate even if it fails. + *************************************************************************/ + inline bool SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + void* privateData, + PVRTuint64& outSize, + PVRTuint8*(pfnRealloc)(void* privateData, PVRTuint64 allocSize)) const; + + /*!*********************************************************************** + @brief Similar to SaveToFile, but redirects + the data to a memory buffer instead of a file. + @param[in] fileType File container type to wrap the texture data with. + @param[in,out] outData std::vector containing the resulting data. + @return True if the method succeeds. + *************************************************************************/ + inline bool SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + std::vector& outData) const; + + /*!*********************************************************************** + @brief Similar to SaveToFile, but redirects the data to a memory + buffer instead of a file. + @param[in] fileType File container type to wrap the texture data with. + @param[out] outSize Size, in bytes, of the resulting 'file'/data. + @return Managed pointer to the resulting data or nullptr on failure. + *************************************************************************/ + inline std::unique_ptr SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + PVRTuint64& outSize) const; + + /*!*********************************************************************** + @brief Writes out a single surface to a given image file. + @details File type is determined by the extension present in the filepath string. + Supported file types are PNG, JPG, BMP, TGA and HDR. + If no extension is present then the PNG format will be selected. + Unsupported formats will result in failure. + @param[in] filepath Path to write the image file. + @param[in] MIPLevel Mip level. + @param[in] arrayMember Array index. + @param[in] face Face index. + @param[in] ZSlice Z index. + @return True if the method succeeds. + *************************************************************************/ + inline bool SaveSurfaceToImageFile( + const std::string& filePath, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 ZSlice = 0U) const; + + /*!*********************************************************************** + @brief Queries the texture object to determine if there are multiple + texture objects associated with it. This may be the case after + loading certain file types such as EXR, since EXR files may + contain several images/layers with unique pixel formats. + In these cases PVRTexLib will group all images with the same + pixel format into a single PVRTexLib_PVRTexture object, where + each PVRTexLib_PVRTexture can contain multiple array surfaces. + @return True if this texture contains more than one PVRTexLib_PVRTexture. + *************************************************************************/ + inline bool IsTextureMultiPart() const; + + /*!*********************************************************************** + @brief Retrieves (and moves ownership of) all PVRTexLib_PVRTexture handles + associated with this texture object. After calling this function + any subsequent calls on this texture to IsTextureMultiPart + will return false. + @return Vector of PVRTexture objects. All returned textures are + independent of each other and this texture. + *************************************************************************/ + inline std::vector GetTextureParts(); + + /*!*********************************************************************** + @brief Resizes the texture to new specified dimensions. + @param[in] newWidth New width + @param[in] newHeight New height + @param[in] newDepth New depth + @param[in] resizeMode Filtering mode + @return True if the method succeeds. + *************************************************************************/ + inline bool Resize( + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTexLibResizeMode resizeMode); + + /*!*********************************************************************** + @brief Resizes the canvas of a texture to new specified dimensions. + Offset area is filled with transparent black colour. + @param[in] u32NewWidth New width + @param[in] u32NewHeight New height + @param[in] u32NewDepth New depth + @param[in] i32XOffset X Offset value from the top left corner + @param[in] i32YOffset Y Offset value from the top left corner + @param[in] i32ZOffset Z Offset value from the top left corner + @return True if the method succeeds. + *************************************************************************/ + inline bool ResizeCanvas( + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTint32 xOffset, + PVRTint32 yOffset, + PVRTint32 zOffset); + + /*!*********************************************************************** + @brief Rotates a texture by 90 degrees around the given axis. + @param[in] rotationAxis Rotation axis + @param[in] forward Direction of rotation; true = clockwise, false = anti-clockwise + @return True if the method succeeds or not. + *************************************************************************/ + inline bool Rotate(PVRTexLibAxis rotationAxis, bool forward); + + /*!*********************************************************************** + @brief Flips a texture on a given axis. + @param[in] flipDirection Flip direction + @return True if the method succeeds. + *************************************************************************/ + inline bool Flip(PVRTexLibAxis flipDirection); + + /*!*********************************************************************** + @brief Adds a user specified border to the texture. + @param[in] borderX X border + @param[in] borderY Y border + @param[in] borderZ Z border + @return True if the method succeeds. + *************************************************************************/ + inline bool Border(PVRTuint32 borderX, PVRTuint32 borderY, PVRTuint32 borderZ); + + /*!*********************************************************************** + @brief Pre-multiplies a texture's colours by its alpha values. + @return True if the method succeeds. + *************************************************************************/ + inline bool PreMultiplyAlpha(); + + /*!*********************************************************************** + @brief Allows a texture's colours to run into any fully transparent areas. + @return True if the method succeeds. + *************************************************************************/ + inline bool Bleed(); + + /*!*********************************************************************** + @brief Sets the specified number of channels to values specified in pValues. + @param[in] numChannelSets Number of channels to set + @param[in] channels Channels to set + @param[in] pValues uint32 values to set channels to + @return True if the method succeeds. + *************************************************************************/ + inline bool SetChannels( + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const PVRTuint32* pValues); + + /*!*********************************************************************** + @brief Sets the specified number of channels to values specified in float pValues. + @param[in] numChannelSets Number of channels to set + @param[in] channels Channels to set + @param[in] pValues float values to set channels to + @return True if the method succeeds. + *************************************************************************/ + inline bool SetChannels( + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const float* pValues); + + /*!*********************************************************************** + @brief Copies the specified channels from textureSource + into textureDestination. textureSource is not modified so it + is possible to use the same texture as both input and output. + When using the same texture as source and destination, channels + are preserved between swaps e.g. copying Red to Green and then + Green to Red will result in the two channels trading places + correctly. Channels in eChannels are set to the value of the channels + in eChannelSource. + @param[in] sourceTexture A PVRTexture to copy channels from. + @param[in] uiNumChannelCopies Number of channels to copy + @param[in] destinationChannels Channels to set + @param[in] sourceChannels Source channels to copy from + @return True if the method succeeds. + *************************************************************************/ + inline bool CopyChannels( + const PVRTexture& sourceTexture, + PVRTuint32 numChannelCopies, + const PVRTexLibChannelName* destinationChannels, + const PVRTexLibChannelName* sourceChannels); + + /*!*********************************************************************** + @brief Generates a Normal Map from a given height map. + Assumes the red channel has the height values. + By default outputs to red/green/blue = x/y/z, + this can be overridden by specifying a channel + order in channelOrder. The channels specified + will output to red/green/blue/alpha in that order. + So "xyzh" maps x to red, y to green, z to blue + and h to alpha. 'h' is used to specify that the + original height map data should be preserved in + the given channel. + @param[in] fScale Scale factor + @param[in] channelOrder Channel order + @return True if the method succeeds. + *************************************************************************/ + inline bool GenerateNormalMap(float fScale, const std::string& channelOrder); + + /*!*********************************************************************** + @brief Generates MIPMap chain for a texture. + @param[in] filterMode Filter mode + @param[in] mipMapsToDo Number of levels of MIPMap chain to create. + Use PVRTEX_ALLMIPLEVELS to create a full mip chain. + @return True if the method succeeds. + *************************************************************************/ + inline bool GenerateMIPMaps(PVRTexLibResizeMode filterMode, PVRTint32 mipMapsToDo = PVRTEX_ALLMIPLEVELS); + + /*!*********************************************************************** + @brief Colours a texture's MIPMap levels with different colours + for debugging purposes. MIP levels are coloured in the + following repeating pattern: Red, Green, Blue, Cyan, + Magenta and Yellow + @return True if the method succeeds. + *************************************************************************/ + inline bool ColourMIPMaps(); + + /*!*********************************************************************** + @brief Transcodes a texture from its original format into the specified format. + Will either quantise or dither to lower precisions based on "bDoDither". + "quality" specifies the quality for compressed formats: PVRTC, ETC, + ASTC, and BASISU. Higher quality generally means a longer computation time. + @param[in] pixelFormat Pixel format type + @param[in] channelType Channel type + @param[in] colourspace Colour space + @param[in] quality Quality level for compressed formats, higher quality generally + requires more processing time. + @param[in] doDither Dither the texture to lower precisions + @param[in] maxRange Maximum range value for RGB{M/D} encoding + @param[in] maxThreads Maximum number of threads to use for transcoding, if set to + 0 then PVRTexLib will use all available logical cores. + @return True if the method succeeds. + *************************************************************************/ + inline bool Transcode( + PVRTuint64 pixelFormat, + PVRTexLibVariableType channelType, + PVRTexLibColourSpace colourspace, + PVRTexLibCompressorQuality quality = PVRTexLibCompressorQuality::PVRTLCQ_PVRTCNormal, + bool doDither = false, + float maxRange = 1.0f, + PVRTuint32 maxThreads = 0U); + + /*!*********************************************************************** + @brief Transcodes a texture from its original format into the specified format. + @param[in] options structure containing transcoder options. + @return True if the method succeeds. + *************************************************************************/ + inline bool Transcode(const PVRTexLib_TranscoderOptions& options); + + /*!*********************************************************************** + @brief A convenience function to decompresses a texture into the most + appropriate format based on the textures 'compressed' format, + for example a PVRTC compressed texture may decompress to RGB888 + or RGBA8888. This function may also be used to 'decompress' + packed formats into something easier to manipulate for example + RGB565 will be decompressed to RGB888. + @param[in] maxThreads The maximum number of threads to use for decompression, + if set to 0 PVRTexLib will use all available cores. + @return True if the method succeeds. + *************************************************************************/ + inline bool Decompress(PVRTuint32 maxThreads = 0U); + + /*!*********************************************************************** + @brief Creates a cube-map with six faces from an equi-rectangular + projected texture. The input must have an aspect ratio of 2:1, + i.e. the width must be exactly twice the height. + @param[in] filterMode Filtering mode to apply when sampling the source texture. + @return True if the method succeeds. + *************************************************************************/ + inline bool EquiRectToCubeMap(PVRTexLibResizeMode filter); + + /*!*********************************************************************** + @brief Generates a mip-mapped diffuse irradiance texture from a cube-map + environment map, to be used primarily with physically based + rendering (PBR) techniques. + The texture must be a cube-map, the width must equal height, + and the depth must equal 1. + @param[in] sampleCount The number of samples to use when generating + the diffuse map. + @param[in] mapSize Output dimensions, in pixels. + @return True if the method succeeds. + *************************************************************************/ + inline bool GenerateDiffuseIrradianceCubeMap(PVRTuint32 sampleCount, PVRTuint32 mapSize); + + /*!*********************************************************************** + @brief Generates a pre-filtered specular irradiance texture from a + cube-map environment map, to be used primarily with physically + based rendering (PBR) techniques. + Each Mip level of the specular map is blurred by a roughness + value between 0 and 1. + The texture must be a cube-map, the width must equal height, + and the depth must equal 1. + @param[in] sampleCount The number of samples to use when generating + the specular map. + @param[in] mapSize Output dimensions, in pixels. + @param[in] numMipLevelsToDiscard The number of Mip levels to be discarded + from the bottom of the Mip chain. + @param[in] zeroRoughnessIsExternal False to include a roughness of zero + when generating the pre-filtered environment map. + True to omit a roughness of zero, implying that the user + will supply roughness zero from the environment texture. + @return True if the method succeeds. + *************************************************************************/ + inline bool GeneratePreFilteredSpecularCubeMap( + PVRTuint32 sampleCount, + PVRTuint32 mapSize, + PVRTuint32 numMipLevelsToDiscard, + bool zeroRoughnessIsExternal); + + /*!*********************************************************************** + @brief Computes the maximum difference between two textures; this and + 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool MaxDifference( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the mean error between two textures; this and 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool MeanError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the mean squared error (MSE) between two textures; + this and 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool MeanSquaredError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the root mean squared error (RMSE) between two textures; + this and 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool RootMeanSquaredError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the standard deviation between two textures; this and + 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool StandardDeviation( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the PSNR between two textures; this and 'texture'. + The MIPLevel, arrayMember, face and zSlice values determine which + surfaces are compared. NB: MIPLevel, arrayMember, face and zSlice + should be valid in both textures. Both textures must have the + same dimensions. The function will only compare common channels + i.e. if 'this' has RGB while 'texture' has RGBA channels, then + only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] metrics Structure containing the resulting values. + @param[in] MIPLevel The Mip to compare. + @param[in] arrayMember The array to compare. + @param[in] face The face to compare. + @param[in] zSlice The Z slice to compare. + @return True if the method succeeds. + *************************************************************************/ + inline bool PeakSignalToNoiseRatio( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel = 0U, + PVRTuint32 arrayMember = 0U, + PVRTuint32 face = 0U, + PVRTuint32 zSlice = 0U) const; + + /*!*********************************************************************** + @brief Computes the the [mode] delta per channel between this + and 'texture'. Both textures must have the same dimensions and + may not be compressed. The function will only compare common + channels i.e. if 'LHS' has RGB while 'RHS' has RGBA channels, + then only the RGB channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] textureResult A PVRTexture that will contain the result on success. + @param[in] multiplier The factor to multiply the deltas to highlight differences, + generally a value between 1 and 10. + @param[in] mode The clamping mode to use, currently supports absolute and signed. + @return True if the method succeeds. + *************************************************************************/ + inline bool ColourDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float multiplier = 1.0f, + PVRTexLibColourDiffMode mode = PVRTexLibColourDiffMode::PVRTLCDM_Abs) const; + + /*!*********************************************************************** + @brief Computes the total absolute pixel difference between this + and 'texture', modulating the output based on the tolerance + value supplied. Deltas of zero will appear black while pixels + with deltas greater than or equal to the threshold are set to + red and finally deltas less than the tolerance are set to blue. + Both textures must have the same dimensions and may not be + compressed. The function will only compare common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be compared. + @param[in] texture The PVRTexture to compare with this. + @param[out] textureResult A PVRTexture that will contain the result on success. + @param[in] tolerance The cut-off value to compare the pixel delta to. + @return True if the method succeeds. + *************************************************************************/ + inline bool ToleranceDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float tolerance = 0.1f) const; + + /*!*********************************************************************** + @brief Blend each channel of this texture with 'texture' using the + blend factor as a weighting of the first texture against the second. + Both textures must have the same dimensions and may not be + compressed. The function will only blend common channels i.e. + if 'LHS' has RGB while 'RHS' has RGBA channels, then only the RGB + channels will be blended. + @param[in] texture The PVRTexture to compare with this. + @param[out] textureResult A PVRTexture that will contain the result on success. + @param[in] blendFactor The blend weight to use in the blend equation: + (LHS_delta * BF) + (RHS_delta * (1 - BF)). The value is clamped + between 0 and 1. + @return True if the method succeeds. + *************************************************************************/ + inline bool BlendDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float blendFactor = 0.5f) const; + + protected: + inline void Destroy(); + inline PVRTexture& operator=(PVRTexLib_PVRTexture rhs) noexcept; + PVRTexLib_PVRTexture m_hTexture; + }; + + /*!*********************************************************************** + Begin implementation for PVRTextureHeader + *************************************************************************/ + PVRTextureHeader::PVRTextureHeader() + : m_hTextureHeader() + { + PVRHeader_CreateParams params; + PVRTexLib_SetDefaultTextureHeaderParams(¶ms); + m_hTextureHeader = PVRTexLib_CreateTextureHeader(¶ms); + } + + PVRTextureHeader::PVRTextureHeader(const PVRHeader_CreateParams* params) + : m_hTextureHeader(PVRTexLib_CreateTextureHeader(params)) {} + + PVRTextureHeader::PVRTextureHeader( + PVRTuint64 pixelFormat, + PVRTuint32 width, + PVRTuint32 height, + PVRTuint32 depth, + PVRTuint32 numMipMaps, + PVRTuint32 numArrayMembers, + PVRTuint32 numFaces, + PVRTexLibColourSpace colourSpace, + PVRTexLibVariableType channelType, + bool preMultiplied) + : m_hTextureHeader() + { + PVRHeader_CreateParams params; + params.pixelFormat = pixelFormat; + params.width = width; + params.height = height; + params.depth = depth; + params.numMipMaps = numMipMaps; + params.numArrayMembers = numArrayMembers; + params.numFaces = numFaces; + params.colourSpace = colourSpace; + params.channelType = channelType; + params.preMultiplied = preMultiplied; + m_hTextureHeader = PVRTexLib_CreateTextureHeader(¶ms); + } + + PVRTextureHeader::PVRTextureHeader(bool) + : m_hTextureHeader() {} + + PVRTextureHeader::PVRTextureHeader(const PVRTextureHeader& rhs) + : m_hTextureHeader(PVRTexLib_CopyTextureHeader(rhs.m_hTextureHeader)) {} + + PVRTextureHeader::PVRTextureHeader(PVRTextureHeader&& rhs) noexcept + : m_hTextureHeader(rhs.m_hTextureHeader) + { + rhs.m_hTextureHeader = nullptr; + } + + PVRTextureHeader& PVRTextureHeader::operator=(const PVRTextureHeader& rhs) + { + if (&rhs == this) + return *this; + + if (m_hTextureHeader) + { + PVRTexLib_DestroyTextureHeader(m_hTextureHeader); + m_hTextureHeader = nullptr; + } + + m_hTextureHeader = PVRTexLib_CopyTextureHeader(rhs.m_hTextureHeader); + return *this; + } + + PVRTextureHeader& PVRTextureHeader::operator=(PVRTextureHeader&& rhs) noexcept + { + if (&rhs == this) + return *this; + + if (m_hTextureHeader) + { + PVRTexLib_DestroyTextureHeader(m_hTextureHeader); + m_hTextureHeader = nullptr; + } + + m_hTextureHeader = rhs.m_hTextureHeader; + rhs.m_hTextureHeader = nullptr; + return *this; + } + + PVRTextureHeader::~PVRTextureHeader() + { + if (m_hTextureHeader) + { + PVRTexLib_DestroyTextureHeader(m_hTextureHeader); + m_hTextureHeader = nullptr; + } + } + + PVRTexLib_CPVRTextureHeader PVRTextureHeader::GetHeader(const PVRTextureHeader& header) + { + return header.m_hTextureHeader; + } + + PVRTuint32 PVRTextureHeader::GetTextureBitsPerPixel() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureBitsPerPixel(m_hTextureHeader); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureBitsPerPixel(PVRTuint64 u64PixelFormat) + { + return PVRTexLib_GetFormatBitsPerPixel(u64PixelFormat); + } + + PVRTuint32 PVRTextureHeader::GetTextureChannelCount() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureChannelCount(m_hTextureHeader); + } + + return 0U; + } + + PVRTexLibVariableType PVRTextureHeader::GetTextureChannelType() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureChannelType(m_hTextureHeader); + } + + return PVRTexLibVariableType::PVRTLVT_Invalid; + } + + PVRTexLibColourSpace PVRTextureHeader::GetColourSpace() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureColourSpace(m_hTextureHeader); + } + + return PVRTexLibColourSpace::PVRTLCS_NumSpaces; + } + + PVRTuint32 PVRTextureHeader::GetTextureWidth(PVRTuint32 mipLevel) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureWidth(m_hTextureHeader, mipLevel); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureHeight(PVRTuint32 mipLevel) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureHeight(m_hTextureHeader, mipLevel); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureDepth(PVRTuint32 mipLevel) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureDepth(m_hTextureHeader, mipLevel); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureSize(PVRTint32 mipLevel, bool allSurfaces, bool allFaces) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureSize(m_hTextureHeader, mipLevel, allSurfaces, allFaces); + } + + return 0U; + } + + PVRTuint64 PVRTextureHeader::GetTextureDataSize(PVRTint32 mipLevel, bool allSurfaces, bool allFaces) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureDataSize(m_hTextureHeader, mipLevel, allSurfaces, allFaces); + } + + return 0ULL; + } + + void PVRTextureHeader::GetTextureOrientation(PVRTexLib_Orientation& result) const + { + if (m_hTextureHeader) + { + PVRTexLib_GetTextureOrientation(m_hTextureHeader, &result); + } + else + { + result.x = (PVRTexLibOrientation)0U; + result.y = (PVRTexLibOrientation)0U; + result.z = (PVRTexLibOrientation)0U; + } + } + + void PVRTextureHeader::GetTextureOpenGLFormat(PVRTexLib_OpenGLFormat& result) const + { + if (m_hTextureHeader) + { + PVRTexLib_GetTextureOpenGLFormat(m_hTextureHeader, &result); + } + else + { + result.internalFormat = 0U; + result.format = 0U; + result.type = 0U; + } + } + + void PVRTextureHeader::GetTextureOpenGLESFormat(PVRTexLib_OpenGLESFormat& result) const + { + if (m_hTextureHeader) + { + PVRTexLib_GetTextureOpenGLESFormat(m_hTextureHeader, &result); + } + else + { + result.internalFormat = 0U; + result.format = 0U; + result.type = 0U; + } + } + + PVRTuint32 PVRTextureHeader::GetTextureVulkanFormat() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureVulkanFormat(m_hTextureHeader); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureD3DFormat() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureD3DFormat(m_hTextureHeader); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureDXGIFormat() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureDXGIFormat(m_hTextureHeader); + } + + return 0U; + } + + void PVRTextureHeader::GetTextureFormatMinDims(PVRTuint32& minX, PVRTuint32& minY, PVRTuint32& minZ) const + { + if (m_hTextureHeader) + { + PVRTexLib_GetTextureFormatMinDims(m_hTextureHeader, &minX, &minY, &minZ); + } + else + { + minX = 1U; + minY = 1U; + minZ = 1U; + } + } + + void PVRTextureHeader::GetPixelFormatMinDims(PVRTuint64 ui64Format, PVRTuint32& minX, PVRTuint32& minY, PVRTuint32& minZ) + { + PVRTexLib_GetPixelFormatMinDims(ui64Format, &minX, &minY, &minZ); + } + + PVRTuint32 PVRTextureHeader::GetTextureMetaDataSize() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureMetaDataSize(m_hTextureHeader); + } + + return 0U; + } + + bool PVRTextureHeader::GetTextureIsPreMultiplied() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureIsPreMultiplied(m_hTextureHeader); + } + + return false; + } + + bool PVRTextureHeader::GetTextureIsFileCompressed() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureIsFileCompressed(m_hTextureHeader); + } + + return false; + } + + bool PVRTextureHeader::GetTextureIsBumpMap() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureIsBumpMap(m_hTextureHeader); + } + + return false; + } + + float PVRTextureHeader::GetTextureBumpMapScale() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureBumpMapScale(m_hTextureHeader); + } + + return 0.0f; + } + + PVRTuint32 PVRTextureHeader::GetNumTextureAtlasMembers() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetNumTextureAtlasMembers(m_hTextureHeader); + } + + return 0U; + } + + const float* PVRTextureHeader::GetTextureAtlasData(PVRTuint32& count) const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureAtlasData(m_hTextureHeader, &count); + } + + count = 0U; + return nullptr; + } + + PVRTuint32 PVRTextureHeader::GetTextureNumMipMapLevels() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureNumMipMapLevels(m_hTextureHeader); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureNumFaces() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureNumFaces(m_hTextureHeader); + } + + return 0U; + } + + PVRTuint32 PVRTextureHeader::GetTextureNumArrayMembers() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTextureNumArrayMembers(m_hTextureHeader); + } + + return 0U; + } + + std::string PVRTextureHeader::GetTextureCubeMapOrder() const + { + std::string cubeOrder(7, '\0'); + if (m_hTextureHeader) + { + PVRTexLib_GetTextureCubeMapOrder(m_hTextureHeader, &cubeOrder[0]); + } + + return cubeOrder; + } + + std::string PVRTextureHeader::GetTextureBumpMapOrder() const + { + std::string bumpOrder(5, '\0'); + if (m_hTextureHeader) + { + PVRTexLib_GetTextureBumpMapOrder(m_hTextureHeader, &bumpOrder[0]); + } + + return bumpOrder; + } + + PVRTuint64 PVRTextureHeader::GetTexturePixelFormat() const + { + if (m_hTextureHeader) + { + return PVRTexLib_GetTexturePixelFormat(m_hTextureHeader); + } + + return static_cast(PVRTexLibPixelFormat::PVRTLPF_NumCompressedPFs); + } + + bool PVRTextureHeader::TextureHasPackedChannelData() const + { + if (m_hTextureHeader) + { + return PVRTexLib_TextureHasPackedChannelData(m_hTextureHeader); + } + + return false; + } + + bool PVRTextureHeader::IsPixelFormatCompressed() const + { + return !(GetTexturePixelFormat() & PVRTEX_PFHIGHMASK); + } + + void PVRTextureHeader::SetTextureChannelType(PVRTexLibVariableType type) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureChannelType(m_hTextureHeader, type); + } + } + + void PVRTextureHeader::SetTextureColourSpace(PVRTexLibColourSpace colourSpace) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureColourSpace(m_hTextureHeader, colourSpace); + } + } + + bool PVRTextureHeader::SetTextureD3DFormat(PVRTuint32 d3dFormat) + { + if (m_hTextureHeader) + { + return PVRTexLib_SetTextureD3DFormat(m_hTextureHeader, d3dFormat); + } + + return false; + } + + bool PVRTextureHeader::SetTextureDXGIFormat(PVRTuint32 dxgiFormat) + { + if (m_hTextureHeader) + { + return PVRTexLib_SetTextureDXGIFormat(m_hTextureHeader, dxgiFormat); + } + + return false; + } + + bool PVRTextureHeader::SetTextureOGLFormat(const PVRTexLib_OpenGLFormat& oglFormat) + { + if (m_hTextureHeader) + { + return PVRTexLib_SetTextureOGLFormat(m_hTextureHeader, &oglFormat); + } + + return false; + } + + bool PVRTextureHeader::SetTextureOGLESFormat(const PVRTexLib_OpenGLESFormat& oglesFormat) + { + if (m_hTextureHeader) + { + return PVRTexLib_SetTextureOGLESFormat(m_hTextureHeader, &oglesFormat); + } + + return false; + } + + bool PVRTextureHeader::SetTextureVulkanFormat(PVRTuint32 vulkanFormat) + { + if (m_hTextureHeader) + { + return PVRTexLib_SetTextureVulkanFormat(m_hTextureHeader, vulkanFormat); + } + + return false; + } + + void PVRTextureHeader::SetTexturePixelFormat(PVRTuint64 format) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTexturePixelFormat(m_hTextureHeader, format); + } + } + + void PVRTextureHeader::SetTextureWidth(PVRTuint32 width) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureWidth(m_hTextureHeader, width); + } + } + + void PVRTextureHeader::SetTextureHeight(PVRTuint32 height) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureHeight(m_hTextureHeader, height); + } + } + + void PVRTextureHeader::SetTextureDepth(PVRTuint32 depth) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureDepth(m_hTextureHeader, depth); + } + } + + void PVRTextureHeader::SetTextureNumArrayMembers(PVRTuint32 numMembers) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureNumArrayMembers(m_hTextureHeader, numMembers); + } + } + + void PVRTextureHeader::SetTextureNumMIPLevels(PVRTuint32 numMIPLevels) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureNumMIPLevels(m_hTextureHeader, numMIPLevels); + } + } + + void PVRTextureHeader::SetTextureNumFaces(PVRTuint32 numFaces) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureNumFaces(m_hTextureHeader, numFaces); + } + } + + void PVRTextureHeader::SetTextureOrientation(const PVRTexLib_Orientation& orientation) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureOrientation(m_hTextureHeader, &orientation); + } + } + + void PVRTextureHeader::SetTextureIsFileCompressed(bool isFileCompressed) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureIsFileCompressed(m_hTextureHeader, isFileCompressed); + } + } + + void PVRTextureHeader::SetTextureIsPreMultiplied(bool isPreMultiplied) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureIsPreMultiplied(m_hTextureHeader, isPreMultiplied); + } + } + + void PVRTextureHeader::GetTextureBorder(PVRTuint32& borderWidth, PVRTuint32& borderHeight, PVRTuint32& borderDepth) const + { + if (m_hTextureHeader) + { + PVRTexLib_GetTextureBorder(m_hTextureHeader, &borderWidth, &borderHeight, &borderDepth); + } + else + { + borderWidth = 0U; + borderHeight = 0U; + borderDepth = 0U; + } + } + + bool PVRTextureHeader::GetMetaDataBlock(PVRTuint32 key, MetaDataBlock& dataBlock, PVRTuint32 devFOURCC) const + { + if (m_hTextureHeader) + { + PVRTexLib_MetaDataBlock tmp; + if (PVRTexLib_GetMetaDataBlock(m_hTextureHeader, devFOURCC, key, + &tmp, [](PVRTuint32 bytes) { return (void*)new PVRTuint8[bytes]; })) + { + dataBlock.DevFOURCC = tmp.DevFOURCC; + dataBlock.u32Key = tmp.u32Key; + dataBlock.u32DataSize = tmp.u32DataSize; + dataBlock.Data.reset(tmp.Data); + return true; + } + } + + dataBlock = MetaDataBlock(); + return false; + } + + bool PVRTextureHeader::TextureHasMetaData(PVRTuint32 key, PVRTuint32 devFOURCC) const + { + if (m_hTextureHeader) + { + return PVRTexLib_TextureHasMetaData(m_hTextureHeader, devFOURCC, key); + } + + return false; + } + + void PVRTextureHeader::SetTextureBumpMap(float bumpScale, const std::string& bumpOrder) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureBumpMap(m_hTextureHeader, bumpScale, bumpOrder.c_str()); + } + } + + void PVRTextureHeader::SetTextureAtlas(const float* atlasData, PVRTuint32 dataSize) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureAtlas(m_hTextureHeader, atlasData, dataSize); + } + } + + void PVRTextureHeader::SetTextureCubeMapOrder(const std::string& cubeMapOrder) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureCubeMapOrder(m_hTextureHeader, cubeMapOrder.c_str()); + } + } + + void PVRTextureHeader::SetTextureBorder(PVRTuint32 borderWidth, PVRTuint32 borderHeight, PVRTuint32 borderDepth) + { + if (m_hTextureHeader) + { + PVRTexLib_SetTextureBorder(m_hTextureHeader, borderWidth, borderHeight, borderDepth); + } + } + + void PVRTextureHeader::AddMetaData(const MetaDataBlock& dataBlock) + { + if (m_hTextureHeader && dataBlock.u32DataSize) + { + PVRTexLib_MetaDataBlock tmp; + tmp.DevFOURCC = dataBlock.DevFOURCC; + tmp.u32Key = dataBlock.u32Key; + tmp.u32DataSize = dataBlock.u32DataSize; + tmp.Data = dataBlock.Data.get(); + PVRTexLib_AddMetaData(m_hTextureHeader, &tmp); + } + } + + void PVRTextureHeader::AddMetaData(const PVRTexLib_MetaDataBlock& dataBlock) + { + if (m_hTextureHeader && dataBlock.u32DataSize) + { + PVRTexLib_AddMetaData(m_hTextureHeader, &dataBlock); + } + } + + void PVRTextureHeader::RemoveMetaData(PVRTuint32 key, PVRTuint32 devFOURCC) + { + if (m_hTextureHeader) + { + PVRTexLib_RemoveMetaData(m_hTextureHeader, devFOURCC, key); + } + } + + /*!*********************************************************************** + Begin implementation for PVRTexture + *************************************************************************/ + PVRTexture::PVRTexture() + : PVRTextureHeader(false) + , m_hTexture() {} + + PVRTexture::PVRTexture(const PVRTextureHeader& header, const void *textureData) + : PVRTextureHeader(false) + , m_hTexture(PVRTexLib_CreateTexture(GetHeader(header), textureData)) + { + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + } + + PVRTexture::PVRTexture(const std::string& filePath) + : PVRTextureHeader(false) + , m_hTexture(PVRTexLib_CreateTextureFromFile(filePath.c_str())) + { + if (m_hTexture) + { + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + } + else + { + throw std::runtime_error("Couldn't load texture: " + filePath); + } + } + + PVRTexture::PVRTexture(const char* filePath) + : PVRTextureHeader(false) + , m_hTexture(PVRTexLib_CreateTextureFromFile(filePath)) + { + if (m_hTexture) + { + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + } + else + { + throw std::runtime_error("Couldn't load texture: " + std::string(filePath)); + } + } + + PVRTexture::PVRTexture(const void* data) + : PVRTextureHeader(false) + , m_hTexture(PVRTexLib_CreateTextureFromData(data)) + { + if (m_hTexture) + { + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + } + else + { + throw std::runtime_error("Provided pointer to texture data is invalid"); + } + } + + PVRTexture::PVRTexture(const PVRTexture& rhs) + : PVRTextureHeader(false) + , m_hTexture(PVRTexLib_CopyTexture(rhs.m_hTexture)) + { + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + } + + PVRTexture::PVRTexture(PVRTexture&& rhs) noexcept + : PVRTextureHeader(false) + , m_hTexture(rhs.m_hTexture) + { + m_hTextureHeader = rhs.m_hTextureHeader; + rhs.m_hTextureHeader = nullptr; + rhs.m_hTexture = nullptr; + } + + PVRTexture& PVRTexture::operator=(const PVRTexture& rhs) + { + if (&rhs == this) + return *this; + + Destroy(); + m_hTexture = PVRTexLib_CopyTexture(rhs.m_hTexture); + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + return *this; + } + + PVRTexture& PVRTexture::operator=(PVRTexture&& rhs) noexcept + { + if (&rhs == this) + return *this; + + Destroy(); + m_hTexture = rhs.m_hTexture; + m_hTextureHeader = rhs.m_hTextureHeader; + + rhs.m_hTextureHeader = nullptr; + rhs.m_hTexture = nullptr; + return *this; + } + + PVRTexture& PVRTexture::operator=(PVRTexLib_PVRTexture rhs) noexcept + { + if (m_hTexture == rhs || rhs == nullptr) + return *this; + + Destroy(); + m_hTexture = rhs; + m_hTextureHeader = PVRTexLib_GetTextureHeaderW(m_hTexture); + return *this; + } + + PVRTexture::~PVRTexture() + { + Destroy(); + } + + void PVRTexture::Destroy() + { + if (m_hTexture) + { + PVRTexLib_DestroyTexture(m_hTexture); + m_hTexture = nullptr; + m_hTextureHeader = nullptr; + } + } + + void* PVRTexture::GetTextureDataPointer( + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 faceNumber, + PVRTuint32 ZSlice) + { + if (m_hTexture) + { + return PVRTexLib_GetTextureDataPtr(m_hTexture, MIPLevel, arrayMember, faceNumber, ZSlice); + } + + return nullptr; + } + + const void* PVRTexture::GetTextureDataPointer( + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 faceNumber, + PVRTuint32 ZSlice) const + { + if (m_hTexture) + { + return PVRTexLib_GetTextureDataConstPtr(m_hTexture, MIPLevel, arrayMember, faceNumber, ZSlice); + } + + return nullptr; + } + + void PVRTexture::AddPaddingMetaData(PVRTuint32 padding) + { + if (m_hTexture) + { + PVRTexLib_AddPaddingMetaData(m_hTexture, padding); + } + } + + bool PVRTexture::SaveToFile(const std::string& filePath) const + { + if (m_hTexture) + { + return PVRTexLib_SaveTextureToFile(m_hTexture, filePath.c_str()); + } + + return false; + } + + bool PVRTexture::SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + void* privateData, + PVRTuint64& outSize, + PVRTuint8*(pfnRealloc)(void* privateData, PVRTuint64 allocSize)) const + { + if (m_hTexture) + { + return PVRTexLib_SaveTextureToMemory(m_hTexture, fileType, privateData, &outSize, pfnRealloc); + } + + return false; + } + + bool PVRTexture::SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + std::vector& outData) const + { + if (m_hTexture) + { + PVRTuint64 outSize; + + if (PVRTexLib_SaveTextureToMemory(m_hTexture, fileType, + static_cast(&outData), &outSize, + [](void* privateData, PVRTuint64 allocSize) { + auto buffer = static_cast*>(privateData); + assert(allocSize <= std::numeric_limits::max()); + buffer->resize(static_cast(allocSize)); + return buffer->data(); + })) + { + outData.resize(static_cast(outSize)); + return true; + } + } + + return false; + } + + std::unique_ptr PVRTexture::SaveTextureToMemory( + PVRTexLibFileContainerType fileType, + PVRTuint64& outSize) const + { + std::unique_ptr result(nullptr, [](PVRTuint8* data) { free(data); }); + + if (m_hTexture) + { + if (!PVRTexLib_SaveTextureToMemory(m_hTexture, fileType, + static_cast(&result), &outSize, + [](void* privateData, PVRTuint64 allocSize) { + auto buffer = static_cast*>(privateData); + auto currentPtr = buffer->release(); + assert(allocSize <= std::numeric_limits::max()); + auto newPtr = std::realloc(currentPtr, static_cast(allocSize)); + + if (!newPtr) + { + free(currentPtr); + } + + buffer->reset(static_cast(newPtr)); + return buffer->get(); + })) + { + result.reset(); + } + } + + return result; + } + + bool PVRTexture::SaveToFile(const std::string& filePath, PVRTexLibLegacyApi api) const + { + if (m_hTexture) + { + return PVRTexLib_SaveTextureToLegacyPVRFile(m_hTexture, filePath.c_str(), api); + } + + return false; + } + + bool PVRTexture::SaveSurfaceToImageFile( + const std::string& filePath, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 ZSlice) const + { + if (m_hTexture) + { + return PVRTexLib_SaveSurfaceToImageFile(m_hTexture, filePath.c_str(), MIPLevel, arrayMember, face, ZSlice); + } + + return false; + } + + bool PVRTexture::IsTextureMultiPart() const + { + if (m_hTexture) + { + return PVRTexLib_IsTextureMultiPart(m_hTexture); + } + + return false; + } + + std::vector PVRTexture::GetTextureParts() + { + std::vector textures; + + if (m_hTexture) + { + PVRTuint32 count; + std::vector handles; + + PVRTexLib_GetTextureParts(m_hTexture, nullptr, &count); + handles.resize(count); + PVRTexLib_GetTextureParts(m_hTexture, handles.data(), &count); + + for (auto handle : handles) + { + textures.emplace_back(); + textures.back().m_hTexture = handle; + textures.back().m_hTextureHeader = PVRTexLib_GetTextureHeaderW(handle); + } + } + + return textures; + } + + bool PVRTexture::Resize( + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTexLibResizeMode resizeMode) + { + if (m_hTexture) + { + return PVRTexLib_ResizeTexture(m_hTexture, newWidth, newHeight, newDepth, resizeMode); + } + + return false; + } + + bool PVRTexture::ResizeCanvas( + PVRTuint32 newWidth, + PVRTuint32 newHeight, + PVRTuint32 newDepth, + PVRTint32 xOffset, + PVRTint32 yOffset, + PVRTint32 zOffset) + { + if (m_hTexture) + { + return PVRTexLib_ResizeTextureCanvas(m_hTexture, newWidth, newHeight, newDepth, xOffset, yOffset, zOffset); + } + + return false; + } + + bool PVRTexture::Rotate(PVRTexLibAxis rotationAxis, bool forward) + { + if (m_hTexture) + { + return PVRTexLib_RotateTexture(m_hTexture, rotationAxis, forward); + } + + return false; + } + + bool PVRTexture::Flip(PVRTexLibAxis flipDirection) + { + if (m_hTexture) + { + return PVRTexLib_FlipTexture(m_hTexture, flipDirection); + } + + return false; + } + + bool PVRTexture::Border(PVRTuint32 borderX, PVRTuint32 borderY, PVRTuint32 borderZ) + { + if (m_hTexture) + { + return PVRTexLib_BorderTexture(m_hTexture, borderX, borderY, borderZ); + } + + return false; + } + + bool PVRTexture::PreMultiplyAlpha() + { + if (m_hTexture) + { + return PVRTexLib_PreMultiplyAlpha(m_hTexture); + } + + return false; + } + + bool PVRTexture::Bleed() + { + if (m_hTexture) + { + return PVRTexLib_Bleed(m_hTexture); + } + + return false; + } + + bool PVRTexture::SetChannels( + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const PVRTuint32* pValues) + { + if (m_hTexture) + { + return PVRTexLib_SetTextureChannels(m_hTexture, numChannelSets, channels, pValues); + } + + return false; + } + + bool PVRTexture::SetChannels( + PVRTuint32 numChannelSets, + const PVRTexLibChannelName* channels, + const float* pValues) + { + if (m_hTexture) + { + return PVRTexLib_SetTextureChannelsFloat(m_hTexture, numChannelSets, channels, pValues); + } + + return false; + } + + bool PVRTexture::CopyChannels( + const PVRTexture& sourceTexture, + PVRTuint32 numChannelCopies, + const PVRTexLibChannelName* destinationChannels, + const PVRTexLibChannelName* sourceChannels) + { + if (m_hTexture && sourceTexture.m_hTexture) + { + return PVRTexLib_CopyTextureChannels(m_hTexture, sourceTexture.m_hTexture, numChannelCopies, destinationChannels, sourceChannels); + } + + return false; + } + + bool PVRTexture::GenerateNormalMap(float fScale, const std::string& channelOrder) + { + if (m_hTexture) + { + return PVRTexLib_GenerateNormalMap(m_hTexture, fScale, channelOrder.c_str()); + } + + return false; + } + + bool PVRTexture::GenerateMIPMaps(PVRTexLibResizeMode filterMode, PVRTint32 mipMapsToDo) + { + if (m_hTexture) + { + return PVRTexLib_GenerateMIPMaps(m_hTexture, filterMode, mipMapsToDo); + } + + return false; + } + + bool PVRTexture::ColourMIPMaps() + { + if (m_hTexture) + { + return PVRTexLib_ColourMIPMaps(m_hTexture); + } + + return false; + } + + bool PVRTexture::Transcode( + PVRTuint64 pixelFormat, + PVRTexLibVariableType channelType, + PVRTexLibColourSpace colourspace, + PVRTexLibCompressorQuality quality, + bool doDither, + float maxRange, + PVRTuint32 maxThreads) + { + if (m_hTexture) + { + + PVRTexLib_TranscoderOptions options; + options.sizeofStruct = sizeof(PVRTexLib_TranscoderOptions); + options.pixelFormat = pixelFormat; + options.channelType[0] = options.channelType[1] = options.channelType[2] = options.channelType[3] = channelType; + options.colourspace = colourspace; + options.quality = quality; + options.doDither = doDither; + options.maxRange = maxRange; + options.maxThreads = maxThreads; + return PVRTexLib_TranscodeTexture(m_hTexture, options); + } + + return false; + } + + bool PVRTexture::Transcode(const PVRTexLib_TranscoderOptions& options) + { + if (m_hTexture) + { + return PVRTexLib_TranscodeTexture(m_hTexture, options); + } + + return false; + } + + bool PVRTexture::Decompress(PVRTuint32 maxThreads) + { + if (m_hTexture) + { + return PVRTexLib_Decompress(m_hTexture, maxThreads); + } + + return false; + } + + bool PVRTexture::EquiRectToCubeMap(PVRTexLibResizeMode filter) + { + if (m_hTexture) + { + return PVRTexLib_EquiRectToCubeMap(m_hTexture, filter); + } + + return false; + } + + bool PVRTexture::GenerateDiffuseIrradianceCubeMap(PVRTuint32 sampleCount, PVRTuint32 mapSize) + { + if (m_hTexture) + { + return PVRTexLib_GenerateDiffuseIrradianceCubeMap(m_hTexture, sampleCount, mapSize); + } + + return false; + } + + bool PVRTexture::GeneratePreFilteredSpecularCubeMap( + PVRTuint32 sampleCount, + PVRTuint32 mapSize, + PVRTuint32 numMipLevelsToDiscard, + bool zeroRoughnessIsExternal) + { + if (m_hTexture) + { + return PVRTexLib_GeneratePreFilteredSpecularCubeMap(m_hTexture, sampleCount, mapSize, numMipLevelsToDiscard, zeroRoughnessIsExternal); + } + + return false; + } + + bool PVRTexture::MaxDifference( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_MaxDifference(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::MeanError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_MeanError(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::MeanSquaredError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_MeanSquaredError(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::RootMeanSquaredError( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_RootMeanSquaredError(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::StandardDeviation( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_StandardDeviation(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::PeakSignalToNoiseRatio( + const PVRTexture& texture, + PVRTexLib_ErrorMetrics& metrics, + PVRTuint32 MIPLevel, + PVRTuint32 arrayMember, + PVRTuint32 face, + PVRTuint32 zSlice) const + { + if (m_hTexture && texture.m_hTexture) + { + return PVRTexLib_PeakSignalToNoiseRatio(m_hTexture, texture.m_hTexture, MIPLevel, arrayMember, face, zSlice, &metrics); + } + + return false; + } + + bool PVRTexture::ColourDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float multiplier, + PVRTexLibColourDiffMode mode) const + { + if (m_hTexture && + texture.m_hTexture) + { + PVRTexLib_PVRTexture result = nullptr; + if (PVRTexLib_ColourDiff(m_hTexture, texture.m_hTexture, &result, multiplier, mode)) + { + textureResult = result; + return true; + } + } + + return false; + } + + bool PVRTexture::ToleranceDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float tolerance) const + { + if (m_hTexture && + texture.m_hTexture) + { + PVRTexLib_PVRTexture result = nullptr; + if (PVRTexLib_ToleranceDiff(m_hTexture, texture.m_hTexture, &result, tolerance)) + { + textureResult = result; + return true; + } + } + + return false; + } + + bool PVRTexture::BlendDiff( + const PVRTexture& texture, + PVRTexture& textureResult, + float blendFactor) const + { + if (m_hTexture && + texture.m_hTexture) + { + PVRTexLib_PVRTexture result = nullptr; + if (PVRTexLib_BlendDiff(m_hTexture, texture.m_hTexture, &result, blendFactor)) + { + textureResult = result; + return true; + } + } + + return false; + } +} +/***************************************************************************** +End of file (PVRTexLib.hpp) +*****************************************************************************/ diff --git a/deps/PVRTT/Include/PVRTexLibDefines.h b/deps/PVRTT/Include/PVRTexLibDefines.h new file mode 100755 index 0000000000..eefc0107d2 --- /dev/null +++ b/deps/PVRTT/Include/PVRTexLibDefines.h @@ -0,0 +1,484 @@ +/*!**************************************************************************** + + @file PVRTexLibDefines.h + @copyright Copyright (c) Imagination Technologies Limited. + @brief Public PVRTexLib defines header. + +******************************************************************************/ +#ifndef _PVRTEXLIBDEFINES_H_ +#define _PVRTEXLIBDEFINES_H_ + +/**************************************************************************** +** Integer types +****************************************************************************/ +typedef char PVRTchar8; +typedef signed char PVRTint8; +typedef signed short PVRTint16; +typedef signed int PVRTint32; +typedef unsigned char PVRTuint8; +typedef unsigned short PVRTuint16; +typedef unsigned int PVRTuint32; +typedef float PVRTfloat32; +typedef signed long long PVRTint64; +typedef unsigned long long PVRTuint64; + +#define PVRTEXLIBSIZEASSERT(T, size) typedef int (sizeof_##T)[sizeof(T) == (size)] +PVRTEXLIBSIZEASSERT(PVRTchar8, 1); +PVRTEXLIBSIZEASSERT(PVRTint8, 1); +PVRTEXLIBSIZEASSERT(PVRTuint8, 1); +PVRTEXLIBSIZEASSERT(PVRTint16, 2); +PVRTEXLIBSIZEASSERT(PVRTuint16, 2); +PVRTEXLIBSIZEASSERT(PVRTint32, 4); +PVRTEXLIBSIZEASSERT(PVRTuint32, 4); +PVRTEXLIBSIZEASSERT(PVRTint64, 8); +PVRTEXLIBSIZEASSERT(PVRTuint64, 8); +PVRTEXLIBSIZEASSERT(PVRTfloat32, 4); +#undef PVRTEXLIBSIZEASSERT + +/***************************************************************************** +* Texture related constants and enumerations. +*****************************************************************************/ +// V3 Header Identifiers. +#define PVRTEX3_IDENT 0x03525650U // 'P''V''R'3 +#define PVRTEX3_IDENT_REV 0x50565203U +// If endianness is backwards then PVR3 will read as 3RVP, hence why it is written as an int. + +//Current version texture identifiers +#define PVRTEX_CURR_IDENT PVRTEX3_IDENT +#define PVRTEX_CURR_IDENT_REV PVRTEX3_IDENT_REV + +// PVR Header file flags. Condition if true. If false, opposite is true unless specified. +#define PVRTEX3_FILE_COMPRESSED (1U << 0U) // Texture has been file compressed using PVRTexLib (currently unused) +#define PVRTEX3_PREMULTIPLIED (1U << 1U) // Texture has been premultiplied by alpha value. + +// Mip Map level specifier constants. Other levels are specified by 1,2...n +#define PVRTEX_TOPMIPLEVEL 0 +#define PVRTEX_ALLMIPLEVELS -1 //This is a special number used simply to return a total of all MIP levels when dealing with data sizes. + +// A 64 bit pixel format ID & this will give you the high bits of a pixel format to check for a compressed format. +#define PVRTEX_PFHIGHMASK 0xffffffff00000000ull + +/* + Preprocessor definitions to generate a pixelID for use when consts are needed. For example - switch statements. + These should be evaluated by the compiler rather than at run time - assuming that arguments are all constant. +*/ + +//Generate a 4 channel PixelID. +#define PVRTGENPIXELID4(C1Name, C2Name, C3Name, C4Name, C1Bits, C2Bits, C3Bits, C4Bits) ( ( (PVRTuint64)C1Name) + ( (PVRTuint64)C2Name<<8) + ( (PVRTuint64)C3Name<<16) + ( (PVRTuint64)C4Name<<24) + ( (PVRTuint64)C1Bits<<32) + ( (PVRTuint64)C2Bits<<40) + ( (PVRTuint64)C3Bits<<48) + ( (PVRTuint64)C4Bits<<56) ) + +//Generate a 1 channel PixelID. +#define PVRTGENPIXELID3(C1Name, C2Name, C3Name, C1Bits, C2Bits, C3Bits)( PVRTGENPIXELID4(C1Name, C2Name, C3Name, 0, C1Bits, C2Bits, C3Bits, 0) ) + +//Generate a 2 channel PixelID. +#define PVRTGENPIXELID2(C1Name, C2Name, C1Bits, C2Bits) ( PVRTGENPIXELID4(C1Name, C2Name, 0, 0, C1Bits, C2Bits, 0, 0) ) + +//Generate a 3 channel PixelID. +#define PVRTGENPIXELID1(C1Name, C1Bits) ( PVRTGENPIXELID4(C1Name, 0, 0, 0, C1Bits, 0, 0, 0)) + +/*!*********************************************************************** + @enum PVRTexLibMetaData + @brief Values for each meta data type that PVRTexLib knows 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 PVRTexLibMetaData +{ + PVRTLMD_TextureAtlasCoords = 0, + PVRTLMD_BumpData, + PVRTLMD_CubeMapOrder, + PVRTLMD_TextureOrientation, + PVRTLMD_BorderData, + PVRTLMD_Padding, + PVRTLMD_PerChannelType, + PVRTLMD_SupercompressionGlobalData, + PVRTLMD_MaxRange, + PVRTLMD_NumMetaDataTypes +}; + +/*!*********************************************************************** + @enum PVRTexLibAxis + @brief Axis +*************************************************************************/ +enum PVRTexLibAxis +{ + PVRTLA_X = 0, + PVRTLA_Y = 1, + PVRTLA_Z = 2 +}; + +/*!*********************************************************************** + @enum PVRTexLibOrientation + @brief Image orientations per axis +*************************************************************************/ +enum PVRTexLibOrientation +{ + PVRTLO_Left = 1 << PVRTexLibAxis::PVRTLA_X, + PVRTLO_Right = 0, + PVRTLO_Up = 1 << PVRTexLibAxis::PVRTLA_Y, + PVRTLO_Down = 0, + PVRTLO_Out = 1 << PVRTexLibAxis::PVRTLA_Z, + PVRTLO_In = 0 +}; + +/*!*********************************************************************** + @enum PVRTexLibColourSpace + @brief Describes the colour space of the texture +*************************************************************************/ +enum PVRTexLibColourSpace +{ + PVRTLCS_Linear, + PVRTLCS_sRGB, + PVRTLCS_BT601, + PVRTLCS_BT709, + PVRTLCS_BT2020, + PVRTLCS_NumSpaces +}; + +/*!*********************************************************************** + @enum PVRTexLibChannelName + @brief Channel names for non-compressed formats +*************************************************************************/ +enum PVRTexLibChannelName +{ + PVRTLCN_NoChannel, + PVRTLCN_Red, + PVRTLCN_Green, + PVRTLCN_Blue, + PVRTLCN_Alpha, + PVRTLCN_Luminance, + PVRTLCN_Intensity, + PVRTLCN_Depth, + PVRTLCN_Stencil, + PVRTLCN_Unspecified, + PVRTLCN_NumChannels +}; + +/*!*********************************************************************** + @enum PVRTexLibPixelFormat + @brief Compressed pixel formats that PVRTexLib understands +*************************************************************************/ +enum PVRTexLibPixelFormat +{ + PVRTLPF_PVRTCI_2bpp_RGB, + PVRTLPF_PVRTCI_2bpp_RGBA, + PVRTLPF_PVRTCI_4bpp_RGB, + PVRTLPF_PVRTCI_4bpp_RGBA, + PVRTLPF_PVRTCII_2bpp, + PVRTLPF_PVRTCII_4bpp, + PVRTLPF_ETC1, + PVRTLPF_DXT1, + PVRTLPF_DXT2, + PVRTLPF_DXT3, + PVRTLPF_DXT4, + PVRTLPF_DXT5, + + //These formats are identical to some DXT formats. + PVRTLPF_BC1 = PVRTLPF_DXT1, + PVRTLPF_BC2 = PVRTLPF_DXT3, + PVRTLPF_BC3 = PVRTLPF_DXT5, + PVRTLPF_BC4, + PVRTLPF_BC5, + + /* Currently unsupported: */ + PVRTLPF_BC6, + PVRTLPF_BC7, + /* ~~~~~~~~~~~~~~~~~~ */ + + // Packed YUV formats + PVRTLPF_UYVY_422, // https://www.fourcc.org/pixel-format/yuv-uyvy/ + PVRTLPF_YUY2_422, // https://www.fourcc.org/pixel-format/yuv-yuy2/ + + PVRTLPF_BW1bpp, + PVRTLPF_SharedExponentR9G9B9E5, + PVRTLPF_RGBG8888, + PVRTLPF_GRGB8888, + PVRTLPF_ETC2_RGB, + PVRTLPF_ETC2_RGBA, + PVRTLPF_ETC2_RGB_A1, + PVRTLPF_EAC_R11, + PVRTLPF_EAC_RG11, + + PVRTLPF_ASTC_4x4, + PVRTLPF_ASTC_5x4, + PVRTLPF_ASTC_5x5, + PVRTLPF_ASTC_6x5, + PVRTLPF_ASTC_6x6, + PVRTLPF_ASTC_8x5, + PVRTLPF_ASTC_8x6, + PVRTLPF_ASTC_8x8, + PVRTLPF_ASTC_10x5, + PVRTLPF_ASTC_10x6, + PVRTLPF_ASTC_10x8, + PVRTLPF_ASTC_10x10, + PVRTLPF_ASTC_12x10, + PVRTLPF_ASTC_12x12, + + PVRTLPF_ASTC_3x3x3, + PVRTLPF_ASTC_4x3x3, + PVRTLPF_ASTC_4x4x3, + PVRTLPF_ASTC_4x4x4, + PVRTLPF_ASTC_5x4x4, + PVRTLPF_ASTC_5x5x4, + PVRTLPF_ASTC_5x5x5, + PVRTLPF_ASTC_6x5x5, + PVRTLPF_ASTC_6x6x5, + PVRTLPF_ASTC_6x6x6, + + PVRTLPF_BASISU_ETC1S, + PVRTLPF_BASISU_UASTC, + + PVRTLPF_RGBM, + PVRTLPF_RGBD, + + PVRTLPF_PVRTCI_HDR_6bpp, + PVRTLPF_PVRTCI_HDR_8bpp, + PVRTLPF_PVRTCII_HDR_6bpp, + PVRTLPF_PVRTCII_HDR_8bpp, + + // The memory layout for 10 and 12 bit YUV formats that are packed into a WORD (16 bits) is denoted by MSB or LSB: + // MSB denotes that the sample is stored in the most significant bits + // LSB denotes that the sample is stored in the least significant bits + // All YUV formats are little endian + + // Packed YUV formats + PVRTLPF_VYUA10MSB_444, + PVRTLPF_VYUA10LSB_444, + PVRTLPF_VYUA12MSB_444, + PVRTLPF_VYUA12LSB_444, + PVRTLPF_UYV10A2_444, // Y410 + PVRTLPF_UYVA16_444, // Y416 + PVRTLPF_YUYV16_422, // Y216 + PVRTLPF_UYVY16_422, + PVRTLPF_YUYV10MSB_422, // Y210 + PVRTLPF_YUYV10LSB_422, + PVRTLPF_UYVY10MSB_422, + PVRTLPF_UYVY10LSB_422, + PVRTLPF_YUYV12MSB_422, + PVRTLPF_YUYV12LSB_422, + PVRTLPF_UYVY12MSB_422, + PVRTLPF_UYVY12LSB_422, + + /* + Reserved for future expansion + */ + + // 3 Plane (Planar) YUV formats + PVRTLPF_YUV_3P_444 = 270, + PVRTLPF_YUV10MSB_3P_444, + PVRTLPF_YUV10LSB_3P_444, + PVRTLPF_YUV12MSB_3P_444, + PVRTLPF_YUV12LSB_3P_444, + PVRTLPF_YUV16_3P_444, + PVRTLPF_YUV_3P_422, + PVRTLPF_YUV10MSB_3P_422, + PVRTLPF_YUV10LSB_3P_422, + PVRTLPF_YUV12MSB_3P_422, + PVRTLPF_YUV12LSB_3P_422, + PVRTLPF_YUV16_3P_422, + PVRTLPF_YUV_3P_420, + PVRTLPF_YUV10MSB_3P_420, + PVRTLPF_YUV10LSB_3P_420, + PVRTLPF_YUV12MSB_3P_420, + PVRTLPF_YUV12LSB_3P_420, + PVRTLPF_YUV16_3P_420, + PVRTLPF_YVU_3P_420, + + /* + Reserved for future expansion + */ + + // 2 Plane (Biplanar/semi-planar) YUV formats + PVRTLPF_YUV_2P_422 = 480, // P208 + PVRTLPF_YUV10MSB_2P_422, // P210 + PVRTLPF_YUV10LSB_2P_422, + PVRTLPF_YUV12MSB_2P_422, + PVRTLPF_YUV12LSB_2P_422, + PVRTLPF_YUV16_2P_422, // P216 + PVRTLPF_YUV_2P_420, // NV12 + PVRTLPF_YUV10MSB_2P_420, // P010 + PVRTLPF_YUV10LSB_2P_420, + PVRTLPF_YUV12MSB_2P_420, + PVRTLPF_YUV12LSB_2P_420, + PVRTLPF_YUV16_2P_420, // P016 + PVRTLPF_YUV_2P_444, + PVRTLPF_YVU_2P_444, + PVRTLPF_YUV10MSB_2P_444, + PVRTLPF_YUV10LSB_2P_444, + PVRTLPF_YVU10MSB_2P_444, + PVRTLPF_YVU10LSB_2P_444, + PVRTLPF_YVU_2P_422, + PVRTLPF_YVU10MSB_2P_422, + PVRTLPF_YVU10LSB_2P_422, + PVRTLPF_YVU_2P_420, // NV21 + PVRTLPF_YVU10MSB_2P_420, + PVRTLPF_YVU10LSB_2P_420, + + //Invalid value + PVRTLPF_NumCompressedPFs +}; + +/*!*********************************************************************** + @enum PVRTexLibVariableType + @brief Data types. Describes how the data is interpreted by PVRTexLib and + how the pointer returned by PVRTexLib_GetTextureDataPtr() should + be interpreted. +*************************************************************************/ +enum PVRTexLibVariableType +{ + PVRTLVT_UnsignedByteNorm, + PVRTLVT_SignedByteNorm, + PVRTLVT_UnsignedByte, + PVRTLVT_SignedByte, + PVRTLVT_UnsignedShortNorm, + PVRTLVT_SignedShortNorm, + PVRTLVT_UnsignedShort, + PVRTLVT_SignedShort, + PVRTLVT_UnsignedIntegerNorm, + PVRTLVT_SignedIntegerNorm, + PVRTLVT_UnsignedInteger, + PVRTLVT_SignedInteger, + PVRTLVT_SignedFloat, + PVRTLVT_Float = PVRTLVT_SignedFloat, //the name Float is now deprecated. + PVRTLVT_UnsignedFloat, + PVRTLVT_NumVarTypes, + + PVRTLVT_Invalid = 255 +}; + +/*!*********************************************************************** + @enum PVRTexLibCompressorQuality + @brief Quality level to compress the texture with. Applies to PVRTC, + ETC, ASTC, BASIS and IMGIC formats. +*************************************************************************/ +enum PVRTexLibCompressorQuality +{ + PVRTLCQ_PVRTCFastest = 0, //!< PVRTC fastest + PVRTLCQ_PVRTCFast, //!< PVRTC fast + PVRTLCQ_PVRTCLow, //!< PVRTC low + PVRTLCQ_PVRTCNormal, //!< PVRTC normal + PVRTLCQ_PVRTCHigh, //!< PVRTC high + PVRTLCQ_PVRTCVeryHigh, //!< PVRTC very high + PVRTLCQ_PVRTCThorough, //!< PVRTC thorough + PVRTLCQ_PVRTCBest, //!< PVRTC best + PVRTLCQ_NumPVRTCModes, //!< Number of PVRTC modes + + PVRTLCQ_ETCFast = 0, //!< ETC fast + PVRTLCQ_ETCNormal, //!< ETC normal + PVRTLCQ_ETCSlow, //!< ETC slow + PVRTLCQ_NumETCModes, //!< Number of ETC modes + + PVRTLCQ_ASTCVeryFast = 0, //!< ASTC very fast + PVRTLCQ_ASTCFast, //!< ASTC fast + PVRTLCQ_ASTCMedium, //!< ASTC medium + PVRTLCQ_ASTCThorough, //!< ASTC thorough + PVRTLCQ_ASTCExhaustive, //!< ASTC exhaustive + PVRTLCQ_NumASTCModes, //!< Number of ASTC modes + + PVRTLCQ_BASISULowest = 0, //!< BASISU lowest quality + PVRTLCQ_BASISULow, //!< BASISU low quality + PVRTLCQ_BASISUNormal, //!< BASISU normal quality + PVRTLCQ_BASISUHigh, //!< BASISU high quality + PVRTLCQ_BASISUBest, //!< BASISU best quality + PVRTLCQ_NumBASISUModes, //!< Number of BASISU modes +}; + +/*!*********************************************************************** + @enum PVRTexLibResizeMode + @brief Filter to apply when resizing an image +*************************************************************************/ +enum PVRTexLibResizeMode +{ + PVRTLRM_Nearest, //!< Nearest filtering + PVRTLRM_Linear, //!< Linear filtering + PVRTLRM_Cubic, //!< Cubic filtering, uses Catmull-Rom splines. + PVRTLRM_Modes //!< Number of resize modes +}; + +/*!*********************************************************************** + @enum PVRTexLibFileContainerType + @brief File container type +*************************************************************************/ +enum PVRTexLibFileContainerType +{ + PVRTLFCT_PVR, //!< PVR: https://docs.imgtec.com/Specifications/PVR_File_Format_Specification/topics/pvr_intro.html + PVRTLFCT_KTX, //!< KTX version 1: https://www.khronos.org/registry/KTX/specs/1.0/ktxspec_v1.html + PVRTLFCT_KTX2, //!< KTX version 2: https://github.khronos.org/KTX-Specification/ + PVRTLFCT_ASTC, //!< ASTC compressed textures only: https://github.com/ARM-software/astc-encoder + PVRTLFCT_BASIS, //!< Basis Universal compressed textures only: https://github.com/BinomialLLC/basis_universal + PVRTLFCT_DDS, //!< DirectDraw Surface: https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-reference + PVRTLFCT_CHeader //!< C style header +}; + +/*!*********************************************************************** + @enum PVRTexLibColourDiffMode + @brief The clamping mode to use when performing a colour diff +*************************************************************************/ +enum PVRTexLibColourDiffMode +{ + PVRTLCDM_Abs, //!< Absolute + PVRTLCDM_Signed //!< Signed +}; + +/*!*********************************************************************** + @enum PVRTexLibLegacyApi + @brief Legacy API enum. +*************************************************************************/ +enum PVRTexLibLegacyApi +{ + PVRTLLAPI_OGLES = 1, //!< OpenGL ES 1.x + PVRTLLAPI_OGLES2, //!< OpenGL ES 2.0 + PVRTLLAPI_D3DM, //!< Direct 3D M + PVRTLLAPI_OGL, //!< Open GL + PVRTLLAPI_DX9, //!< DirextX 9 + PVRTLLAPI_DX10, //!< DirectX 10 + PVRTLLAPI_OVG, //!< Open VG + PVRTLLAPI_MGL, //!< MGL +}; + +#define PVRT_MIN(a,b) (((a) < (b)) ? (a) : (b)) +#define PVRT_MAX(a,b) (((a) > (b)) ? (a) : (b)) +#define PVRT_CLAMP(x, l, h) (PVRT_MIN((h), PVRT_MAX((x), (l)))) + +/*!*************************************************************************** + @def TEXOFFSET2D + @brief 2D texture offset +*****************************************************************************/ +#define TEXOFFSET2D(x,y,width) (((x)+(y)*(width))) + +/*!*************************************************************************** + @def TEXOFFSET3D + @brief 3D texture offset +*****************************************************************************/ +#define TEXOFFSET3D(x,y,z,width,height) (((x)+(y)*(width)+(z)*(width)*(height))) + +/*!*************************************************************************** + @struct PVRTextureHeaderV3 + @brief A header for a PVR texture. + @details Contains everything required to read a texture accurately, and nothing more. Extraneous data is stored in a MetaDataBlock. + Correct use of the texture may rely on MetaDataBlock, but accurate data loading can be done through the standard header alone. +*****************************************************************************/ +#pragma pack(push,4) +struct PVRTextureHeaderV3 +{ + PVRTuint32 u32Version; ///< Version of the file header, used to identify it. + PVRTuint32 u32Flags; ///< Various format flags. + PVRTuint64 u64PixelFormat; ///< The pixel format, 8cc value storing the 4 channel identifiers and their respective sizes. + PVRTuint32 u32ColourSpace; ///< The Colour Space of the texture, currently either linear RGB or sRGB. + PVRTuint32 u32ChannelType; ///< Variable type that the channel is stored in. Supports signed/unsigned int/short/byte or float for now. + PVRTuint32 u32Height; ///< Height of the texture. + PVRTuint32 u32Width; ///< Width of the texture. + PVRTuint32 u32Depth; ///< Depth of the texture. (Z-slices) + PVRTuint32 u32NumSurfaces; ///< Number of members in a Texture Array. + PVRTuint32 u32NumFaces; ///< Number of faces in a Cube Map. Maybe be a value other than 6. + PVRTuint32 u32MIPMapCount; ///< Number of MIP Maps in the texture - NB: Includes top level. + PVRTuint32 u32MetaDataSize; ///< Size of the accompanying meta data. +}; +#pragma pack(pop) +#define PVRTEX3_HEADERSIZE 52U +#endif /* _PVRTEXLIBDEFINES_H_ */ + +/***************************************************************************** +End of file (PVRTexLibDefines.h) +*****************************************************************************/ \ No newline at end of file diff --git a/deps/PVRTT/Include/PVRTextureVersion.h b/deps/PVRTT/Include/PVRTextureVersion.h new file mode 100755 index 0000000000..0725dc94fc --- /dev/null +++ b/deps/PVRTT/Include/PVRTextureVersion.h @@ -0,0 +1,7 @@ +#pragma once + +#define PVRTEXLIB_MAJORVERSION 5 +#define PVRTEXLIB_MINORVERSION 6 +#define PVRTEXLIB_SUBVERSION 0 +#define PVRTEXLIB_STRINGVERSION "5.6.0" +#define PVRTEXLIB_FULLVERSIONSTRING "PVRTexLib v5.6.0" diff --git a/deps/PVRTT/include/PVRTArray.h b/deps/PVRTT/include/PVRTArray.h deleted file mode 100644 index 487ddbae09..0000000000 --- a/deps/PVRTT/include/PVRTArray.h +++ /dev/null @@ -1,660 +0,0 @@ -/*!**************************************************************************** - - @file PVRTArray.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Expanding array template class. Allows appending and direct - access. Mixing access methods should be approached with caution. - -******************************************************************************/ -#ifndef __PVRTARRAY_H__ -#define __PVRTARRAY_H__ - -#include "PVRTGlobal.h" -#include "PVRTError.h" - -/****************************************************************************** -** Classes -******************************************************************************/ - -/*!*************************************************************************** - @class CPVRTArray - @brief Expanding array template class. -*****************************************************************************/ -template -class CPVRTArray -{ -public: - /*!*************************************************************************** - @brief Blank constructor. Makes a default sized array. - *****************************************************************************/ - CPVRTArray() : m_uiSize(0), m_uiCapacity(GetDefaultSize()) - { - m_pArray = new T[m_uiCapacity]; - } - - /*!*************************************************************************** - @brief Constructor taking initial size of array in elements. - @param[in] uiSize intial size of array - *****************************************************************************/ - CPVRTArray(const unsigned int uiSize) : m_uiSize(0), m_uiCapacity(uiSize) - { - _ASSERT(uiSize != 0); - m_pArray = new T[uiSize]; - } - - /*!*************************************************************************** - @brief Copy constructor. - @param[in] original the other dynamic array - *****************************************************************************/ - CPVRTArray(const CPVRTArray& original) : m_uiSize(original.m_uiSize), - m_uiCapacity(original.m_uiCapacity) - { - m_pArray = new T[m_uiCapacity]; - for(unsigned int i=0;i= m_uiSize) // Are we adding to the end - uiIndex = Append(addT); - else - { - unsigned int uiNewCapacity = 0; - T* pArray = m_pArray; - - if(m_uiSize >= m_uiCapacity) - { - uiNewCapacity = m_uiCapacity + 10; // Expand the array by 10. - - pArray = new T[uiNewCapacity]; // New Array - - if(!pArray) - return -1; // Failed to allocate memory! - - // Copy the first half to the new array - for(unsigned int i = 0; i < pos; ++i) - { - pArray[i] = m_pArray[i]; - } - } - - // Copy last half to the new array - for(unsigned int i = m_uiSize; i > pos; --i) - { - pArray[i] = m_pArray[i - 1]; - } - - // Insert our new element - pArray[pos] = addT; - uiIndex = pos; - - // Increase our size - ++m_uiSize; - - // Switch pointers and free memory if needed - if(pArray != m_pArray) - { - m_uiCapacity = uiNewCapacity; - delete[] m_pArray; - m_pArray = pArray; - } - } - - return uiIndex; - } - - /*!*************************************************************************** - @brief Appends an element to the end of the array, expanding it - if necessary. - @param[in] addT The element to append - @return The index of the new item. - *****************************************************************************/ - unsigned int Append(const T& addT) - { - unsigned int uiIndex = Append(); - m_pArray[uiIndex] = addT; - return uiIndex; - } - - /*!*************************************************************************** - @brief Creates space for a new item, but doesn't add. Instead - returns the index of the new item. - @return The index of the new item. - *****************************************************************************/ - unsigned int Append() - { - unsigned int uiIndex = m_uiSize; - SetCapacity(m_uiSize+1); - m_uiSize++; - - return uiIndex; - } - - /*!*************************************************************************** - @brief Clears the array. - *****************************************************************************/ - void Clear() - { - m_uiSize = 0U; - } - - /*!*************************************************************************** - @brief Changes the array to the new size. - @param[in] uiSize New size of array - *****************************************************************************/ - EPVRTError Resize(const unsigned int uiSize) - { - EPVRTError err = SetCapacity(uiSize); - - if(err != PVR_SUCCESS) - return err; - - m_uiSize = uiSize; - return PVR_SUCCESS; - } - - /*!*************************************************************************** - @brief Expands array to new capacity. - @param[in] uiSize New capacity of array - *****************************************************************************/ - EPVRTError SetCapacity(const unsigned int uiSize) - { - if(uiSize <= m_uiCapacity) - return PVR_SUCCESS; // nothing to be done - - unsigned int uiNewCapacity; - if(uiSize < m_uiCapacity*2) - { - uiNewCapacity = m_uiCapacity*2; // Ignore the new size. Expand to twice the previous size. - } - else - { - uiNewCapacity = uiSize; - } - - T* pNewArray = new T[uiNewCapacity]; // New Array - if(!pNewArray) - return PVR_FAIL; // Failed to allocate memory! - - // Copy source data to new array - for(unsigned int i = 0; i < m_uiSize; ++i) - { - pNewArray[i] = m_pArray[i]; - } - - // Switch pointers and free memory - m_uiCapacity = uiNewCapacity; - T* pOldArray = m_pArray; - m_pArray = pNewArray; - delete [] pOldArray; - return PVR_SUCCESS; - } - - /*!*************************************************************************** - @fn Copy - @brief A copy function. Will attempt to copy from other CPVRTArrays - if this is possible. - @param[in] other The CPVRTArray needing copied - *****************************************************************************/ - template - void Copy(const CPVRTArray& other) - { - T* pNewArray = new T[other.GetCapacity()]; - if(pNewArray) - { - // Copy data - for(unsigned int i = 0; i < other.GetSize(); i++) - { - pNewArray[i] = other[i]; - } - - // Free current array - if(m_pArray) - delete [] m_pArray; - - // Swap pointers - m_pArray = pNewArray; - - m_uiCapacity = other.GetCapacity(); - m_uiSize = other.GetSize(); - } - } - - /*!*************************************************************************** - @brief Assignment operator. - @param[in] other The CPVRTArray needing copied - *****************************************************************************/ - CPVRTArray& operator=(const CPVRTArray& other) - { - if(&other != this) - Copy(other); - - return *this; - } - - /*!*************************************************************************** - @brief Appends an existing CPVRTArray on to this one. - @param[in] other the array to append. - *****************************************************************************/ - CPVRTArray& operator+=(const CPVRTArray& other) - { - if(&other != this) - { - for(unsigned int uiIndex = 0; uiIndex < other.GetSize(); ++uiIndex) - { - Append(other[uiIndex]); - } - } - - return *this; - } - - /*!*************************************************************************** - @brief Indexed access into array. Note that this has no error - checking whatsoever. - @param[in] uiIndex index of element in array - @return the element indexed - *****************************************************************************/ - T& operator[](const unsigned int uiIndex) - { - _ASSERT(uiIndex < m_uiSize); - return m_pArray[uiIndex]; - } - - /*!*************************************************************************** - @brief Indexed access into array. Note that this has no error checking whatsoever. - @param[in] uiIndex index of element in array - @return The element indexed - *****************************************************************************/ - const T& operator[](const unsigned int uiIndex) const - { - _ASSERT(uiIndex < m_uiSize); - return m_pArray[uiIndex]; - } - - /*!*************************************************************************** - @return Size of array - @brief Gives current size of array/number of elements. - *****************************************************************************/ - unsigned int GetSize() const - { - return m_uiSize; - } - - /*!*************************************************************************** - @brief Gives the default size of array/number of elements. - @return Default size of array - *****************************************************************************/ - static unsigned int GetDefaultSize() - { - return 16U; - } - - /*!*************************************************************************** - @brief Gives current allocated size of array/number of elements. - @return Capacity of array - *****************************************************************************/ - unsigned int GetCapacity() const - { - return m_uiCapacity; - } - - /*!*************************************************************************** - @brief Indicates whether the given object resides inside the array. - @param[in] object The object to check in the array - @return true if object is contained in this array. - *****************************************************************************/ - bool Contains(const T& object) const - { - for(unsigned int uiIndex = 0; uiIndex < m_uiSize; ++uiIndex) - { - if(m_pArray[uiIndex] == object) - return true; - } - return false; - } - - /*!*************************************************************************** - @brief Attempts to find the object in the array and returns a - pointer if it is found, or NULL if not found. The time - taken is O(N). - @param[in] object The object to check in the array - @return Pointer to the found object or NULL. - *****************************************************************************/ - T* Find(const T& object) const - { - for(unsigned int uiIndex = 0; uiIndex < m_uiSize; ++uiIndex) - { - if(m_pArray[uiIndex] == object) - return &m_pArray[uiIndex]; - } - return NULL; - } - - /*!*************************************************************************** - @brief Performs a merge-sort on the array. Pred should be an object that - defines a bool operator(). - @param[in] predicate The object which defines "bool operator()" - *****************************************************************************/ - template - void Sort(Pred predicate) - { - _Sort(0, m_uiSize, predicate); - } - - /*!*************************************************************************** - @brief Removes an element from the array. - @param[in] uiIndex The index to remove - @return success or failure - *****************************************************************************/ - virtual EPVRTError Remove(unsigned int uiIndex) - { - _ASSERT(uiIndex < m_uiSize); - if(m_uiSize == 0) - return PVR_FAIL; - - if(uiIndex == m_uiSize-1) - { - return RemoveLast(); - } - - m_uiSize--; - // Copy the data. memmove will only work for built-in types. - for(unsigned int uiNewIdx = uiIndex; uiNewIdx < m_uiSize; ++uiNewIdx) - { - m_pArray[uiNewIdx] = m_pArray[uiNewIdx+1]; - } - - return PVR_SUCCESS; - } - - /*!*************************************************************************** - @brief Removes the last element. Simply decrements the size value. - @return success or failure - *****************************************************************************/ - virtual EPVRTError RemoveLast() - { - if(m_uiSize > 0) - { - m_uiSize--; - return PVR_SUCCESS; - } - else - { - return PVR_FAIL; - } - } - -protected: - enum eBounds - { - eLowerBounds, - eUpperBounds, - }; - - /*!*************************************************************************** - @brief Internal sort algorithm. - @param[in] first The beginning index of the array - @param[in] last The last index of the array - @param[in] predicate A functor object to perform the comparison - *****************************************************************************/ - template - void _Sort(unsigned int first, unsigned int last, Pred predicate) - { - unsigned int size = last - first; - if(size < 2) - return; - - unsigned int middle = first + size / 2; - _Sort(first, middle, predicate); - _Sort(middle, last, predicate); - _SortMerge(first, middle, last, middle-first, last-middle, predicate); - } - - /*!*************************************************************************** - @brief Internal sort algorithm - in-place merge method. - @param[in] first The beginning index of the array - @param[in] middle The middle index of the array - @param[in] last The last index of the array - @param[in] len1 Length of first half of the array - @param[in] len2 Length of the second half of the array - @param[in] predicate A functor object to perform the comparison - *****************************************************************************/ - template - void _SortMerge(unsigned int first, unsigned int middle, unsigned int last, int len1, int len2, Pred predicate) - { - if(len1 == 0 || len2 == 0) - return; - - if(len1 + len2 == 2) - { - if(predicate(m_pArray[middle], m_pArray[first])) - PVRTswap(m_pArray[first], m_pArray[middle]); - - return; - } - - unsigned int firstCut = first; - unsigned int secondCut = middle; - int dist1 = 0; - int dist2 = 0; - if(len1 > len2) - { - dist1 = len1 / 2; - firstCut += dist1; - secondCut = _SortBounds(middle, last, m_pArray[firstCut], eLowerBounds, predicate); - dist2 += secondCut - middle; - } - else - { - dist2 = len2 / 2; - secondCut += dist2; - firstCut = _SortBounds(first, middle, m_pArray[secondCut], eUpperBounds, predicate); - dist1 += firstCut - first; - } - - unsigned int newMiddle = _SortRotate(firstCut, middle, secondCut); - _SortMerge(first, firstCut, newMiddle, dist1, dist2, predicate); - _SortMerge(newMiddle, secondCut, last, len1-dist1, len2-dist2, predicate); - } - - /*!*************************************************************************** - @brief Internal sort algorithm - returns the bounded index of the range. - @param[in] first The beginning index of the array - @param[in] last The last index of the array - @param[in] v Comparison object - @param[in] bounds Which bound to check (upper or lower) - @param[in] predicate A functor object to perform the comparison - *****************************************************************************/ - template - unsigned int _SortBounds(unsigned int first, unsigned int last, const T& v, eBounds bounds, Pred predicate) - { - int count = last - first, step; - unsigned int idx; - while(count > 0) - { - step = count / 2; - idx = first + step; - if((bounds == eLowerBounds && predicate(m_pArray[idx], v)) || (bounds == eUpperBounds && !predicate(v, m_pArray[idx]))) - { - first = ++idx; - count -= step + 1; - } - else - { - count = step; - } - } - return first; - } - - /*!*************************************************************************** - @brief Internal sort algorithm - rotates the contents of the array such - that the middle becomes the first element. - @param[in] first The beginning index of the array - @param[in] middle The middle index of the array - @param[in] last The last index of the array - *****************************************************************************/ - int _SortRotate(unsigned int first, unsigned int middle, unsigned int last) - { - if(first == middle) - return last; - if(last == middle) - return first; - - unsigned int newFirst = middle; - do - { - PVRTswap(m_pArray[first++], m_pArray[newFirst++]); - if(first == middle) - middle = newFirst; - } while (newFirst != last); - - unsigned int newMiddle = first; - newFirst = middle; - while(newFirst != last) - { - PVRTswap(m_pArray[first++], m_pArray[newFirst++]); - if(first == middle) - middle = newFirst; - else if(newFirst == last) - newFirst = middle; - } - - return newMiddle; - } - -protected: - unsigned int m_uiSize; /*!< Current size of contents of array */ - unsigned int m_uiCapacity; /*!< Currently allocated size of array */ - T *m_pArray; /*!< The actual array itself */ -}; - -// note "this" is required for ISO standard, C++ and gcc complains otherwise -// http://lists.apple.com/archives/Xcode-users//2005/Dec/msg00644.html - -/*!*************************************************************************** - @class CPVRTArrayManagedPointers - @brief Maintains an array of managed pointers. -*****************************************************************************/ -template -class CPVRTArrayManagedPointers : public CPVRTArray -{ -public: - /*!*************************************************************************** - @brief Destructor. - *****************************************************************************/ - virtual ~CPVRTArrayManagedPointers() - { - if(this->m_pArray) - { - for(unsigned int i=0;im_uiSize;i++) - { - delete(this->m_pArray[i]); - } - } - } - - /*!*************************************************************************** - @brief Removes an element from the array. - @param[in] uiIndex The index to remove. - @return success or failure - *****************************************************************************/ - virtual EPVRTError Remove(unsigned int uiIndex) - { - _ASSERT(uiIndex < this->m_uiSize); - if(this->m_uiSize == 0) - return PVR_FAIL; - - if(uiIndex == this->m_uiSize-1) - { - return this->RemoveLast(); - } - - unsigned int uiSize = (this->m_uiSize - (uiIndex+1)) * sizeof(T*); - - delete this->m_pArray[uiIndex]; - memmove(this->m_pArray + uiIndex, this->m_pArray + (uiIndex+1), uiSize); - - this->m_uiSize--; - return PVR_SUCCESS; - } - - /*!*************************************************************************** - @brief Removes the last element. Simply decrements the size value. - @return success or failure - *****************************************************************************/ - virtual EPVRTError RemoveLast() - { - if(this->m_uiSize > 0 && this->m_pArray) - { - delete this->m_pArray[this->m_uiSize-1]; - this->m_uiSize--; - return PVR_SUCCESS; - } - else - { - return PVR_FAIL; - } - } -}; - -#endif // __PVRTARRAY_H__ - -/***************************************************************************** -End of file (PVRTArray.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTDecompress.h b/deps/PVRTT/include/PVRTDecompress.h deleted file mode 100644 index 174b46074c..0000000000 --- a/deps/PVRTT/include/PVRTDecompress.h +++ /dev/null @@ -1,48 +0,0 @@ -/*!**************************************************************************** - - @file PVRTDecompress.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief PVRTC and ETC Texture Decompression. - -******************************************************************************/ - -#ifndef _PVRTDECOMPRESS_H_ -#define _PVRTDECOMPRESS_H_ - -/*!*********************************************************************** - @brief Decompresses PVRTC to RGBA 8888. - @param[in] pCompressedData The PVRTC texture data to decompress - @param[in] Do2bitMode Signifies whether the data is PVRTC2 or PVRTC4 - @param[in] XDim X dimension of the texture - @param[in] YDim Y dimension of the texture - @param[in,out] pResultImage The decompressed texture data - @return Returns the amount of data that was decompressed. -*************************************************************************/ -int PVRTDecompressPVRTC(const void *pCompressedData, - const int Do2bitMode, - const int XDim, - const int YDim, - unsigned char* pResultImage); - -/*!*********************************************************************** - @brief Decompresses ETC to RGBA 8888. - @param[in] pSrcData The ETC texture data to decompress - @param[in] x X dimension of the texture - @param[in] y Y dimension of the texture - @param[in,out] pDestData The decompressed texture data - @param[in] nMode The format of the data - @return The number of bytes of ETC data decompressed -*************************************************************************/ -int PVRTDecompressETC(const void * const pSrcData, - const unsigned int &x, - const unsigned int &y, - void *pDestData, - const int &nMode); - - -#endif /* _PVRTDECOMPRESS_H_ */ - -/***************************************************************************** - End of file (PVRTBoneBatch.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTError.h b/deps/PVRTT/include/PVRTError.h deleted file mode 100644 index bab132adf3..0000000000 --- a/deps/PVRTT/include/PVRTError.h +++ /dev/null @@ -1,65 +0,0 @@ -/*!**************************************************************************** - - @file PVRTError.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief PVRT error codes. - -******************************************************************************/ -#ifndef _PVRTERROR_H_ -#define _PVRTERROR_H_ - -#if defined(ANDROID) - #include -#else - #if defined(_WIN32) - #include - #else - #include - #endif -#endif -/*!*************************************************************************** - Macros -*****************************************************************************/ - -/*! Outputs a string to the standard error if built for debugging. */ -#if !defined(PVRTERROR_OUTPUT_DEBUG) - #if defined(_DEBUG) || defined(DEBUG) - #if defined(ANDROID) - #define PVRTERROR_OUTPUT_DEBUG(A) __android_log_print(ANDROID_LOG_INFO, "PVRTools", A); - #elif defined(_WIN32) && !defined(UNDER_CE) - #define PVRTERROR_OUTPUT_DEBUG(A) OutputDebugStringA(A); - #else - #define PVRTERROR_OUTPUT_DEBUG(A) fprintf(stderr,"%s",A); - #endif - #else - #define PVRTERROR_OUTPUT_DEBUG(A) - #endif -#endif - - -/*!*************************************************************************** - Enums -*****************************************************************************/ -/*!*************************************************************************** - @enum EPVRTError - @brief EPVRT error conditions. -*****************************************************************************/ -enum EPVRTError -{ - PVR_SUCCESS = 0, /*!< Success! :D */ - PVR_FAIL = 1, /*!< Failed :( */ - PVR_OVERFLOW = 2 /*!< Overflow error :| */ -}; - -/*!*************************************************************************** - @brief Outputs a string to the standard error. - @param[in] format printf style format followed by arguments it requires. -*****************************************************************************/ -void PVRTErrorOutputDebug(char const * const format, ...); - -#endif // _PVRTERROR_H_ - -/***************************************************************************** -End of file (PVRTError.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTGlobal.h b/deps/PVRTT/include/PVRTGlobal.h deleted file mode 100644 index 729778f836..0000000000 --- a/deps/PVRTT/include/PVRTGlobal.h +++ /dev/null @@ -1,305 +0,0 @@ -/*!**************************************************************************** - - @file PVRTGlobal.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Global defines and typedefs for PVRTools. - -******************************************************************************/ -#ifndef _PVRTGLOBAL_H_ -#define _PVRTGLOBAL_H_ - -/*!*************************************************************************** - Macros -*****************************************************************************/ -#define PVRT_MIN(a,b) (((a) < (b)) ? (a) : (b)) -#define PVRT_MAX(a,b) (((a) > (b)) ? (a) : (b)) -#define PVRT_CLAMP(x, l, h) (PVRT_MIN((h), PVRT_MAX((x), (l)))) - -// avoid warning about unused parameter -#define PVRT_UNREFERENCED_PARAMETER(x) ((void) x) - -#if defined(_WIN32) && !defined(__QT__) && !defined(UNDER_CE) /* Windows desktop */ -#if !defined(_CRTDBG_MAP_ALLOC) -#define _CRTDBG_MAP_ALLOC -#endif -#include -#include -#include -#endif - -#if defined(UNDER_CE) -#include - -#ifndef _ASSERT -#ifdef _DEBUG -#define _ASSERT(X) { (X) ? 0 : DebugBreak(); } -#else -#define _ASSERT(X) -#endif -#endif - -#ifndef _ASSERTE -#ifdef _DEBUG -#define _ASSERTE _ASSERT -#else -#define _ASSERTE(X) -#endif -#endif -#define _RPT0(a,b) -#define _RPT1(a,b,c) -#define _RPT2(a,b,c,d) -#define _RPT3(a,b,c,d,e) -#define _RPT4(a,b,c,d,e,f) -#else - -#if defined(_WIN32) && !defined(__QT__) - -#else -#if defined(__linux__) || defined(__APPLE__) -#ifdef _DEBUG -#include -#ifndef _RPT0 -#define _RPT0(a,b) printf(b) -#endif -#ifndef _RPT1 -#define _RPT1(a,b,c) printf(b,c) -#endif -#ifndef _ASSERT -#define _ASSERT(a) if (!(a)) ::raise(SIGTRAP) -#endif -#ifndef _ASSERTE -#define _ASSERTE(a) if (!(a)) ::raise(SIGTRAP) -#endif -#else -#ifndef _RPT0 -#define _RPT0(a,b)((void)0) -#endif -#ifndef _RPT1 -#define _RPT1(a,b,c)((void)0) -#endif -#ifndef _ASSERT -#define _ASSERT(a)((void)0) -#endif -#ifndef _ASSERTE -#define _ASSERTE(a)((void)0) -#endif -#endif -#ifndef _RPT2 -#define _RPT2(a,b,c,d)((void)0) -#endif -#ifndef _RPT3 -#define _RPT3(a,b,c,d,e)((void)0) -#endif -#ifndef _RPT4 -#define _RPT4(a,b,c,d,e,f)((void)0) -#endif -#else -#define _CRT_WARN 0 -#define _RPT0(a,b) -#define _RPT1(a,b,c) -#define _RPT2(a,b,c,d) -#define _RPT3(a,b,c,d,e) -#define _RPT4(a,b,c,d,e,f) -#define _ASSERT(X) -#define _ASSERTE(X) -#endif -#endif -#endif - -#include -#include - -#define FREE(X) { if(X) { free(X); (X) = 0; } } - -// This macro is used to check at compile time that types are of a certain size -// If the size does not equal the expected size, this typedefs an array of size 0 -// which causes a compile error -#define PVRTSIZEASSERT(T, size) typedef int (sizeof_##T)[sizeof(T) == (size)] -#define PVRTCOMPILEASSERT(T, expr) typedef int (assert_##T)[expr] - - -/**************************************************************************** -** Integer types -****************************************************************************/ - -typedef char PVRTchar8; -typedef signed char PVRTint8; -typedef signed short PVRTint16; -typedef signed int PVRTint32; -typedef unsigned char PVRTuint8; -typedef unsigned short PVRTuint16; -typedef unsigned int PVRTuint32; - -typedef float PVRTfloat32; - -#if (defined(__int64) || defined(_WIN32)) -typedef signed __int64 PVRTint64; -typedef unsigned __int64 PVRTuint64; -#elif defined(__GNUC__) -__extension__ typedef signed long long PVRTint64; -__extension__ typedef unsigned long long PVRTuint64; -#else -typedef signed long long PVRTint64; -typedef unsigned long long PVRTuint64; -#endif - -#if __SIZEOF_WCHAR_T__ == 4 || __WCHAR_MAX__ > 0x10000 -#define PVRTSIZEOFWCHAR 4 -#else -#define PVRTSIZEOFWCHAR 2 -#endif - -PVRTSIZEASSERT(PVRTchar8, 1); -PVRTSIZEASSERT(PVRTint8, 1); -PVRTSIZEASSERT(PVRTuint8, 1); -PVRTSIZEASSERT(PVRTint16, 2); -PVRTSIZEASSERT(PVRTuint16, 2); -PVRTSIZEASSERT(PVRTint32, 4); -PVRTSIZEASSERT(PVRTuint32, 4); -PVRTSIZEASSERT(PVRTint64, 8); -PVRTSIZEASSERT(PVRTuint64, 8); -PVRTSIZEASSERT(PVRTfloat32, 4); - -/*!************************************************************************** - @enum ETextureFilter - @brief Enum values for defining texture filtering. -****************************************************************************/ -enum ETextureFilter -{ - eFilter_Nearest, - eFilter_Linear, - eFilter_Cubic, - eFilter_None, - - eFilter_Size, - eFilter_Default = eFilter_Linear, - eFilter_MipDefault = eFilter_None -}; - -/*!************************************************************************** - @enum ETextureWrap - @brief Enum values for defining texture wrapping. -****************************************************************************/ -enum ETextureWrap -{ - eWrap_Clamp, - eWrap_Repeat, - - eWrap_Size, - eWrap_Default = eWrap_Repeat -}; - -/**************************************************************************** -** swap template function -****************************************************************************/ -/*!*************************************************************************** - @brief A swap template function that swaps a and b. - @param[in] a Type a - @param[in] b Type b -*****************************************************************************/ - -template -inline void PVRTswap(T& a, T& b) -{ - T temp = a; - a = b; - b = temp; -} - -/*!*************************************************************************** - @brief A clamp template function that clamps val between min and max. - @param[in] val Value to clamp - @param[in] min Minimum legal value - @param[in] max Maximum legal value -*****************************************************************************/ -template -inline T PVRTClamp(const T& val, const T& min, const T& max) -{ - if (val > max) - { return max; } - if (val < min) - { return min; } - return val; -} - -/*!*************************************************************************** - @brief Swaps the endianness of pBytes in place. - @param[in] pBytes A number - @param[in] i32ByteNo Number of bytes in pBytes -*****************************************************************************/ -inline void PVRTByteSwap(unsigned char* pBytes, int i32ByteNo) -{ - int i = 0, j = i32ByteNo - 1; - - while (i < j) - { PVRTswap(pBytes[i++], pBytes[j--]); } -} - -/*!*************************************************************************** - @brief Converts the endianness of an unsigned int. - @param[in] ui32Long A number - @return ui32Long with its endianness changed -*****************************************************************************/ -inline unsigned int PVRTByteSwap32(unsigned int ui32Long) -{ - return ((ui32Long & 0x000000FF) << 24) + ((ui32Long & 0x0000FF00) << 8) + ((ui32Long & 0x00FF0000) >> 8) + ((ui32Long & 0xFF000000) >> 24); -} - -/*!*************************************************************************** - @brief Converts the endianness of a unsigned short. - @param[in] ui16Short A number - @return ui16Short with its endianness changed -*****************************************************************************/ -inline unsigned short PVRTByteSwap16(unsigned short ui16Short) -{ - return (ui16Short >> 8) | (ui16Short << 8); -} - -/*!*************************************************************************** - @brief Returns true if the platform the code is ran on is little endian. - @return True if the platform the code is ran on is little endian -*****************************************************************************/ -inline bool PVRTIsLittleEndian() -{ - static bool bLittleEndian; - static bool bIsInit = false; - - if (!bIsInit) - { - short int word = 0x0001; - char* byte = (char*) &word; - bLittleEndian = byte[0] ? true : false; - bIsInit = true; - } - - return bLittleEndian; -} - - -/*!*************************************************************************** - @brief Minimum of a, b. In case of tie, a is returned. - @return Returns b if a > b, otherwise a -*****************************************************************************/ -template -inline const T& PVRTMin(const T& a, const T& b) -{ - return a > b ? b : a; -} - -/*!*************************************************************************** - @brief Maximum of a, b. In case of tie, a is returned. - @return Returns b if a < b. otherwise a -*****************************************************************************/ -template -inline const T& PVRTMax(const T& a, const T& b) -{ - return a < b ? b : a; -} - - -#endif // _PVRTGLOBAL_H_ - -/***************************************************************************** - End of file (Tools.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTMap.h b/deps/PVRTT/include/PVRTMap.h deleted file mode 100644 index 7802466214..0000000000 --- a/deps/PVRTT/include/PVRTMap.h +++ /dev/null @@ -1,202 +0,0 @@ -/*!**************************************************************************** - - @file PVRTMap.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief A simple and easy-to-use implementation of a map. - -******************************************************************************/ -#ifndef __PVRTMAP_H__ -#define __PVRTMAP_H__ - -#include "PVRTArray.h" - -/*!*************************************************************************** - @class CPVRTMap - @brief Expanding map template class. - @details A simple and easy-to-use implementation of a map. -*****************************************************************************/ -template -class CPVRTMap -{ -public: - - /*!*********************************************************************** - @brief Constructor for a CPVRTMap. - @return A new CPVRTMap. - *************************************************************************/ - CPVRTMap() : m_Keys(), m_Data(), m_uiSize(0) - {} - - /*!*********************************************************************** - @brief Destructor for a CPVRTMap. - *************************************************************************/ - ~CPVRTMap() - { - //Clear the map, that's enough - the CPVRTArray members will tidy everything else up. - Clear(); - } - - EPVRTError Reserve(const PVRTuint32 uiSize) - { - //Sets the capacity of each member array to the requested size. The array used will only expand. - //Returns the most serious error from either method. - return PVRT_MAX(m_Keys.SetCapacity(uiSize),m_Data.SetCapacity(uiSize)); - } - - /*!*********************************************************************** - @brief Returns the number of meaningful members in the map. - @return Number of meaningful members in the map. - *************************************************************************/ - PVRTuint32 GetSize() const - { - //Return the size. - return m_uiSize; - } - - /*!*********************************************************************** - @brief Gets the position of a particular key/data within the map. - If the return value is exactly equal to the value of - GetSize() then the item has not been found. - @param[in] key Key type - @return The index value for a mapped item. - *************************************************************************/ - PVRTuint32 GetIndexOf(const KeyType key) const - { - //Loop through all the valid keys. - for (PVRTuint32 i=0; i=m_uiSize) - return NULL; - - return &(m_Data[uiIndex]); - } - - /*!*********************************************************************** - @brief If a mapping already exists for 'key' then it will return - the associated data. If no mapping currently exists, a new - element is created in place. - @param[in] key Key type - @return Data that is mapped to 'key'. - *************************************************************************/ - DataType& operator[] (const KeyType key) - { - //Get the index of the key. - PVRTuint32 uiIndex = GetIndexOf(key); - - //Check the index is valid - if (uiIndex != m_uiSize) - { - //Return mapped data if the index is valid. - return m_Data[uiIndex]; - } - else - { - //Append the key to the Keys array. - m_Keys.Append(key); - - //Create a new DataType. - DataType sNewData; - - //Append the new pointer to the Data array. - m_Data.Append(sNewData); - - //Increment the size of meaningful data. - ++m_uiSize; - - //Return the contents of pNewData. - return m_Data[m_Keys.GetSize()-1]; - } - } - - /*!*********************************************************************** - @brief Removes an element from the map if it exists. - @param[in] key Key type - @return Returns PVR_FAIL if item doesn't exist. - Otherwise returns PVR_SUCCESS. - *************************************************************************/ - EPVRTError Remove(const KeyType key) - { - //Finds the index of the key. - PVRTuint32 uiIndex=GetIndexOf(key); - - //If the key is invalid, fail. - if (uiIndex==m_uiSize) - { - //Return failure. - return PVR_FAIL; - } - - //Decrement the size of the map to ignore the last element in each array. - m_uiSize--; - - //Copy the last key over the deleted key. There are now two copies of one element, - //but the one at the end of the array is ignored. - m_Keys[uiIndex] = m_Keys[m_uiSize]; m_Keys.RemoveLast(); - - //Copy the last data over the deleted data in the same way as the keys. - m_Data[uiIndex] = m_Data[m_uiSize]; m_Data.RemoveLast(); - - //Return success. - return PVR_SUCCESS; - } - - /*!*********************************************************************** - @brief Clears the Map of all data values. - *************************************************************************/ - void Clear() - { - //Set the size to 0. - m_uiSize=0; - m_Keys.Clear(); - m_Data.Clear(); - } - - /*!*********************************************************************** - @brief Checks whether or not data exists for the specified key. - @param[in] key Key type - @return Whether data exists for the specified key or not. - *************************************************************************/ - bool Exists(const KeyType key) const - { - //Checks for a valid index for key, if not, returns false. - return (GetIndexOf(key) != m_uiSize); - } - -private: - - - CPVRTArray m_Keys; /*!< Array of all the keys. Indices match m_Data. */ - - CPVRTArray m_Data; /*!< Array of pointers to all the allocated data. */ - - PVRTuint32 m_uiSize; /*!< The number of meaningful members in the map. */ -}; - -#endif // __PVRTMAP_H__ - -/***************************************************************************** -End of file (PVRTMap.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTString.h b/deps/PVRTT/include/PVRTString.h deleted file mode 100644 index 5138ca39d5..0000000000 --- a/deps/PVRTT/include/PVRTString.h +++ /dev/null @@ -1,925 +0,0 @@ -/*!**************************************************************************** - - @file PVRTString.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief A string class that can be used as drop-in replacement for - std::string on platforms/compilers that don't provide a full C++ - standard library. - -******************************************************************************/ -#ifndef _PVRTSTRING_H_ -#define _PVRTSTRING_H_ - -#include -#define _USING_PVRTSTRING_ - -/*!*************************************************************************** - @class CPVRTString - @brief A string class. -*****************************************************************************/ - -#if defined(_WINDLL_EXPORT) -class __declspec(dllexport) CPVRTString -#elif defined(_WINDLL_IMPORT) -class __declspec(dllimport) CPVRTString -#else -class CPVRTString -#endif -{ - -private: - - // Checking printf and scanf format strings -#if defined(_CC_GNU_) || defined(__GNUG__) || defined(__GNUC__) -#define FX_PRINTF(fmt,arg) __attribute__((format(printf,fmt,arg))) -#define FX_SCANF(fmt,arg) __attribute__((format(scanf,fmt,arg))) -#else -#define FX_PRINTF(fmt,arg) -#define FX_SCANF(fmt,arg) -#endif - -public: - typedef size_t size_type; - typedef char value_type; - typedef char& reference; - typedef const char& const_reference; - - static const size_type npos; - - - - - /*!*********************************************************************** - @brief CPVRTString constructor. - @param[in] _Ptr A string - @param[in] _Count Length of _Ptr - ************************************************************************/ - CPVRTString(const char* _Ptr, size_t _Count = npos); - - /*!*********************************************************************** - @brief CPVRTString constructor. - @param[in] _Right A string - @param[in] _Roff Offset into _Right - @param[in] _Count Number of chars from _Right to assign to the new string - ************************************************************************/ - CPVRTString(const CPVRTString& _Right, size_t _Roff = 0, size_t _Count = npos); - - /*!*********************************************************************** - @brief CPVRTString constructor. - @param[in] _Count Length of new string - @param[in] _Ch A char to fill it with - *************************************************************************/ - CPVRTString(size_t _Count, const char _Ch); - - /*!*********************************************************************** - @brief Constructor. - @param[in] _Ch A char - *************************************************************************/ - CPVRTString(const char _Ch); - - /*!*********************************************************************** - @brief Constructor. - ************************************************************************/ - CPVRTString(); - - /*!*********************************************************************** - @brief Destructor. - ************************************************************************/ - virtual ~CPVRTString(); - - /*!*********************************************************************** - @brief Appends a string. - @param[in] _Ptr A string - @return Updated string - *************************************************************************/ - CPVRTString& append(const char* _Ptr); - - /*!*********************************************************************** - @brief Appends a string of length _Count. - @param[in] _Ptr A string - @param[in] _Count String length - @return Updated string - *************************************************************************/ - CPVRTString& append(const char* _Ptr, size_t _Count); - - /*!*********************************************************************** - @brief Appends a string. - @param[in] _Str A string - @return Updated string - *************************************************************************/ - CPVRTString& append(const CPVRTString& _Str); - - /*!*********************************************************************** - @brief Appends _Count letters of _Str from _Off in _Str. - @param[in] _Str A string - @param[in] _Off A position in string - @param[in] _Count Number of letters to append - @return Updated string - *************************************************************************/ - CPVRTString& append(const CPVRTString& _Str, size_t _Off, size_t _Count); - - /*!*********************************************************************** - @brief Appends _Ch _Count times. - @param[in] _Ch A char - @param[in] _Count Number of times to append _Ch - @return Updated string - *************************************************************************/ - CPVRTString& append(size_t _Count, const char _Ch); - - //template CPVRTString& append(InputIterator _First, InputIterator _Last); - - /*!*********************************************************************** - @brief Assigns the string to the string _Ptr. - @param[in] _Ptr A string - @return Updated string - *************************************************************************/ - CPVRTString& assign(const char* _Ptr); - - /*!*********************************************************************** - @brief Assigns the string to the string _Ptr. - @param[in] _Ptr A string - @param[in] _Count Length of _Ptr - @return Updated string - *************************************************************************/ - CPVRTString& assign(const char* _Ptr, size_t _Count); - - /*!*********************************************************************** - @brief Assigns the string to the string _Str. - @param[in] _Str A string - @return Updated string - *************************************************************************/ - CPVRTString& assign(const CPVRTString& _Str); - - /*!*********************************************************************** - @brief Assigns the string to _Count characters in string _Str starting at _Off. - @param[in] _Str A string - @param[in] _Off First char to start assignment from - @param[in] _Count Length of _Str - @return Updated string - *************************************************************************/ - CPVRTString& assign(const CPVRTString& _Str, size_t _Off, size_t _Count=npos); - - /*!*********************************************************************** - @brief Assigns the string to _Count copies of _Ch. - @param[in] _Ch A string - @param[in] _Count Number of times to repeat _Ch - @return Updated string - *************************************************************************/ - CPVRTString& assign(size_t _Count, char _Ch); - - //template CPVRTString& assign(InputIterator _First, InputIterator _Last); - - //const_reference at(size_t _Off) const; - //reference at(size_t _Off); - - // const_iterator begin() const; - // iterator begin(); - - /*!*********************************************************************** - @brief Returns a const char* pointer of the string. - @return const char* pointer of the string - *************************************************************************/ - const char* c_str() const; - - /*!*********************************************************************** - @brief Returns the size of the character array reserved. - @return The size of the character array reserved - *************************************************************************/ - size_t capacity() const; - - /*!*********************************************************************** - @brief Clears the string. - *************************************************************************/ - void clear(); - - /*!*********************************************************************** - @brief Compares the string with _Str. - @param[in] _Str A string to compare with - @return 0 if the strings match - *************************************************************************/ - int compare(const CPVRTString& _Str) const; - - /*!*********************************************************************** - @brief Compares the string with _Str. - @param[in] _Pos1 Position to start comparing from - @param[in] _Num1 Number of chars to compare - @param[in] _Str A string to compare with - @return 0 if the strings match - *************************************************************************/ - int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str) const; - - /*!*********************************************************************** - @brief Compares the string with _Str. - @param[in] _Pos1 Position to start comparing from - @param[in] _Num1 Number of chars to compare - @param[in] _Str A string to compare with - @param[in] _Off Position in _Str to compare from - @param[in] _Count Number of chars in _Str to compare with - @return 0 if the strings match - *************************************************************************/ - int compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Compares the string with _Ptr. - @param[in] _Ptr A string to compare with - @return 0 if the strings match - *************************************************************************/ - int compare(const char* _Ptr) const; - - /*!*********************************************************************** - @brief Compares the string with _Ptr. - @param[in] _Pos1 Position to start comparing from - @param[in] _Num1 Number of chars to compare - @param[in] _Ptr A string to compare with - @return 0 if the strings match - *************************************************************************/ - int compare(size_t _Pos1, size_t _Num1, const char* _Ptr) const; - - /*!*********************************************************************** - @brief Compares the string with _Str. - @param[in] _Pos1 Position to start comparing from - @param[in] _Num1 Number of chars to compare - @param[in] _Ptr A string to compare with - @param[in] _Count Number of chars to compare - @return 0 if the strings match - *************************************************************************/ - int compare(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Count) const; - - /*!*********************************************************************** - @brief Less than operator. - @param[in] _Str A string to compare with - @return True on success - *************************************************************************/ - bool operator<(const CPVRTString & _Str) const; - - /*!*********************************************************************** - @brief == Operator. - @param[in] _Str A string to compare with - @return True if they match - *************************************************************************/ - bool operator==(const CPVRTString& _Str) const; - - /*!*********************************************************************** - @brief == Operator. - @param[in] _Ptr A string to compare with - @return True if they match - *************************************************************************/ - bool operator==(const char* const _Ptr) const; - - /*!*********************************************************************** - @brief != Operator. - @param[in] _Str A string to compare with - @return True if they don't match - *************************************************************************/ - bool operator!=(const CPVRTString& _Str) const; - - /*!*********************************************************************** - @brief != Operator. - @param[in] _Ptr A string to compare with - @return True if they don't match - *************************************************************************/ - bool operator!=(const char* const _Ptr) const; - - /*!*********************************************************************** - @fn copy - @param[in,out] _Ptr A string to copy to - @param[in] _Count Size of _Ptr - @param[in] _Off Position to start copying from - @return Number of bytes copied - @brief Copies the string to _Ptr. - *************************************************************************/ - size_t copy(char* _Ptr, size_t _Count, size_t _Off = 0) const; - - /*!*********************************************************************** - @fn data - @return A const char* version of the string - @brief Returns a const char* version of the string. - *************************************************************************/ - const char* data( ) const; - - /*!*********************************************************************** - @fn empty - @return True if the string is empty - @brief Returns true if the string is empty. - *************************************************************************/ - bool empty() const; - - // const_iterator end() const; - // iterator end(); - - //iterator erase(iterator _First, iterator _Last); - //iterator erase(iterator _It); - - /*!*********************************************************************** - @brief Erases a portion of the string. - @param[in] _Pos The position to start erasing from - @param[in] _Count Number of chars to erase - @return An updated string - *************************************************************************/ - CPVRTString& erase(size_t _Pos = 0, size_t _Count = npos); - - /*!*********************************************************************** - @brief Erases a portion of the string. - @param[in] _src Character to search - @param[in] _subDes Character to substitute for - @param[in] _all Substitute all - @return An updated string - *************************************************************************/ - CPVRTString& substitute(char _src,char _subDes, bool _all = true); - - /*!*********************************************************************** - @brief Erases a portion of the string. - @param[in] _src Character to search - @param[in] _subDes Character to substitute for - @param[in] _all Substitute all - @return An updated string - *************************************************************************/ - CPVRTString& substitute(const char* _src, const char* _subDes, bool _all = true); - - //size_t find(char _Ch, size_t _Off = 0) const; - //size_t find(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Finds a substring within this string. - @param[in] _Ptr String to search. - @param[in] _Off Offset to search from. - @param[in] _Count Number of characters in this string. - @return Position of the first matched string. - *************************************************************************/ - size_t find(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Finds a substring within this string. - @param[in] _Str String to search. - @param[in] _Off Offset to search from. - @return Position of the first matched string. - *************************************************************************/ - size_t find(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that is not _Ch. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Position of the first char that is not _Ch - *************************************************************************/ - size_t find_first_not_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that is not in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Position of the first char that is not in _Ptr - *************************************************************************/ - size_t find_first_not_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that is not in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Number of chars in _Ptr - @return Position of the first char that is not in _Ptr - *************************************************************************/ - size_t find_first_not_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that is not in _Str. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Position of the first char that is not in _Str - *************************************************************************/ - size_t find_first_not_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that is _Ch. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Position of the first char that is _Ch - *************************************************************************/ - size_t find_first_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that matches a char in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Position of the first char that matches a char in _Ptr - *************************************************************************/ - size_t find_first_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that matches a char in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Size of _Ptr - @return Position of the first char that matches a char in _Ptr - *************************************************************************/ - size_t find_first_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the position of the first char that matches all chars in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Size of _Ptr - @return Position of the first char that matches a char in _Ptr - *************************************************************************/ - size_t find_first_ofn(const char* _Ptr, size_t _Off, size_t _Count) const; - - - /*!*********************************************************************** - @brief Returns the position of the first char that matches a char in _Str. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Position of the first char that matches a char in _Str - *************************************************************************/ - size_t find_first_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is not _Ch. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Position of the last char that is not _Ch - *************************************************************************/ - size_t find_last_not_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is not in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Position of the last char that is not in _Ptr - *************************************************************************/ - size_t find_last_not_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is not in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Length of _Ptr - @return Position of the last char that is not in _Ptr - *************************************************************************/ - size_t find_last_not_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is not in _Str. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Position of the last char that is not in _Str - *************************************************************************/ - size_t find_last_not_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is _Ch. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Position of the last char that is _Ch - *************************************************************************/ - size_t find_last_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Position of the last char that is in _Ptr - *************************************************************************/ - size_t find_last_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is in _Ptr. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Length of _Ptr - @return Position of the last char that is in _Ptr - *************************************************************************/ - size_t find_last_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the position of the last char that is in _Str. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Position of the last char that is in _Str - *************************************************************************/ - size_t find_last_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the number of occurances of _Ch in the parent string. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Number of occurances of _Ch in the parent string. - *************************************************************************/ - size_t find_number_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the number of occurances of _Ptr in the parent string. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Number of occurances of _Ptr in the parent string. - *************************************************************************/ - size_t find_number_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the number of occurances of _Ptr in the parent string. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Size of _Ptr - @return Number of occurances of _Ptr in the parent string. - *************************************************************************/ - size_t find_number_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the number of occurances of _Str in the parent string. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Number of occurances of _Str in the parent string. - *************************************************************************/ - size_t find_number_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the next occurance of _Ch in the parent string - after or at _Off. If not found, returns the length of the string. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Next occurance of _Ch in the parent string. - *************************************************************************/ - int find_next_occurance_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the next occurance of _Ptr in the parent string - after or at _Off. If not found, returns the length of the string. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Next occurance of _Ptr in the parent string. - *************************************************************************/ - int find_next_occurance_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the next occurance of _Ptr in the parent string - after or at _Off. If not found, returns the length of the string. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Size of _Ptr - @return Next occurance of _Ptr in the parent string. - *************************************************************************/ - int find_next_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the next occurance of _Str in the parent string - after or at _Off. If not found, returns the length of the string. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Next occurance of _Str in the parent string. - *************************************************************************/ - int find_next_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the previous occurance of _Ch in the parent string. - before _Off. If not found, returns -1. - @param[in] _Ch A char - @param[in] _Off Start position of the find - @return Previous occurance of _Ch in the parent string. - *************************************************************************/ - int find_previous_occurance_of(char _Ch, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the previous occurance of _Ptr in the parent string. - before _Off. If not found, returns -1. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @return Previous occurance of _Ptr in the parent string. - *************************************************************************/ - int find_previous_occurance_of(const char* _Ptr, size_t _Off = 0) const; - - /*!*********************************************************************** - @brief Returns the previous occurance of _Ptr in the parent string. - before _Off. If not found, returns -1. - @param[in] _Ptr A string - @param[in] _Off Start position of the find - @param[in] _Count Size of _Ptr - @return Previous occurance of _Ptr in the parent string. - *************************************************************************/ - int find_previous_occurance_of(const char* _Ptr, size_t _Off, size_t _Count) const; - - /*!*********************************************************************** - @brief Returns the previous occurance of _Str in the parent string. - before _Off. If not found, returns -1. - @param[in] _Str A string - @param[in] _Off Start position of the find - @return Previous occurance of _Str in the parent string. - *************************************************************************/ - int find_previous_occurance_of(const CPVRTString& _Str, size_t _Off = 0) const; - - /*!*********************************************************************** - @fn left - @param[in] iSize number of characters to return (excluding null character) - @return The leftmost 'iSize' characters of the string. - @brief Returns the leftmost characters of the string (excluding - the null character) in a new CPVRTString. If iSize is - larger than the string, a copy of the original string is returned. - *************************************************************************/ - CPVRTString left(size_t iSize) const; - - /*!*********************************************************************** - @fn right - @param[in] iSize number of characters to return (excluding null character) - @return The rightmost 'iSize' characters of the string. - @brief Returns the rightmost characters of the string (excluding - the null character) in a new CPVRTString. If iSize is - larger than the string, a copy of the original string is returned. - *************************************************************************/ - CPVRTString right(size_t iSize) const; - - //allocator_type get_allocator( ) const; - - //CPVRTString& insert(size_t _P0, const char* _Ptr); - //CPVRTString& insert(size_t _P0, const char* _Ptr, size_t _Count); - //CPVRTString& insert(size_t _P0, const CPVRTString& _Str); - //CPVRTString& insert(size_t _P0, const CPVRTString& _Str, size_t _Off, size_t _Count); - //CPVRTString& insert(size_t _P0, size_t _Count, char _Ch); - //iterator insert(iterator _It, char _Ch = char()); - //template void insert(iterator _It, InputIterator _First, InputIterator _Last); - //void insert(iterator _It, size_t _Count, char _Ch); - - /*!*********************************************************************** - @fn length - @return Length of the string - @brief Returns the length of the string. - *************************************************************************/ - size_t length() const; - - /*!*********************************************************************** - @fn max_size - @return The maximum number of chars that the string can contain - @brief Returns the maximum number of chars that the string can contain. - *************************************************************************/ - size_t max_size() const; - - /*!*********************************************************************** - @fn push_back - @param[in] _Ch A char to append - @brief Appends _Ch to the string. - *************************************************************************/ - void push_back(char _Ch); - - // const_reverse_iterator rbegin() const; - // reverse_iterator rbegin(); - - // const_reverse_iterator rend() const; - // reverse_iterator rend(); - - //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr); - //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str); - //CPVRTString& replace(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Num2); - //CPVRTString& replace(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t _Pos2, size_t _Num2); - //CPVRTString& replace(size_t _Pos1, size_t _Num1, size_t _Count, char _Ch); - - //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr); - //CPVRTString& replace(iterator _First0, iterator _Last0, const CPVRTString& _Str); - //CPVRTString& replace(iterator _First0, iterator _Last0, const char* _Ptr, size_t _Num2); - //CPVRTString& replace(iterator _First0, iterator _Last0, size_t _Num2, char _Ch); - //template CPVRTString& replace(iterator _First0, iterator _Last0, InputIterator _First, InputIterator _Last); - - /*!*********************************************************************** - @fn reserve - @param[in] _Count Size of string to reserve - @brief Reserves space for _Count number of chars. - *************************************************************************/ - void reserve(size_t _Count = 0); - - /*!*********************************************************************** - @fn resize - @param[in] _Count Size of string to resize to - @param[in] _Ch Character to use to fill any additional space - @brief Resizes the string to _Count in length. - *************************************************************************/ - void resize(size_t _Count, char _Ch = char()); - - //size_t rfind(char _Ch, size_t _Off = npos) const; - //size_t rfind(const char* _Ptr, size_t _Off = npos) const; - //size_t rfind(const char* _Ptr, size_t _Off = npos, size_t _Count) const; - //size_t rfind(const CPVRTString& _Str, size_t _Off = npos) const; - - /*!*********************************************************************** - @fn size - @return Size of the string - @brief Returns the size of the string. - *************************************************************************/ - size_t size() const; - - /*!*********************************************************************** - @fn substr - @param[in] _Off Start of the substring - @param[in] _Count Length of the substring - @return A substring of the string - @brief Returns the size of the string. - *************************************************************************/ - CPVRTString substr(size_t _Off = 0, size_t _Count = npos) const; - - /*!*********************************************************************** - @fn swap - @param[in] _Str A string to swap with - @brief Swaps the contents of the string with _Str. - *************************************************************************/ - void swap(CPVRTString& _Str); - - /*!*********************************************************************** - @fn toLower - @return An updated string - @brief Converts the string to lower case. - *************************************************************************/ - CPVRTString& toLower(); - - /*!*********************************************************************** - @fn toUpper - @return An updated string - @brief Converts the string to upper case. - *************************************************************************/ - CPVRTString& toUpper(); - - /*!*********************************************************************** - @fn format - @param[in] pFormat A string containing the formating - @return A formatted string - @brief Return the formatted string. - ************************************************************************/ - CPVRTString format(const char *pFormat, ...); - -#ifndef UNDER_CE - /*!*********************************************************************** - @fn formatPositional - @param[in] pFormat A string containing the formatting. - Positional modifiers may be used. - @return A formatted string - @brief Return the formatted string. - ************************************************************************/ - CPVRTString formatPositional(const char *pFormat, ...); -#endif - - /*!*********************************************************************** - @brief += Operator. - @param[in] _Ch A char - @return An updated string - *************************************************************************/ - CPVRTString& operator+=(char _Ch); - - /*!*********************************************************************** - @brief += Operator. - @param[in] _Ptr A string - @return An updated string - *************************************************************************/ - CPVRTString& operator+=(const char* _Ptr); - - /*!*********************************************************************** - @brief += Operator. - @param[in] _Right A string - @return An updated string - *************************************************************************/ - CPVRTString& operator+=(const CPVRTString& _Right); - - /*!*********************************************************************** - @brief = Operator. - @param[in] _Ch A char - @return An updated string - *************************************************************************/ - CPVRTString& operator=(char _Ch); - - /*!*********************************************************************** - @brief = Operator. - @param[in] _Ptr A string - @return An updated string - *************************************************************************/ - CPVRTString& operator=(const char* _Ptr); - - /*!*********************************************************************** - @brief = Operator. - @param[in] _Right A string - @return An updated string - *************************************************************************/ - CPVRTString& operator=(const CPVRTString& _Right); - - /*!*********************************************************************** - @brief [] Operator. - @param[in] _Off An index into the string - @return A character - *************************************************************************/ - const_reference operator[](size_t _Off) const; - - /*!*********************************************************************** - @brief [] Operator. - @param[in] _Off An index into the string - @return A character - *************************************************************************/ - reference operator[](size_t _Off); - - /*!*********************************************************************** - @brief + Operator. - @param[in] _Left A string - @param[in] _Right A string - @return An updated string - *************************************************************************/ - friend CPVRTString operator+ (const CPVRTString& _Left, const CPVRTString& _Right); - - /*!*********************************************************************** - @brief + Operator. - @param[in] _Left A string - @param[in] _Right A string - @return An updated string - *************************************************************************/ - friend CPVRTString operator+ (const CPVRTString& _Left, const char* _Right); - - /*!*********************************************************************** - @brief + Operator. - @param[in] _Left A string - @param[in] _Right A string - @return An updated string - *************************************************************************/ - friend CPVRTString operator+ (const CPVRTString& _Left, const char _Right); - - /*!*********************************************************************** - @brief + Operator. - @param[in] _Left A string - @param[in] _Right A string - @return An updated string - *************************************************************************/ - friend CPVRTString operator+ (const char* _Left, const CPVRTString& _Right); - - - /*!*********************************************************************** - @brief + Operator. - @param[in] _Left A string - @param[in] _Right A string - @return An updated string - *************************************************************************/ - friend CPVRTString operator+ (const char _Left, const CPVRTString& _Right); - -protected: - char* m_pString; - size_t m_Size; - size_t m_Capacity; -}; - -/************************************************************************* -* MISCELLANEOUS UTILITY FUNCTIONS -*************************************************************************/ -/*!*********************************************************************** - @fn PVRTStringGetFileExtension - @param[in] strFilePath A string - @return Extension - @brief Extracts the file extension from a file path. - Returns an empty CPVRTString if no extension is found. -************************************************************************/ -CPVRTString PVRTStringGetFileExtension(const CPVRTString& strFilePath); - -/*!*********************************************************************** - @fn PVRTStringGetContainingDirectoryPath - @param[in] strFilePath A string - @return Directory - @brief Extracts the directory portion from a file path. -************************************************************************/ -CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath); - -/*!*********************************************************************** - @fn PVRTStringGetFileName - @param[in] strFilePath A string - @return FileName - @brief Extracts the name and extension portion from a file path. -************************************************************************/ -CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath); - -/*!*********************************************************************** - @fn PVRTStringStripWhiteSpaceFromStartOf - @param[in] strLine A string - @return Result of the white space stripping - @brief Strips white space characters from the beginning of a CPVRTString. -************************************************************************/ -CPVRTString PVRTStringStripWhiteSpaceFromStartOf(const CPVRTString& strLine); - -/*!*********************************************************************** - @fn PVRTStringStripWhiteSpaceFromEndOf - @param[in] strLine A string - @return Result of the white space stripping - @brief Strips white space characters from the end of a CPVRTString. -************************************************************************/ -CPVRTString PVRTStringStripWhiteSpaceFromEndOf(const CPVRTString& strLine); - -/*!*********************************************************************** - @fn PVRTStringFromFormattedStr - @param[in] pFormat A string containing the formating - @return A formatted string - @brief Creates a formatted string. -************************************************************************/ -CPVRTString PVRTStringFromFormattedStr(const char *pFormat, ...); - -#ifndef UNDER_CE -/*!*********************************************************************** -@Function PVRTStringFromFormattedStrPositional -@Input pFormat A string containing the formatting - with optional positional qualifiers -@Returns A formatted string -@Description Creates a formatted string -************************************************************************/ -CPVRTString PVRTStringFromFormattedStrPositional(const char *pFormat, ...); -#endif - -#endif // _PVRTSTRING_H_ - -/***************************************************************************** -End of file (PVRTString.h) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTTexture.h b/deps/PVRTT/include/PVRTTexture.h deleted file mode 100644 index 23765f0c0a..0000000000 --- a/deps/PVRTT/include/PVRTTexture.h +++ /dev/null @@ -1,736 +0,0 @@ -/*!**************************************************************************** - - @file PVRTTexture.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Texture loading. - -******************************************************************************/ -#ifndef _PVRTTEXTURE_H_ -#define _PVRTTEXTURE_H_ - -#include "PVRTGlobal.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; - - -/*!*********************************************************************** - @fn PVRTGetBitsPerPixel - @param[in] u64PixelFormat A PVR Pixel Format ID. - @return const PVRTuint32 Number of bits per pixel. - @brief Returns the number of bits per pixel in a PVR Pixel Format - identifier. -*************************************************************************/ -PVRTuint32 PVRTGetBitsPerPixel(PVRTuint64 u64PixelFormat); - -/*!*********************************************************************** - @fn PVRTGetFormatMinDims - @param[in] u64PixelFormat A PVR Pixel Format ID. - @param[in,out] minX Returns the minimum width. - @param[in,out] minY Returns the minimum height. - @param[in,out] minZ Returns the minimum depth. - @brief Gets the minimum dimensions (x,y,z) for a given pixel format. -*************************************************************************/ -void PVRTGetFormatMinDims(PVRTuint64 u64PixelFormat, PVRTuint32 &minX, PVRTuint32 &minY, PVRTuint32 &minZ); - -/*!*********************************************************************** - @fn PVRTConvertOldTextureHeaderToV3 - @param[in] LegacyHeader Legacy header for conversion. - @param[in,out] NewHeader New header to output into. - @param[in,out] pMetaData MetaData Map to output into. - @brief 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); - -/*!*********************************************************************** - @fn PVRTMapLegacyTextureEnumToNewFormat - @param[in] OldFormat Legacy Enumeration Value - @param[in,out] newType New PixelType identifier. - @param[in,out] newCSpace New ColourSpace - @param[in,out] newChanType New Channel Type - @param[in,out] isPreMult Whether format is pre-multiplied - @brief Maps a legacy enumeration value to the new PVR3 style format. -*************************************************************************/ -void PVRTMapLegacyTextureEnumToNewFormat(PVRTPixelType OldFormat, PVRTuint64& newType, EPVRTColourSpace& newCSpace, EPVRTVariableType& newChanType, bool& isPreMult); - -/*!*************************************************************************** - @fn PVRTTextureLoadTiled - @param[in,out] pDst Texture to place the tiled data - @param[in] nWidthDst Width of destination texture - @param[in] nHeightDst Height of destination texture - @param[in] pSrc Texture to tile - @param[in] nWidthSrc Width of source texture - @param[in] nHeightSrc Height of source texture - @param[in] nElementSize Bytes per pixel - @param[in] bTwiddled True if the data is twiddled - @brief 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); - - -/*!*************************************************************************** - @fn PVRTTextureTwiddle - @param[out] a Twiddled value - @param[in] u Coordinate axis 0 - @param[in] v Coordinate axis 1 - @brief Combine a 2D coordinate into a twiddled value. -*****************************************************************************/ -void PVRTTextureTwiddle(unsigned int &a, const unsigned int u, const unsigned int v); - -/*!*************************************************************************** - @fn PVRTTextureDeTwiddle - @param[out] u Coordinate axis 0 - @param[out] v Coordinate axis 1 - @param[in] a Twiddled value - @brief Extract 2D coordinates from a twiddled value. -*****************************************************************************/ -void PVRTTextureDeTwiddle(unsigned int &u, unsigned int &v, const unsigned int a); - -/*!*********************************************************************** - @fn PVRTGetTextureDataSize - @param[in] sTextureHeader Specifies the texture header. - @param[in] iMipLevel Specifies a mip level to check, 'PVRTEX_ALLMIPLEVELS' - can be passed to get the size of all MIP levels. - @param[in] bAllSurfaces Size of all surfaces is calculated if true, - only a single surface if false. - @param[in] 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. - @brief 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) -*****************************************************************************/ - diff --git a/deps/PVRTT/include/PVRTexture.h b/deps/PVRTT/include/PVRTexture.h deleted file mode 100644 index b1694a7817..0000000000 --- a/deps/PVRTT/include/PVRTexture.h +++ /dev/null @@ -1,291 +0,0 @@ -/*!*********************************************************************** - - @file PVRTexture.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Contains methods concerning basic CPVRTexture creation, saving - and data duplication. This is the main class for PVRTexLib. - -*************************************************************************/ - -/*****************************************************************************/ -/*! @mainpage PVRTexLib -****************************************************************************** - - @section overview Overview -***************************** - -PVRTexLib is a library for the management of textures. It occupies the @ref pvrtexture -namespace and allows users to access the PVRTexTool functionality in a library, -for easy integration with existing tool chains. - -PVRTexLib contains the facility to: - \li Load and save PVR files. - \li Transcode to and from many different texture formats. - \li Perform a variety of pre-process techniques on decompressed pixel data. - \li Provide information about a texture file loaded by the library. - - @section pvrtools PVRTools -***************************** -A number of header files from the PowerVR SDK Tools libraries are present in PVRTexLib: - \li PVRTGlobal.h - \li PVRTError.h - \li PVRTArray.h - \li PVRTMap.h - \li PVRTString.h - \li PVRTTexture.h - -These header files are included in the PVRTexLib package so that separate installation -of the tools libraries is not required. If PowerVR Graphics SDK Tools are installed, -documentation for the these files can be found in the ‘Tools’ folder -in the PowerVR Insider SDK directory. - -*/ - -#ifndef _PVRTEXTURE_H -#define _PVRTEXTURE_H - -#include - -#include "PVRTextureHeader.h" -#include "PVRTString.h" - -namespace pvrtexture -{ - /*!*********************************************************************** - @class CPVRTexture - @brief A full public texture container format, with support for custom - meta-data, and complete, optimised, resource loading code into PVRTools. - *************************************************************************/ - class PVR_DLL CPVRTexture : public CPVRTextureHeader - { - public: - // Construction methods for a texture. - - /*!*********************************************************************** - @brief Creates a new empty texture - @return A new CPVRTexture. - *************************************************************************/ - CPVRTexture(); - - /*!*********************************************************************** - @brief Creates a new texture based on a texture header, - pre-allocating the correct amount of memory. If data is - supplied, it will be copied into memory. - @param[in] sHeader Texture header - @param[in] pData Texture data - @return A new CPVRTexture. - *************************************************************************/ - CPVRTexture(const CPVRTextureHeader& sHeader, const void* pData=NULL); - - /*!*********************************************************************** - @brief Creates a new texture from a filepath. - @param[in] szFilePath File path to existing texture - @return A new CPVRTexture. - *************************************************************************/ - CPVRTexture(const char* szFilePath); - - /*!*********************************************************************** - @brief Creates a new texture from a pointer that includes a header - structure, meta data and texture data as laid out in a file. - This functionality is primarily for user-defined file loading. - Header may be any version of pvr. - @param[in] pTexture Pointer to texture data - @return A new CPVRTexture. - *************************************************************************/ - CPVRTexture( const void* pTexture ); - - /*!*********************************************************************** - @brief Creates a new texture as a copy of another. - @param[in] texture Texture to copy - @return A new CPVRTexture - *************************************************************************/ - CPVRTexture(const CPVRTexture& texture); - - /*!*********************************************************************** - @brief Deconstructor for CPVRTextures. - *************************************************************************/ - ~CPVRTexture(); - - /*!*********************************************************************** - @brief Will copy the contents and information of another texture into this one. - @param[in] rhs Texture to copy - @return This texture. - *************************************************************************/ - CPVRTexture& operator=(const CPVRTexture& rhs); - - // Texture accessor functions - others are inherited from CPVRTextureHeader. - - /*!*********************************************************************** - @brief Returns a pointer into the texture's data. - @details It is possible to specify an offset to specific array members, - faces and MIP Map levels. - @param[in] uiMIPLevel Offset to MIP Map levels - @param[in] uiArrayMember Offset to array members - @param[in] uiFaceNumber Offset to face numbers - @return Pointer to a location in the texture. - *************************************************************************/ - void* getDataPtr(uint32 uiMIPLevel = 0, uint32 uiArrayMember = 0, uint32 uiFaceNumber = 0) const; - - /*!*********************************************************************** - @brief Gets the header for this texture, allowing you to create a new - texture based on this one with some changes. Useful for passing - information about a texture without passing all of its data. - @return Returns the header only for this texture. - *************************************************************************/ - const CPVRTextureHeader& getHeader() const; - - // File io. - - /*!*********************************************************************** - @brief When writing the texture out to a PVR file, it is often - desirable to pad the meta data so that the start of the - texture data aligns to a given boundary. - @details This function pads to a boundary value equal to "uiPadding". - For example setting uiPadding=8 will align the start of the - texture data to an 8 byte boundary. - Note - this should be called immediately before saving as - the value is worked out based on the current meta data size. - @param[in] uiPadding Padding boundary value - *************************************************************************/ - void addPaddingMetaData( uint32 uiPadding ); - - /*!*********************************************************************** - @brief Writes out to a file, given a filename and path. - @details File type will be determined by the extension present in the string. - If no extension is present, PVR format will be selected. - Unsupported formats will result in failure. - @param[in] filepath File path to write to - @return True if the method succeeds. - *************************************************************************/ - bool saveFile(const CPVRTString& filepath) const; - - /*!*********************************************************************** - @brief Writes out to a file, stripping any extensions specified - and appending .pvr. This function is for legacy support only - and saves out to PVR Version 2 file. The target api must be - specified in order to save to this format. - @param[in] filepath File path to write to - @param[in] eApi Target API - @return True if the method succeeds. - *************************************************************************/ - bool saveFileLegacyPVR(const CPVRTString& filepath, ELegacyApi eApi) const; - - /*!*********************************************************************** - @brief Saves an ASTC File. - @param[in] filepath File path to write to - @return True if the method succeeds. - *************************************************************************/ - bool saveASTCFile(const CPVRTString& filepath) const; - - /*!*********************************************************************** - @brief Convert texture to KTX - @param[in] out Output stream for KTX data - *************************************************************************/ - void toKTX(std::ostream & out) const; - - /*!*********************************************************************** - @brief Convert texture to ASTC - @param[in] out Output stream for ASTC data - *************************************************************************/ - void toASTC(std::ostream & out) const; - - /*!*********************************************************************** - @brief Makes a PVRTexture from a KTX file stream - @param[in] in The KTX file stream - @return The texture - *************************************************************************/ - static CPVRTexture fromKTX(std::istream & in); - - /*!*********************************************************************** - @brief Makes a PVRTexture from a pointer to an ASTC file in memory - @param[in] in The ASTC file stream - @return The texture - *************************************************************************/ - static CPVRTexture fromASTC(std::istream & in); - - private: - size_t m_stDataSize; //!< Size of the texture data. - uint8* m_pTextureData; //!< Pointer to texture data. - - // Private IO functions - - /*!*********************************************************************** - @brief Loads a PVR file. - @param[in] pTextureFile PVR texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateLoadPVRFile(FILE* pTextureFile); - - /*!*********************************************************************** - @brief Saves a PVR File. - @param[in] pTextureFile PVR texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateSavePVRFile(FILE* pTextureFile) const; - - /*!*********************************************************************** - @brief Loads a KTX file. - @param[in] pTextureFile KTX texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateLoadKTXFile(FILE* pTextureFile); - bool privateLoadKTXFile(std::istream & in); - - /*!*********************************************************************** - @brief Saves a KTX File. - @param[in] pTextureFile KTX texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateSaveKTXFile(FILE* pTextureFile) const; - - /*!*********************************************************************** - @brief Loads a DDS file. - @param[in] pTextureFile DDS texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateLoadDDSFile(FILE* pTextureFile); - - /*!*********************************************************************** - @brief Saves a DDS File. - @param[in] pTextureFile DDS texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateSaveDDSFile(FILE* pTextureFile) const; - - /*!*********************************************************************** - @brief Loads an ASTC file. - @param[in] pTextureFile ASTC texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateLoadASTCFile(FILE* pTextureFile); - bool privateLoadASTCFile(std::istream & in); - - /*!*********************************************************************** - @brief Saves an ASTC file. - @param[in] pTextureFile ASTC texture file - @return True if the method succeeds. - *************************************************************************/ - bool privateSaveASTCFile(FILE* pTextureFile) const; - - //Legacy IO - - /*!*********************************************************************** - @brief Saves a .h File. Legacy operator - @param[in] pTextureFile PVR texture file - @param[in] filename File path to write to - @return True if the method succeeds. - *************************************************************************/ - bool privateSaveCHeaderFile(FILE* pTextureFile, CPVRTString filename) const; - - /*!*********************************************************************** - @brief Saves a legacy PVR File - Uses version 2 file format. - @param[in] pTextureFile PVR texture file - @param[in] eApi Target API - @return True if the method succeeds. - *************************************************************************/ - bool privateSaveLegacyPVRFile(FILE* pTextureFile, ELegacyApi eApi) const; - }; -} - -#endif //_PVRTEXTURE_H - diff --git a/deps/PVRTT/include/PVRTextureDefines.h b/deps/PVRTT/include/PVRTextureDefines.h deleted file mode 100644 index cb66e55eff..0000000000 --- a/deps/PVRTT/include/PVRTextureDefines.h +++ /dev/null @@ -1,140 +0,0 @@ -/*!*********************************************************************** - - @file PVRTextureDefines.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Method, template and type defines for PVRTexture. - -*************************************************************************/ - -#ifndef _PVRTEXTURE_DEFINES_H -#define _PVRTEXTURE_DEFINES_H - -//To use the PVRTexLib .dll on Windows, you need to define _WINDLL_IMPORT -#ifndef PVR_DLL -#if defined(_WINDLL_EXPORT) -#define PVR_DLL __declspec(dllexport) -//Forward declaration of various classes/structs used by this library. This exports their interfaces for DLLs. -struct PVR_DLL PVRTextureHeaderV3; -struct PVR_DLL MetaDataBlock; -template -class PVR_DLL CPVRTMap; -template -class PVR_DLL CPVRTArray; -class PVR_DLL CPVRTString; -#elif defined(_WINDLL_IMPORT) -#define PVR_DLL __declspec(dllimport) -//Forward declaration of various classes/structs used by this library. This imports their interfaces for DLLs. -struct PVR_DLL PVRTextureHeaderV3; -struct PVR_DLL MetaDataBlock; -template -class PVR_DLL CPVRTMap; -template -class PVR_DLL CPVRTArray; -class PVR_DLL CPVRTString; -#else - -/*!*********************************************************************** - @def PVR_DLL - @brief Required to use PVRTexLib.dll on Windows. -*************************************************************************/ -#define PVR_DLL -#endif -#endif - -#include "PVRTTexture.h" - -/*!*********************************************************************** - @namespace pvrtexture - @brief PVRTexture namespace. Contains methods and classes for PVRTexLib. -*************************************************************************/ -namespace pvrtexture -{ - // Type defines for standard variable sizes. - - typedef signed char int8; //!< Signed 8 bit integer - typedef signed short int16; //!< Signed 16 bit integer - typedef signed int int32; //!< Signed 32 bit integer - typedef signed long long int64; //!< Signed 64 bit integer - typedef unsigned char uint8; //!< Unsigned 8 bit integer - typedef unsigned short uint16; //!< Unsigned 16 bit integer - typedef unsigned int uint32; //!< Unsigned 32 bit integer - typedef unsigned long long uint64; //!< Unsigned 64 bit integer - - // Texture related constants and enumerations. - - /*!*********************************************************************** - @enum ECompressorQuality - @brief Quality level to compress the texture with. Currently valid with - ETC and PVRTC formats. - *************************************************************************/ - enum ECompressorQuality - { - ePVRTCFastest=0, //!< PVRTC fastest - ePVRTCFast, //!< PVRTC fast - ePVRTCNormal, //!< PVRTC normal - ePVRTCHigh, //!< PVRTC high - ePVRTCBest, //!< PVRTC best - eNumPVRTCModes, //!< Number of PVRTC modes - - eETCFast=0, //!< ETC fast - eETCFastPerceptual, //!< ETC fast perceptual - eETCSlow, //!< ETC slow - eETCSlowPerceptual, //!< ETC slow perceptual - eNumETCModes, //!< Number of ETC modes - - eASTCVeryFast=0, //!< ASTC very fast - eASTCFast, //!< ASTC fast - eASTCMedium, //!< ASTC medium - eASTCThorough, //!< ASTC thorough - eASTCExhaustive, //!< ASTC exhaustive - eNumASTCModes //!< Number of ASTC modes - }; - - /*!*********************************************************************** - @enum EResizeMode - @brief Texture resize mode - *************************************************************************/ - enum EResizeMode - { - eResizeNearest, //!< Nearest filtering - eResizeLinear, //!< Linear filtering - eResizeCubic, //!< Cubic filtering, uses Catmull-Rom splines. - eNumResizeModes //!< Number of resize modes - }; - - /*!*********************************************************************** - @enum ELegacyApi - @brief Legacy API enum. - *************************************************************************/ - enum ELegacyApi - { - eOGLES=1, //!< OpenGL ES 1.x - eOGLES2, //!< OpenGL ES 2.0 - eD3DM, //!< Direct 3D M - eOGL, //!< Open GL - eDX9, //!< DirextX 9 - eDX10, //!< DirectX 10 - eOVG, //!< Open VG - eMGL, //!< MGL - }; - - // Useful macros. - /*!*************************************************************************** - @def TEXOFFSET2D - @brief 2D texture offset - *****************************************************************************/ - #define TEXOFFSET2D(x,y,width) ( ((x)+(y)*(width)) ) - - /*!*************************************************************************** - @def TEXOFFSET3D - @brief 3D texture offset - *****************************************************************************/ - #define TEXOFFSET3D(x,y,z,width,height) ( ((x)+(y)*(width)+(z)*(width)*(height)) ) - - /*!*************************************************************************** - @typedef MetaDataMap - @brief Useful typedef for generating maps of MetaData blocks. - *****************************************************************************/ - typedef CPVRTMap > MetaDataMap; -} -#endif //_PVRTEXTURE_DEFINES_H diff --git a/deps/PVRTT/include/PVRTextureFormat.h b/deps/PVRTT/include/PVRTextureFormat.h deleted file mode 100644 index 48627ec278..0000000000 --- a/deps/PVRTT/include/PVRTextureFormat.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _PVRT_PIXEL_FORMAT_H -#define _PVRT_PIXEL_FORMAT_H - -#include "PVRTextureDefines.h" -#include "PVRTString.h" - -namespace pvrtexture -{ - //Channel Names - enum EChannelName - { - eNoChannel, - eRed, - eGreen, - eBlue, - eAlpha, - eLuminance, - eIntensity, - eUnspecified, - eNumChannels - }; - - //PixelType union - union PVR_DLL PixelType - { - /*!*********************************************************************** - @Function PixelType - @Return A new PixelType - @Description Creates an empty pixeltype. - *************************************************************************/ - PixelType(); - - /*!*********************************************************************** - @Function PixelType - @Input Type - @Return A new PixelType - @Description Initialises a new pixel type from a 64 bit integer value. - *************************************************************************/ - PixelType(uint64 Type); - - /*!*********************************************************************** - @Function PixelType - @Input C1Name - @Input C2Name - @Input C3Name - @Input C4Name - @Input C1Bits - @Input C2Bits - @Input C3Bits - @Input C4Bits - @Return A new PixelType - @Description Takes up to 4 characters (CnName) and 4 values (CnBits) - to create a new PixelType. Any unused channels should be set to 0. - For example: PixelType('r','g','b',0,8,8,8,0); - *************************************************************************/ - PixelType(uint8 C1Name, uint8 C2Name, uint8 C3Name, uint8 C4Name, uint8 C1Bits, uint8 C2Bits, uint8 C3Bits, uint8 C4Bits); - - struct PVR_DLL LowHigh - { - uint32 Low; - uint32 High; - } Part; - - uint64 PixelTypeID; - uint8 PixelTypeChar[8]; - }; - - static const PixelType PVRStandard8PixelType = PixelType('r','g','b','a',8,8,8,8); - static const PixelType PVRStandard16PixelType = PixelType('r','g','b','a',16,16,16,16); - static const PixelType PVRStandard32PixelType = PixelType('r','g','b','a',32,32,32,32); -} - -#endif diff --git a/deps/PVRTT/include/PVRTextureHeader.h b/deps/PVRTT/include/PVRTextureHeader.h deleted file mode 100644 index f6109416b5..0000000000 --- a/deps/PVRTT/include/PVRTextureHeader.h +++ /dev/null @@ -1,552 +0,0 @@ -/*!*********************************************************************** - - @file PVRTextureHeader.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief Texture header methods. - @details Includes pixel and channel type methods, size retrieval and - dimension manipulation. As well as set and get methods for - BumpMaps, Meta Data and cube map order. - -*************************************************************************/ - -#ifndef _PVRTEXTURE_HEADER_H -#define _PVRTEXTURE_HEADER_H - -#include "PVRTextureDefines.h" -#include "PVRTextureFormat.h" -#include "PVRTString.h" -#include "PVRTMap.h" - -namespace pvrtexture -{ - /*!*********************************************************************** - @class CPVRTextureHeader - @brief Wrapper class for PVRTextureHeaderV3, adds 'smart' accessor functions. - *************************************************************************/ - class PVR_DLL CPVRTextureHeader - { - protected: - PVRTextureHeaderV3 m_sHeader; //!< Texture header as laid out in a file. - CPVRTMap > m_MetaData; //!< Map of all the meta data stored for a texture. - - public: - // Construction methods for a texture header. - /*!*********************************************************************** - @brief Default constructor for a CPVRTextureHeader. Returns an empty header. - @return A new texture header. - *************************************************************************/ - CPVRTextureHeader(); - - /*!*********************************************************************** - @brief Creates a new texture header from a PVRTextureHeaderV3, - and appends Meta data if any is supplied. - @param[in] fileHeader PVRTextureHeaderV3 - @param[in] metaDataCount Number of Meta data blocks to add - @param[in] metaData Pointer to meta data block - @return A new texture header. - *************************************************************************/ - CPVRTextureHeader( PVRTextureHeaderV3 fileHeader, - uint32 metaDataCount=0, - MetaDataBlock* metaData=NULL); - - /*!*********************************************************************** - @brief Creates a new texture header based on individual header - variables. - @param[in] u64PixelFormat PixelFormat - @param[in] u32Height Texture height - @param[in] u32Width Texture width - @param[in] u32Depth Texture depth - @param[in] u32NumMipMaps Number of MIP Maps - @param[in] u32NumArrayMembers Number of array members - @param[in] u32NumFaces Number of faces - @param[in] eColourSpace Colour space - @param[in] eChannelType Channel type - @param[in] bPreMultiplied Whether or not the texture's colour has been - pre-multiplied by the alpha values - @return A new texture header. - *************************************************************************/ - CPVRTextureHeader( uint64 u64PixelFormat, - uint32 u32Height=1, - uint32 u32Width=1, - uint32 u32Depth=1, - uint32 u32NumMipMaps=1, - uint32 u32NumArrayMembers=1, - uint32 u32NumFaces=1, - EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, - EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, - bool bPreMultiplied=false); - - /*!*********************************************************************** - @brief Deconstructor for CPVRTextureHeader. - *************************************************************************/ - ~CPVRTextureHeader(); - - /*!*********************************************************************** - @brief Will copy the contents and information of another header into this one. - @param[in] rhs Header to copy. - @return This header. - *************************************************************************/ - CPVRTextureHeader& operator=(const CPVRTextureHeader& rhs); - - // Accessor Methods for a texture's properties - getters. - - /*!*********************************************************************** - @brief Gets the file header structure. - @return The file header. - *************************************************************************/ - PVRTextureHeaderV3 getFileHeader() const; - - /*!*********************************************************************** - @brief Gets the 64-bit pixel type ID of the texture. - @return 64-bit pixel type ID. - *************************************************************************/ - PixelType getPixelType() const; - - /*!*********************************************************************** - @brief Gets the bits per pixel of the texture format. - @return Number of bits per pixel. - *************************************************************************/ - uint32 getBitsPerPixel() const; - - /*!*********************************************************************** - @brief Returns the colour space of the texture. - @return enum representing colour space. - *************************************************************************/ - EPVRTColourSpace getColourSpace() const; - - /*!*********************************************************************** - @brief Returns the variable type that the texture's data is stored in. - @return enum representing the type of the texture. - *************************************************************************/ - EPVRTVariableType getChannelType() const; - - /*!*********************************************************************** - @brief Gets the width of the user specified MIP-Map - level for the texture - @param[in] uiMipLevel MIP level that user is interested in. - @return Width of the specified MIP-Map level. - *************************************************************************/ - uint32 getWidth(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; - - /*!*********************************************************************** - @brief Gets the height of the user specified MIP-Map - level for the texture - @param[in] uiMipLevel MIP level that user is interested in. - @return Height of the specified MIP-Map level. - *************************************************************************/ - uint32 getHeight(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; - - /*!*********************************************************************** - @brief Gets the depth of the user specified MIP-Map - level for the texture - @param[in] uiMipLevel MIP level that user is interested in. - @return Depth of the specified MIP-Map level. - *************************************************************************/ - uint32 getDepth(uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) const; - - /*!*********************************************************************** - @brief Gets the size in PIXELS of the texture, given various input - parameters. User can retrieve the total 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. All of these - @param[in] iMipLevel Specifies a MIP level to check, - 'PVRTEX_ALLMIPLEVELS' can be passed to get - the size of all MIP levels. - @param[in] bAllSurfaces Size of all surfaces is calculated if true, - only a single surface if false. - @param[in] bAllFaces Size of all faces is calculated if true, - only a single face if false. - @return Size in PIXELS of the specified texture area. - *************************************************************************/ - uint32 getTextureSize(int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) const; - - /*!*********************************************************************** - @brief 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. - @param[in] iMipLevel Specifies a mip level to check, - 'PVRTEX_ALLMIPLEVELS' can be passed to get - the size of all MIP levels. - @param[in] bAllSurfaces Size of all surfaces is calculated if true, - only a single surface if false. - @param[in] bAllFaces Size of all faces is calculated if true, - only a single face if false. - @return Size in BYTES of the specified texture area. - *************************************************************************/ - uint32 getDataSize(int32 iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) const; - - /*!*********************************************************************** - @brief Gets the number of array members stored in this texture. - @return Number of array members in this texture. - *************************************************************************/ - uint32 getNumArrayMembers() const; - - /*!*********************************************************************** - @brief Gets the number of MIP-Map levels stored in this texture. - @return Number of MIP-Map levels in this texture. - *************************************************************************/ - uint32 getNumMIPLevels() const; - - /*!*********************************************************************** - @brief Gets the number of faces stored in this texture. - @return Number of faces in this texture. - *************************************************************************/ - uint32 getNumFaces() const; - - /*!*********************************************************************** - @brief Gets the data orientation for this texture. - @param[in] axis EPVRTAxis type specifying the axis to examine. - @return Enum orientation of the axis. - *************************************************************************/ - EPVRTOrientation getOrientation(EPVRTAxis axis) const; - - /*!*********************************************************************** - @brief Returns whether or not the texture is compressed using - PVRTexLib's FILE compression - this is independent of - any texture compression. - @return True if it is file compressed. - *************************************************************************/ - bool isFileCompressed() const; - - /*!*********************************************************************** - @brief Returns whether or not the texture's colour has been - pre-multiplied by the alpha values. - @return True if texture is premultiplied. - *************************************************************************/ - bool isPreMultiplied() const; - - /*!*********************************************************************** - @brief Returns the total size of the meta data stored in the header. - This includes the size of all information stored in all MetaDataBlocks. - @return Size, in bytes, of the meta data stored in the header. - *************************************************************************/ - uint32 getMetaDataSize() const; - - /*!*********************************************************************** - @brief Gets the OpenGL equivalent values of internal format, format - and type for this texture. This will return any supported - OpenGL texture values, it is up to the user to decide if - these are valid for their current platform. - @param[in,out] internalformat Internal format - @param[in,out] format Format - @param[in,out] type Type - *************************************************************************/ - void getOGLFormat(uint32& internalformat, uint32& format, uint32& type) const; - - /*!*********************************************************************** - @brief Gets the OpenGLES equivalent values of internal format, - format and type for this texture. This will return any - supported OpenGLES texture values, it is up to the user - to decide if these are valid for their current platform. - @param[in,out] internalformat Internal format - @param[in,out] format Format - @param[in,out] type Type - *************************************************************************/ - void getOGLESFormat(uint32& internalformat, uint32& format, uint32& type) const; - - /*!*********************************************************************** - @brief Gets the Vulkan equivalent values for this texture. - This will return any supported Vulkan texture formats, it is up to - the user to decide if these are valid for their current platform. - @return VkFormat, represented by a uint32. - *************************************************************************/ - uint32 getVulkanFormat() const; - - /*!*********************************************************************** - @brief Gets the D3DFormat (up to DirectX 9 and Direct 3D Mobile) - equivalent values for this texture. This will return any - supported D3D texture formats, it is up to the user to - decide if this is valid for their current platform. - @return D3D format, represented by an uint32. - *************************************************************************/ - uint32 getD3DFormat() const; - - /*!*********************************************************************** - @brief Gets the DXGIFormat (DirectX 10 onward) equivalent values - for this texture. This will return any supported DX texture - formats, it is up to the user to decide if this is valid - for their current platform. - @return DXGIFormat, represented by a uint32. - *************************************************************************/ - uint32 getDXGIFormat() const; - - // Accessor Methods for a texture's properties - setters. - - /*!*********************************************************************** - @brief Sets the pixel format for this texture. - @param[in] uPixelFormat The format of the pixel. - *************************************************************************/ - void setPixelFormat(PixelType uPixelFormat); - - /*!*********************************************************************** - @brief Sets the colour space for this texture. Default is lRGB. - @param[in] eColourSpace A colour space enum. - *************************************************************************/ - void setColourSpace(EPVRTColourSpace eColourSpace); - - /*!*********************************************************************** - @brief Sets the variable type for the channels in this texture. - @param[in] eVarType A variable type enum. - *************************************************************************/ - void setChannelType(EPVRTVariableType eVarType); - - /*!*********************************************************************** - @brief Sets the format of the texture to PVRTexLib's internal - representation of the OGL format. - @param[in,out] internalformat Internal format - @param[in,out] format Format - @param[in,out] type Type - @return True if successful. - *************************************************************************/ - bool setOGLFormat(const uint32& internalformat, const uint32& format, const uint32& type); - - /*!*********************************************************************** - @brief Sets the format of the texture to PVRTexLib's internal - representation of the OGLES format. - @param[in,out] internalformat Internal format - @param[in,out] format Format - @param[in,out] type Type - @return True if successful. - *************************************************************************/ - bool setOGLESFormat(const uint32& internalformat, const uint32& format, const uint32& type); - - /*!*********************************************************************** - @brief Sets the format of the texture to PVRTexLib's internal - representation of the D3D format. - @return True if successful. - *************************************************************************/ - bool setD3DFormat(const uint32& DWORD_D3D_FORMAT); - - /*!*********************************************************************** - @brief Sets the format of the texture to PVRTexLib's internal - representation of the DXGI format. - @return True if successful. - *************************************************************************/ - bool setDXGIFormat(const uint32& DWORD_DXGI_FORMAT); - - /*!*********************************************************************** - @brief Sets the width. - @param[in] newWidth The new width. - *************************************************************************/ - void setWidth(uint32 newWidth); - - /*!*********************************************************************** - @brief Sets the height. - @param[in] newHeight The new height. - *************************************************************************/ - void setHeight(uint32 newHeight); - - /*!*********************************************************************** - @brief Sets the depth. - @param[in] newDepth The new depth. - *************************************************************************/ - void setDepth(uint32 newDepth); - - /*!*********************************************************************** - @brief Sets the depth. - @param[in] newNumMembers The new number of members in this array. - *************************************************************************/ - void setNumArrayMembers(uint32 newNumMembers); - - /*!*********************************************************************** - @brief Sets the number of MIP-Map levels in this texture. - @param[in] newNumMIPLevels New number of MIP-Map levels. - *************************************************************************/ - void setNumMIPLevels(uint32 newNumMIPLevels); - - /*!*********************************************************************** - @brief Sets the number of faces stored in this texture. - @param[in] newNumFaces New number of faces for this texture. - *************************************************************************/ - void setNumFaces(uint32 newNumFaces); - - /*!*********************************************************************** - @brief Sets the data orientation for a given axis in this texture. - @param[in] eAxisOrientation Enum specifying axis and orientation. - *************************************************************************/ - void setOrientation(EPVRTOrientation eAxisOrientation); - - /*!*********************************************************************** - @brief Sets whether or not the texture is compressed using - PVRTexLib's FILE compression - this is independent of - any texture compression. Currently unsupported. - @param[in] isFileCompressed Sets file compression to true/false. - *************************************************************************/ - void setIsFileCompressed(bool isFileCompressed); - - /*!*********************************************************************** - @brief Sets whether or not the texture's colour has been - pre-multiplied by the alpha values. - @return isPreMultiplied Sets if texture is premultiplied. - *************************************************************************/ - void setIsPreMultiplied(bool isPreMultiplied); - - // Meta Data functions - Getters. - - /*!*********************************************************************** - @brief Returns whether the texture is a bump map or not. - @return True if the texture is a bump map. - *************************************************************************/ - bool isBumpMap() const; - - /*!*********************************************************************** - @brief Gets the bump map scaling value for this texture. - @details If the texture is not a bump map, 0.0f is returned. If the - texture is a bump map but no meta data is stored to - specify its scale, then 1.0f is returned. - @return Returns the bump map scale value as a float. - *************************************************************************/ - float getBumpMapScale() const; - - /*!*********************************************************************** - @brief Gets the bump map channel order relative to rgba. - @details For example, an RGB texture with bumps mapped to XYZ returns - 'xyz'. A BGR texture with bumps in the order ZYX will also - return 'xyz' as the mapping is the same: R=X, G=Y, B=Z. - If the letter 'h' is present in the string, it means that - the height map has been stored here. - Other characters are possible if the bump map was created - manually, but PVRTexLib will ignore these characters. They - are returned simply for completeness. - @return Bump map order relative to rgba. - *************************************************************************/ - CPVRTString getBumpMapOrder() const; - - /*!*********************************************************************** - @brief Works out the number of possible texture atlas members in - the texture based on the w/h/d and the data size. - @return The number of sub textures defined by meta data. - *************************************************************************/ - int getNumTextureAtlasMembers() const; - - /*!*********************************************************************** - @brief Returns a pointer to the texture atlas data. - @return A pointer directly to the texture atlas data. - *************************************************************************/ - const float* getTextureAtlasData() const; - - /*!*********************************************************************** - @brief Gets the cube map face order. - @details Returned string will be in the form "ZzXxYy" with capitals - representing positive and small letters representing - negative. I.e. Z=Z-Positive, z=Z-Negative. - @return Cube map order string. - *************************************************************************/ - CPVRTString getCubeMapOrder() const; - - /*!*********************************************************************** - @brief Obtains the border size in each dimension for this texture. - @param[in] uiBorderWidth Border width - @param[in] uiBorderHeight Border height - @param[in] uiBorderDepth Border depth - *************************************************************************/ - void getBorder(uint32& uiBorderWidth, uint32& uiBorderHeight, uint32& uiBorderDepth) const; - - /*!*********************************************************************** - @brief Returns a block of meta data from the texture. If the meta - data doesn't exist, a block with data size 0 will be returned. - @param[in] DevFOURCC Four character descriptor representing the - creator of the meta data - @param[in] u32Key Key value representing the type of meta - data stored - @return A copy of the meta data from the texture. - *************************************************************************/ - MetaDataBlock getMetaData(uint32 DevFOURCC, uint32 u32Key) const; - - /*!*********************************************************************** - @brief Returns whether or not the specified meta data exists as - part of this texture header. - @param[in] DevFOURCC Four character descriptor representing the - creator of the meta data - @param[in] u32Key Key value representing the type of meta - data stored - @return True if the specified meta data bock exists - *************************************************************************/ - bool hasMetaData(uint32 DevFOURCC, uint32 u32Key) const; - - /*!*********************************************************************** - @brief A pointer directly to the Meta Data Map, to allow users to read out data. - @return A direct pointer to the MetaData map. - *************************************************************************/ - const MetaDataMap* getMetaDataMap() const; - - // Meta Data functions - Setters. - - /*!*********************************************************************** - @brief Sets a texture's bump map data. - @param[in] bumpScale Floating point "height" value to scale the bump map. - @param[in] bumpOrder Up to 4 character string, with values x,y,z,h in - some combination. Not all values need to be present. - Denotes channel order; x,y,z refer to the - corresponding axes, h indicates presence of the - original height map. It is possible to have only some - of these values rather than all. For example if 'h' - is present alone it will be considered a height map. - The values should be presented in RGBA order, regardless - of the texture format, so a zyxh order in a bgra texture - should still be passed as 'xyzh'. Capitals are allowed. - Any character stored here that is not one of x,y,z,h - or a NULL character will be ignored when PVRTexLib - reads the data, but will be preserved. This is useful - if you wish to define a custom data channel for instance. - In these instances PVRTexLib will assume it is simply - colour data. - *************************************************************************/ - void setBumpMap(float bumpScale, CPVRTString bumpOrder="xyz"); - - /*!*********************************************************************** - @brief Sets the texture atlas coordinate meta data for later display. - It is up to the user to make sure that this texture atlas - data actually makes sense in the context of the header. It is - suggested that the "generateTextureAtlas" method in the tools - is used to create a texture atlas, manually setting one up is - possible but should be done with care. - @param[in] pAtlasData Pointer to an array of atlas data. - @param[in] dataSize Number of floats that the data pointer contains. - *************************************************************************/ - void setTextureAtlas(float* pAtlasData, uint32 dataSize); - - /*!*********************************************************************** - @brief Sets a texture's bump map data. - @param[in] cubeMapOrder Up to 6 character string, with values - x,X,y,Y,z,Z in some combination. Not all - values need to be present. Denotes face - order; Capitals refer to positive axis - positions and small letters refer to - negative axis positions. E.g. x=X-Negative, - X=X-Positive. It is possible to have only - some of these values rather than all, as - long as they are NULL terminated. - NB: Values past the 6th character are not read. - *************************************************************************/ - void setCubeMapOrder(CPVRTString cubeMapOrder="XxYyZz"); - - /*!*********************************************************************** - @brief Sets a texture's border size data. This value is subtracted - from the current texture height/width/depth to get the valid - texture data. - @param[in] uiBorderWidth Border width - @param[in] uiBorderHeight Border height - @param[in] uiBorderDepth Border depth - *************************************************************************/ - void setBorder(uint32 uiBorderWidth, uint32 uiBorderHeight, uint32 uiBorderDepth); - - /*!*********************************************************************** - @brief Adds an arbitrary piece of meta data. - @param[in] MetaBlock Meta data block to be added. - *************************************************************************/ - void addMetaData(const MetaDataBlock& MetaBlock); - - /*!*********************************************************************** - @brief Removes a specified piece of meta data, if it exists. - @param[in] DevFOURCC Four character descriptor representing the - creator of the meta data - @param[in] u32Key Key value representing the type of meta - data stored - *************************************************************************/ - void removeMetaData(const uint32& DevFOURCC, const uint32& u32Key); - }; -} - -#endif diff --git a/deps/PVRTT/include/PVRTextureUtilities.h b/deps/PVRTT/include/PVRTextureUtilities.h deleted file mode 100644 index 7aabe1a721..0000000000 --- a/deps/PVRTT/include/PVRTextureUtilities.h +++ /dev/null @@ -1,180 +0,0 @@ -/*!*********************************************************************** - - @file PVRTextureUtilities.h - @copyright Copyright (c) Imagination Technologies Limited. - @brief This is the main PVRTexLib header file. This header contains - a utility function for transcoding textures, as well as - pre-processor utilities such as; resizing, rotating, channel - copying and MIPMap manipulation. - -*************************************************************************/ - -#ifndef _PVRTEXTURE_UTILITIES_H -#define _PVRTEXTURE_UTILITIES_H - -#include "PVRTextureFormat.h" -#include "PVRTexture.h" - -namespace pvrtexture -{ - /*!*********************************************************************** - @brief Resizes the texture to new specified dimensions. Filtering - mode is specified with "eResizeMode". - @param[in] sTexture Texture to resize - @param[in] u32NewWidth New width - @param[in] u32NewHeight New height - @param[in] u32NewDepth New depth - @param[in] eResizeMode Filtering mode - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL Resize(CPVRTexture& sTexture, const uint32& u32NewWidth, const uint32& u32NewHeight, const uint32& u32NewDepth, const EResizeMode eResizeMode); - - /*!*********************************************************************** - @brief Resizes the canvas of a texture to new specified dimensions. Filtering - mode is specified with "eResizeMode". - @details Offset area is filled with transparent black colour. - @param[in] sTexture Texture - @param[in] u32NewWidth New width - @param[in] u32NewHeight New height - @param[in] u32NewDepth New depth - @param[in] i32XOffset X Offset value from the top left corner - @param[in] i32YOffset Y Offset value from the top left corner - @param[in] i32ZOffset Z Offset value from the top left corner - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL ResizeCanvas(CPVRTexture& sTexture, const uint32& u32NewWidth, const uint32& u32NewHeight, const uint32& u32NewDepth, const int32& i32XOffset, const int32& i32YOffset, const int32& i32ZOffset); - - /*!*********************************************************************** - @brief Rotates a texture by 90 degrees around the given axis. bForward controls direction of rotation. - @param[in] sTexture Texture to rotate - @param[in] eRotationAxis Rotation axis - @param[in] bForward Direction of rotation; 1 = clockwise, 0 = anti-clockwise - @return True if the method succeeds or not. - *************************************************************************/ - bool PVR_DLL Rotate90(CPVRTexture& sTexture, const EPVRTAxis eRotationAxis, const bool bForward); - - /*!*********************************************************************** - @brief Flips a texture in a given direction. - @param[in] sTexture Texture to flip - @param[in] eFlipDirection Flip direction - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL Flip(CPVRTexture& sTexture, const EPVRTAxis eFlipDirection); - - /*!*********************************************************************** - @brief Adds a user specified border to the texture. - @param[in] sTexture Texture - @param[in] uiBorderX X border - @param[in] uiBorderY Y border - @param[in] uiBorderZ Z border - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL Border(CPVRTexture& sTexture, uint32 uiBorderX, uint32 uiBorderY, uint32 uiBorderZ); - - /*!*********************************************************************** - @brief Pre-multiplies a texture's colours by its alpha values. - @param[in] sTexture Texture to premultiply - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL PreMultiplyAlpha(CPVRTexture& sTexture); - - /*!*********************************************************************** - @brief Allows a texture's colours to run into any fully transparent areas. - @param[in] sTexture Texture - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL Bleed(CPVRTexture& sTexture); - - /*!*********************************************************************** - @brief Sets the specified number of channels to values specified in pValues. - @param[in] sTexture Texture - @param[in] uiNumChannelSets Number of channels to set - @param[in] eChannels Channels to set - @param[in] pValues uint32 values to set channels to - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL SetChannels(CPVRTexture& sTexture, uint32 uiNumChannelSets, EChannelName *eChannels, uint32 *pValues); - - /*!*********************************************************************** - @brief Sets the specified number of channels to values specified in float pValues. - @param[in] sTexture Texture - @param[in] uiNumChannelSets Number of channels to set - @param[in] eChannels Channels to set - @param[in] pValues float values to set channels to - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL SetChannelsFloat(CPVRTexture& sTexture, uint32 uiNumChannelSets, EChannelName *eChannels, float *pValues); - - /*!*********************************************************************** - @brief Copies the specified channels from sTextureSource into sTexture. - @details sTextureSource is not modified so it is possible to use the - same texture as both input and output. When using the same - texture as source and destination, channels are preserved - between swaps (e.g. copying Red to Green and then Green to Red - will result in the two channels trading places correctly). - Channels in eChannels are set to the value of the channels - in eChannelSource. - @param[in] sTexture Destination texture to copy channels to - @param[in] sTextureSource Source texture to copy channels from - @param[in] uiNumChannelCopies Number of channels to copy - @param[in] eChannels Channels to set - @param[in] eChannelsSource Source channels to copy from - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL CopyChannels(CPVRTexture& sTexture, const CPVRTexture& sTextureSource, uint32 uiNumChannelCopies, EChannelName *eChannels, EChannelName *eChannelsSource); - - /*!*********************************************************************** - @brief Generates a Normal Map from a given height map. - @details Assumes the red channel has the height values. - By default outputs to red/green/blue = x/y/z, - this can be overridden by specifying a channel - order in sChannelOrder. The channels specified - will output to red/green/blue/alpha in that order. - So "xyzh" maps x to red, y to green, z to blue - and h to alpha. 'h' is used to specify that the - original height map data should be preserved in - the given channel. - @param[in] sTexture Texture - @param[in] fScale Scale factor - @param[in] sChannelOrder Channel order - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL GenerateNormalMap(CPVRTexture& sTexture, const float fScale, CPVRTString sChannelOrder); - - /*!*********************************************************************** - @brief Generates MIPMaps for a source texture. Default is to - create a complete MIPMap chain, however this can be - overridden with uiMIPMapsToDo. - @param[in] sTexture Texture - @param[in] eFilterMode Filter mode - @param[in] uiMIPMapsToDo Level of MIPMap chain to create - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL GenerateMIPMaps(CPVRTexture& sTexture, const EResizeMode eFilterMode, const uint32 uiMIPMapsToDo=PVRTEX_ALLMIPLEVELS); - - /*!*********************************************************************** - @brief Colours a texture's MIPMap levels with artificial colours - for debugging. MIP levels are coloured in the following order: - Red, Green, Blue, Cyan, Magenta and Yellow - in a repeating pattern. - @param[in] sTexture Texture - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL ColourMIPMaps(CPVRTexture& sTexture); - - /*!*********************************************************************** - @brief Transcodes a texture from its original format into a newly specified format. - Will either quantise or dither to lower precisions based on bDoDither. - uiQuality specifies the quality for PVRTC and ETC compression. - @param[in] sTexture Texture - @param[in] ptFormat Pixel format type - @param[in] eChannelType Channel type - @param[in] eColourspace Colour space - @param[in] eQuality Quality for PVRTC and ETC compression - @param[in] bDoDither Dither the texture to lower precisions - @return True if the method succeeds. - *************************************************************************/ - bool PVR_DLL Transcode(CPVRTexture& sTexture, const PixelType ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const ECompressorQuality eQuality=ePVRTCNormal, const bool bDoDither=false); -} -#endif //_PVRTEXTURE_UTILTIES_H - diff --git a/deps/PVRTT/include/PVRTextureVersion.h b/deps/PVRTT/include/PVRTextureVersion.h deleted file mode 100644 index 872f17e86d..0000000000 --- a/deps/PVRTT/include/PVRTextureVersion.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef PVRTEXLIBVERSION_H -#define PVRTEXLIBVERSION_H -#define PVRTLMAJORVERSION 4 -#define PVRTLMINORVERSION 22 -#define PVRTLSUBVERSION 0 -#define PVRTLSTRINGVERSION "4.22.0" -#endif diff --git a/deps/PVRTT/linux-x64/PVRTexLib.so b/deps/PVRTT/linux-x64/PVRTexLib.so new file mode 100755 index 0000000000..6f6885b832 --- /dev/null +++ b/deps/PVRTT/linux-x64/PVRTexLib.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecc516b705f99497d4201dd3da0925d9b5172eabc2d66e0fab7801634a9c0c66 +size 6510344 diff --git a/deps/PVRTT/source/PVRTDecompress.cpp b/deps/PVRTT/source/PVRTDecompress.cpp deleted file mode 100644 index 000e24cf8a..0000000000 --- a/deps/PVRTT/source/PVRTDecompress.cpp +++ /dev/null @@ -1,956 +0,0 @@ -/****************************************************************************** - - @File PVRTDecompress.cpp - - @Title PVRTDecompress - - @Version - - @Copyright Copyright (c) Imagination Technologies Limited. - - @Platform ANSI compatible - - @Description PVRTC Texture Decompression. - -******************************************************************************/ - -/***************************************************************************** - * INCLUDES - *****************************************************************************/ -#include -#include -#include -#include -#include -#include "PVRTDecompress.h" -#include "PVRTTexture.h" -#include "PVRTGlobal.h" - -/*********************************************************** - DECOMPRESSION ROUTINES -************************************************************/ -/***************************************************************************** - * Useful structs - *****************************************************************************/ -struct Pixel32 -{ - PVRTuint8 red,green,blue,alpha; -}; - -struct Pixel128S -{ - PVRTint32 red,green,blue,alpha; -}; - -struct PVRTCWord -{ - PVRTuint32 u32ModulationData; - PVRTuint32 u32ColourData; -}; - -struct PVRTCWordIndices -{ - int P[2], Q[2], R[2], S[2]; -}; -/********************************************************************************/ -/*!*********************************************************************** - @Function getColourA - @Input u32ColourData Colour information from a PVRTCWord. - @Return Returns the first colour in a PVRTCWord's colour data. - @Description Decodes the first colour in a PVRTCWord's colour data. -*************************************************************************/ -static Pixel32 getColourA(PVRTuint32 u32ColourData) -{ - Pixel32 colour; - - // Opaque Colour Mode - RGB 554 - if ((u32ColourData & 0x8000) != 0) - { - colour.red = (PVRTuint8)((u32ColourData & 0x7c00) >> 10); // 5->5 bits - colour.green = (PVRTuint8)((u32ColourData & 0x3e0) >> 5); // 5->5 bits - colour.blue = (PVRTuint8)(u32ColourData & 0x1e) | ((u32ColourData & 0x1e) >> 4); // 4->5 bits - colour.alpha = (PVRTuint8)0xf;// 0->4 bits - } - // Transparent Colour Mode - ARGB 3443 - else - { - colour.red = (PVRTuint8)((u32ColourData & 0xf00) >> 7) | ((u32ColourData & 0xf00) >> 11); // 4->5 bits - colour.green = (PVRTuint8)((u32ColourData & 0xf0) >> 3) | ((u32ColourData & 0xf0) >> 7); // 4->5 bits - colour.blue = (PVRTuint8)((u32ColourData & 0xe) << 1) | ((u32ColourData & 0xe) >> 2); // 3->5 bits - colour.alpha = (PVRTuint8)((u32ColourData & 0x7000) >> 11);// 3->4 bits - note 0 at right - } - - return colour; -} - -/*!*********************************************************************** - @Function getColourB - @Input u32ColourData Colour information from a PVRTCWord. - @Return Returns the second colour in a PVRTCWord's colour data. - @Description Decodes the second colour in a PVRTCWord's colour data. -*************************************************************************/ -static Pixel32 getColourB(PVRTuint32 u32ColourData) -{ - Pixel32 colour; - - // Opaque Colour Mode - RGB 555 - if (u32ColourData & 0x80000000) - { - colour.red = (PVRTuint8)((u32ColourData & 0x7c000000) >> 26); // 5->5 bits - colour.green = (PVRTuint8)((u32ColourData & 0x3e00000) >> 21); // 5->5 bits - colour.blue = (PVRTuint8)((u32ColourData & 0x1f0000) >> 16); // 5->5 bits - colour.alpha = (PVRTuint8)0xf;// 0 bits - } - // Transparent Colour Mode - ARGB 3444 - else - { - colour.red = (PVRTuint8)(((u32ColourData & 0xf000000) >> 23) | ((u32ColourData & 0xf000000) >> 27)); // 4->5 bits - colour.green = (PVRTuint8)(((u32ColourData & 0xf00000) >> 19) | ((u32ColourData & 0xf00000) >> 23)); // 4->5 bits - colour.blue = (PVRTuint8)(((u32ColourData & 0xf0000) >> 15) | ((u32ColourData & 0xf0000) >> 19)); // 4->5 bits - colour.alpha = (PVRTuint8)((u32ColourData & 0x70000000) >> 27);// 3->4 bits - note 0 at right - } - - return colour; -} - -/*!*********************************************************************** - @Function interpolateColours - @Input P,Q,R,S Low bit-rate colour values for each PVRTCWord. - @Modified pPixel Output array for upscaled colour values. - @Input ui8Bpp Number of bpp. - @Description Bilinear upscale from 2x2 pixels to 4x4/8x4 pixels (depending on PVRTC bpp mode). -*************************************************************************/ -static void interpolateColours(Pixel32 P, Pixel32 Q, Pixel32 R, Pixel32 S, - Pixel128S *pPixel, PVRTuint8 ui8Bpp) -{ - PVRTuint32 ui32WordWidth=4; - PVRTuint32 ui32WordHeight=4; - if (ui8Bpp==2) - ui32WordWidth=8; - - //Convert to int 32. - Pixel128S hP = {(PVRTint32)P.red,(PVRTint32)P.green,(PVRTint32)P.blue,(PVRTint32)P.alpha}; - Pixel128S hQ = {(PVRTint32)Q.red,(PVRTint32)Q.green,(PVRTint32)Q.blue,(PVRTint32)Q.alpha}; - Pixel128S hR = {(PVRTint32)R.red,(PVRTint32)R.green,(PVRTint32)R.blue,(PVRTint32)R.alpha}; - Pixel128S hS = {(PVRTint32)S.red,(PVRTint32)S.green,(PVRTint32)S.blue,(PVRTint32)S.alpha}; - - //Get vectors. - Pixel128S QminusP = {hQ.red - hP.red, hQ.green - hP.green, hQ.blue - hP.blue, hQ.alpha - hP.alpha}; - Pixel128S SminusR = {hS.red - hR.red, hS.green - hR.green, hS.blue - hR.blue, hS.alpha - hR.alpha}; - - //Multiply colours. - hP.red *= ui32WordWidth; - hP.green *= ui32WordWidth; - hP.blue *= ui32WordWidth; - hP.alpha *= ui32WordWidth; - hR.red *= ui32WordWidth; - hR.green *= ui32WordWidth; - hR.blue *= ui32WordWidth; - hR.alpha *= ui32WordWidth; - - if (ui8Bpp==2) - { - //Loop through pixels to achieve results. - for (unsigned int x=0; x < ui32WordWidth; x++) - { - Pixel128S Result={4*hP.red, 4*hP.green, 4*hP.blue, 4*hP.alpha}; - Pixel128S dY = {hR.red - hP.red, hR.green - hP.green, hR.blue - hP.blue, hR.alpha - hP.alpha}; - - for (unsigned int y=0; y < ui32WordHeight; y++) - { - pPixel[y*ui32WordWidth+x].red = (PVRTint32)((Result.red >> 7) + (Result.red >> 2)); - pPixel[y*ui32WordWidth+x].green = (PVRTint32)((Result.green >> 7) + (Result.green >> 2)); - pPixel[y*ui32WordWidth+x].blue = (PVRTint32)((Result.blue >> 7) + (Result.blue >> 2)); - pPixel[y*ui32WordWidth+x].alpha = (PVRTint32)((Result.alpha >> 5) + (Result.alpha >> 1)); - - Result.red += dY.red; - Result.green += dY.green; - Result.blue += dY.blue; - Result.alpha += dY.alpha; - } - - hP.red += QminusP.red; - hP.green += QminusP.green; - hP.blue += QminusP.blue; - hP.alpha += QminusP.alpha; - - hR.red += SminusR.red; - hR.green += SminusR.green; - hR.blue += SminusR.blue; - hR.alpha += SminusR.alpha; - } - } - else - { - //Loop through pixels to achieve results. - for (unsigned int y=0; y < ui32WordHeight; y++) - { - Pixel128S Result={4*hP.red, 4*hP.green, 4*hP.blue, 4*hP.alpha}; - Pixel128S dY = {hR.red - hP.red, hR.green - hP.green, hR.blue - hP.blue, hR.alpha - hP.alpha}; - - for (unsigned int x=0; x < ui32WordWidth; x++) - { - pPixel[y*ui32WordWidth+x].red = (PVRTint32)((Result.red >> 6) + (Result.red >> 1)); - pPixel[y*ui32WordWidth+x].green = (PVRTint32)((Result.green >> 6) + (Result.green >> 1)); - pPixel[y*ui32WordWidth+x].blue = (PVRTint32)((Result.blue >> 6) + (Result.blue >> 1)); - pPixel[y*ui32WordWidth+x].alpha = (PVRTint32)((Result.alpha >> 4) + (Result.alpha)); - - Result.red += dY.red; - Result.green += dY.green; - Result.blue += dY.blue; - Result.alpha += dY.alpha; - } - - hP.red += QminusP.red; - hP.green += QminusP.green; - hP.blue += QminusP.blue; - hP.alpha += QminusP.alpha; - - hR.red += SminusR.red; - hR.green += SminusR.green; - hR.blue += SminusR.blue; - hR.alpha += SminusR.alpha; - } - } -} - -/*!*********************************************************************** - @Function unpackModulations - @Input word PVRTCWord to be decompressed - @Input offsetX X position within the PVRTCWord - @Input offsetY Y position within the PVRTCWord - @Modified i32ModulationValues The array of modulation values. - @Modified i32ModulationModes The array of modulation modes. - @Input ui8Bpp Number of bpp. - @Description Reads out and decodes the modulation values within the a given PVRTCWord -*************************************************************************/ -static void unpackModulations(const PVRTCWord& word, int offsetX, int offsetY, PVRTint32 i32ModulationValues[16][8], PVRTint32 i32ModulationModes[16][8], PVRTuint8 ui8Bpp) -{ - PVRTuint32 WordModMode = word.u32ColourData & 0x1; - PVRTuint32 ModulationBits = word.u32ModulationData; - - // Unpack differently depending on 2bpp or 4bpp modes. - if (ui8Bpp==2) - { - if(WordModMode) - { - // determine which of the three modes are in use: - - // If this is the either the H-only or V-only interpolation mode... - if(ModulationBits & 0x1) - { - // look at the "LSB" for the "centre" (V=2,H=4) texel. Its LSB is now - // actually used to indicate whether it's the H-only mode or the V-only... - - // The centre texel data is the at (y==2, x==4) and so its LSB is at bit 20. - if(ModulationBits & (0x1 << 20)) - { - // This is the V-only mode - WordModMode = 3; - } - else - { - // This is the H-only mode - WordModMode = 2; - } - - // Create an extra bit for the centre pixel so that it looks like - // we have 2 actual bits for this texel. It makes later coding much easier. - if(ModulationBits & (0x1 << 21)) - { - // set it to produce code for 1.0 - ModulationBits |= (0x1 << 20); - } - else - { - // clear it to produce 0.0 code - ModulationBits &= ~(0x1 << 20); - } - }// end if H-Only or V-Only interpolation mode was chosen - - if(ModulationBits & 0x2) - { - ModulationBits |= 0x1; /*set it*/ - } - else - { - ModulationBits &= ~0x1; /*clear it*/ - } - - // run through all the pixels in the block. Note we can now treat all the - // "stored" values as if they have 2bits (even when they didn't!) - for(int y = 0; y < 4; y++) - { - for(int x = 0; x < 8; x++) - { - i32ModulationModes[x+offsetX][y+offsetY] = WordModMode; - - // if this is a stored value... - if(((x^y)&1) == 0) - { - i32ModulationValues[x+offsetX][y+offsetY] = ModulationBits & 3; - ModulationBits >>= 2; - } - } - } // end for y - } - // else if direct encoded 2bit mode - i.e. 1 mode bit per pixel - else - { - for(int y = 0; y < 4; y++) - { - for(int x = 0; x < 8; x++) - { - i32ModulationModes[x+offsetX][y+offsetY] = WordModMode; - - /* - // double the bits so 0=> 00, and 1=>11 - */ - if(ModulationBits & 1) - { - i32ModulationValues[x+offsetX][y+offsetY] = 0x3; - } - else - { - i32ModulationValues[x+offsetX][y+offsetY] = 0x0; - } - ModulationBits >>= 1; - } - }// end for y - } - } - else - { - //Much simpler than the 2bpp decompression, only two modes, so the n/8 values are set directly. - // run through all the pixels in the word. - if (WordModMode) - { - for(int y = 0; y < 4; y++) - { - for(int x = 0; x < 4; x++) - { - i32ModulationValues[y+offsetY][x+offsetX] = ModulationBits & 3; - //if (i32ModulationValues==0) {}; don't need to check 0, 0 = 0/8. - if (i32ModulationValues[y+offsetY][x+offsetX]==1) { i32ModulationValues[y+offsetY][x+offsetX]=4;} - else if (i32ModulationValues[y+offsetY][x+offsetX]==2) { i32ModulationValues[y+offsetY][x+offsetX]=14;} //+10 tells the decompressor to punch through alpha. - else if (i32ModulationValues[y+offsetY][x+offsetX]==3) { i32ModulationValues[y+offsetY][x+offsetX]=8;} - ModulationBits >>= 2; - } // end for x - } // end for y - } - else - { - for(int y = 0; y < 4; y++) - { - for(int x = 0; x < 4; x++) - { - i32ModulationValues[y+offsetY][x+offsetX] = ModulationBits & 3; - i32ModulationValues[y+offsetY][x+offsetX]*=3; - if (i32ModulationValues[y+offsetY][x+offsetX]>3) i32ModulationValues[y+offsetY][x+offsetX]-=1; - ModulationBits >>= 2; - } // end for x - } // end for y - } - } -} - -/*!*********************************************************************** - @Function getModulationValues - @Input i32ModulationValues The array of modulation values. - @Input i32ModulationModes The array of modulation modes. - @Input xPos The x Position within the current word. - @Input yPos The y Position within the current word. - @Input ui8Bpp Number of bpp. - @Return Returns the modulation value. - @Description Gets the effective modulation values for a given pixel. -*************************************************************************/ -static PVRTint32 getModulationValues(PVRTint32 i32ModulationValues[16][8],PVRTint32 i32ModulationModes[16][8],PVRTuint32 xPos,PVRTuint32 yPos,PVRTuint8 ui8Bpp) -{ - if (ui8Bpp==2) - { - const int RepVals0[4] = {0, 3, 5, 8}; - - // extract the modulation value. If a simple encoding - if(i32ModulationModes[xPos][yPos]==0) - { - return RepVals0[i32ModulationValues[xPos][yPos]]; - } - else - { - // if this is a stored value - if(((xPos^yPos)&1)==0) - { - return RepVals0[i32ModulationValues[xPos][yPos]]; - } - - // else average from the neighbours - // if H&V interpolation... - else if(i32ModulationModes[xPos][yPos] == 1) - { - return (RepVals0[i32ModulationValues[xPos][yPos-1]] + - RepVals0[i32ModulationValues[xPos][yPos+1]] + - RepVals0[i32ModulationValues[xPos-1][yPos]] + - RepVals0[i32ModulationValues[xPos+1][yPos]] + 2) / 4; - } - // else if H-Only - else if(i32ModulationModes[xPos][yPos] == 2) - { - return (RepVals0[i32ModulationValues[xPos-1][yPos]] + - RepVals0[i32ModulationValues[xPos+1][yPos]] + 1) / 2; - } - // else it's V-Only - else - { - return (RepVals0[i32ModulationValues[xPos][yPos-1]] + - RepVals0[i32ModulationValues[xPos][yPos+1]] + 1) / 2; - } - } - } - else if (ui8Bpp==4) - return i32ModulationValues[xPos][yPos]; - - return 0; -} - -/*!*********************************************************************** - @Function pvrtcGetDecompressedPixels - @Input P,Q,R,S PVRTWords in current decompression area. - @Modified pColourData Output pixels. - @Input ui8Bpp Number of bpp. - @Description Gets decompressed pixels for a given decompression area. -*************************************************************************/ -static void pvrtcGetDecompressedPixels(const PVRTCWord& P, const PVRTCWord& Q, - const PVRTCWord& R, const PVRTCWord& S, - Pixel32 *pColourData, - PVRTuint8 ui8Bpp) -{ - //4bpp only needs 8*8 values, but 2bpp needs 16*8, so rather than wasting processor time we just statically allocate 16*8. - PVRTint32 i32ModulationValues[16][8]; - //Only 2bpp needs this. - PVRTint32 i32ModulationModes[16][8]; - //4bpp only needs 16 values, but 2bpp needs 32, so rather than wasting processor time we just statically allocate 32. - Pixel128S upscaledColourA[32]; - Pixel128S upscaledColourB[32]; - - PVRTuint32 ui32WordWidth=4; - PVRTuint32 ui32WordHeight=4; - if (ui8Bpp==2) - ui32WordWidth=8; - - //Get the modulations from each word. - unpackModulations(P, 0, 0, i32ModulationValues, i32ModulationModes, ui8Bpp); - unpackModulations(Q, ui32WordWidth, 0, i32ModulationValues, i32ModulationModes, ui8Bpp); - unpackModulations(R, 0, ui32WordHeight, i32ModulationValues, i32ModulationModes, ui8Bpp); - unpackModulations(S, ui32WordWidth, ui32WordHeight, i32ModulationValues, i32ModulationModes, ui8Bpp); - - // Bilinear upscale image data from 2x2 -> 4x4 - interpolateColours(getColourA(P.u32ColourData), getColourA(Q.u32ColourData), - getColourA(R.u32ColourData), getColourA(S.u32ColourData), - upscaledColourA, ui8Bpp); - interpolateColours(getColourB(P.u32ColourData), getColourB(Q.u32ColourData), - getColourB(R.u32ColourData), getColourB(S.u32ColourData), - upscaledColourB, ui8Bpp); - - for (unsigned int y=0; y < ui32WordHeight; y++) - { - for (unsigned int x=0; x < ui32WordWidth; x++) - { - PVRTint32 mod = getModulationValues(i32ModulationValues,i32ModulationModes,x+ui32WordWidth/2,y+ui32WordHeight/2,ui8Bpp); - bool punchthroughAlpha=false; - if (mod>10) {punchthroughAlpha=true; mod-=10;} - - Pixel128S result; - result.red = (upscaledColourA[y*ui32WordWidth+x].red * (8-mod) + upscaledColourB[y*ui32WordWidth+x].red * mod) / 8; - result.green = (upscaledColourA[y*ui32WordWidth+x].green * (8-mod) + upscaledColourB[y*ui32WordWidth+x].green * mod) / 8; - result.blue = (upscaledColourA[y*ui32WordWidth+x].blue * (8-mod) + upscaledColourB[y*ui32WordWidth+x].blue * mod) / 8; - if (punchthroughAlpha) result.alpha = 0; - else result.alpha = (upscaledColourA[y*ui32WordWidth+x].alpha * (8-mod) + upscaledColourB[y*ui32WordWidth+x].alpha * mod) / 8; - - //Convert the 32bit precision result to 8 bit per channel colour. - if (ui8Bpp==2) - { - pColourData[y*ui32WordWidth+x].red = (PVRTuint8)result.red; - pColourData[y*ui32WordWidth+x].green = (PVRTuint8)result.green; - pColourData[y*ui32WordWidth+x].blue = (PVRTuint8)result.blue; - pColourData[y*ui32WordWidth+x].alpha = (PVRTuint8)result.alpha; - } - else if (ui8Bpp==4) - { - pColourData[y+x*ui32WordHeight].red = (PVRTuint8)result.red; - pColourData[y+x*ui32WordHeight].green = (PVRTuint8)result.green; - pColourData[y+x*ui32WordHeight].blue = (PVRTuint8)result.blue; - pColourData[y+x*ui32WordHeight].alpha = (PVRTuint8)result.alpha; - } - } - } -} - -/*!*********************************************************************** - @Function wrapWordIndex - @Input numWords Total number of PVRTCWords in the current surface. - @Input word Original index for a PVRTCWord. - @Return unsigned int Wrapped PVRTCWord index. - @Description Maps decompressed data to the correct location in the output buffer. -*************************************************************************/ -static unsigned int wrapWordIndex(unsigned int numWords, int word) -{ - return ((word + numWords) % numWords); -} - -#if defined(_DEBUG) - /*!*********************************************************************** - @Function isPowerOf2 - @Input input Value to be checked - @Returns true if the number is an integer power of two, else false. - @Description Check that a number is an integer power of two, i.e. - 1, 2, 4, 8, ... etc. - Returns false for zero. -*************************************************************************/ -static bool isPowerOf2( unsigned int input ) -{ - unsigned int minus1; - - if( !input ) return 0; - - minus1 = input - 1; - return ( (input | minus1) == (input ^ minus1) ); -} -#endif - -/*!*********************************************************************** - @Function TwiddleUV - @Input YSize Y dimension of the texture in pixels - @Input XSize X dimension of the texture in pixels - @Input YPos Pixel Y position - @Input XPos Pixel X position - @Returns The twiddled offset of the pixel - @Description Given the Word (or pixel) coordinates and the dimension of - the texture in words (or pixels) this returns the twiddled - offset of the word (or pixel) from the start of the map. - - NOTE: the dimensions of the texture must be a power of 2 -*************************************************************************/ -static PVRTuint32 TwiddleUV(PVRTuint32 XSize, PVRTuint32 YSize, PVRTuint32 XPos, PVRTuint32 YPos) -{ - //Initially assume X is the larger size. - PVRTuint32 MinDimension=XSize; - PVRTuint32 MaxValue=YPos; - PVRTuint32 Twiddled=0; - PVRTuint32 SrcBitPos=1; - PVRTuint32 DstBitPos=1; - int ShiftCount=0; - - //Check the sizes are valid. - _ASSERT(YPos < YSize); - _ASSERT(XPos < XSize); - _ASSERT(isPowerOf2(YSize)); - _ASSERT(isPowerOf2(XSize)); - - //If Y is the larger dimension - switch the min/max values. - if(YSize < XSize) - { - MinDimension = YSize; - MaxValue = XPos; - } - - // Step through all the bits in the "minimum" dimension - while(SrcBitPos < MinDimension) - { - if(YPos & SrcBitPos) - { - Twiddled |= DstBitPos; - } - - if(XPos & SrcBitPos) - { - Twiddled |= (DstBitPos << 1); - } - - SrcBitPos <<= 1; - DstBitPos <<= 2; - ShiftCount += 1; - } - - // Prepend any unused bits - MaxValue >>= ShiftCount; - Twiddled |= (MaxValue << (2*ShiftCount)); - - return Twiddled; -} - -/*!*********************************************************************** - @Function mapDecompressedData - @Modified pOutput The PVRTC texture data to decompress - @Input width Width of the texture surface. - @Input pWord A pointer to the decompressed PVRTCWord in pixel form. - @Input &words Indices for the PVRTCword. - @Input ui8Bpp number of bits per pixel - @Description Maps decompressed data to the correct location in the output buffer. -*************************************************************************/ -static void mapDecompressedData(Pixel32* pOutput, int width, - const Pixel32 *pWord, - const PVRTCWordIndices &words, - const PVRTuint8 ui8Bpp) -{ - PVRTuint32 ui32WordWidth=4; - PVRTuint32 ui32WordHeight=4; - if (ui8Bpp==2) - ui32WordWidth=8; - - for (unsigned int y=0; y < ui32WordHeight/2; y++) - { - for (unsigned int x=0; x < ui32WordWidth/2; x++) - { - pOutput[(((words.P[1] * ui32WordHeight) + y + ui32WordHeight/2) - * width + words.P[0] *ui32WordWidth + x + ui32WordWidth/2)] = pWord[y*ui32WordWidth+x]; // map P - - pOutput[(((words.Q[1] * ui32WordHeight) + y + ui32WordHeight/2) - * width + words.Q[0] *ui32WordWidth + x)] = pWord[y*ui32WordWidth+x+ui32WordWidth/2]; // map Q - - pOutput[(((words.R[1] * ui32WordHeight) + y) - * width + words.R[0] *ui32WordWidth + x + ui32WordWidth/2)] = pWord[(y+ui32WordHeight/2)*ui32WordWidth+x]; // map R - - pOutput[(((words.S[1] * ui32WordHeight) + y) - * width + words.S[0] *ui32WordWidth + x)] = pWord[(y+ui32WordHeight/2)*ui32WordWidth+x+ui32WordWidth/2]; // map S - } - } -} -/*!*********************************************************************** - @Function pvrtcDecompress - @Input pCompressedData The PVRTC texture data to decompress - @Modified pDecompressedData The output buffer to decompress into. - @Input ui32Width X dimension of the texture - @Input ui32Height Y dimension of the texture - @Input ui8Bpp number of bits per pixel - @Description Internally decompresses PVRTC to RGBA 8888 -*************************************************************************/ -static int pvrtcDecompress( PVRTuint8 *pCompressedData, - Pixel32 *pDecompressedData, - PVRTuint32 ui32Width, - PVRTuint32 ui32Height, - PVRTuint8 ui8Bpp) -{ - PVRTuint32 ui32WordWidth=4; - PVRTuint32 ui32WordHeight=4; - if (ui8Bpp==2) - ui32WordWidth=8; - - PVRTuint32 *pWordMembers = (PVRTuint32 *)pCompressedData; - Pixel32 *pOutData = pDecompressedData; - - // Calculate number of words - int i32NumXWords = (int)(ui32Width / ui32WordWidth); - int i32NumYWords = (int)(ui32Height / ui32WordHeight); - - // Structs used for decompression - PVRTCWordIndices indices; - Pixel32 *pPixels; - pPixels = (Pixel32*)malloc(ui32WordWidth*ui32WordHeight*sizeof(Pixel32)); - - // For each row of words - for(int wordY=-1; wordY < i32NumYWords-1; wordY++) - { - // for each column of words - for(int wordX=-1; wordX < i32NumXWords-1; wordX++) - { - indices.P[0] = wrapWordIndex(i32NumXWords, wordX); - indices.P[1] = wrapWordIndex(i32NumYWords, wordY); - indices.Q[0] = wrapWordIndex(i32NumXWords, wordX + 1); - indices.Q[1] = wrapWordIndex(i32NumYWords, wordY); - indices.R[0] = wrapWordIndex(i32NumXWords, wordX); - indices.R[1] = wrapWordIndex(i32NumYWords, wordY + 1); - indices.S[0] = wrapWordIndex(i32NumXWords, wordX + 1); - indices.S[1] = wrapWordIndex(i32NumYWords, wordY + 1); - - //Work out the offsets into the twiddle structs, multiply by two as there are two members per word. - PVRTuint32 WordOffsets[4] = - { - TwiddleUV(i32NumXWords,i32NumYWords,indices.P[0], indices.P[1])*2, - TwiddleUV(i32NumXWords,i32NumYWords,indices.Q[0], indices.Q[1])*2, - TwiddleUV(i32NumXWords,i32NumYWords,indices.R[0], indices.R[1])*2, - TwiddleUV(i32NumXWords,i32NumYWords,indices.S[0], indices.S[1])*2, - }; - - //Access individual elements to fill out PVRTCWord - PVRTCWord P,Q,R,S; - P.u32ColourData = pWordMembers[WordOffsets[0]+1]; - P.u32ModulationData = pWordMembers[WordOffsets[0]]; - Q.u32ColourData = pWordMembers[WordOffsets[1]+1]; - Q.u32ModulationData = pWordMembers[WordOffsets[1]]; - R.u32ColourData = pWordMembers[WordOffsets[2]+1]; - R.u32ModulationData = pWordMembers[WordOffsets[2]]; - S.u32ColourData = pWordMembers[WordOffsets[3]+1]; - S.u32ModulationData = pWordMembers[WordOffsets[3]]; - - // assemble 4 words into struct to get decompressed pixels from - pvrtcGetDecompressedPixels(P,Q,R,S,pPixels,ui8Bpp); - mapDecompressedData(pOutData, ui32Width, pPixels, indices, ui8Bpp); - - } // for each word - } // for each row of words - - free(pPixels); - //Return the data size - return ui32Width * ui32Height / (PVRTuint32)(ui32WordWidth/2); -} - -/*!*********************************************************************** - @Function PVRTDecompressPVRTC - @Input pCompressedData The PVRTC texture data to decompress - @Input Do2bitMode Signifies whether the data is PVRTC2 or PVRTC4 - @Input XDim X dimension of the texture - @Input YDim Y dimension of the texture - @Modified pResultImage The decompressed texture data - @Return Returns the amount of data that was decompressed. - @Description Decompresses PVRTC to RGBA 8888 -*************************************************************************/ -int PVRTDecompressPVRTC(const void *pCompressedData, - const int Do2bitMode, - const int XDim, - const int YDim, - unsigned char* pResultImage) -{ - //Cast the output buffer to a Pixel32 pointer. - Pixel32* pDecompressedData = (Pixel32*)pResultImage; - - //Check the X and Y values are at least the minimum size. - int XTrueDim = PVRT_MAX(XDim,((Do2bitMode==1)?16:8)); - int YTrueDim = PVRT_MAX(YDim,8); - - //If the dimensions aren't correct, we need to create a new buffer instead of just using the provided one, as the buffer will overrun otherwise. - if(XTrueDim!=XDim || YTrueDim!=YDim) - { - pDecompressedData=(Pixel32*)malloc(XTrueDim*YTrueDim*sizeof(Pixel32)); - } - - //Decompress the surface. - int retval = pvrtcDecompress((PVRTuint8*)pCompressedData,pDecompressedData,XTrueDim,YTrueDim,(Do2bitMode==1?2:4)); - - //If the dimensions were too small, then copy the new buffer back into the output buffer. - if(XTrueDim!=XDim || YTrueDim!=YDim) - { - //Loop through all the required pixels. - for (int x=0; x>(index+24))&0x1)+((mostSig>>(index+8))&0x2)]; - else - pixelMod = mod[modTable][((modBlock>>(index+8))&0x1)+((mostSig>>(index-8))&0x2)]; - - red = _CLAMP_(red+pixelMod,0,255); - green = _CLAMP_(green+pixelMod,0,255); - blue = _CLAMP_(blue+pixelMod,0,255); - - return ((red<<16) + (green<<8) + blue)|0xff000000; -} - - /*!*********************************************************************** - @Function ETCTextureDecompress - @Input pSrcData The ETC texture data to decompress - @Input x X dimension of the texture - @Input y Y dimension of the texture - @Modified pDestData The decompressed texture data - @Input nMode The format of the data - @Returns The number of bytes of ETC data decompressed - @Description Decompresses ETC to RGBA 8888 -*************************************************************************/ -static int ETCTextureDecompress(const void * const pSrcData, const int &x, const int &y, const void *pDestData,const int &/*nMode*/) -{ - unsigned int blockTop, blockBot, *input = (unsigned int*)pSrcData, *output; - unsigned char red1, green1, blue1, red2, green2, blue2; - bool bFlip, bDiff; - int modtable1,modtable2; - - for(int i=0;i>16); - green1 = (unsigned char)((blockTop&0xf800)>>8); - red1 = (unsigned char)(blockTop&0xf8); - - // get differential colour for subblock 2 - signed char blues = (signed char)(blue1>>3) + ((signed char) ((blockTop & 0x70000) >> 11)>>5); - signed char greens = (signed char)(green1>>3) + ((signed char)((blockTop & 0x700) >>3)>>5); - signed char reds = (signed char)(red1>>3) + ((signed char)((blockTop & 0x7)<<5)>>5); - - blue2 = (unsigned char)blues; - green2 = (unsigned char)greens; - red2 = (unsigned char)reds; - - red1 = red1 +(red1>>5); // copy bits to lower sig - green1 = green1 + (green1>>5); // copy bits to lower sig - blue1 = blue1 + (blue1>>5); // copy bits to lower sig - - red2 = (red2<<3) +(red2>>2); // copy bits to lower sig - green2 = (green2<<3) + (green2>>2); // copy bits to lower sig - blue2 = (blue2<<3) + (blue2>>2); // copy bits to lower sig - } - else - { // individual mode 4 + 4 colour bits - // get base colour for subblock 1 - blue1 = (unsigned char)((blockTop&0xf00000)>>16); - blue1 = blue1 +(blue1>>4); // copy bits to lower sig - green1 = (unsigned char)((blockTop&0xf000)>>8); - green1 = green1 + (green1>>4); // copy bits to lower sig - red1 = (unsigned char)(blockTop&0xf0); - red1 = red1 + (red1>>4); // copy bits to lower sig - - // get base colour for subblock 2 - blue2 = (unsigned char)((blockTop&0xf0000)>>12); - blue2 = blue2 +(blue2>>4); // copy bits to lower sig - green2 = (unsigned char)((blockTop&0xf00)>>4); - green2 = green2 + (green2>>4); // copy bits to lower sig - red2 = (unsigned char)((blockTop&0xf)<<4); - red2 = red2 + (red2>>4); // copy bits to lower sig - } - // get the modtables for each subblock - modtable1 = (blockTop>>29)&0x7; - modtable2 = (blockTop>>26)&0x7; - - if(!bFlip) - { // 2 2x4 blocks side by side - - for(int j=0;j<4;j++) // vertical - { - for(int k=0;k<2;k++) // horizontal - { - *(output+j*x+k) = modifyPixel(red1,green1,blue1,k,j,blockBot,modtable1); - *(output+j*x+k+2) = modifyPixel(red2,green2,blue2,k+2,j,blockBot,modtable2); - } - } - - } - else - { // 2 4x2 blocks on top of each other - for(int j=0;j<2;j++) - { - for(int k=0;k<4;k++) - { - *(output+j*x+k) = modifyPixel(red1,green1,blue1,k,j,blockBot,modtable1); - *(output+(j+2)*x+k) = modifyPixel(red2,green2,blue2,k,j+2,blockBot,modtable2); - } - } - } - } - } - - return x*y/2; -} - -/*!*********************************************************************** -@Function PVRTDecompressETC -@Input pSrcData The ETC texture data to decompress -@Input x X dimension of the texture -@Input y Y dimension of the texture -@Modified pDestData The decompressed texture data -@Input nMode The format of the data -@Returns The number of bytes of ETC data decompressed -@Description Decompresses ETC to RGBA 8888 -*************************************************************************/ -int PVRTDecompressETC(const void * const pSrcData, - const unsigned int &x, - const unsigned int &y, - void *pDestData, - const int &nMode) -{ - int i32read; - - if(x -#include -#include - -#include "PVRTGlobal.h" - -const size_t CPVRTString::npos = (size_t) -1; - -#if defined(_WIN32) && !defined(__BADA__) -#define vsnprintf _vsnprintf -#endif - -/*!*********************************************************************** -@Function CPVRTString -@Input _Ptr A string -@Input _Count Length of _Ptr -@Description Constructor -************************************************************************/ -CPVRTString::CPVRTString(const char* _Ptr, size_t _Count) : -m_pString(0), m_Capacity(0) -{ - if (_Count == npos) - assign(_Ptr); - else - assign(_Ptr, _Count); -} - -/*!*********************************************************************** -@Function CPVRTString -@Input _Right A string -@Input _Roff Offset into _Right -@Input _Count Number of chars from _Right to assign to the new string -@Description Constructor -************************************************************************/ -CPVRTString::CPVRTString(const CPVRTString& _Right, size_t _Roff, size_t _Count) : -m_pString(0), m_Capacity(0) -{ - assign(_Right, _Roff, _Count); -} - -/*!*********************************************************************** -@Function CPVRTString -@Input _Count Length of new string -@Input _Ch A char to fill it with -@Description Constructor -*************************************************************************/ -CPVRTString::CPVRTString(size_t _Count, char _Ch) : -m_pString(0), m_Capacity(0) -{ - assign(_Count,_Ch); -} - -/*!*********************************************************************** -@Function CPVRTString -@Input _Ch A char -@Description Constructor -*************************************************************************/ -CPVRTString::CPVRTString(const char _Ch) : -m_pString(0), m_Capacity(0) -{ - assign( 1, _Ch); -} - -/*!*********************************************************************** -@Function CPVRTString -@Description Constructor -*************************************************************************/ -CPVRTString::CPVRTString() : -m_Size(0), m_Capacity(1) -{ - m_pString = (char*)calloc(1, 1); -} - -/*!*********************************************************************** -@Function ~CPVRTString -@Description Destructor -*************************************************************************/ -CPVRTString::~CPVRTString() -{ - free(m_pString); -} - -/*!*********************************************************************** -@Function append -@Input _Ptr A string -@Returns Updated string -@Description Appends a string -*************************************************************************/ -CPVRTString& CPVRTString::append(const char* _Ptr) -{ - return append(_Ptr,strlen(_Ptr)); -} - -/*!*********************************************************************** -@Function append -@Input _Ptr A string -@Input _Count String length -@Returns Updated string -@Description Appends a string of length _Count -*************************************************************************/ -CPVRTString& CPVRTString::append(const char* _Ptr, size_t _Count) -{ - char* pString = m_pString; - size_t newCapacity = _Count + m_Size + 1; // +1 for null termination - - // extend CPVRTString if necessary - if (m_Capacity < newCapacity) - { - pString = (char*)malloc(newCapacity); - m_Capacity = newCapacity; - memmove(pString, m_pString, m_Size); - pString[m_Capacity-1]='\0'; - } - - // append chars from _Ptr - memmove(pString + m_Size, _Ptr, _Count); - m_Size += _Count; - pString[m_Size] = 0; - - // remove old CPVRTString if necessary - if (pString != m_pString) - { - free(m_pString); - m_pString = pString; - } - return *this; -} - -/*!*********************************************************************** -@Function append -@Input _Str A string -@Returns Updated string -@Description Appends a string -*************************************************************************/ -CPVRTString& CPVRTString::append(const CPVRTString& _Str) -{ - return append(_Str.m_pString,_Str.m_Size); -} - -/*!*********************************************************************** -@Function append -@Input _Str A string -@Input _Off A position in string -@Input _Count Number of letters to append -@Returns Updated string -@Description Appends _Count letters of _Str from _Off in _Str -*************************************************************************/ -CPVRTString& CPVRTString::append(const CPVRTString& _Str, size_t _Off, size_t _Count) -{ - return append(_Str.m_pString+_Off,_Count); -} - -/*!*********************************************************************** -@Function append -@Input _Ch A char -@Input _Count Number of times to append _Ch -@Returns Updated string -@Description Appends _Ch _Count times -*************************************************************************/ -CPVRTString& CPVRTString::append(size_t _Count, char _Ch) -{ - char* pString = m_pString; - size_t newCapacity = _Count + m_Size + 1; // +1 for null termination - // extend CPVRTString if necessary - if (m_Capacity < newCapacity) - { - pString = (char*)malloc(newCapacity); - m_Capacity = newCapacity; - memmove(pString, m_pString, m_Size+1); - } - - char* newChar = &pString[m_Size]; - // fill new space with _Ch - for(size_t i=0;i<_Count;++i) - { - *newChar++ = _Ch; - } - *newChar = '\0'; // set null terminato - m_Size+=_Count; // adjust length of string for new characters - - // remove old CPVRTString if necessary - if (pString != m_pString) - { - free(m_pString); - m_pString = pString; - } - return *this; -} - -/*!*********************************************************************** -@Function assign -@Input _Ptr A string -@Returns Updated string -@Description Assigns the string to the string _Ptr -*************************************************************************/ -CPVRTString& CPVRTString::assign(const char* _Ptr) -{ - return assign(_Ptr, strlen(_Ptr)); -} - -/*!*********************************************************************** -@Function assign -@Input _Ptr A string -@Input _Count Length of _Ptr -@Returns Updated string -@Description Assigns the string to the string _Ptr -*************************************************************************/ -CPVRTString& CPVRTString::assign(const char* _Ptr, size_t _Count) -{ - char* pString = m_pString; - if (m_Capacity <= _Count) - { - pString = (char*)malloc(_Count + 1); - m_Capacity = _Count+1; - } - m_Size = _Count; - - memmove(pString, _Ptr, m_Size); - pString[m_Size] = 0; - - if (pString != m_pString) - { - free(m_pString); - m_pString = pString; - } - return *this; -} - -/*!*********************************************************************** -@Function assign -@Input _Str A string -@Returns Updated string -@Description Assigns the string to the string _Str -*************************************************************************/ -CPVRTString& CPVRTString::assign(const CPVRTString& _Str) -{ - return assign(_Str.m_pString, _Str.m_Size); -} - -/*!*********************************************************************** -@Function assign -@Input _Str A string -@Input _Off First char to start assignment from -@Input _Count Length of _Str -@Returns Updated string -@Description Assigns the string to _Count characters in string _Str starting at _Off -*************************************************************************/ -CPVRTString& CPVRTString::assign(const CPVRTString& _Str, size_t _Off, size_t _Count) -{ - if(_Count==npos) - { - _Count = _Str.m_Size - _Off; - } - return assign(&_Str.m_pString[_Off], _Count); -} - -/*!*********************************************************************** -@Function assign -@Input _Ch A string -@Input _Count Number of times to repeat _Ch -@Returns Updated string -@Description Assigns the string to _Count copies of _Ch -*************************************************************************/ -CPVRTString& CPVRTString::assign(size_t _Count,char _Ch) -{ - if (m_Capacity <= _Count) - { - free(m_pString); - m_pString = (char*)malloc(_Count + 1); - m_Capacity = _Count+1; - } - m_Size = _Count; - memset(m_pString, _Ch, _Count); - m_pString[m_Size] = 0; - - return *this; -} - -//const_reference at(size_t _Off) const; -//reference at(size_t _Off); - -/*!*********************************************************************** -@Function c_str -@Returns const char* pointer of the string -@Description Returns a const char* pointer of the string -*************************************************************************/ -const char* CPVRTString::c_str() const -{ - return m_pString; -} - -/*!*********************************************************************** -@Function capacity -@Returns The size of the character array reserved -@Description Returns the size of the character array reserved -*************************************************************************/ -size_t CPVRTString::capacity() const -{ - return m_Capacity; -} - -/*!*********************************************************************** -@Function clear -@Description Clears the string -*************************************************************************/ -void CPVRTString::clear() -{ - free(m_pString); - m_pString = (char*)calloc(1, 1); - m_Size = 0; - m_Capacity = 1; -} - -/*!*********************************************************************** -@Function compare -@Input _Str A string to compare with -@Returns 0 if the strings match -@Description Compares the string with _Str -*************************************************************************/ -int CPVRTString::compare(const CPVRTString& _Str) const -{ - return strcmp(m_pString,_Str.m_pString); -} - -/*!*********************************************************************** -@Function < -@Input _Str A string to compare with -@Returns True on success -@Description Less than operator -*************************************************************************/ -bool CPVRTString::operator<(const CPVRTString & _Str) const -{ - return (strcmp(m_pString, _Str.m_pString) < 0); -} - -/*!*********************************************************************** -@Function compare -@Input _Pos1 Position to start comparing from -@Input _Num1 Number of chars to compare -@Input _Str A string to compare with -@Returns 0 if the strings match -@Description Compares the string with _Str -*************************************************************************/ -int CPVRTString::compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str) const -{ - _ASSERT(_Pos1<=m_Size); // check comparison starts within lhs CPVRTString - - int i32Ret; // value to return if no difference in actual comparisons between chars - size_t stLhsLength = m_Size-_Pos1; - size_t stSearchLength = PVRT_MIN(stLhsLength,PVRT_MIN(_Str.m_Size,_Num1)); // number of comparisons to do - if(PVRT_MIN(stLhsLength,_Num1)PVRT_MIN(_Str.m_Size,_Num1)) - { - i32Ret = 1; - } - else - { - i32Ret = 0; - } - - // do actual comparison - const char* lhptr = &m_pString[_Pos1]; - const char* rhptr = _Str.m_pString; - for(size_t i=0;i*rhptr) - return 1; - lhptr++;rhptr++; - } - // no difference found in compared characters - return i32Ret; -} - -/*!*********************************************************************** -@Function compare -@Input _Pos1 Position to start comparing from -@Input _Num1 Number of chars to compare -@Input _Str A string to compare with -@Input _Off Position in _Str to compare from -@Input _Count Number of chars in _Str to compare with -@Returns 0 if the strings match -@Description Compares the string with _Str -*************************************************************************/ -int CPVRTString::compare(size_t _Pos1, size_t _Num1, const CPVRTString& _Str, size_t /*_Off*/, size_t _Count) const -{ - _ASSERT(_Pos1<=m_Size); // check comparison starts within lhs CPVRTString - - int i32Ret; // value to return if no difference in actual comparisons between chars - size_t stLhsLength = m_Size-_Pos1; - size_t stSearchLength = PVRT_MIN(stLhsLength,PVRT_MIN(_Str.m_Size,PVRT_MIN(_Num1,_Count))); // number of comparisons to do - if(PVRT_MIN(stLhsLength,_Num1)PVRT_MIN(_Str.m_Size,_Count)) - { - i32Ret = 1; - } - else - { - i32Ret = 0; - } - - - // do actual comparison - char* lhptr = &m_pString[_Pos1]; - char* rhptr = _Str.m_pString; - for(size_t i=0;i*rhptr) - return 1; - lhptr++;rhptr++; - } - // no difference found in compared characters - return i32Ret; -} - -/*!*********************************************************************** -@Function compare -@Input _Ptr A string to compare with -@Returns 0 if the strings match -@Description Compares the string with _Ptr -*************************************************************************/ -int CPVRTString::compare(const char* _Ptr) const -{ - return strcmp(m_pString,_Ptr); -} - -/*!*********************************************************************** -@Function compare -@Input _Pos1 Position to start comparing from -@Input _Num1 Number of chars to compare -@Input _Ptr A string to compare with -@Returns 0 if the strings match -@Description Compares the string with _Ptr -*************************************************************************/ -int CPVRTString::compare(size_t _Pos1, size_t _Num1, const char* _Ptr) const -{ - _ASSERT(_Pos1<=m_Size); // check comparison starts within lhs CPVRTString - - int i32Ret; // value to return if no difference in actual comparisons between chars - size_t stLhsLength = m_Size-_Pos1; - size_t stRhsLength = strlen(_Ptr); - size_t stSearchLength = PVRT_MIN(stLhsLength,PVRT_MIN(stRhsLength,_Num1)); // number of comparisons to do - if(PVRT_MIN(stLhsLength,_Num1)PVRT_MIN(stRhsLength,_Num1)) - { - i32Ret = 1; - } - else - { - i32Ret = 0; - } - - // do actual comparison - const char* lhptr = &m_pString[_Pos1]; - const char* rhptr = _Ptr; - for(size_t i=0;i*rhptr) - return 1; - lhptr++;rhptr++; - } - // no difference found in compared characters - return i32Ret; -} - -/*!*********************************************************************** -@Function compare -@Input _Pos1 Position to start comparing from -@Input _Num1 Number of chars to compare -@Input _Ptr A string to compare with -@Input _Count Number of char to compare -@Returns 0 if the strings match -@Description Compares the string with _Str -*************************************************************************/ -int CPVRTString::compare(size_t _Pos1, size_t _Num1, const char* _Ptr, size_t _Count) const -{ - _ASSERT(_Pos1<=m_Size); // check comparison starts within lhs CPVRTString - - int i32Ret; // value to return if no difference in actual comparisons between chars - size_t stLhsLength = m_Size-_Pos1; - size_t stRhsLength = strlen(_Ptr); - size_t stSearchLength = PVRT_MIN(stLhsLength,PVRT_MIN(stRhsLength,PVRT_MIN(_Num1,_Count))); // number of comparisons to do - if(PVRT_MIN(stLhsLength,_Num1)PVRT_MIN(stRhsLength,_Count)) - { - i32Ret = 1; - } - else - { - i32Ret = 0; - } - - - // do actual comparison - char* lhptr = &m_pString[_Pos1]; - const char* rhptr = _Ptr; - for(size_t i=0;i*rhptr) - return 1; - lhptr++;rhptr++; - } - // no difference found in compared characters - return i32Ret; -} - -/*!*********************************************************************** -@Function == -@Input _Str A string to compare with -@Returns True if they match -@Description == Operator -*************************************************************************/ -bool CPVRTString::operator==(const CPVRTString& _Str) const -{ - return strcmp(m_pString, _Str.m_pString)==0; -} - -/*!*********************************************************************** -@Function == -@Input _Ptr A string to compare with -@Returns True if they match -@Description == Operator -*************************************************************************/ -bool CPVRTString::operator==(const char* const _Ptr) const -{ - return strcmp(m_pString, _Ptr)==0; -} - -/*!*********************************************************************** -@Function != -@Input _Str A string to compare with -@Returns True if they don't match -@Description != Operator -*************************************************************************/ -bool CPVRTString::operator!=(const CPVRTString& _Str) const -{ - return strcmp(m_pString, _Str.m_pString)!=0; -} - -/*!*********************************************************************** -@Function != -@Input _Ptr A string to compare with -@Returns True if they don't match -@Description != Operator -*************************************************************************/ -bool CPVRTString::operator!=(const char* const _Ptr) const -{ - return strcmp(m_pString, _Ptr)!=0; -} - -/*!*********************************************************************** -@Function copy -@Modified _Ptr A string to copy to -@Input _Count Size of _Ptr -@Input _Off Position to start copying from -@Returns Number of bytes copied -@Description Copies the string to _Ptr -*************************************************************************/ -size_t CPVRTString::copy(char* _Ptr, size_t _Count, size_t _Off) const -{ - if(memcpy(_Ptr, &m_pString[_Off], PVRT_MIN(_Count, m_Size - _Off))) - return _Count; - - return 0; -} - -/*!*********************************************************************** -@Function data -@Returns A const char* version of the string -@Description Returns a const char* version of the string -*************************************************************************/ -const char* CPVRTString::data() const -{ - return m_pString; -} - -/*!*********************************************************************** -@Function empty -@Returns True if the string is empty -@Description Returns true if the string is empty -*************************************************************************/ -bool CPVRTString::empty() const -{ - return (m_Size == 0); -} - -/*!*********************************************************************** -@Function erase -@Input _Pos The position to start erasing from -@Input _Count Number of chars to erase -@Returns An updated string -@Description Erases a portion of the string -*************************************************************************/ -CPVRTString& CPVRTString::erase(size_t _Pos, size_t _Count) -{ - if (_Count == npos || _Pos + _Count >= m_Size) - { - resize(_Pos, 0); - } - else - { - memmove(&m_pString[_Pos], &m_pString[_Pos + _Count], m_Size + 1 - (_Pos + _Count)); - } - return *this; -} - -/*!*********************************************************************** -@Function find_first_not_of -@Input _Ch A char -@Input _Off Start position of the find -@Returns Position of the first char that is not _Ch -@Description Returns the position of the first char that is not _Ch -*************************************************************************/ -size_t CPVRTString::find_first_not_of(char _Ch, size_t _Off) const -{ - for(size_t i=_Off;i= m_Capacity) - { - m_pString = (char*)realloc(m_pString, _Count + 1); - m_Capacity = _Count + 1; - } -} - -/*!*********************************************************************** -@Function resize -@Input _Count Size of string to resize to -@Input _Ch Character to use to fill any additional space -@Description Resizes the string to _Count in length -*************************************************************************/ -void CPVRTString::resize(size_t _Count, char _Ch) -{ - if (_Count <= m_Size) - { - m_Size = _Count; - m_pString[m_Size] = 0; - } - else - { - append(_Count - m_Size,_Ch); - } -} - -//size_t rfind(char _Ch, size_t _Off = npos) const; -//size_t rfind(const char* _Ptr, size_t _Off = npos) const; -//size_t rfind(const char* _Ptr, size_t _Off = npos, size_t _Count) const; -//size_t rfind(const CPVRTString& _Str, size_t _Off = npos) const; - -/*!*********************************************************************** -@Function size -@Returns Size of the string -@Description Returns the size of the string -*************************************************************************/ -size_t CPVRTString::size() const -{ - return m_Size; -} - -/*!*********************************************************************** -@Function substr -@Input _Off Start of the substring -@Input _Count Length of the substring -@Returns A substring of the string -@Description Returns the size of the string -*************************************************************************/ -CPVRTString CPVRTString::substr(size_t _Off, size_t _Count) const -{ - return CPVRTString(*this, _Off, _Count); -} - -/*!*********************************************************************** -@Function swap -@Input _Str A string to swap with -@Description Swaps the contents of the string with _Str -*************************************************************************/ -void CPVRTString::swap(CPVRTString& _Str) -{ - size_t Size = _Str.m_Size; - size_t Capacity = _Str.m_Capacity; - char* pString = _Str.m_pString; - _Str.m_Size = m_Size; - _Str.m_Capacity = m_Capacity; - _Str.m_pString = m_pString; - m_Size = Size; - m_Capacity = Capacity; - m_pString = pString; -} - -/*!*********************************************************************** -@Function toLower -@Returns An updated string -@Description Converts the string to lower case -*************************************************************************/ -CPVRTString& CPVRTString::toLower() -{ - int i = 0; - while ( (m_pString[i] = (m_pString[i]>='A'&&m_pString[i]<='Z') ? ('a'+m_pString[i])-'A': m_pString[i]) != 0) i++; - return *this; -} - -/*!*********************************************************************** -@Function += -@Input _Ch A char -@Returns An updated string -@Description += Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator+=(char _Ch) -{ - return append(_Ch, 1); -} - -/*!*********************************************************************** -@Function += -@Input _Ptr A string -@Returns An updated string -@Description += Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator+=(const char* _Ptr) -{ - return append(_Ptr); -} - -/*!*********************************************************************** -@Function += -@Input _Right A string -@Returns An updated string -@Description += Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator+=(const CPVRTString& _Right) -{ - return append(_Right); -} - -/*!*********************************************************************** -@Function = -@Input _Ch A char -@Returns An updated string -@Description = Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator=(char _Ch) -{ - return assign(_Ch, 1); -} - -/*!*********************************************************************** -@Function = -@Input _Ptr A string -@Returns An updated string -@Description = Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator=(const char* _Ptr) -{ - return assign(_Ptr); -} - -/*!*********************************************************************** -@Function = -@Input _Right A string -@Returns An updated string -@Description = Operator -*************************************************************************/ -CPVRTString& CPVRTString::operator=(const CPVRTString& _Right) -{ - return assign(_Right); -} - -/*!*********************************************************************** -@Function [] -@Input _Off An index into the string -@Returns A character -@Description [] Operator -*************************************************************************/ -CPVRTString::const_reference CPVRTString::operator[](size_t _Off) const -{ - return m_pString[_Off]; -} - -/*!*********************************************************************** -@Function [] -@Input _Off An index into the string -@Returns A character -@Description [] Operator -*************************************************************************/ -CPVRTString::reference CPVRTString::operator[](size_t _Off) -{ - return m_pString[_Off]; -} - -/*!*********************************************************************** -@Function + -@Input _Left A string -@Input _Right A string -@Returns An updated string -@Description + Operator -*************************************************************************/ -CPVRTString operator+ (const CPVRTString& _Left, const CPVRTString& _Right) -{ - return CPVRTString(_Left).append(_Right); -} - -/*!*********************************************************************** -@Function + -@Input _Left A string -@Input _Right A string -@Returns An updated string -@Description + Operator -*************************************************************************/ -CPVRTString operator+ (const CPVRTString& _Left, const char* _Right) -{ - return CPVRTString(_Left).append(_Right); -} - -/*!*********************************************************************** -@Function + -@Input _Left A string -@Input _Right A string -@Returns An updated string -@Description + Operator -*************************************************************************/ -CPVRTString operator+ (const CPVRTString& _Left, const char _Right) -{ - return CPVRTString(_Left).append(_Right); -} - -/*!*********************************************************************** -@Function + -@Input _Left A string -@Input _Right A string -@Returns An updated string -@Description + Operator -*************************************************************************/ -CPVRTString operator+ (const char* _Left, const CPVRTString& _Right) -{ - return CPVRTString(_Left).append(_Right); -} - -/*!*********************************************************************** -@Function + -@Input _Left A string -@Input _Right A string -@Returns An updated string -@Description + Operator -*************************************************************************/ -CPVRTString operator+ (const char _Left, const CPVRTString& _Right) -{ - return CPVRTString(_Left).append(_Right); -} - -/************************************************************************* -* MISCELLANEOUS UTILITY FUNCTIONS -*************************************************************************/ -/*!*********************************************************************** -@Function PVRTStringGetFileExtension -@Input strFilePath A string -@Returns Extension -@Description Extracts the file extension from a file path. - Returns an empty CPVRTString if no extension is found. -************************************************************************/ -CPVRTString PVRTStringGetFileExtension(const CPVRTString& strFilePath) -{ - CPVRTString::size_type idx = strFilePath.find_last_of ( '.' ); - - if (idx == CPVRTString::npos) - return CPVRTString(""); - else - return strFilePath.substr(idx); -} - -/*!*********************************************************************** -@Function PVRTStringGetContainingDirectoryPath -@Input strFilePath A string -@Returns Directory -@Description Extracts the directory portion from a file path. -************************************************************************/ -CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath) -{ - size_t i32sep = strFilePath.find_last_of('/'); - if(i32sep == strFilePath.npos) - { - i32sep = strFilePath.find_last_of('\\'); - if(i32sep == strFilePath.npos) - { // can't find an actual \ or /, so return an empty string - return CPVRTString(""); - } - } - return strFilePath.substr(0,i32sep); -} - -/*!*********************************************************************** -@Function PVRTStringGetFileName -@Input strFilePath A string -@Returns FileName -@Description Extracts the name and extension portion from a file path. -************************************************************************/ -CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath) -{ - size_t i32sep = strFilePath.find_last_of('/'); - if(i32sep == strFilePath.npos) - { - i32sep = strFilePath.find_last_of('\\'); - if(i32sep == strFilePath.npos) - { // can't find an actual \ or / so leave it be - return strFilePath; - } - } - return strFilePath.substr(i32sep+1,strFilePath.length()); -} - -/*!*********************************************************************** -@Function PVRTStringStripWhiteSpaceFromStartOf -@Input strLine A string -@Returns Result of the white space stripping -@Description strips white space characters from the beginning of a CPVRTString. -************************************************************************/ -CPVRTString PVRTStringStripWhiteSpaceFromStartOf(const CPVRTString& strLine) -{ - size_t start = strLine.find_first_not_of(" \t \n\r"); - if(start!=strLine.npos) - return strLine.substr(start,strLine.length()-(start)); - return strLine; -} - - -/*!*********************************************************************** -@Function PVRTStringStripWhiteSpaceFromEndOf -@Input strLine A string -@Returns Result of the white space stripping -@Description strips white space characters from the end of a CPVRTString. -************************************************************************/ -CPVRTString PVRTStringStripWhiteSpaceFromEndOf(const CPVRTString& strLine) -{ - size_t end = strLine.find_last_not_of(" \t \n\r"); - if(end!=strLine.npos) - return strLine.substr(0,end+1); - return strLine; -} - -/*!*********************************************************************** -@Function PVRTStringFromFormattedStr -@Input pFormat A string containing the formating -@Returns A formatted string -@Description Creates a formatted string -************************************************************************/ -CPVRTString PVRTStringFromFormattedStr(const char *pFormat, ...) -{ - va_list arg; - char buf[1024]; - - va_start(arg, pFormat); -#if defined(__SYMBIAN32__) || defined(UITRON) || defined(_UITRON_) - vsprintf(buf, pFormat, arg); -#else - vsnprintf(buf, 1024, pFormat, arg); -#endif - va_end(arg); - - return buf; -} - -///*!*************************************************************************** - -#endif // _USING_PVRTSTRING_ - -/***************************************************************************** - End of file (PVRTString.cpp) -*****************************************************************************/ - -#endif // DEBUG \ No newline at end of file diff --git a/deps/PVRTT/win-x64/PVRTexLib.dll b/deps/PVRTT/win-x64/PVRTexLib.dll index 3b46352c73..70cf4e109f 100644 --- a/deps/PVRTT/win-x64/PVRTexLib.dll +++ b/deps/PVRTT/win-x64/PVRTexLib.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9b686bacc28059ab06517a39a741346195817e93782cb72bd3eb3b7e336e9c4f -size 2182144 +oid sha256:9312bd0e039fbf5d915160a81cda754c3d3c6e941d949a3382f152f07708302b +size 5041456 diff --git a/deps/PVRTT/win-x64/PVRTexLib.lib b/deps/PVRTT/win-x64/PVRTexLib.lib index 5e7ae82d9b..5d3bf49f0e 100644 --- a/deps/PVRTT/win-x64/PVRTexLib.lib +++ b/deps/PVRTT/win-x64/PVRTexLib.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1a5b85a2714ddbb3d4f607578cee925e9c601f16222eff0578c4c5b929e77271 -size 4498620 +oid sha256:56f5446a72a4abc8b4ff1174227863ee24f1c3d8065081cae9ffac23d1443818 +size 31118 diff --git a/deps/PVRTT/win-x86/PVRTexLib.dll b/deps/PVRTT/win-x86/PVRTexLib.dll index dc7716f2cb..15b1bf1e98 100644 --- a/deps/PVRTT/win-x86/PVRTexLib.dll +++ b/deps/PVRTT/win-x86/PVRTexLib.dll @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1816a1f3c9fe0b994347ecf2f449e1fbd1870f157fb4283a73a8d74b9801f967 -size 2180608 +oid sha256:135e1b54296afe3bb5d19a09f4f8f77b14d1ea3bd3af319a879746a2794e412b +size 4670768 diff --git a/deps/PVRTT/win-x86/PVRTexLib.lib b/deps/PVRTT/win-x86/PVRTexLib.lib index f06870bc8a..6fcf10d70a 100644 --- a/deps/PVRTT/win-x86/PVRTexLib.lib +++ b/deps/PVRTT/win-x86/PVRTexLib.lib @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:74fa42864a5347d5464ed257273cad7eaf1e23ef470db8cd9300b9b960114332 -size 3685238 +oid sha256:4906ce719c799292d8c33283edd2e067605e0342e08d86189b11b6b5bd2019e9 +size 31670 diff --git a/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.dll b/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.dll deleted file mode 100644 index a450e29413..0000000000 --- a/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a9dda5b511882cd26b2bc8a095a635d1b27b00353509a3eb9ce0ee9941477d59 -size 3564544 diff --git a/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.pdb b/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.pdb deleted file mode 100644 index 80e5ea70ce..0000000000 --- a/deps/TextureWrappers/Debug/win-x86/PvrttWrapper.pdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b7ed578fecdc89ae8f8771c522932b544c01ee35d1cc5e6468929d305a184aad -size 1413120 diff --git a/deps/TextureWrappers/Release/win-x64/PvrttWrapper.dll b/deps/TextureWrappers/Release/win-x64/PvrttWrapper.dll deleted file mode 100644 index bfc9ef4333..0000000000 --- a/deps/TextureWrappers/Release/win-x64/PvrttWrapper.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a5043f0fcf13c203e65660f5c72fb7635ab925d7535204c36935d3494a07a6ce -size 2849280 diff --git a/deps/TextureWrappers/Release/win-x64/PvrttWrapper.pdb b/deps/TextureWrappers/Release/win-x64/PvrttWrapper.pdb deleted file mode 100644 index 90ce8d8a82..0000000000 --- a/deps/TextureWrappers/Release/win-x64/PvrttWrapper.pdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:501157c577dfd76201e2adc747bc164a5ea06559b27800cb444ff07a0a104dff -size 1191936 diff --git a/deps/TextureWrappers/Release/win-x86/PvrttWrapper.dll b/deps/TextureWrappers/Release/win-x86/PvrttWrapper.dll deleted file mode 100644 index 15e264e1cd..0000000000 --- a/deps/TextureWrappers/Release/win-x86/PvrttWrapper.dll +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b1e09b968aacde5d3ac7239bd9473fc364881d6a330274e386d1d9021ca6dd06 -size 2723328 diff --git a/deps/TextureWrappers/Release/win-x86/PvrttWrapper.pdb b/deps/TextureWrappers/Release/win-x86/PvrttWrapper.pdb deleted file mode 100644 index f0c7504959..0000000000 --- a/deps/TextureWrappers/Release/win-x86/PvrttWrapper.pdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5e0470e9dc4060fd209cf68988d55ce2591a98cc7de84ca395e95cba83787627 -size 1191936 diff --git a/sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs b/sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs index 6d88be6512..65afd36ff7 100644 --- a/sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs +++ b/sources/engine/Stride.Graphics/Vulkan/VulkanConvertExtensions.cs @@ -653,16 +653,6 @@ public static int BlockSizeInBytes(this VkFormat format) case VkFormat.ASTC12x12SRgbBlock: return 16; - //case VkFormat.Pvrtc12BppUNormBlock: - //case VkFormat.Pvrtc14BppUNormBlock: - //case VkFormat.Pvrtc22BppUNormBlock: - //case VkFormat.Pvrtc24BppUNormBlock: - //case VkFormat.Pvrtc12BppSRgbBlock: - //case VkFormat.Pvrtc14BppSRgbBlock: - //case VkFormat.Pvrtc22BppSRgbBlock: - //case VkFormat.Pvrtc24BppSRgbBlock: - // return 8; - default: throw new ArgumentOutOfRangeException(nameof(format)); } diff --git a/sources/engine/Stride/Graphics/PixelFormatExtensions.cs b/sources/engine/Stride/Graphics/PixelFormatExtensions.cs index 7136816150..cf531a4294 100644 --- a/sources/engine/Stride/Graphics/PixelFormatExtensions.cs +++ b/sources/engine/Stride/Graphics/PixelFormatExtensions.cs @@ -179,10 +179,8 @@ public static int AlphaSizeInBits(this PixelFormat format) /// True if the is valid. public static bool IsValid(this PixelFormat format) { - return ((int)(format) >= 1 && (int)(format) <= 115) // DirectX formats - || ((int)(format) >= 1024 && (int)(format) <= 1033) // PVRTC formats - || ((int)(format) >= 1088 && (int)(format) <= 1097) // ETC formats - || ((int)(format) >= 1120 && (int)(format) <= 1122); // ATITC formats + return ((int)format >= 1 && (int)format <= 115) // DirectX formats + || ((int)format >= 1088 && (int)format <= 1097); // ETC formats } /// diff --git a/sources/tests/tools/Stride.TextureConverter.Tests/TestTools.cs b/sources/tests/tools/Stride.TextureConverter.Tests/TestTools.cs index f02782691d..68ad0ccd7f 100644 --- a/sources/tests/tools/Stride.TextureConverter.Tests/TestTools.cs +++ b/sources/tests/tools/Stride.TextureConverter.Tests/TestTools.cs @@ -67,15 +67,6 @@ private TestTools() { {"ExportMinMipMapTest_4_Texture3D_WMipMaps_ATC_RGBA_Explicit.sd", "b59b422af672e22f16d435f55b68203cf0121874"}, {"ExportMinMipMapTest_16_TextureCube_WMipMaps_RGBA8888.sd", "1d3640be224834c1f84a84fa24340519d56f2291"}, - - // AtitcTexLibrary - {"CompressTest_ATC_RGBA_Explicit_TextureCube_WMipMaps_RGBA8888.sd", "38d7745886f590f9fe40425f8b86a2fc7d0dbb18"}, - {"CompressTest_ATC_RGBA_Interpolated_TextureArray_WMipMaps_RGBA8888.sd", "205e81fe258bc93bb8f06af1742d1d2c507e91bd"}, - {"CompressTest_ATC_RGBA_Explicit_Texture3D_WMipMap_RGBA8888.sd", "db42523c04e32205ed0fa92397f965172147c2c4"}, - {"DecompressTest_Texture3D_WMipMaps_ATC_RGBA_Explicit.sd", "c8df38d68f24bb1d937596b2371a6344e9c52b7d"}, - {"DecompressTest_TextureArray_WMipMaps_ATC_RGBA_Explicit.sd", "3d0eed304b118e2abf040b6fc64147caa3353613"}, - {"DecompressTest_TextureCube_WMipMaps_ATC_RGBA_Explicit.sd", "227932d9ae0d026c15324c194848e8428a03a09b"}, - // DxtTexLib {"DecompressTest_TextureArray_WMipMaps_BC3.dds", "54e100f9fb5982a8e51984911918e2f663d21805"}, {"DecompressTest_TextureCube_WMipMaps_BC3.dds", "78a23f5778fd66113bb1e71971e3708cbb8531b5"}, diff --git a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj b/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj deleted file mode 100644 index a26db004ce..0000000000 --- a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj +++ /dev/null @@ -1,173 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5} - PvrttWrapperC - PvrttWrapper - 10.0 - - - - DynamicLibrary - true - v143 - MultiByte - - - DynamicLibrary - true - v143 - MultiByte - - - DynamicLibrary - false - v143 - true - MultiByte - - - DynamicLibrary - false - v143 - true - MultiByte - - - - - - - - - - - - - - - - - - - $(ProjectName) - $(MSBuildThisFileDirectory)..\..\..\..\build\$(Configuration)\$(Platform) - $(Configuration)\$(Platform) - - - $(ProjectName) - $(MSBuildThisFileDirectory)..\..\..\..\build\$(Configuration)\$(Platform) - $(Configuration)\$(Platform) - - - $(ProjectName) - $(MSBuildThisFileDirectory)..\..\..\..\build\$(Configuration)\$(Platform) - $(Configuration)\$(Platform) - - - $(ProjectName) - $(MSBuildThisFileDirectory)..\..\..\..\build\$(Configuration)\$(Platform) - $(Configuration)\$(Platform) - - - - Level3 - Disabled - $(ProjectDir)..\..\..\..\deps\PVRTT\include;%(AdditionalIncludeDirectories) - DEBUG;_WINDLL;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - $(ProjectDir)..\..\..\..\deps\PVRTT\x86;%(AdditionalLibraryDirectories) - PVRTexLib.lib;%(AdditionalDependencies) - - - xcopy /y $(OutDir)$(TargetName).dll $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x86\ & xcopy /y $(OutDir)$(TargetName).pdb $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x86\ - - - - - Level3 - Disabled - $(ProjectDir)..\..\..\..\deps\PVRTT\include;%(AdditionalIncludeDirectories) - DEBUG;_WINDLL;%(PreprocessorDefinitions) - MultiThreadedDLL - - - true - $(ProjectDir)..\..\..\..\deps\PVRTT\x64;%(AdditionalLibraryDirectories) - PVRTexLib.lib;%(AdditionalDependencies) - - - xcopy /y $(OutDir)$(TargetName).dll $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x64\ & xcopy /y $(OutDir)$(TargetName).pdb $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x64\ - - - - - Level3 - MaxSpeed - true - true - $(ProjectDir)..\..\..\..\deps\PVRTT\include;%(AdditionalIncludeDirectories) - _WINDLL;%(PreprocessorDefinitions) - - - true - true - true - $(ProjectDir)..\..\..\..\deps\PVRTT\x86;%(AdditionalLibraryDirectories) - PVRTexLib.lib;%(AdditionalDependencies) - - - xcopy /y $(OutDir)$(TargetName).dll $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x86\ & xcopy /y $(OutDir)$(TargetName).pdb $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x86\ - - - - - Level3 - MaxSpeed - true - true - $(ProjectDir)..\..\..\..\deps\PVRTT\include;%(AdditionalIncludeDirectories) - _WINDLL;%(PreprocessorDefinitions) - - - true - true - true - $(ProjectDir)..\..\..\..\deps\PVRTT\x64;%(AdditionalLibraryDirectories) - PVRTexLib.lib;%(AdditionalDependencies) - - - xcopy /y $(OutDir)$(TargetName).dll $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x64\ & xcopy /y $(OutDir)$(TargetName).pdb $(ProjectDir)..\..\..\..\deps\TextureWrappers\$(Configuration)\x64\ - - - - - - - - - - - - diff --git a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj.filters b/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj.filters deleted file mode 100644 index 2fb970c1f0..0000000000 --- a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/PvrttWrapperC++.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.cpp b/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.cpp deleted file mode 100644 index 7d0907db31..0000000000 --- a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.cpp +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -#include "pvrtt_wrapper.h" -#include -#include -#include - -//#include -// intern conversion class -pvrtexture::PixelType convertPixelType(PvrttPixelType pixelFormat) -{ - switch(pixelFormat) - { - default: - case PVRTT_Standard8PixelType: - return pvrtexture::PixelType('r','g','b','a',8,8,8,8); - break; - case PVRTT_tandard16PixelType: - return pvrtexture::PixelType('r','g','b','a',16,16,16,16); - break; - case PVRTT_Standard32PixelType: - return pvrtexture::PixelType('r','g','b','a',32,32,32,32); - break; - } -} - -pvrtexture::uint64 pvrttConvertPixelType(PvrttPixelType pixelFormat) -{ - switch(pixelFormat) - { - default: - case PVRTT_Standard8PixelType: - return pvrtexture::PixelType('r','g','b','a',8,8,8,8).PixelTypeID; - break; - case PVRTT_tandard16PixelType: - return pvrtexture::PixelType('r','g','b','a',16,16,16,16).PixelTypeID; - break; - case PVRTT_Standard32PixelType: - return pvrtexture::PixelType('r','g','b','a',32,32,32,32).PixelTypeID; - break; - } -} - - -// CPVRTextureHeader class -PvrttTextureHeader * pvrttCreateTextureHeaderEmpty() -{ - return new pvrtexture::CPVRTextureHeader(); -} - -PvrttTextureHeader * pvrttCreateTextureHeader(PvrttPixelType pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false) -{ - return new PvrttTextureHeader(convertPixelType(pixelFormat).PixelTypeID, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied); -} - -PvrttTextureHeader * pvrttCreateTextureHeaderFromCompressedTexture(pvrtexture::uint64 pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=ePVRTCSpacelRGB, EPVRTVariableType eChannelType=ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false) -{ - return new PvrttTextureHeader(pixelFormat, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied); -} - -PvrttTextureHeader * pvrttCopyTextureHeader(const PvrttTextureHeader * headerIn) -{ - PvrttTextureHeader * headerOut = new PvrttTextureHeader(); - *headerOut = *headerIn; - return headerOut; -} - -pvrtexture::uint32 pvrttGetWidth(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) -{ - return header->getWidth(uiMipLevel); -} - -pvrtexture::uint32 pvrttGetHeight(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel=PVRTEX_TOPMIPLEVEL) -{ - return header->getHeight(uiMipLevel); -} - -void pvrttSetWidth(PvrttTextureHeader * header, pvrtexture::uint32 newWidth) -{ - header->setWidth(newWidth); -} - -void pvrttSetHeight(PvrttTextureHeader * header, pvrtexture::uint32 newHeight) -{ - header->setWidth(newHeight); -} - -void pvrttSetPixelFormat(PvrttTextureHeader * header, PvrttPixelType pixelFormat) -{ - header->setPixelFormat(convertPixelType(pixelFormat)); -} - -pvrtexture::uint32 pvrttGetDataSize(PvrttTextureHeader * header, int iMipLevel=PVRTEX_ALLMIPLEVELS, bool bAllSurfaces=true, bool bAllFaces=true) -{ - return header->getDataSize(iMipLevel, bAllSurfaces, bAllFaces); -} - -pvrtexture::uint32 pvrttGetTextureSize(PvrttTextureHeader * header, int iMipLevel, bool bAllSurfaces, bool bAllFaces) -{ - return header->getTextureSize(); -} - -pvrtexture::uint32 pvrttGetNumMIPLevels(PvrttTextureHeader * header) -{ - return header->getNumMIPLevels(); -} - -void pvrttSetNumMIPLevels(PvrttTextureHeader * header, int newNumMIPLevels) -{ - header->setNumMIPLevels(newNumMIPLevels); -} - -pvrtexture::uint32 pvrttGetDepth(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel = PVRTEX_TOPMIPLEVEL) -{ - return header->getDepth(uiMipLevel); -} - -pvrtexture::uint32 pvrttGetBPP(PvrttTextureHeader * header) -{ - return header->getBitsPerPixel(); -} - -pvrtexture::uint32 pvrttGetNumArrayMembers(PvrttTextureHeader * header) -{ - return header->getNumArrayMembers(); -} - -pvrtexture::uint32 pvrttGetNumFaces(PvrttTextureHeader * header) -{ - return header->getNumFaces(); -} - -bool pvrttIsFileCompressed(PvrttTextureHeader * header) -{ - return header->isFileCompressed(); -} - -pvrtexture::uint64 pvrttGetPixelType(PvrttTextureHeader * header) -{ - return header->getPixelType().PixelTypeID; -} - -pvrtexture::uint32 pvrttGetMetaDataSize(PvrttTextureHeader * header) -{ - return header->getMetaDataSize(); -} - -EPVRTVariableType pvrttGetChannelType(PvrttTextureHeader * header) -{ - return header->getChannelType(); -} - -EPVRTColourSpace pvrttGetColourSpace(PvrttTextureHeader * header) -{ - return header->getColourSpace(); -} - - - -// CPVRTexture class -PvrttTexture * pvrttCreateTexture() -{ - return new pvrtexture::CPVRTexture(); -} - -PvrttTexture * pvrttCreateTextureFromHeader(PvrttTextureHeader* sHeader, const void* pData=NULL) -{ - if(pData == 0) pData=NULL; - return new pvrtexture::CPVRTexture(*sHeader, pData); -} - -PvrttTexture * pvrttCreateTextureFromFile(const char* szFilePath) -{ - return new pvrtexture::CPVRTexture(szFilePath); -} - -PvrttTexture * pvrttCreateTextureFromMemory(const void* pTexture ) -{ - return new pvrtexture::CPVRTexture(pTexture); -} - -/*PvrttTexture * pvrttCreateTexture(const PvrttTexture& texture) -{ - return new pvrtexture::CPVRTexture(texture); -}*/ - -void pvrttDestroyTexture(PvrttTexture * texture) -{ - delete texture; -} - -bool pvrttSaveFile(PvrttTexture * texture, const char* filePath) -{ - return texture->saveFile(filePath); -} - -const PvrttTextureHeader * pvrttGetHeader(PvrttTexture * texture) -{ - return &(texture->getHeader()); -} - -void* pvrttGetDataPtr(PvrttTexture * texture, pvrtexture::uint32 uiMIPLevel = 0, pvrtexture::uint32 uiArrayMember = 0, pvrtexture::uint32 uiFaceNumber = 0) -{ - return texture->getDataPtr(uiMIPLevel, uiArrayMember, uiFaceNumber); -} - -// Utilities - -bool pvrttGenerateMIPMaps(PvrttTexture& texture, const pvrtexture::EResizeMode eFilterMode, int uiMIPMapsToDo=PVRTEX_ALLMIPLEVELS) -{ - return pvrtexture::GenerateMIPMaps(texture, eFilterMode, uiMIPMapsToDo); -} - -bool pvrttTranscodeWithNoConversion(PvrttTexture& texture, const PvrttPixelType ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality=pvrtexture::ePVRTCNormal, const bool bDoDither=false) -{ - return pvrtexture::Transcode(texture, convertPixelType(ptFormat), eChannelType, eColourspace, eQuality, bDoDither); -} - -bool pvrttTranscode(PvrttTexture& texture, pvrtexture::uint64 ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality, const bool bDoDither) -{ - return pvrtexture::Transcode(texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); -} - - -/*int pvrttDecompressPVRTC(const void *pCompressedData, const int Do2bitMode, const int XDim, const int YDim, unsigned char* pResultImage) -{ - return PVRTDecompressPVRTC(pCompressedData, Do2bitMode, XDim, YDim, pResultImage); -} - -int pvrttDecompressETC(const void * const pSrcData, const unsigned int &x, const unsigned int &y, void *pDestData, const int &nMode) -{ - return PVRTDecompressETC(pSrcData, x, y, pDestData, nMode); -}*/ - -bool pvrttCopyChannels(PvrttTexture& sTexture, const PvrttTexture& sTextureSource, pvrtexture::uint32 uiNumChannelCopies, pvrtexture::EChannelName *eChannels, pvrtexture::EChannelName *eChannelsSource) -{ - return pvrtexture::CopyChannels(sTexture, sTextureSource, uiNumChannelCopies, eChannels, eChannelsSource); -} - -bool pvrttResize(PvrttTexture& sTexture, const pvrtexture::uint32& u32NewWidth, const pvrtexture::uint32& u32NewHeight, const pvrtexture::uint32& u32NewDepth, const pvrtexture::EResizeMode eResizeMode) -{ - return pvrtexture::Resize(sTexture, u32NewWidth, u32NewHeight, u32NewDepth, eResizeMode); -} - -bool pvrttFlip(PvrttTexture& sTexture, const EPVRTAxis eFlipDirection) -{ - return pvrtexture::Flip(sTexture, eFlipDirection); -} - -bool pvrttGenerateNormalMap(PvrttTexture& sTexture, const float fScale, const char* sChannelOrder) -{ - return pvrtexture::GenerateNormalMap(sTexture, fScale, sChannelOrder); -} - -bool pvrttPreMultipliedAlpha(PvrttTexture& sTexture) -{ - return pvrtexture::PreMultiplyAlpha(sTexture); -} diff --git a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.h b/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.h deleted file mode 100644 index 653b6e869b..0000000000 --- a/sources/tools/Stride.TextureConverter.Wrappers/PvrttWrapperC++/pvrtt_wrapper.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -#ifndef PVRTT_WRAPPER_H -#define PVRTT_WRAPPER_H - -#define PVRTT_API __declspec(dllexport) - -//#include -#include - -typedef class pvrtexture::CPVRTextureHeader PvrttTextureHeader; -typedef class pvrtexture::CPVRTexture PvrttTexture; - -typedef enum -{ - PVRTT_Standard8PixelType, - PVRTT_tandard16PixelType, - PVRTT_Standard32PixelType, -} PvrttPixelType; - -extern "C" { - - // CPVRTextureHeader class - PVRTT_API PvrttTextureHeader * pvrttCreateTextureHeaderEmpty(); - PVRTT_API PvrttTextureHeader * pvrttCopyTextureHeader(const PvrttTextureHeader * headerIn); - PVRTT_API PvrttTextureHeader * pvrttCreateTextureHeader(PvrttPixelType pixelFormat, int height, int width, int depth, int numMipMaps,int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied); - PVRTT_API PvrttTextureHeader * pvrttCreateTextureHeaderFromCompressedTexture(pvrtexture::uint64 pixelFormat, int height, int width, int depth, int numMipMaps, int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied); - PVRTT_API pvrtexture::uint32 pvrttGetWidth(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel); - PVRTT_API pvrtexture::uint32 pvrttGetHeight(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel); - PVRTT_API void pvrttSetWidth(PvrttTextureHeader * header, pvrtexture::uint32 newWidth); - PVRTT_API void pvrttSetHeight(PvrttTextureHeader * header, pvrtexture::uint32 newHeight); - PVRTT_API void pvrttSetPixelFormat(PvrttTextureHeader * header, PvrttPixelType pixelFormat); - PVRTT_API pvrtexture::uint32 pvrttGetDataSize(PvrttTextureHeader * header, int iMipLevel, bool bAllSurfaces, bool bAllFaces); - PVRTT_API pvrtexture::uint32 pvrttGetTextureSize(PvrttTextureHeader * header, int iMipLevel, bool bAllSurfaces, bool bAllFaces); - PVRTT_API pvrtexture::uint32 pvrttGetNumMIPLevels(PvrttTextureHeader * header); - PVRTT_API void pvrttSetNumMIPLevels(PvrttTextureHeader * header, int newNumMIPLevels); - PVRTT_API pvrtexture::uint32 pvrttGetDepth(PvrttTextureHeader * header, pvrtexture::uint32 uiMipLevel); - PVRTT_API pvrtexture::uint32 pvrttGetBPP(PvrttTextureHeader * header); - PVRTT_API pvrtexture::uint32 pvrttGetNumArrayMembers(PvrttTextureHeader * header); - PVRTT_API pvrtexture::uint32 pvrttGetNumFaces(PvrttTextureHeader * header); - PVRTT_API bool pvrttIsFileCompressed(PvrttTextureHeader * header); - PVRTT_API pvrtexture::uint64 pvrttGetPixelType(PvrttTextureHeader * header); - PVRTT_API pvrtexture::uint32 pvrttGetMetaDataSize(PvrttTextureHeader * header); - PVRTT_API EPVRTVariableType pvrttGetChannelType(PvrttTextureHeader * header); - PVRTT_API EPVRTColourSpace pvrttGetColourSpace(PvrttTextureHeader * header); - - // CPVRTexture class - PVRTT_API PvrttTexture * pvrttCreateTexture(); - PVRTT_API PvrttTexture * pvrttCreateTextureFromHeader(PvrttTextureHeader* sHeader, const void* pData); - PVRTT_API PvrttTexture * pvrttCreateTextureFromFile(const char* szFilePath); - PVRTT_API PvrttTexture * pvrttCreateTextureFromMemory(const void* pTexture ); - PVRTT_API void pvrttDestroyTexture(PvrttTexture * texture); - PVRTT_API bool pvrttSaveFile(PvrttTexture * texture, const char* filePath); - PVRTT_API const PvrttTextureHeader * pvrttGetHeader(PvrttTexture * texture); - PVRTT_API void* pvrttGetDataPtr(PvrttTexture * texture, pvrtexture::uint32 uiMIPLevel, pvrtexture::uint32 uiArrayMember, pvrtexture::uint32 uiFaceNumber); - - // Utilities - PVRTT_API bool pvrttGenerateMIPMaps(PvrttTexture& texture, const pvrtexture::EResizeMode eFilterMode, int uiMIPMapsToDo); - PVRTT_API bool pvrttTranscodeWithNoConversion(PvrttTexture& texture, const PvrttPixelType ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality, const bool bDoDither); - PVRTT_API bool pvrttTranscode(PvrttTexture& texture, pvrtexture::uint64 ptFormat, const EPVRTVariableType eChannelType, const EPVRTColourSpace eColourspace, const pvrtexture::ECompressorQuality eQuality, const bool bDoDither); - //PVRTT_API int pvrttDecompressPVRTC(const void *pCompressedData, const int Do2bitMode, const int XDim, const int YDim, unsigned char* pResultImage); - //PVRTT_API int pvrttDecompressETC(const void * const pSrcData, const unsigned int &x, const unsigned int &y, void *pDestData, const int &nMode); - PVRTT_API bool pvrttCopyChannels(PvrttTexture& sTexture, const PvrttTexture& sTextureSource, pvrtexture::uint32 uiNumChannelCopies, pvrtexture::EChannelName *eChannels, pvrtexture::EChannelName *eChannelsSource); - PVRTT_API bool pvrttResize(PvrttTexture& sTexture, const pvrtexture::uint32& u32NewWidth, const pvrtexture::uint32& u32NewHeight, const pvrtexture::uint32& u32NewDepth, const pvrtexture::EResizeMode eResizeMode); - PVRTT_API bool pvrttFlip(PvrttTexture& sTexture, const EPVRTAxis eFlipDirection); - PVRTT_API bool pvrttGenerateNormalMap(PvrttTexture& sTexture, const float fScale, const char* sChannelOrder); - PVRTT_API pvrtexture::uint64 pvrttConvertPixelType(PvrttPixelType pixelFormat); - PVRTT_API bool pvrttPreMultipliedAlpha(PvrttTexture& sTexture); -} // extern "C" - - - -#endif // PVRTT_WRAPPER_H diff --git a/sources/tools/Stride.TextureConverter.Wrappers/Stride.TextureConverter.Wrappers.sln b/sources/tools/Stride.TextureConverter.Wrappers/Stride.TextureConverter.Wrappers.sln index 51b788ab9c..b5d26b32f9 100644 --- a/sources/tools/Stride.TextureConverter.Wrappers/Stride.TextureConverter.Wrappers.sln +++ b/sources/tools/Stride.TextureConverter.Wrappers/Stride.TextureConverter.Wrappers.sln @@ -10,8 +10,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DxtWrapper", "DxtWrapper\Dx EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeImage.NET", "FreeImage.Net\FreeImage.NET.csproj", "{6598A7CD-8F27-4D3F-A675-5AE63113A7C3}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PvrttWrapper", "PvrttWrapperC++\PvrttWrapperC++.vcxproj", "{B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2017.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" EndProject Global @@ -89,32 +87,6 @@ Global {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x64.Build.0 = Release|x64 {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.ActiveCfg = Release|x86 {6598A7CD-8F27-4D3F-A675-5AE63113A7C3}.Release|x86.Build.0 = Release|x86 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|Win32.ActiveCfg = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|Win32.Build.0 = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|x64.ActiveCfg = Debug|x64 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|x64.Build.0 = Debug|x64 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|x86.ActiveCfg = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Debug|x86.Build.0 = Debug|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|Any CPU.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|Mixed Platforms.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|Mixed Platforms.Build.0 = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|Win32.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|Win32.Build.0 = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|x64.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|x86.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Profile|x86.Build.0 = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|Any CPU.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|Mixed Platforms.Build.0 = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|Win32.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|Win32.Build.0 = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|x64.ActiveCfg = Release|x64 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|x64.Build.0 = Release|x64 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|x86.ActiveCfg = Release|Win32 - {B8B85886-0F82-4FF3-BCD5-8EAE7EA19EA5}.Release|x86.Build.0 = Release|Win32 {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Any CPU.ActiveCfg = Debug|Win32 {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|Mixed Platforms.Build.0 = Debug|Win32 diff --git a/sources/tools/Stride.TextureConverter/Backend/Requests/TextureQuality.cs b/sources/tools/Stride.TextureConverter/Backend/Requests/TextureQuality.cs index 4e04aadd0d..5ae410f8f5 100644 --- a/sources/tools/Stride.TextureConverter/Backend/Requests/TextureQuality.cs +++ b/sources/tools/Stride.TextureConverter/Backend/Requests/TextureQuality.cs @@ -10,6 +10,6 @@ public enum TextureQuality // Matches PvrttWrapper.ECompressorQuality Fast, Normal, High, - Best, + Best = High, } } diff --git a/sources/tools/Stride.TextureConverter/Backend/TexLibraries/PvrttTexLib.cs b/sources/tools/Stride.TextureConverter/Backend/TexLibraries/PvrttTexLib.cs index 3be8a3def0..fc14fbd580 100644 --- a/sources/tools/Stride.TextureConverter/Backend/TexLibraries/PvrttTexLib.cs +++ b/sources/tools/Stride.TextureConverter/Backend/TexLibraries/PvrttTexLib.cs @@ -73,7 +73,7 @@ public bool CanHandleRequest(PixelFormat format, IRequest request) { switch (request.Type) { - // Loading only file with a .pvr extension + // Loading only file with a .pvr extension case RequestType.Loading: LoadingRequest loader = (LoadingRequest)request; return loader.Mode == LoadingRequest.LoadingMode.FilePath && (Path.GetExtension(loader.FilePath).Equals(".pvr") || Path.GetExtension(loader.FilePath).Equals(".ktx")); @@ -284,8 +284,8 @@ public void Execute(TexImage image, IRequest request) break; default: - Log.Error("FITexLib (FreeImage) can't handle this request: " + request.Type); - throw new TextureToolsException("FITexLib (FreeImage) can't handle this request: " + request.Type); + Log.Error("PvrTexLib (PVR Texture Tool) can't handle this request: " + request.Type); + throw new TextureToolsException("PvrTexLib (PVR Texture Tool) can't handle this request: " + request.Type); } } @@ -350,20 +350,20 @@ private void Rescale(TexImage image, PvrTextureLibraryData libraryData, Rescalin switch(request.Filter) { case Filter.Rescaling.Bilinear: - filter = EResizeMode.eResizeLinear; + filter = EResizeMode.Linear; break; case Filter.Rescaling.Bicubic: - filter = EResizeMode.eResizeCubic; + filter = EResizeMode.Cubic; break; case Filter.Rescaling.Nearest: - filter = EResizeMode.eResizeNearest; + filter = EResizeMode.Nearest; break; default: - filter = EResizeMode.eResizeCubic; + filter = EResizeMode.Cubic; break; } - Utilities.Resize(libraryData.Texture, (uint)width, (uint)height, (uint)image.Depth, filter); + PVRTextureUtilities.Resize(libraryData.Texture, (uint)width, (uint)height, (uint)image.Depth, filter); UpdateImage(image, libraryData); // Updating image data @@ -465,11 +465,11 @@ private void SwitchChannels(TexImage image, PvrTextureLibraryData libraryData, S PVRTexture textureTemp = new PVRTexture(libraryData.Header, libraryData.Texture.GetDataPtr()); - EChannelName e1 = EChannelName.eBlue; - EChannelName e2 = EChannelName.eRed; + EChannelName e1 = EChannelName.Blue; + EChannelName e2 = EChannelName.Red; - Utilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e1, out e2); - Utilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e2, out e1); + PVRTextureUtilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e1, out e2); + PVRTextureUtilities.CopyChannels(libraryData.Texture, textureTemp, 1, out e2, out e1); textureTemp.Dispose(); @@ -494,7 +494,7 @@ private void Compress(TexImage image, PvrTextureLibraryData libraryData, Compres lock (lockObject) { - if (!Utilities.Transcode(libraryData.Texture, format, pixelType, colorSpace, (ECompressorQuality)compress.Quality, false)) + if (!PVRTextureUtilities.Transcode(libraryData.Texture, format, pixelType, colorSpace, (ECompressorQuality)compress.Quality, false)) { Log.Error("Compression failed!"); throw new TextureToolsException("Compression failed!"); @@ -583,7 +583,7 @@ public void Decompress(TexImage image, PvrTextureLibraryData libraryData, Decomp { Log.Verbose("Decompressing texture ..."); - if (!Utilities.Transcode(libraryData.Texture, PixelType.Standard8PixelType, libraryData.Header.GetChannelType(), libraryData.Header.GetColourSpace(), ECompressorQuality.ePVRTCNormal, true)) + if (!PVRTextureUtilities.Transcode(libraryData.Texture, (ulong)EPVRTPixelFormat.RGBG8888, libraryData.Header.GetChannelType(), libraryData.Header.GetColourSpace(), ECompressorQuality.ETCNormal, true)) { Log.Error("Decompression failed!"); throw new TextureToolsException("Decompression failed!"); @@ -609,24 +609,14 @@ public void Decompress(TexImage image, PvrTextureLibraryData libraryData, Decomp private void GenerateMipMaps(TexImage image, PvrTextureLibraryData libraryData, MipMapsGenerationRequest request) { Log.Verbose("Generating Mipmaps ... "); - - EResizeMode filter; - switch (request.Filter) + + var filter = request.Filter switch { - case Filter.MipMapGeneration.Linear: - filter = EResizeMode.eResizeLinear; - break; - case Filter.MipMapGeneration.Cubic: - filter = EResizeMode.eResizeCubic; - break; - case Filter.MipMapGeneration.Nearest: - filter = EResizeMode.eResizeNearest; - break; - default: - filter = EResizeMode.eResizeCubic; - break; - } - + Filter.MipMapGeneration.Linear => EResizeMode.Linear, + Filter.MipMapGeneration.Cubic => EResizeMode.Cubic, + Filter.MipMapGeneration.Nearest => EResizeMode.Nearest, + _ => EResizeMode.Cubic, + }; libraryData.Texture.GenerateMIPMaps(filter); UpdateImage(image, libraryData); @@ -647,14 +637,14 @@ private void Flip(TexImage image, PvrTextureLibraryData libraryData, FlippingReq switch(request.Flip) { case Orientation.Horizontal: - if (!Utilities.Flip(libraryData.Texture, EPVRTAxis.ePVRTAxisX)) + if (!PVRTextureUtilities.Flip(libraryData.Texture, EPVRTAxis.AxisX)) { Log.Error("Flipping failed."); throw new TextureToolsException("Flipping failed."); } break; case Orientation.Vertical: - if (!Utilities.Flip(libraryData.Texture, EPVRTAxis.ePVRTAxisY)) + if (!PVRTextureUtilities.Flip(libraryData.Texture, EPVRTAxis.AxisY)) { Log.Error("Flipping failed."); throw new TextureToolsException("Flipping failed."); @@ -688,7 +678,7 @@ public void GenerateNormalMap(TexImage image, PvrTextureLibraryData libraryData, request.NormalMap.CurrentLibrary = this; request.NormalMap.DisposingLibrary = this; - if (!Utilities.GenerateNormalMap(normalMapLibraryData.Texture, request.Amplitude, "xyzh")) + if (!PVRTextureUtilities.GenerateNormalMap(normalMapLibraryData.Texture, request.Amplitude, "xyzh")) { Log.Error("Failed to generate normal map."); throw new TextureToolsException("Failed to generate normal map."); @@ -710,7 +700,7 @@ public void PreMultiplyAlpha(TexImage image, PvrTextureLibraryData libraryData) { Log.Verbose("Premultiplying alpha ... "); - if (!Utilities.PreMultipliedAlpha(libraryData.Texture)) + if (!PVRTextureUtilities.PreMultipliedAlpha(libraryData.Texture)) { Log.Error("Failed to premultiply the alpha."); throw new TextureToolsException("Failed to premultiply the alpha."); @@ -785,46 +775,44 @@ private bool SupportFormat(Stride.Graphics.PixelFormat format) /// The format. /// /// UnHandled compression format by PowerVC Texture Tool. - private UInt64 RetrieveNativeFormat(Stride.Graphics.PixelFormat format) + private ulong RetrieveNativeFormat(Stride.Graphics.PixelFormat format) { switch (format) { case Stride.Graphics.PixelFormat.ETC1: - return 6; + return (ulong)EPVRTPixelFormat.ETC1; case Stride.Graphics.PixelFormat.ETC2_RGB: case Stride.Graphics.PixelFormat.ETC2_RGB_SRgb: - return 22; + return (ulong)EPVRTPixelFormat.ETC2_RGB; case Stride.Graphics.PixelFormat.ETC2_RGBA: case Stride.Graphics.PixelFormat.ETC2_RGBA_SRgb: - return 23; + return (ulong)EPVRTPixelFormat.ETC2_RGBA; case Stride.Graphics.PixelFormat.ETC2_RGB_A1: - return 24; + return (ulong)EPVRTPixelFormat.ETC2_RGB_A1; case Stride.Graphics.PixelFormat.EAC_R11_Unsigned: - return 25; + return (ulong)EPVRTPixelFormat.EAC_R11; case Stride.Graphics.PixelFormat.EAC_R11_Signed: - return 26; + return (ulong)EPVRTPixelFormat.EAC_R11; case Stride.Graphics.PixelFormat.EAC_RG11_Unsigned: - return 27; + return (ulong)EPVRTPixelFormat.EAC_RG11; case Stride.Graphics.PixelFormat.EAC_RG11_Signed: - return 28; + return (ulong)EPVRTPixelFormat.EAC_RG11; case Stride.Graphics.PixelFormat.R32G32B32A32_Float: case Stride.Graphics.PixelFormat.R32G32B32_Float: case Stride.Graphics.PixelFormat.R32G32B32A32_UInt: case Stride.Graphics.PixelFormat.R32G32B32_UInt: case Stride.Graphics.PixelFormat.R32G32B32A32_SInt: case Stride.Graphics.PixelFormat.R32G32B32_SInt: - return Utilities.ConvertPixelType(PixelType.Standard32PixelType); case Stride.Graphics.PixelFormat.R16G16B16A16_UNorm: case Stride.Graphics.PixelFormat.R16G16B16A16_UInt: case Stride.Graphics.PixelFormat.R16G16B16A16_SNorm: case Stride.Graphics.PixelFormat.R16G16B16A16_SInt: - return Utilities.ConvertPixelType(PixelType.Standard16PixelType); case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb: case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm: case Stride.Graphics.PixelFormat.R8G8B8A8_UInt: case Stride.Graphics.PixelFormat.R8G8B8A8_SNorm: case Stride.Graphics.PixelFormat.R8G8B8A8_SInt: - return Utilities.ConvertPixelType(PixelType.Standard8PixelType); + return (ulong)EPVRTPixelFormat.RGBG8888; default: Log.Error("UnHandled compression format by PowerVC Texture Tool."); throw new TextureToolsException("UnHandled compression format by PowerVC Texture Tool."); @@ -838,38 +826,38 @@ private EPVRTVariableType RetrieveNativePixelType(Stride.Graphics.PixelFormat fo { case Stride.Graphics.PixelFormat.R32G32B32A32_Float: case Stride.Graphics.PixelFormat.R32G32B32_Float: - return EPVRTVariableType.ePVRTVarTypeFloat; + return EPVRTVariableType.Float; //case Stride.Framework.Graphics.PixelFormat.R16G16B16A16_Float: case Stride.Graphics.PixelFormat.R32G32B32A32_UInt: case Stride.Graphics.PixelFormat.R32G32B32_UInt: - return EPVRTVariableType.ePVRTVarTypeUnsignedInteger; + return EPVRTVariableType.UnsignedInteger; case Stride.Graphics.PixelFormat.R32G32B32A32_SInt: case Stride.Graphics.PixelFormat.R32G32B32_SInt: - return EPVRTVariableType.ePVRTVarTypeSignedInteger; + return EPVRTVariableType.SignedInteger; case Stride.Graphics.PixelFormat.R16G16B16A16_UNorm: - return EPVRTVariableType.ePVRTVarTypeUnsignedShortNorm; + return EPVRTVariableType.UnsignedShortNorm; case Stride.Graphics.PixelFormat.R16G16B16A16_UInt: - return EPVRTVariableType.ePVRTVarTypeUnsignedShort; + return EPVRTVariableType.UnsignedShort; case Stride.Graphics.PixelFormat.R16G16B16A16_SNorm: - return EPVRTVariableType.ePVRTVarTypeSignedShortNorm; + return EPVRTVariableType.SignedShortNorm; case Stride.Graphics.PixelFormat.R16G16B16A16_SInt: - return EPVRTVariableType.ePVRTVarTypeSignedShort; + return EPVRTVariableType.SignedShort; case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb: case Stride.Graphics.PixelFormat.R8G8B8A8_UNorm: - return EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm; + return EPVRTVariableType.UnsignedByteNorm; case Stride.Graphics.PixelFormat.R8G8B8A8_UInt: - return EPVRTVariableType.ePVRTVarTypeUnsignedByte; + return EPVRTVariableType.UnsignedByte; case Stride.Graphics.PixelFormat.R8G8B8A8_SNorm: - return EPVRTVariableType.ePVRTVarTypeSignedByteNorm; + return EPVRTVariableType.SignedByteNorm; case Stride.Graphics.PixelFormat.R8G8B8A8_SInt: - return EPVRTVariableType.ePVRTVarTypeSignedByte; + return EPVRTVariableType.SignedByte; default: - return EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm; + return EPVRTVariableType.UnsignedByteNorm; } } @@ -881,11 +869,11 @@ private Stride.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeade { switch (header.GetChannelType()) { - case EPVRTVariableType.ePVRTVarTypeFloat: + case EPVRTVariableType.Float: return Stride.Graphics.PixelFormat.R32G32B32A32_Float; - case EPVRTVariableType.ePVRTVarTypeUnsignedInteger: + case EPVRTVariableType.UnsignedInteger: return Stride.Graphics.PixelFormat.R32G32B32A32_UInt; - case EPVRTVariableType.ePVRTVarTypeSignedInteger: + case EPVRTVariableType.SignedInteger: return Stride.Graphics.PixelFormat.R32G32B32A32_SInt; } } @@ -893,13 +881,13 @@ private Stride.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeade { switch (header.GetChannelType()) { - case EPVRTVariableType.ePVRTVarTypeUnsignedShortNorm: + case EPVRTVariableType.UnsignedShortNorm: return Stride.Graphics.PixelFormat.R16G16B16A16_UNorm; - case EPVRTVariableType.ePVRTVarTypeUnsignedShort: + case EPVRTVariableType.UnsignedShort: return Stride.Graphics.PixelFormat.R16G16B16A16_UInt; - case EPVRTVariableType.ePVRTVarTypeSignedShortNorm: + case EPVRTVariableType.SignedShortNorm: return Stride.Graphics.PixelFormat.R16G16B16A16_SNorm; - case EPVRTVariableType.ePVRTVarTypeSignedShort: + case EPVRTVariableType.SignedShort: return Stride.Graphics.PixelFormat.R16G16B16A16_SInt; } } @@ -907,18 +895,17 @@ private Stride.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeade { switch (header.GetChannelType()) { - case EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm: + case EPVRTVariableType.UnsignedByteNorm: { - if (header.GetColourSpace() == EPVRTColourSpace.ePVRTCSpacelRGB) + if (header.GetColourSpace() == EPVRTColourSpace.Linear) return Stride.Graphics.PixelFormat.R8G8B8A8_UNorm; - else - return Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb; + return Stride.Graphics.PixelFormat.R8G8B8A8_UNorm_SRgb; } - case EPVRTVariableType.ePVRTVarTypeUnsignedByte: + case EPVRTVariableType.UnsignedByte: return Stride.Graphics.PixelFormat.R8G8B8A8_UInt; - case EPVRTVariableType.ePVRTVarTypeSignedByteNorm: + case EPVRTVariableType.SignedByteNorm: return Stride.Graphics.PixelFormat.R8G8B8A8_SNorm; - case EPVRTVariableType.ePVRTVarTypeSignedByte: + case EPVRTVariableType.SignedByte: return Stride.Graphics.PixelFormat.R8G8B8A8_SInt; } } @@ -928,7 +915,7 @@ private Stride.Graphics.PixelFormat RetrieveFormatFromNativeData(PVRTextureHeade private EPVRTColourSpace RetrieveNativeColorSpace(Stride.Graphics.PixelFormat format) { - return format.IsSRgb() ? EPVRTColourSpace.ePVRTCSpaceSRgb : EPVRTColourSpace.ePVRTCSpacelRGB; + return format.IsSRgb() ? EPVRTColourSpace.SRgb : EPVRTColourSpace.Linear; } } } diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EChannelName.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EChannelName.cs new file mode 100644 index 0000000000..f613e0a93f --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EChannelName.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EChannelName +{ + NoChannel, + Red, + Green, + Blue, + Alpha, + Luminance, + Intensity, + Depth, + Stencil, + Unspecified, + NumChannels +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/ECompressorQuality.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/ECompressorQuality.cs new file mode 100644 index 0000000000..bdeefa1e31 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/ECompressorQuality.cs @@ -0,0 +1,35 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum ECompressorQuality +{ + PVRTCFastest = -9, + PVRTCFast, + PVRTCLow, + PVRTCNormal, + PVRTCHigh, + PVRTCVeryHigh, + PVRTCThorough, + PVRTCBest, + NumPVRTCModes, + + ETCFast, + ETCNormal, + ETCSlow, + NumETCModes, + + ASTCVeryFast, + ASTCFast, + ASTCMedium, + ASTCThorough, + ASTCExhaustive, + NumASTCModes, + + BASISULowest, + BASISULow, + BASISUNormal, + BASISUHigh, + BASISUBest, + NumBASISUModes, +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTAxis.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTAxis.cs new file mode 100644 index 0000000000..19a4761146 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTAxis.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EPVRTAxis +{ + AxisX = 0, + AxisY = 1, + AxisZ = 2 +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTColourSpace.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTColourSpace.cs new file mode 100644 index 0000000000..816703b26a --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTColourSpace.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EPVRTColourSpace +{ + Linear, + SRgb, + BT601, + BT709, + BT2020, + NumSpaces +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTPixelFormat.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTPixelFormat.cs new file mode 100644 index 0000000000..d17c920c5b --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTPixelFormat.cs @@ -0,0 +1,163 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EPVRTPixelFormat +{ + PVRTCI_2bpp_RGB, + PVRTCI_2bpp_RGBA, + PVRTCI_4bpp_RGB, + PVRTCI_4bpp_RGBA, + PVRTCII_2bpp, + PVRTCII_4bpp, + ETC1, + DXT1, + DXT2, + DXT3, + DXT4, + DXT5, + + //These formats are identical to some DXT formats. + BC1 = DXT1, + BC2 = DXT3, + BC3 = DXT5, + BC4, + BC5, + /* Currently unsupported: */ + BC6, + BC7, + /* ~~~~~~~~~~~~~~~~~~ */ + + // Packed YUV formats + UYVY_422, + YUY2_422, + + BW1bpp, + SharedExponentR9G9B9E5, + RGBG8888, + GRGB8888, + ETC2_RGB, + ETC2_RGBA, + ETC2_RGB_A1, + EAC_R11, + EAC_RG11, + + + ASTC_4x4, + ASTC_5x4, + ASTC_5x5, + ASTC_6x5, + ASTC_6x6, + ASTC_8x5, + ASTC_8x6, + ASTC_8x8, + ASTC_10x5, + ASTC_10x6, + ASTC_10x8, + ASTC_10x10, + ASTC_12x10, + ASTC_12x12, + + ASTC_3x3x3, + ASTC_4x3x3, + ASTC_4x4x3, + ASTC_4x4x4, + ASTC_5x4x4, + ASTC_5x5x4, + ASTC_5x5x5, + ASTC_6x5x5, + ASTC_6x6x5, + ASTC_6x6x6, + + BASISU_ETC1S, + BASISU_UASTC, + + RGBM, + RGBD, + + PVRTCI_HDR_6bpp, + PVRTCI_HDR_8bpp, + PVRTCII_HDR_6bpp, + PVRTCII_HDR_8bpp, + + // The memory layout for 10 and 12 bit YUV formats that are packed into a WORD (16 bits) is denoted by MSB or LSB: + // MSB denotes that the sample is stored in the most significant bits + // LSB denotes that the sample is stored in the least significant bits + // All YUV formats are little endian + + // Packed YUV formats + VYUA10MSB_444, + VYUA10LSB_444, + VYUA12MSB_444, + VYUA12LSB_444, + UYV10A2_444, // Y410 + UYVA16_444, // Y416 + YUYV16_422, // Y216 + UYVY16_422, + YUYV10MSB_422, // Y210 + YUYV10LSB_422, + UYVY10MSB_422, + UYVY10LSB_422, + YUYV12MSB_422, + YUYV12LSB_422, + UYVY12MSB_422, + UYVY12LSB_422, + + /* + Reserved for future expansion + */ + + // 3 Plane (Planar) YUV formats + YUV_3P_444 = 270, + YUV10MSB_3P_444, + YUV10LSB_3P_444, + YUV12MSB_3P_444, + YUV12LSB_3P_444, + YUV16_3P_444, + YUV_3P_422, + YUV10MSB_3P_422, + YUV10LSB_3P_422, + YUV12MSB_3P_422, + YUV12LSB_3P_422, + YUV16_3P_422, + YUV_3P_420, + YUV10MSB_3P_420, + YUV10LSB_3P_420, + YUV12MSB_3P_420, + YUV12LSB_3P_420, + YUV16_3P_420, + YVU_3P_420, + + /* + Reserved for future expansion + */ + + // 2 Plane (Biplanar/semi-planar) YUV formats + YUV_2P_422 = 480, // P208 + YUV10MSB_2P_422, // P210 + YUV10LSB_2P_422, + YUV12MSB_2P_422, + YUV12LSB_2P_422, + YUV16_2P_422, // P216 + YUV_2P_420, // NV12 + YUV10MSB_2P_420, // P010 + YUV10LSB_2P_420, + YUV12MSB_2P_420, + YUV12LSB_2P_420, + YUV16_2P_420, // P016 + YUV_2P_444, + YVU_2P_444, + YUV10MSB_2P_444, + YUV10LSB_2P_444, + YVU10MSB_2P_444, + YVU10LSB_2P_444, + YVU_2P_422, + YVU10MSB_2P_422, + YVU10LSB_2P_422, + YVU_2P_420, // NV21 + YVU10MSB_2P_420, + YVU10LSB_2P_420, + + //Invalid value + NumCompressedPFs +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTVariableType.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTVariableType.cs new file mode 100644 index 0000000000..02e99a772a --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EPVRTVariableType.cs @@ -0,0 +1,23 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EPVRTVariableType +{ + UnsignedByteNorm, + SignedByteNorm, + UnsignedByte, + SignedByte, + UnsignedShortNorm, + SignedShortNorm, + UnsignedShort, + SignedShort, + UnsignedIntegerNorm, + SignedIntegerNorm, + UnsignedInteger, + SignedInteger, + SignedFloat, Float = SignedFloat, //the name ePVRTVarTypeFloat is now deprecated. + UnsignedFloat, + NumVarTypes, + Invalid = 255 +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EResizeMode.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EResizeMode.cs new file mode 100644 index 0000000000..ca3be38f32 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/EResizeMode.cs @@ -0,0 +1,11 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum EResizeMode +{ + Nearest, + Linear, + Cubic, + NumResizeModes +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/PixelType.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/PixelType.cs new file mode 100644 index 0000000000..25e991f91f --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Enums/PixelType.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +namespace Stride.TextureConverter.PvrttWrapper; + +internal enum PixelType +{ + Standard8PixelType, + Standard16PixelType, + Standard32PixelType, +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTexture.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTexture.cs new file mode 100644 index 0000000000..f602817d13 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTexture.cs @@ -0,0 +1,90 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +using System; +using System.Security; +using System.Runtime.InteropServices; + +namespace Stride.TextureConverter.PvrttWrapper; + +/// +/// Binding class of PVR Texture class PVRTexture. +/// +internal class PVRTexture : IDisposable +{ + internal IntPtr texture; + + #region Constants + const uint TOPMIPLEVEL = 0; + const int ALLMIPLEVELS = -1; + #endregion + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_CreateTexture(IntPtr header, IntPtr data); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_CreateTextureFromData(IntPtr pTexture); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_CreateTextureFromFile(string filePath); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern void PVRTexLib_DestroyTexture(IntPtr texture); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_SaveTextureToFile(IntPtr texture, string filePath); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_GetTextureHeader(IntPtr texture); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_GetTextureDataPtr(IntPtr texture, uint uiMIPLevel, uint uiArrayMember, uint uiFaceNumber); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_GenerateMIPMaps(IntPtr texture, EResizeMode eFilterMode, int uiMIPMapsToDo); + + + public PVRTexture() + { + texture = PVRTexLib_CreateTexture(0,0); + } + + public PVRTexture(IntPtr pTexture) + { + texture = PVRTexLib_CreateTextureFromData(pTexture); + } + + public PVRTexture(string filePath) + { + texture = PVRTexLib_CreateTextureFromFile(filePath); + } + + public PVRTexture(PVRTextureHeader headerIn, IntPtr data) + { + texture = PVRTexLib_CreateTexture(headerIn.header, data); + } + + public bool Save(string filePath) + { + return PVRTexLib_SaveTextureToFile(texture, filePath); + } + + public PVRTextureHeader GetHeader() + { + return new PVRTextureHeader(PVRTexLib_GetTextureHeader(texture)); + } + + public IntPtr GetDataPtr(uint uiMIPLevel = 0, uint uiArrayMember = 0, uint uiFaceNumber = 0) + { + return PVRTexLib_GetTextureDataPtr(texture, uiMIPLevel, uiArrayMember, uiFaceNumber); + } + + public bool GenerateMIPMaps(EResizeMode eFilterMode, int uiMIPMapsToDo = ALLMIPLEVELS) + { + return PVRTexLib_GenerateMIPMaps(texture, eFilterMode, uiMIPMapsToDo); + } + + public void Dispose() + { + PVRTexLib_DestroyTexture(texture); + } +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureHeader.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureHeader.cs new file mode 100644 index 0000000000..4dbd8069f7 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureHeader.cs @@ -0,0 +1,189 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +using System; +using System.Security; +using System.Runtime.InteropServices; + +namespace Stride.TextureConverter.PvrttWrapper; + +/// +/// Binding class of PVR Texture class PVRTextureHeader. +/// +internal class PVRTextureHeader : IDisposable +{ + public IntPtr header { internal set; get; } + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern IntPtr PVRTexLib_CreateTextureHeader(PVRHeaderCreateParams parameters); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureWidth(IntPtr header, uint uiMipLevel); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureHeight(IntPtr header, uint uiMipLevel); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureNumMipMapLevels(IntPtr header); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureDataSize(IntPtr header, int iMipLevel, bool bAllSurfaces, bool bAllFaces); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureDepth(IntPtr header, uint uiMipLevel); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureNumArrayMembers(IntPtr header); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern uint PVRTexLib_GetTextureNumFaces(IntPtr header); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern ulong PVRTexLib_GetTexturePixelFormat(IntPtr header); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern EPVRTVariableType PVRTexLib_GetTextureChannelType(IntPtr header); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern EPVRTColourSpace PVRTexLib_GetTextureColourSpace(IntPtr header); + + public PVRTextureHeader() + { + header = PVRTexLib_CreateTextureHeader(new()); + } + + public PVRTextureHeader(ulong pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=EPVRTColourSpace.Linear, EPVRTVariableType eChannelType=EPVRTVariableType.UnsignedByteNorm, bool bPreMultiplied=false) + { + header = PVRTexLib_CreateTextureHeader(new(){ + pixelFormat = pixelFormat, + height = (uint)height, + width = (uint)width, + depth = (uint)depth, + numMipMaps = (uint)numMipMaps, + numArrayMembers = (uint)numArrayMembers, + numFaces = (uint)numFaces, + colourSpace = eColourSpace, + channelType = eChannelType, + preMultiplied = bPreMultiplied + }); + } + + public PVRTextureHeader(IntPtr headerPtr) + { + header = headerPtr; + } + + public uint GetWidth(uint uiMipLevel = Constant.TOPMIPLEVEL) + { + return PVRTexLib_GetTextureWidth(header, uiMipLevel); + } + + public uint GetHeight(uint uiMipLevel = Constant.TOPMIPLEVEL) + { + return PVRTexLib_GetTextureHeight(header, uiMipLevel); + } + + public uint GetNumMIPLevels() + { + return PVRTexLib_GetTextureNumMipMapLevels(header); + } + + public uint GetDataSize(int iMipLevel = Constant.ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) + { + return PVRTexLib_GetTextureDataSize(header, iMipLevel, bAllSurfaces, bAllFaces); + } + + public uint GetDepth(uint uiMipLevel = Constant.TOPMIPLEVEL) + { + return PVRTexLib_GetTextureDepth(header, uiMipLevel); + } + + public uint GetNumArrayMembers() + { + return PVRTexLib_GetTextureNumArrayMembers(header); + } + + public uint GetNumFaces() + { + return PVRTexLib_GetTextureNumFaces(header); + } + + public EPVRTVariableType GetChannelType() + { + return PVRTexLib_GetTextureChannelType(header); + } + + public EPVRTColourSpace GetColourSpace() + { + return PVRTexLib_GetTextureColourSpace(header); + } + + public Stride.Graphics.PixelFormat GetFormat() + { + EPVRTPixelFormat format = (EPVRTPixelFormat)PVRTexLib_GetTexturePixelFormat(header); + + switch (format) + { + case EPVRTPixelFormat.ETC1: + return Stride.Graphics.PixelFormat.ETC1; + case EPVRTPixelFormat.ETC2_RGB: + return Stride.Graphics.PixelFormat.ETC2_RGB; + case EPVRTPixelFormat.ETC2_RGBA: + return Stride.Graphics.PixelFormat.ETC2_RGBA; + case EPVRTPixelFormat.ETC2_RGB_A1: + return Stride.Graphics.PixelFormat.ETC2_RGB_A1; + case EPVRTPixelFormat.EAC_R11: + return Stride.Graphics.PixelFormat.EAC_R11_Signed; + case EPVRTPixelFormat.EAC_RG11: + return Stride.Graphics.PixelFormat.EAC_RG11_Signed; + } + + if (format == EPVRTPixelFormat.RGBG8888) + return Stride.Graphics.PixelFormat.R8G8B8A8_UNorm; + + return Stride.Graphics.PixelFormat.None; + } + + public int GetAlphaDepth() + { + ulong format = PVRTexLib_GetTexturePixelFormat(header); + if (format <= 0xffffffff) + { + switch (format) + { + case (int)EPVRTPixelFormat.PVRTCI_2bpp_RGB: + case (int)EPVRTPixelFormat.PVRTCI_4bpp_RGB: + case (int)EPVRTPixelFormat.ETC1: + case (int)EPVRTPixelFormat.ETC2_RGB: + case (int)EPVRTPixelFormat.EAC_R11: + case (int)EPVRTPixelFormat.EAC_RG11: + return 0; + + case (int)EPVRTPixelFormat.ETC2_RGB_A1: + return 1; + + case (int)EPVRTPixelFormat.ETC2_RGBA: + case (int)EPVRTPixelFormat.PVRTCI_2bpp_RGBA: + case (int)EPVRTPixelFormat.PVRTCI_4bpp_RGBA: + return 8; + + case (int)EPVRTPixelFormat.PVRTCII_2bpp: + case (int)EPVRTPixelFormat.PVRTCII_4bpp: + return 8; // or 0 + } + return 0; + } + for (int i = 0 ; i < 4 ; i++) + { + if (((format & 255)|0x20) == 'a') + { + return (int)(format>>32) & 255; + } + format >>= 8; + } + return 0; + } + + public void Dispose() + { + } +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureUtilities.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureUtilities.cs new file mode 100644 index 0000000000..8656476fdc --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/PVRTextureUtilities.cs @@ -0,0 +1,93 @@ +// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) +// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. +using System; +using System.Security; +using System.Runtime.InteropServices; + +namespace Stride.TextureConverter.PvrttWrapper; + +public class Constant +{ + public const uint TOPMIPLEVEL = 0; + public const int ALLMIPLEVELS = -1; +} + +/// +/// Provides utilities methods to handle PVR Texture type. +/// +internal class PVRTextureUtilities +{ + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_TranscodeTexture(IntPtr texture, ref PVRTTranscoderOptions options); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_CopyTextureChannels(IntPtr sTexture, IntPtr sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_ResizeTexture(IntPtr sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_FlipTexture(IntPtr sTexture, EPVRTAxis eFlipDirection); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_GenerateNormalMap(IntPtr sTexture, float fScale, string sChannelOrder); + + [DllImport("PVRTexLib", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] + private static extern bool PVRTexLib_PreMultiplyAlpha(IntPtr sTexture); + + /// + /// Copies a specified channel from one texture to a specified channel in another texture. + /// + /// The destination texture. + /// The source texture. + /// The UI num channel copies. + /// The destination channel. + /// The source channel. + /// + public static bool CopyChannels(PVRTexture sTexture, PVRTexture sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource) + { + return PVRTexLib_CopyTextureChannels(sTexture.texture, sTextureSource.texture, uiNumChannelCopies, out eChannels, out eChannelsSource); + } + + public static unsafe bool Transcode(PVRTexture sTexture, ulong ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ETCNormal, bool bDoDither = false, float maxRange = 1f) + { + PVRTTranscoderOptions options = new((uint)sizeof(PVRTTranscoderOptions), ptFormat, eColourspace, eQuality, bDoDither, maxRange ); + options.channelType[0] = options.channelType[1] = options.channelType[2] = options.channelType[3] = eChannelType; + return PVRTexLib_TranscodeTexture(sTexture.texture, ref options); + } + + /// + /// Resizes the specified texture. + /// + /// The texture. + /// The new width. + /// The new height. + /// The new depth. + /// The resize mode (Filter). + /// + public static bool Resize(PVRTexture sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode) + { + return PVRTexLib_ResizeTexture(sTexture.texture, u32NewWidth, u32NewHeight, u32NewDepth, eResizeMode); + } + + /// + /// Flips the specified texture. + /// + /// The texture. + /// The flip direction. + /// + public static bool Flip(PVRTexture sTexture, EPVRTAxis eFlipDirection) + { + return PVRTexLib_FlipTexture(sTexture.texture, eFlipDirection); + } + + public static bool GenerateNormalMap(PVRTexture sTexture, float fScale, string sChannelOrder) + { + return PVRTexLib_GenerateNormalMap(sTexture.texture, fScale, sChannelOrder); + } + + public static bool PreMultipliedAlpha(PVRTexture sTexture) + { + return PVRTexLib_PreMultiplyAlpha(sTexture.texture); + } +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRHeaderCreateParams.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRHeaderCreateParams.cs new file mode 100644 index 0000000000..e4f0ae25d5 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRHeaderCreateParams.cs @@ -0,0 +1,35 @@ +namespace Stride.TextureConverter.PvrttWrapper; + +internal struct PVRHeaderCreateParams +{ + ///Pixel format + internal ulong pixelFormat; + + ///Texture width + internal uint width; + + ///Texture height + internal uint height; + + ///Texture depth + internal uint depth; + + ///Number of MIP maps + internal uint numMipMaps; + + ///Number of array members + internal uint numArrayMembers; + + ///Number of faces + internal uint numFaces; + + ///Colour space + internal EPVRTColourSpace colourSpace; + + ///Channel type + internal EPVRTVariableType channelType; + + ///Has the RGB been pre-multiplied by the alpha? + internal bool preMultiplied; + +} diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRTTranscoderOptions.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRTTranscoderOptions.cs new file mode 100644 index 0000000000..9981ea3dc0 --- /dev/null +++ b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrTexLib/Structs/PVRTTranscoderOptions.cs @@ -0,0 +1,36 @@ +using System.Runtime.InteropServices; + +namespace Stride.TextureConverter.PvrttWrapper; + +[StructLayout(LayoutKind.Sequential, Pack = 4)] +internal struct PVRTTranscoderOptions +{ + ///For versioning - sizeof(PVRTexLib_TranscoderOptions)` + internal uint sizeofStruct; + internal ulong pixelFormat; + internal EPVRTVariableTypeArray channelType; + internal EPVRTColourSpace colourspace; + internal ECompressorQuality quality; + internal bool doDither; + ///Max range value for RGB[M|D] encoding + internal float maxRange; + /// Max number of threads to use for transcoding, if set to 0 PVRTexLib will use all available cores. + internal uint maxThreads; + + public PVRTTranscoderOptions(uint sizeofStruct, ulong pixelFormat, + EPVRTColourSpace colourSpace, ECompressorQuality quality, + bool doDither, float maxRange) + { + this.sizeofStruct = sizeofStruct; + this.pixelFormat = pixelFormat; + colourspace = colourSpace; + this.quality = quality; + this.doDither = doDither; + this.maxRange = maxRange; + } +} +[System.Runtime.CompilerServices.InlineArray(4)] +public struct EPVRTVariableTypeArray +{ + private EPVRTVariableType _value; +} \ No newline at end of file diff --git a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrttNetWrapper.cs b/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrttNetWrapper.cs deleted file mode 100644 index a590b8d5c3..0000000000 --- a/sources/tools/Stride.TextureConverter/Backend/Wrappers/PvrttNetWrapper.cs +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp) -// Distributed under the MIT license. See the LICENSE.md file in the project root for more information. -using System; -using System.Security; -using System.Runtime.InteropServices; - -namespace Stride.TextureConverter.PvrttWrapper -{ - - #region Enum - internal enum PixelType - { - Standard8PixelType, - Standard16PixelType, - Standard32PixelType, - }; - - internal enum EPVRTColourSpace - { - ePVRTCSpacelRGB, - ePVRTCSpaceSRgb, - ePVRTCSpaceNumSpaces - }; - - internal enum EPVRTVariableType - { - ePVRTVarTypeUnsignedByteNorm, - ePVRTVarTypeSignedByteNorm, - ePVRTVarTypeUnsignedByte, - ePVRTVarTypeSignedByte, - ePVRTVarTypeUnsignedShortNorm, - ePVRTVarTypeSignedShortNorm, - ePVRTVarTypeUnsignedShort, - ePVRTVarTypeSignedShort, - ePVRTVarTypeUnsignedIntegerNorm, - ePVRTVarTypeSignedIntegerNorm, - ePVRTVarTypeUnsignedInteger, - ePVRTVarTypeSignedInteger, - ePVRTVarTypeSignedFloat, ePVRTVarTypeFloat = ePVRTVarTypeSignedFloat, //the name ePVRTVarTypeFloat is now deprecated. - ePVRTVarTypeUnsignedFloat, - ePVRTVarTypeNumVarTypes - }; - - internal enum ECompressorQuality - { - ePVRTCFast=0, - ePVRTCNormal, - ePVRTCHigh, - ePVRTCBest, - eNumPVRTCModes, - - eETCFast=0, - eETCFastPerceptual, - eETCSlow, - eETCSlowPerceptual, - eNumETCModes - }; - - internal enum EResizeMode - { - eResizeNearest, - eResizeLinear, - eResizeCubic, - eNumResizeModes - }; - - internal enum EChannelName - { - eNoChannel, - eRed, - eGreen, - eBlue, - eAlpha, - eLuminance, - eIntensity, - eUnspecified, - eNumChannels - }; - - internal enum EPVRTAxis - { - ePVRTAxisX = 0, - ePVRTAxisY = 1, - ePVRTAxisZ = 2 - }; - - internal enum EPVRTPixelFormat - { - ePVRTPF_PVRTCI_2bpp_RGB, - ePVRTPF_PVRTCI_2bpp_RGBA, - ePVRTPF_PVRTCI_4bpp_RGB, - ePVRTPF_PVRTCI_4bpp_RGBA, - ePVRTPF_PVRTCII_2bpp, - ePVRTPF_PVRTCII_4bpp, - ePVRTPF_ETC1, - ePVRTPF_DXT1, - ePVRTPF_DXT2, - ePVRTPF_DXT3, - ePVRTPF_DXT4, - ePVRTPF_DXT5, - - //These formats are identical to some DXT formats. - ePVRTPF_BC1 = ePVRTPF_DXT1, - ePVRTPF_BC2 = ePVRTPF_DXT3, - ePVRTPF_BC3 = ePVRTPF_DXT5, - - //These are currently unsupported: - ePVRTPF_BC4, - ePVRTPF_BC5, - ePVRTPF_BC6, - ePVRTPF_BC7, - - //These are supported - ePVRTPF_UYVY, - ePVRTPF_YUY2, - ePVRTPF_BW1bpp, - ePVRTPF_SharedExponentR9G9B9E5, - ePVRTPF_RGBG8888, - ePVRTPF_GRGB8888, - ePVRTPF_ETC2_RGB, - ePVRTPF_ETC2_RGBA, - ePVRTPF_ETC2_RGB_A1, - ePVRTPF_EAC_R11, - ePVRTPF_EAC_RG11, - - //Invalid value - ePVRTPF_NumCompressedPFs - }; - - #endregion - - #region Constants - public class Constant - { - public const uint TOPMIPLEVEL = 0; - public const int ALLMIPLEVELS = -1; - public const uint PVRTEX3_IDENT = 0x03525650; // 'P''V''R'3 - public const uint PVRTEX3_PREMULTIPLIED = (1 << 1); // Texture has been premultiplied by alpha value. - } - #endregion - - - - - #region public class Utilities - - /// - /// Provides utilities methods to handle PVR Texture type. - /// - internal class Utilities - { - #region Bindings - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttTranscodeWithNoConversion(IntPtr texture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality, bool bDoDither); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttTranscode(IntPtr texture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality, bool bDoDither); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttCopyChannels(IntPtr sTexture, IntPtr sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttResize(IntPtr sTexture, out uint u32NewWidth, out uint u32NewHeight, out uint u32NewDepth, EResizeMode eResizeMode); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttFlip(IntPtr sTexture, EPVRTAxis eFlipDirection); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttGenerateNormalMap(IntPtr sTexture, float fScale, string sChannelOrder); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt64 pvrttConvertPixelType(PixelType pixelFormat); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static int pvrttDecompressPVRTC(IntPtr pCompressedData, int Do2bitMode, int XDim, int YDim, IntPtr pResultImage); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static int pvrttDecompressETC(IntPtr pSrcData, uint x, uint y, IntPtr pDestData, int nMode); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttPreMultipliedAlpha(IntPtr sTexture); - - #endregion - - /// - /// Copies a specified channel from one texture to a specified channel in another texture. - /// - /// The destination texture. - /// The source texture. - /// The UI num channel copies. - /// The destination channel. - /// The source channel. - /// - public static bool CopyChannels(PVRTexture sTexture, PVRTexture sTextureSource, uint uiNumChannelCopies, out EChannelName eChannels, out EChannelName eChannelsSource) - { - return pvrttCopyChannels(sTexture.texture, sTextureSource.texture, uiNumChannelCopies, out eChannels, out eChannelsSource); - } - - public static bool Transcode(PVRTexture sTexture, PixelType ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false) - { - return pvrttTranscodeWithNoConversion(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); - } - - public static bool Transcode(PVRTexture sTexture, UInt64 ptFormat, EPVRTVariableType eChannelType, EPVRTColourSpace eColourspace, ECompressorQuality eQuality = ECompressorQuality.ePVRTCNormal, bool bDoDither = false) - { - return pvrttTranscode(sTexture.texture, ptFormat, eChannelType, eColourspace, eQuality, bDoDither); - } - - /// - /// Resizes the specified texture. - /// - /// The texture. - /// The new width. - /// The new height. - /// The new depth. - /// The resize mode (Filter). - /// - public static bool Resize(PVRTexture sTexture, uint u32NewWidth, uint u32NewHeight, uint u32NewDepth, EResizeMode eResizeMode) - { - return pvrttResize(sTexture.texture, out u32NewWidth, out u32NewHeight, out u32NewDepth, eResizeMode); - } - - - /// - /// Flips the specified texture. - /// - /// The texture. - /// The flip direction. - /// - public static bool Flip(PVRTexture sTexture, EPVRTAxis eFlipDirection) - { - return pvrttFlip(sTexture.texture, eFlipDirection); - } - - public static bool GenerateNormalMap(PVRTexture sTexture, float fScale, string sChannelOrder) - { - return pvrttGenerateNormalMap(sTexture.texture, fScale, sChannelOrder); - } - - public static UInt64 ConvertPixelType(PixelType pixelFormat) - { - return pvrttConvertPixelType(pixelFormat); - } - - public static int DecompressPVRTC(IntPtr pCompressedData, int Do2bitMode, int XDim, int YDim, IntPtr pResultImage) - { - return pvrttDecompressPVRTC(pCompressedData, Do2bitMode, XDim, YDim, pResultImage); - } - - public static int DecompressETC(IntPtr pSrcData, uint x, uint y, IntPtr pDestData, int nMode) - { - return pvrttDecompressETC(pSrcData, x, y, pDestData, nMode); - } - - public static bool PreMultipliedAlpha(PVRTexture sTexture) - { - return pvrttPreMultipliedAlpha(sTexture.texture); - } - } - #endregion - - #region public class CPVRTexture - /// - /// Binding class of PVR Texture class PVRTexture. - /// - internal class PVRTexture : IDisposable - { - internal IntPtr texture; - - #region Constants - const uint TOPMIPLEVEL = 0; - const int ALLMIPLEVELS = -1; - #endregion - - #region Bindings - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTexture(); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureFromHeader(IntPtr header, IntPtr data); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureFromMemory(IntPtr pTexture); - - [DllImport("PvrttWrapper.dll", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureFromFile(String filePath); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void pvrttDestroyTexture(IntPtr texture); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttSaveFile(IntPtr texture, String filePath); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttGetHeader(IntPtr texture); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttGetDataPtr(IntPtr texture, uint uiMIPLevel, uint uiArrayMember, uint uiFaceNumber); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttGenerateMIPMaps(IntPtr texture, EResizeMode eFilterMode, int uiMIPMapsToDo); - - #endregion - - public PVRTexture() - { - texture = pvrttCreateTexture(); - } - - public PVRTexture(IntPtr pTexture) - { - texture = pvrttCreateTextureFromMemory(pTexture); - } - - public PVRTexture(string filePath) - { - texture = pvrttCreateTextureFromFile(filePath); - } - - public PVRTexture(PVRTextureHeader headerIn, IntPtr data) - { - texture = pvrttCreateTextureFromHeader(headerIn.header, data); - } - - public bool Save(string filePath) - { - return pvrttSaveFile(texture, filePath); - } - - public PVRTextureHeader GetHeader() - { - return new PVRTextureHeader(pvrttGetHeader(texture)); - } - - public IntPtr GetDataPtr(uint uiMIPLevel = 0, uint uiArrayMember = 0, uint uiFaceNumber = 0) { - return pvrttGetDataPtr(texture, uiMIPLevel, uiArrayMember, uiFaceNumber); - } - - public bool GenerateMIPMaps(EResizeMode eFilterMode, int uiMIPMapsToDo = ALLMIPLEVELS) - { - return pvrttGenerateMIPMaps(texture, eFilterMode, uiMIPMapsToDo); - } - - - public void Dispose() - { - pvrttDestroyTexture(texture); - } - } - #endregion - - #region public class PvrttTextureHeader - /// - /// Binding class of PVR Texture class PVRTextureHeader. - /// - internal class PVRTextureHeader : IDisposable - { - public IntPtr header { internal set; get; } - - #region Bindings - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureHeaderEmpty(); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureHeader(PixelType pixelFormat, int height, int width, int depth, int numMipMaps, int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCreateTextureHeaderFromCompressedTexture(UInt64 pixelFormat, int height, int width, int depth, int numMipMaps, int numArrayMembers, int numFaces, EPVRTColourSpace eColourSpace, EPVRTVariableType eChannelType, bool bPreMultiplied); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static IntPtr pvrttCopyTextureHeader(IntPtr headerIn); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt32 pvrttGetWidth(IntPtr header, uint uiMipLevel); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt32 pvrttGetHeight(IntPtr header, uint uiMipLevel); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt32 pvrttGetNumMIPLevels(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void pvrttSetNumMIPLevels(IntPtr header, int newMipsLevels); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void pvrttSetWidth(IntPtr header, uint newWidth); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void pvrttSetHeight(IntPtr header, uint newHeight); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static void pvrttSetPixelFormat(IntPtr header, PixelType pixelType); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetDataSize(IntPtr header, int iMipLevel, bool bAllSurfaces, bool bAllFaces); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetTextureSize(IntPtr header, int iMipLevel, bool bAllSurfaces, bool bAllFaces); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetDepth(IntPtr header, uint uiMipLevel); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetBPP(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetNumArrayMembers(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static uint pvrttGetNumFaces(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static bool pvrttIsFileCompressed(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt64 pvrttGetPixelType(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static UInt32 pvrttGetMetaDataSize(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static EPVRTVariableType pvrttGetChannelType(IntPtr header); - - [DllImport("PvrttWrapper", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] - private extern static EPVRTColourSpace pvrttGetColourSpace(IntPtr header); - - #endregion - - - public PVRTextureHeader() - { - header = pvrttCreateTextureHeaderEmpty(); - } - - public PVRTextureHeader(PixelType pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=EPVRTColourSpace.ePVRTCSpacelRGB, EPVRTVariableType eChannelType=EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false) - { - header = pvrttCreateTextureHeader(pixelFormat, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied); - } - - public PVRTextureHeader(UInt64 pixelFormat, int height=1, int width=1, int depth=1, int numMipMaps=1, int numArrayMembers=1, int numFaces=1, EPVRTColourSpace eColourSpace=EPVRTColourSpace.ePVRTCSpacelRGB, EPVRTVariableType eChannelType=EPVRTVariableType.ePVRTVarTypeUnsignedByteNorm, bool bPreMultiplied=false) - { - header = pvrttCreateTextureHeaderFromCompressedTexture(pixelFormat, height, width, depth, numMipMaps, numArrayMembers, numFaces, eColourSpace, eChannelType, bPreMultiplied); - } - - public PVRTextureHeader(IntPtr headerPtr) - { - header = headerPtr; - } - - public PVRTextureHeader Copy() - { - return new PVRTextureHeader(pvrttCopyTextureHeader(header)); - } - - public uint GetWidth(uint uiMipLevel = Constant.TOPMIPLEVEL) - { - return pvrttGetWidth(header, uiMipLevel); - } - - public uint GetHeight(uint uiMipLevel = Constant.TOPMIPLEVEL) - { - return pvrttGetHeight(header, uiMipLevel); - } - - public uint GetNumMIPLevels() - { - return pvrttGetNumMIPLevels(header); - } - - public void SetNumMIPLevels(int newMipsLevels) - { - pvrttSetNumMIPLevels(header, newMipsLevels); - } - - public void SetPixelFormat(PixelType pixelType) - { - pvrttSetPixelFormat(header, pixelType); - } - - public void SetWidth(uint newWidth) - { - pvrttSetWidth(header, newWidth); - } - - public void SetHeight(uint newHeight) - { - pvrttSetHeight(header, newHeight); - } - - public uint GetDataSize(int iMipLevel = Constant.ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) - { - return pvrttGetDataSize(header, iMipLevel, bAllSurfaces, bAllFaces); - } - - public uint GetTextureSize(int iMipLevel = Constant.ALLMIPLEVELS, bool bAllSurfaces = true, bool bAllFaces = true) - { - return pvrttGetTextureSize(header, iMipLevel, bAllSurfaces, bAllFaces); - } - - public uint GetDepth(uint uiMipLevel = Constant.TOPMIPLEVEL) - { - return pvrttGetDepth(header, uiMipLevel); - } - - public uint GetBPP() - { - return pvrttGetBPP(header); - } - - public uint GetNumArrayMembers() - { - return pvrttGetNumArrayMembers(header); - } - - - public uint GetNumFaces() - { - return pvrttGetNumFaces(header); - } - - public uint GetMetaDataSize() - { - return pvrttGetMetaDataSize(header); - } - - public EPVRTVariableType GetChannelType() - { - return pvrttGetChannelType(header); - } - - public UInt64 GetPixelType() - { - return pvrttGetPixelType(header); - } - - public EPVRTColourSpace GetColourSpace() - { - return pvrttGetColourSpace(header); - } - - public Stride.Graphics.PixelFormat GetFormat() - { - UInt64 format = pvrttGetPixelType(header); - - switch (format) - { - case 6: - return Stride.Graphics.PixelFormat.ETC1; - case 22: - return Stride.Graphics.PixelFormat.ETC2_RGB; - case 23: - return Stride.Graphics.PixelFormat.ETC2_RGBA; - case 24: - return Stride.Graphics.PixelFormat.ETC2_RGB_A1; - case 25: - return Stride.Graphics.PixelFormat.EAC_R11_Unsigned; - case 26: - return Stride.Graphics.PixelFormat.EAC_R11_Signed; - case 27: - return Stride.Graphics.PixelFormat.EAC_RG11_Unsigned; - case 28: - return Stride.Graphics.PixelFormat.EAC_RG11_Signed; - /*default: - throw new TexLibraryException("Unknown format by PowerVC Texture Tool.");*/ - } - - if (format == Utilities.ConvertPixelType(PixelType.Standard8PixelType)) - return Stride.Graphics.PixelFormat.R8G8B8A8_UNorm; - else if (format == Utilities.ConvertPixelType(PixelType.Standard16PixelType)) - return Stride.Graphics.PixelFormat.R16G16B16A16_UNorm; - else if (format == Utilities.ConvertPixelType(PixelType.Standard32PixelType)) - return Stride.Graphics.PixelFormat.R32G32B32A32_Float; - else - throw new TextureToolsException("Unknown format by PowerVC Texture Tool."); - } - - public int GetAlphaDepth() - { - UInt64 format = pvrttGetPixelType(header); - if (format <= 0xffffffff) - { - switch (format) - { - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCI_2bpp_RGB: - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCI_4bpp_RGB: - case (int)EPVRTPixelFormat.ePVRTPF_ETC1: - case (int)EPVRTPixelFormat.ePVRTPF_ETC2_RGB: - case (int)EPVRTPixelFormat.ePVRTPF_EAC_R11: - case (int)EPVRTPixelFormat.ePVRTPF_EAC_RG11: - return 0; - - case (int)EPVRTPixelFormat.ePVRTPF_ETC2_RGB_A1: - return 1; - - case (int)EPVRTPixelFormat.ePVRTPF_ETC2_RGBA: - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCI_2bpp_RGBA: - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCI_4bpp_RGBA: - return 8; - - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCII_2bpp: - case (int)EPVRTPixelFormat.ePVRTPF_PVRTCII_4bpp: - return 8; // or 0 - } - return 0; - } - for (int i = 0 ; i < 4 ; i++) - { - if (((format & 255)|0x20) == 'a') - { - return ((int)(format>>32) & 255); - } - format >>= 8; - } - return 0; - } - - public void Dispose() - { - } - } - #endregion - -} diff --git a/sources/tools/Stride.TextureConverter/Frontend/TextureTool.cs b/sources/tools/Stride.TextureConverter/Frontend/TextureTool.cs index 0001264cdc..f8c6c17354 100644 --- a/sources/tools/Stride.TextureConverter/Frontend/TextureTool.cs +++ b/sources/tools/Stride.TextureConverter/Frontend/TextureTool.cs @@ -20,7 +20,7 @@ namespace Stride.TextureConverter /// Provides method to load images or textures, to modify them and to convert them with different texture compression format. /// Input supported format : gif, png, jpe, pds (Every FreeImage supported format...), dds, pvr, ktx. /// Output format : gif, png, jpe, pds (Every FreeImage supported format...), dds, pvr, ktx. - /// Compression format : DXT1-5, ATC, PVRTC1-2, ETC1-2, uncompressed formats (BGRA8888, RGBA8888) + /// Compression format : DXT1-5, ETC1-2, uncompressed formats (BGRA8888, RGBA8888) /// Image processing : resize, flip, gamma correction /// Texture utilities : Mipmap generation, normal map generation /// @@ -39,7 +39,6 @@ static TextureTool() var type = typeof(TextureTool); NativeLibraryHelper.PreloadLibrary("DxtWrapper", type); NativeLibraryHelper.PreloadLibrary("PVRTexLib", type); - NativeLibraryHelper.PreloadLibrary("PvrttWrapper", type); NativeLibraryHelper.PreloadLibrary("freeimage", type); //TODO: needs to explain why FreeImageNET is loaded as a dll instead of directly referencing the C# project (this does not affect the compilation process on Linux). if (OperatingSystem.IsWindows()) @@ -59,7 +58,7 @@ public TextureTool() new DxtTexLib(), // used to compress/decompress texture to DXT1-5 and load/save *.dds compressed texture files. new FITexLib(), // used to open/save common bitmap image formats. new StrideTexLibrary(), // used to save/load stride texture format. - new PvrttTexLib(), // used to compress/decompress texture to PVRTC1-2 and ETC1-2 and load/save *.pvr compressed texture file. + new PvrttTexLib(), // used to compress/decompress texture to ETC1-2 and load/save *.pvr, *.ktx compressed texture file. new ColorKeyTexLibrary(), // used to apply ColorKey on R8G8B8A8/B8G8R8A8_Unorm new AtlasTexLibrary(), // used to create and manipulate texture atlas new ArrayTexLib(), // used to create and manipulate texture array and texture cube diff --git a/sources/tools/Stride.TextureConverter/Stride.TextureConverter.csproj b/sources/tools/Stride.TextureConverter/Stride.TextureConverter.csproj index f016c74287..f04c66df33 100644 --- a/sources/tools/Stride.TextureConverter/Stride.TextureConverter.csproj +++ b/sources/tools/Stride.TextureConverter/Stride.TextureConverter.csproj @@ -19,7 +19,7 @@ runtimes\%(RecursiveDir)native\%(Filename)%(Extension) - + runtimes\%(RecursiveDir)native\%(Filename)%(Extension)