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 //  demoGfd.h
14 //
15 // -----------------------------------------------------------------------------
16 
17 #ifndef __DEMO_GFD_H__
18 #define __DEMO_GFD_H__
19 
20 #include <cafe/demo.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /// @addtogroup demoGfd
27 /// @{
28 
29 /// \brief Get a GX2VertexShader with actual shader data from a block of memory loaded from GX2 shader file (.gsh)
30 ///
31 /// Given raw data loaded from .gsh shader file, and an initialized GX2VertexShader structure,
32 /// this fills the GX2VertexShader structure with data from the n'th vertex shader in the file.
33 ///
34 /// \param ppShader             Pointer-pointer to GX2VertexShader structure
35 /// \param index                Index of vertex shader to extract.
36 /// \param pData                Input data, mapped from GX2 Shader file.
37 /// \retval                     True on success, or false if data is invalid or index is out of range.
38 ///
39 BOOL DEMOGFDReadVertexShader(GX2VertexShader **ppShader, u32 index, const void *pData);
40 
41 /// \brief Get a GX2PixelShader with actual shader data from a block of memory loaded from GX2 shader file (.gsh)
42 ///
43 /// Given raw data loaded from .gsh shader file, and an initialized GX2PixelShader structure,
44 /// this fills the GX2PixelShader structure with data from the n'th pixel shader in the file.
45 ///
46 /// \param ppShader             Pointer-pointer to GX2PixelShader structure
47 /// \param index                Index of pixel shader to extract.
48 /// \param pData                Input data, mapped from GX2 Shader file.
49 /// \retval                     True on success, or false if data is invalid or index is out of range.
50 ///
51 BOOL DEMOGFDReadPixelShader(GX2PixelShader **ppShader, u32 index, const void *pData);
52 
53 /// \brief Get a GX2GeometryShader with actual shader data from a block of memory loaded from GX2 shader file (.gsh)
54 ///
55 /// Given raw data loaded from .gsh shader file, and an initialized GX2GeometryShader structure,
56 /// this fills the GX2GeometryShader structure with data from the n'th geometry shader in the file.
57 ///
58 /// \param ppShader             Pointer-pointer to GX2GeometryShader structure
59 /// \param index                Index of geometry shader to extract.
60 /// \param pData                Input data, mapped from GX2 Shader file.
61 /// \retval                     True on success, or false if data is invalid or index is out of range.
62 ///
63 BOOL DEMOGFDReadGeometryShader(GX2GeometryShader **ppShader, u32 index, const void *pData);
64 
65 /// \brief Get a GX2ComputeShader with actual shader data from a block of memory loaded from GX2 shader file (.gsh)
66 ///
67 /// Given raw data loaded from .gsh shader file, and an initialized GX2ComputeShader structure,
68 /// this fills the GX2ComputeShader structure with data from the n'th compute shader in the file.
69 ///
70 /// \param ppShader             Pointer-pointer to GX2ComputeShader structure
71 /// \param index                Index of vertex shader to extract.
72 /// \param pData                Input data, mapped from GX2 Shader file.
73 /// \retval                     True on success, or false if data is invalid or index is out of range.
74 ///
75 BOOL DEMOGFDReadComputeShader(GX2ComputeShader **ppShader, u32 index, const void *pData);
76 
77 /// \brief Get a GX2Texture with actual texture data from a block of memory loaded from a GX2 texture file (.gtx)
78 ///
79 /// Given raw data loaded from .gtx texture file, and an initialized GX2Texture structure,
80 /// this fills the GX2Texture structure with data for the n'th texture in the file.
81 ///
82 /// \param ppTexture        Pointer-pointer to GX2Texture Structure
83 /// \param index            Which texture to extract.
84 /// \param pData            Input data, mapped from GX2 texture file (.gtx).
85 /// \retval                 True on success, or false if data is invalid or index is out of range.
86 ///
87 BOOL DEMOGFDReadTexture(GX2Texture **ppTexture, u32 index, const void *pData);
88 
89 /// \brief Free a GX2VertexShader data
90 ///
91 /// \param pShader         Pointer to GX2VertexShader Structure
92 ///
93 void DEMOGFDFreeVertexShader(GX2VertexShader *pShader);
94 
95 /// \brief Free a GX2PixelShader data
96 ///
97 /// \param pShader         Pointer to GX2PixelShader Structure
98 ///
99 void DEMOGFDFreePixelShader(GX2PixelShader *pShader);
100 
101 /// \brief Free a GX2GeometryShader data
102 ///
103 /// \param pShader         Pointer to GX2GeometryShader Structure
104 ///
105 void DEMOGFDFreeGeometryShader(GX2GeometryShader *pShader);
106 
107 
108 /// \brief Free a GX2ComputeShader data
109 ///
110 /// \param pShader         Pointer to GX2ComputeShader Structure
111 ///
112 void DEMOGFDFreeComputeShader(GX2ComputeShader *pShader);
113 
114 /// \brief Free a GX2Texture data
115 ///
116 /// \param pTexture         Pointer to GX2Texture Structure
117 ///
118 void DEMOGFDFreeTexture(GX2Texture *pTexture);
119 
120 /// \brief Get GX2Texture pointer with actual texture data from a block of memory loaded from an aligned GX2 texture file (.gtx)
121 ///
122 /// This buffer is aligned with alignSize.
123 /// File is automatically closed after it's read from.
124 /// Call \ref DEMOGFDFreeAlignedTexture() to free this buffer.
125 ///
126 /// \param pFileBuf Pointer-pointer to file buffer
127 /// \param index Which texture to extract
128 /// \param align Alignment size for buffer
129 /// \param fileName File string name to read
130 /// \retval GX2Texture pointer
131 ///
132 GX2Texture* DEMOGFDReadAlignedTexture(void **pFileBuf, u32 index, u32 align, const char *fileName);
133 
134 /// \brief Free an aligned GX2Texture File buffer
135 ///
136 /// \param pFileBuf         Pointer to GX2Texture File buffer
137 ///
138 void DEMOGFDFreeAlignedTexture(void *pFileBuf);
139 
140 /// @}  // demoGfd
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /// __DEMO_GFD_H__
147