1 /*---------------------------------------------------------------------------* 2 3 Copyright (C) 2010-2011 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 // gfdFormat.h 14 // 15 // Formats for Cafe graphics binary files (for example, .gtx and .gsh). 16 17 #ifndef _CAFE_GFD_FORMAT_H_ 18 #define _CAFE_GFD_FORMAT_H_ 19 20 #ifdef __cplusplus 21 extern "C" 22 { 23 #endif // __cplusplus 24 25 /// @addtogroup GFDFormatGroup 26 /// @{ 27 28 typedef struct _GFDShaders 29 { 30 GX2VertexShader *pVertexShader; ///< Pointer to GX2VertexShader structure 31 GX2PixelShader *pPixelShader; ///< Pointer to GX2PixelShader structure 32 GX2GeometryShader *pGeometryShader; ///< Pointer to GX2GeometryShader structure 33 } GFDShaders; 34 35 typedef struct _GFDShaders2 36 { 37 u32 abiVersion; ///< ABI version. This must be set to \ref GFD_DLL_ABI_VERSION. 38 GX2VertexShader *pVertexShader; ///< Pointer to GX2VertexShader structure 39 GX2PixelShader *pPixelShader; ///< Pointer to GX2PixelShader structure 40 GX2GeometryShader *pGeometryShader; ///< Pointer to GX2GeometryShader structure 41 GX2ComputeShader *pComputeShader; ///< Pointer to GX2ComputeShader structure 42 } GFDShaders2; 43 44 typedef struct _GFDShadersSrc 45 { 46 u32 abiVersion; ///< ABI version. This must be set to \ref GFD_DLL_ABI_VERSION. 47 const char *pVertexShader; ///< Pointer to GX2VertexShader source string 48 const char *pPixelShader; ///< Pointer to GX2PixelShader source string 49 const char *pGeometryShader; ///< Pointer to GX2GeometryShader source string 50 const char *pComputeShader; ///< Pointer to GX2ComputeShader source string 51 } GFDShadersSrc; 52 53 /// \brief Header structure at the begining of GFD files (gsh and gtx). 54 55 typedef struct _GFDHeader 56 { 57 u32 magic; ///< magic number 58 u32 size; ///< size of header in bytes - must match exactly, or header (and hence file) is unreadable 59 u32 majorVersion; ///< major version number - must match exactly or header is unreadable 60 u32 minorVersion; ///< minor version number - will warn if lower. 61 GFDGPUVersion gpuVersion; ///< GPU version for which this file is designed for, cast to u32 (file is GPU dependent after all) 62 GFDAlignMode alignMode; ///< align mode of this file. 63 u32 reserved1; ///< reserved (should be 0) 64 u32 reserved2; ///< reserved (should be 0) 65 } GFDHeader; 66 67 /// \brief Block header for each block in GFD files (gsh and gtx). 68 /// 69 /// A block is a contiguous section of data in the file of a given type. Each block is preceeded 70 /// by one of these block headers, which specify the block type, its length, and its major/minor version number. 71 /// 72 /// There are also two different counters in this header. 73 /// - id is unique incrementing number among all the blocks. 74 /// - typeIdx is unique among all the blocks of the same type. Used to find the Nth index of the block 75 /// 76 77 typedef struct _GFDBlockHeader 78 { 79 u32 magic; ///< Magic number for block headers 80 u32 size; ///< Size of block header in bytes 81 u32 majorVersion; ///< Major version number - must match exactly or this block is unreadable 82 u32 minorVersion; ///< Minor version number - will warn if lower. 83 GFDBlockType type; ///< Block type 84 u32 dataSize; ///< Size of the following data block, in bytes. 85 u32 id; ///< A unique identifier for this block, allowing it to be referenced by other blocks (currently 0) 86 u32 typeIdx; ///< An incrementing index for each instance of a given type (currently 0) 87 } GFDBlockHeader; 88 89 // ------------------------------------------------ 90 /// \brief Trailer for relocatable blocks in GFD files (gsh and gtx). 91 /// 92 /// This is really simple section at the end of every data block that contains pointers, 93 /// that allows one to easilly deseserialize it. 94 /// 95 /// Main purpose of this is to point to the patch table. 96 /// While were at it, point to the main structure and the string table. 97 /// 98 // ------------------------------------------------ 99 100 typedef struct _GFDBlockRelocationHeader 101 { 102 u32 magic; ///< magic value 103 u32 size; ///< size of this data structure. Must exactly match sizeof(GFDBlockRelocationHeader) 104 u32 type; ///< type of the main data block 105 u32 dataSize; ///< size of the main data section (allocate this size of contiguous memory) 106 u32 dataOffset; ///< offset of the main data section in this block. Should almost always be 4 107 u32 stringTableCharNumber; ///< number of characters in the string table 108 u32 stringTableOffset; ///< offset of string table in this block 109 u32 basePatchAddress; ///< base address used in patches, normally pointer to begining of file block. If zero, no patching has been done. 110 u32 patchTableOffsetNumber; ///< number of offsets in the patch table 111 u32 patchTableOffset; ///< offset of the patch table in this block 112 } GFDBlockRelocationHeader; 113 114 /// @} 115 116 #ifdef __cplusplus 117 } 118 #endif // __cplusplus 119 120 #endif // _CAFE_GFD_FORMAT_H_ 121