/*---------------------------------------------------------------------------* Copyright 2010-2011 Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ // ------------------------------------------------------- // texUtils.h // // Declares functions for texUtils library. // // This library has dependencies on gx2 and pulls in GX2 // source files // ------------------------------------------------------- #ifndef _TEXUTILS_H #define _TEXUTILS_H #if defined(WIN32) || defined(WIN64) #include #undef GPU_V1 #undef GPU_V2 #undef GPU_Cafe #else #include #endif #include "texUtils/Texture.h" #include "texUtils/Version.h" #include "texUtils/TC_PluginAPI.h" #define TC2API __cdecl /// @addtogroup GX2TexUtilGroup /// @{ /// \brief Supported mip filters. typedef enum { MF_NONE, ///< No mip filter MF_BOX ///< Box Filter } TC2MipFilter; /// \brief Supported GPU's typedef enum { GPU_V1, ///< 0 Ver1 GPU_V2, ///< 1 Ver2 GPU_Cafe, ///< 2 Cafe (GPU7) } TC2GPUVersion; /// \brief Conversion options used with TC2ConvertSurfaceFormat API call typedef struct { BOOL useWeighting; ///< Use channel weightings. With swizzled formats the weighting applies to the data within the specified channel not the channel itself. double weightingRed; ///< The weighting of the Red or X Channel. double weightingGreen; ///< The weighting of the Green or Y Channel. double weightingBlue; ///< The weighting of the Blue or Z Channel. BOOL useAdaptiveWeighting; ///< Adapt weighting on a per-block basis. BOOL bc1usealpha; ///< Encode single-bit alpha data. Only valid when converting to BC1 format. u8 bc1alphathreshold; ///< Texels with an alpha value less than the threshold are treated as transparent } TC2ConvertOptions; /// \brief Used to initialize the texUtils library typedef struct { u32 gbTilingConfig; // Used to change default register value. Set to zero to use default TC2GPUVersion gpu; // Target gpu BOOL bugFix2197; // Compatability-gate for fixing bug 2197. } TC2Config; /// \brief Initializes the instance of texUtils library /// /// \param pConfig Configuration used to initialize the library /// /// \donotcall \gx2_typical \userheap \enddonotcall /// BOOL TC2API TC2Initialize(TC2Config* pConfig); /// \brief Destroys the instance of texUtils library /// /// \donotcall \gx2_typical \userheap \enddonotcall /// BOOL TC2API TC2Destroy(void); /// \brief Converts a surface format from a string to a GX2SurfaceFormat. /// /// \param pFormatStr String to be converted /// \param pgx2Format Pointer to GX2SurfaceFormat to hold converted format /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2GX2SurfaceFormatFromStr(char* pFormatStr, GX2SurfaceFormat *pgx2Format); /// \brief Generate mips based on GX2Surface passed in. /// /// \param pInSurface Source surface from which mips will be based. The surface passed in should not already contain mips. /// \param iMinSize Minimum mip size. /// \param filter Mipmap filter mode. /// \param pOutSurface Resulting surface containing mips /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2GenerateMipLevels(GX2Surface* pInSurface, s32 iMinSize, TC2MipFilter filter, GX2Surface* pOutSurface); /// \brief Converts a surface to a given format. /// /// \param pInSurface Source surface for the conversion /// \param dstFormat Desired format for the conversion /// \param pOutSurface resulting converted surface /// \param pOptions Conversion options /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2ConvertSurfaceFormat(GX2Surface *pInSurface, GX2SurfaceFormat dstFormat, GX2Surface *pOutSurface, TC2ConvertOptions* pOptions); /// \brief Tile/detiles a surface and stores in a GX2Texture object. Use TC2DestroyGX2Texture to destroy this GX2Texture. /// /// \param pInSurface Source surface /// \param dstTileMode Destination tile mode /// \param initialSwizzle Initial swizzle value /// \param pOutSurface Resulting surface after the conversion /// /// \donotcall \notthreadsafe \hostonly \enddonotcall /// BOOL TC2API TC2ConvertTiling(GX2Surface *pInSurface, GX2TileMode dstTileMode, u32 initialSwizzle, GX2Surface* pOutSurface); /// \brief Destroys GX2Surface /// /// \param pGX2Surface object to destroy /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2DestroyGX2Surface(GX2Surface* pGX2Surface); /// \brief Creates a GX2Texture from the given surface /// /// \param pInSurface Source surface /// \param pOutTexture Resultant texture /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2GenerateTexture(GX2Surface* pInSurface, GX2Texture* pOutTexture); /// \brief Destroys GX2Texture that was created by TC2GenerateTexture /// /// \param pGX2Texture object to destroy /// /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2DestroyGX2Texture(GX2Texture* pGX2Texture); /// \brief Convert string to tile GX2TileMode /// /// \param str String to convert /// \param pTileMode GX2TileMode object that will contain the tile mode after conversion /// /// \donotcall \hostonly \enddonotcall /// BOOL TC2API TC2ConvertStringToTileMode(char *str, GX2TileMode *pTileMode); /// \brief Fill in surface size related information for a linear source surface /// /// \param pSurface Surface object to fill /// /// \donotcall \threadsafe \hostonly \enddonotcall /// BOOL TC2API TC2GetSourceSurfaceSize(GX2Surface *pSurface); /// \brief Combines a list of surfaces into a texture array /// /// \param pSurfaces List of surfaces used to make the texture array /// \param surfaceCount Number of surfaces in pSurfaces /// \param pTexArraySurface The resulting texture array surface /// /// \donotcall \threadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2CombineAsTextureArray(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pTexArraySurface); /// \brief Combines a list of surfaces into mips /// /// \param pSurfaces List of surfaces used to make the mips /// \param surfaceCount Number of surfaces in pSurfaces /// \param pMipSurface The resulting mip mapped surface /// /// \donotcall \threadsafe \hostonly \userheap \enddonotcall /// BOOL TC2API TC2CombineAsMips(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pMipSurface); /// @} #endif //#ifdef _TEXUTILS_H