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 #pragma once 14 #ifndef __TEX_CONVERT_H__ 15 #define __TEX_CONVERT_H__ 16 17 #ifdef __cplusplus 18 extern "C" 19 { 20 #endif // __cplusplus 21 #include "stdafx.h" 22 #include "types.h" 23 #include "ddraw.h" 24 #include "texUtils.h" 25 #include "cafe/gfd.h" 26 #include "gfdFile.h" 27 28 // Input DLLs 29 #ifdef _DEBUG 30 #define LIB_DLL_TEXUTILS TEXT("texUtilsD.dll") 31 #define LIB_DLL_GFD TEXT("gfdD.dll") 32 #else 33 #define LIB_DLL_TEXUTILS TEXT("texUtils.dll") 34 #define LIB_DLL_GFD TEXT("gfd.dll") 35 #endif 36 37 // Functions 38 typedef bool (*PTC2Initialize)(TC2Config* pConfig); 39 typedef bool (*PTC2Destroy)(void); 40 typedef bool (*PTC2GX2SurfaceFormatFromStr)(char* pFormatStr, GX2SurfaceFormat *pgx2Format); 41 typedef bool (*PTC2GenerateMipLevels)(GX2Surface* pInSurface, s32 iMinSize, TC2MipFilter filter, GX2Surface* pOutSurface); 42 typedef bool (*PTC2ConvertSurfaceFormat)(GX2Surface *pInSurface, GX2SurfaceFormat dstFormat, GX2Surface *pOutSurface, TC2ConvertOptions* pOptions); 43 typedef bool (*PTC2ConvertTiling)(GX2Surface *pInSurface, GX2TileMode dstTileMode, u32 initialSwizzle, GX2Surface* pOutSurface); 44 typedef bool (*PTC2DestroyGX2Surface)(GX2Surface* pGX2Surface); 45 typedef bool (*PTC2GenerateTexture)(GX2Surface* pInSurface, GX2Texture* pOutTexture); 46 typedef bool (*PTC2DestroyGX2Texture)(GX2Texture* pGX2Texture); 47 typedef bool (*PTC2ConvertStringToTileMode)(char *str, GX2TileMode *pTileMode); 48 typedef bool (*PTC2GetSourceSurfaceSize)(GX2Surface *pSurface); 49 typedef bool (*PTC2CombineAsTextureArray)(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pTexArraySurface); 50 typedef bool (*PTC2CombineAsMips)(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pMipSurface); 51 52 typedef bool (*PGFDWriteFileTexture)(char* pFilename, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, GFDAlignMode alignMode, u32 numTextures, GX2Texture* pTexture); 53 typedef bool (*PGFDAppendWriteFileTexture)(char* pFilename, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, GFDAlignMode alignMode, u32 numTexture, GX2Texture* pTexture); 54 typedef bool (*PGFDReadFileTexture)(GX2Texture* pTexture, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, const char* fileName); 55 typedef bool (*PGFDFreeFileTexture)(GX2Texture* pTexture); 56 57 typedef struct 58 { 59 PTC2Initialize Initialize; 60 PTC2Destroy Destroy; 61 PTC2GX2SurfaceFormatFromStr GX2SurfaceFormatFromStr; 62 PTC2GenerateMipLevels GenerateMipLevels; 63 PTC2ConvertSurfaceFormat ConvertSurfaceFormat; 64 PTC2ConvertTiling ConvertTiling; 65 PTC2DestroyGX2Surface DestroyGX2Surface; 66 PTC2GenerateTexture GenerateTexture; 67 PTC2DestroyGX2Texture DestroyGX2Texture; 68 PTC2ConvertStringToTileMode ConvertStringToTileMode; 69 PTC2GetSourceSurfaceSize GetSourceSurfaceSize; 70 PTC2CombineAsTextureArray CombineAsTextureArray; 71 PTC2CombineAsMips CombineAsMips; 72 } TC2Func; 73 74 typedef struct 75 { 76 PGFDWriteFileTexture WriteFileTexture; 77 PGFDAppendWriteFileTexture AppendWriteFileTexture; 78 PGFDReadFileTexture ReadFileTexture; 79 PGFDFreeFileTexture FreeFileTexture; 80 } GFDFunc; 81 82 /// Supported Extension types. 83 typedef enum 84 { 85 ET_DDS, 86 ET_TGA, 87 ET_GTX 88 } ExtensionType; 89 90 /// Supported value types. 91 typedef enum 92 { 93 VT_UNORM, ///< 0 to 255 94 VT_SNORM ///< -128 to 128 95 } ValueType; 96 97 // App config default 98 #define USEBOXFILTER_DEFAULT false 99 #define MINMIPSIZE_DEFAULT 0 100 #define GPU_DEFAULT GPU_Cafe 101 #define INITIALSWIZZLE_DEFAULT 0 102 #define DSTFORMAT_DEFAULT "PASSTHROUGH" 103 #define MIPFILTER_DEFAULT MF_NONE 104 #define TILEMODE_DEFAULT "GX2_TILE_MODE_DEFAULT" 105 #define TEXTUREARRAY_DEFAULT false 106 #define MIPFROMSOURCE_DEFAULT false 107 #define ENDIANBUGFIX_DEFAULT false 108 #define ALIGNMODE_DEFAULT false 109 #define APPENDMODE_DEFAULT false 110 #define INFILECOUNT_DEFAULT 0 111 #define GBTILINGCONFIG_DEFAULT 0 112 #define VALUETYPE_DEFAULT VT_UNORM 113 114 #define USEWEIGHTING_DEFAULT false 115 #define WEIGHTINGRED_DEFAULT 1.0 116 #define WEIGHTINGGREEN_DEFAULT 1.0 117 #define WEIGHTINGBLUE_DEFAULT 1.0 118 119 #define USEADAPTIVEWEIGHTING_DEFAULT false 120 121 #define BC1USEALPHA_DEFAULT true 122 #define BC1ALPHATHRESHOLD_DEFAULT 127 123 #define PRINTINFO_DEFAULT false 124 125 #define DEFAULT_GTX_FILENAME "out.gtx" 126 #define DEFAULT_DDS_FILENAME "out.dds" 127 #define MAX_INPUTFILE_COUNT 64 128 129 // App config 130 typedef struct 131 { 132 char* inFileName[MAX_INPUTFILE_COUNT]; 133 u32 inFileCount; 134 char* outFileName; 135 TC2GPUVersion gpu; 136 u32 initialSwizzle; 137 char tileMode[128]; 138 TC2MipFilter mipFilter; 139 u32 minMipSize; 140 char dstFormat[128]; 141 bool textureArray; 142 bool mipsFromSrc; 143 bool alignMode; 144 bool appendMode; 145 bool endianbugfix; 146 u32 gbtilingconfig; 147 ValueType valuetype; 148 bool useWeighting; 149 double weightingRed; 150 double weightingGreen; 151 double weightingBlue; 152 bool useAdaptiveWeighting; 153 bool bc1usealpha; 154 u8 bc1alphathreshold; 155 bool printinfo; 156 bool fix2197; 157 } AppConfig; 158 159 #ifdef __cplusplus 160 } 161 #endif // __cplusplus 162 163 #endif // __TEX_CONVERT_H__ 164 165