1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) Nintendo. All rights reserved. 4 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 11 *---------------------------------------------------------------------------*/ 12 // ------------------------------------------------------- 13 // texUtils.h 14 // 15 // Declares functions for texUtils library. 16 // 17 // This library has dependencies on gx2 and pulls in GX2 18 // source files 19 // ------------------------------------------------------- 20 #ifndef _TEXUTILS_H 21 #define _TEXUTILS_H 22 23 #if defined(WIN32) || defined(WIN64) 24 #include <windows/gx2.h> 25 #undef GPU_V1 26 #undef GPU_V2 27 #undef GPU_Cafe 28 #else 29 #include <cafe/gx2.h> 30 #endif 31 32 #include "texUtils/Texture.h" 33 #include "texUtils/Version.h" 34 #include "texUtils/TC_PluginAPI.h" 35 36 #define TC2API __cdecl 37 38 /// @addtogroup GX2TexUtilGroup 39 /// @{ 40 41 /// \brief Supported mip filters. 42 typedef enum 43 { 44 MF_NONE, ///< No mip filter 45 MF_BOX ///< Box Filter 46 } TC2MipFilter; 47 48 /// \brief Supported GPU's 49 typedef enum 50 { 51 GPU_V1, ///< 0 Ver1 52 GPU_V2, ///< 1 Ver2 53 GPU_Cafe, ///< 2 Cafe (GPU7) 54 } TC2GPUVersion; 55 56 /// \brief Conversion options used with TC2ConvertSurfaceFormat API call 57 typedef struct 58 { 59 BOOL useWeighting; ///< Use channel weightings. With swizzled formats the weighting applies to the data within the specified channel not the channel itself. 60 double weightingRed; ///< The weighting of the Red or X Channel. 61 double weightingGreen; ///< The weighting of the Green or Y Channel. 62 double weightingBlue; ///< The weighting of the Blue or Z Channel. 63 BOOL useAdaptiveWeighting; ///< Adapt weighting on a per-block basis. 64 BOOL bc1usealpha; ///< Encode single-bit alpha data. Only valid when converting to BC1 format. 65 u8 bc1alphathreshold; ///< Texels with an alpha value less than the threshold are treated as transparent 66 } TC2ConvertOptions; 67 68 /// \brief Used to initialize the texUtils library 69 typedef struct 70 { 71 u32 gbTilingConfig; // Used to change default register value. Set to zero to use default 72 TC2GPUVersion gpu; // Target gpu 73 BOOL bugFix2197; // Compatability-gate for fixing bug 2197. 74 } TC2Config; 75 76 /// \brief Initializes the instance of texUtils library 77 /// 78 /// \param pConfig Configuration used to initialize the library 79 /// 80 /// \donotcall \gx2_typical \userheap \enddonotcall 81 /// 82 BOOL TC2API TC2Initialize(TC2Config* pConfig); 83 84 /// \brief Destroys the instance of texUtils library 85 /// 86 /// \donotcall \gx2_typical \userheap \enddonotcall 87 /// 88 BOOL TC2API TC2Destroy(void); 89 90 /// \brief Converts a surface format from a string to a GX2SurfaceFormat. 91 /// 92 /// \param pFormatStr String to be converted 93 /// \param pgx2Format Pointer to GX2SurfaceFormat to hold converted format 94 /// 95 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 96 /// 97 BOOL TC2API TC2GX2SurfaceFormatFromStr(char* pFormatStr, GX2SurfaceFormat *pgx2Format); 98 99 /// \brief Generate mips based on GX2Surface passed in. 100 /// 101 /// \param pInSurface Source surface from which mips will be based. The surface passed in should not already contain mips. 102 /// \param iMinSize Minimum mip size. 103 /// \param filter Mipmap filter mode. 104 /// \param pOutSurface Resulting surface containing mips 105 /// 106 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 107 /// 108 BOOL TC2API TC2GenerateMipLevels(GX2Surface* pInSurface, s32 iMinSize, TC2MipFilter filter, GX2Surface* pOutSurface); 109 110 /// \brief Converts a surface to a given format. 111 /// 112 /// \param pInSurface Source surface for the conversion 113 /// \param dstFormat Desired format for the conversion 114 /// \param pOutSurface resulting converted surface 115 /// \param pOptions Conversion options 116 /// 117 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 118 /// 119 BOOL TC2API TC2ConvertSurfaceFormat(GX2Surface *pInSurface, GX2SurfaceFormat dstFormat, GX2Surface *pOutSurface, TC2ConvertOptions* pOptions); 120 121 /// \brief Tile/detiles a surface and stores in a GX2Texture object. Use TC2DestroyGX2Texture to destroy this GX2Texture. 122 /// 123 /// \param pInSurface Source surface 124 /// \param dstTileMode Destination tile mode 125 /// \param initialSwizzle Initial swizzle value 126 /// \param pOutSurface Resulting surface after the conversion 127 /// 128 /// \donotcall \notthreadsafe \hostonly \enddonotcall 129 /// 130 BOOL TC2API TC2ConvertTiling(GX2Surface *pInSurface, GX2TileMode dstTileMode, u32 initialSwizzle, GX2Surface* pOutSurface); 131 132 /// \brief Destroys GX2Surface 133 /// 134 /// \param pGX2Surface object to destroy 135 /// 136 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 137 /// 138 BOOL TC2API TC2DestroyGX2Surface(GX2Surface* pGX2Surface); 139 140 /// \brief Creates a GX2Texture from the given surface 141 /// 142 /// \param pInSurface Source surface 143 /// \param pOutTexture Resultant texture 144 /// 145 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 146 /// 147 BOOL TC2API TC2GenerateTexture(GX2Surface* pInSurface, GX2Texture* pOutTexture); 148 149 /// \brief Destroys GX2Texture that was created by TC2GenerateTexture 150 /// 151 /// \param pGX2Texture object to destroy 152 /// 153 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 154 /// 155 BOOL TC2API TC2DestroyGX2Texture(GX2Texture* pGX2Texture); 156 157 /// \brief Convert string to tile GX2TileMode 158 /// 159 /// \param str String to convert 160 /// \param pTileMode GX2TileMode object that will contain the tile mode after conversion 161 /// 162 /// \donotcall \hostonly \enddonotcall 163 /// 164 BOOL TC2API TC2ConvertStringToTileMode(char *str, GX2TileMode *pTileMode); 165 166 /// \brief Fill in surface size related information for a linear source surface 167 /// 168 /// \param pSurface Surface object to fill 169 /// 170 /// \donotcall \threadsafe \hostonly \enddonotcall 171 /// 172 BOOL TC2API TC2GetSourceSurfaceSize(GX2Surface *pSurface); 173 174 /// \brief Combines a list of surfaces into a texture array 175 /// 176 /// \param pSurfaces List of surfaces used to make the texture array 177 /// \param surfaceCount Number of surfaces in pSurfaces 178 /// \param pTexArraySurface The resulting texture array surface 179 /// 180 /// \donotcall \threadsafe \hostonly \userheap \enddonotcall 181 /// 182 BOOL TC2API TC2CombineAsTextureArray(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pTexArraySurface); 183 184 /// \brief Combines a list of surfaces into mips 185 /// 186 /// \param pSurfaces List of surfaces used to make the mips 187 /// \param surfaceCount Number of surfaces in pSurfaces 188 /// \param pMipSurface The resulting mip mapped surface 189 /// 190 /// \donotcall \threadsafe \hostonly \userheap \enddonotcall 191 /// 192 BOOL TC2API TC2CombineAsMips(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pMipSurface); 193 194 /// @} 195 196 #endif //#ifdef _TEXUTILS_H 197