/*---------------------------------------------------------------------------* Copyright (C) 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. *---------------------------------------------------------------------------*/ #pragma once #ifndef __TEX_CONVERT_H__ #define __TEX_CONVERT_H__ #ifdef __cplusplus extern "C" { #endif // __cplusplus #include "stdafx.h" #include "types.h" #include "ddraw.h" #include "texUtils.h" #include "cafe/gfd.h" #include "gfdFile.h" // Input DLLs #ifdef _DEBUG #define LIB_DLL_TEXUTILS TEXT("texUtilsD.dll") #define LIB_DLL_GFD TEXT("gfdD.dll") #else #define LIB_DLL_TEXUTILS TEXT("texUtils.dll") #define LIB_DLL_GFD TEXT("gfd.dll") #endif // Functions typedef bool (*PTC2Initialize)(TC2Config* pConfig); typedef bool (*PTC2Destroy)(void); typedef bool (*PTC2GX2SurfaceFormatFromStr)(char* pFormatStr, GX2SurfaceFormat *pgx2Format); typedef bool (*PTC2GenerateMipLevels)(GX2Surface* pInSurface, s32 iMinSize, TC2MipFilter filter, GX2Surface* pOutSurface); typedef bool (*PTC2ConvertSurfaceFormat)(GX2Surface *pInSurface, GX2SurfaceFormat dstFormat, GX2Surface *pOutSurface, TC2ConvertOptions* pOptions); typedef bool (*PTC2ConvertTiling)(GX2Surface *pInSurface, GX2TileMode dstTileMode, u32 initialSwizzle, GX2Surface* pOutSurface); typedef bool (*PTC2DestroyGX2Surface)(GX2Surface* pGX2Surface); typedef bool (*PTC2GenerateTexture)(GX2Surface* pInSurface, GX2Texture* pOutTexture); typedef bool (*PTC2DestroyGX2Texture)(GX2Texture* pGX2Texture); typedef bool (*PTC2ConvertStringToTileMode)(char *str, GX2TileMode *pTileMode); typedef bool (*PTC2GetSourceSurfaceSize)(GX2Surface *pSurface); typedef bool (*PTC2CombineAsTextureArray)(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pTexArraySurface); typedef bool (*PTC2CombineAsMips)(GX2Surface *pSurfaces, u32 surfaceCount, GX2Surface *pMipSurface); typedef bool (*PGFDWriteFileTexture)(char* pFilename, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, GFDAlignMode alignMode, u32 numTextures, GX2Texture* pTexture); typedef bool (*PGFDAppendWriteFileTexture)(char* pFilename, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, GFDAlignMode alignMode, u32 numTexture, GX2Texture* pTexture); typedef bool (*PGFDReadFileTexture)(GX2Texture* pTexture, GFDGPUVersion gpuVer, GFDEndianSwapMode swapMode, const char* fileName); typedef bool (*PGFDFreeFileTexture)(GX2Texture* pTexture); typedef struct { PTC2Initialize Initialize; PTC2Destroy Destroy; PTC2GX2SurfaceFormatFromStr GX2SurfaceFormatFromStr; PTC2GenerateMipLevels GenerateMipLevels; PTC2ConvertSurfaceFormat ConvertSurfaceFormat; PTC2ConvertTiling ConvertTiling; PTC2DestroyGX2Surface DestroyGX2Surface; PTC2GenerateTexture GenerateTexture; PTC2DestroyGX2Texture DestroyGX2Texture; PTC2ConvertStringToTileMode ConvertStringToTileMode; PTC2GetSourceSurfaceSize GetSourceSurfaceSize; PTC2CombineAsTextureArray CombineAsTextureArray; PTC2CombineAsMips CombineAsMips; } TC2Func; typedef struct { PGFDWriteFileTexture WriteFileTexture; PGFDAppendWriteFileTexture AppendWriteFileTexture; PGFDReadFileTexture ReadFileTexture; PGFDFreeFileTexture FreeFileTexture; } GFDFunc; /// Supported Extension types. typedef enum { ET_DDS, ET_TGA, ET_GTX } ExtensionType; /// Supported value types. typedef enum { VT_UNORM, ///< 0 to 255 VT_SNORM ///< -128 to 128 } ValueType; // App config default #define USEBOXFILTER_DEFAULT false #define MINMIPSIZE_DEFAULT 0 #define GPU_DEFAULT GPU_Cafe #define INITIALSWIZZLE_DEFAULT 0 #define DSTFORMAT_DEFAULT "PASSTHROUGH" #define MIPFILTER_DEFAULT MF_NONE #define TILEMODE_DEFAULT "GX2_TILE_MODE_DEFAULT" #define TEXTUREARRAY_DEFAULT false #define MIPFROMSOURCE_DEFAULT false #define ENDIANBUGFIX_DEFAULT false #define ALIGNMODE_DEFAULT false #define APPENDMODE_DEFAULT false #define INFILECOUNT_DEFAULT 0 #define GBTILINGCONFIG_DEFAULT 0 #define VALUETYPE_DEFAULT VT_UNORM #define USEWEIGHTING_DEFAULT false #define WEIGHTINGRED_DEFAULT 1.0 #define WEIGHTINGGREEN_DEFAULT 1.0 #define WEIGHTINGBLUE_DEFAULT 1.0 #define USEADAPTIVEWEIGHTING_DEFAULT false #define BC1USEALPHA_DEFAULT true #define BC1ALPHATHRESHOLD_DEFAULT 127 #define PRINTINFO_DEFAULT false #define DEFAULT_GTX_FILENAME "out.gtx" #define DEFAULT_DDS_FILENAME "out.dds" #define MAX_INPUTFILE_COUNT 64 // App config typedef struct { char* inFileName[MAX_INPUTFILE_COUNT]; u32 inFileCount; char* outFileName; TC2GPUVersion gpu; u32 initialSwizzle; char tileMode[128]; TC2MipFilter mipFilter; u32 minMipSize; char dstFormat[128]; bool textureArray; bool mipsFromSrc; bool alignMode; bool appendMode; bool endianbugfix; u32 gbtilingconfig; ValueType valuetype; bool useWeighting; double weightingRed; double weightingGreen; double weightingBlue; bool useAdaptiveWeighting; bool bc1usealpha; u8 bc1alphathreshold; bool printinfo; bool fix2197; } AppConfig; #ifdef __cplusplus } #endif // __cplusplus #endif // __TEX_CONVERT_H__