1 /*---------------------------------------------------------------------------*
2 
3   Copyright 2010-2013 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 // shaderUtils.h
14 //
15 // Declares functions for shaderUtils library.
16 //
17 // This library has dependencies on gx2 and pulls in GX2
18 // source files
19 // -------------------------------------------------------
20 #ifndef _SHADERUTILS_H
21 #define _SHADERUTILS_H
22 
23 #if defined(WIN32) || defined(WIN64)
24 #include <windows/gx2.h>
25 #else
26 #include <cafe/gx2.h>
27 #endif
28 #include "optflags.h"
29 
30 #if defined(__cplusplus)
31 extern "C"
32 {
33 #endif
34 
35 #if !(defined _WIN32 || defined _WIN64)
36 
37 #define GSH2_DECLSPEC
38 #define GSH2API GX2API
39 
40 #else
41 
42 #ifdef _EXPORTING
43 #define GSH2_DECLSPEC __declspec(dllexport)
44 #else
45 #define GSH2_DECLSPEC __declspec(dllimport)
46 #endif
47 
48 #define GSH2API __cdecl
49 
50 #endif
51 
52 /// @addtogroup GX2ShaderUtilsGroup
53 /// @{
54 
55 /// \brief Macro to extract the ABI ID from a packed abi_version field.
56 ///
57 /// This field indicates the ABI in use, and is modified to indicate library changes
58 /// that are neither forward nor backward compatible.
59 #define GSH2_ABI_ID(x)  (((x)&0xFF800000))
60 
61 /// \brief Macro to extract the ABI major version from a packed abi_version field.
62 ///
63 /// This field indicates major changes to the structure format that are backward compatible
64 /// but not forward compatible.
65 #define GSH2_ABI_MAJOR(x) ( ((x)&0x7F0000) >> 16 )
66 
67 /// \brief Macro to extract the ABI minor version from a packed abi_version field.
68 ///
69 /// This field indicates changes to the structure format that are both forward and backward
70 /// compatible to some extent, that is applications compiled against an old ABI minor version can
71 /// call libraries with a newer minor ABI version, and vice-versa. An older library may
72 /// not provide all the features of the newer one, of course, but will still produce valid
73 /// output.
74 #define GSH2_ABI_MINOR(x) ((x)&0xFFFF )
75 
76 /// \brief Current ABI ID version. The ABI ID passed in to the
77 /// library must exactly match the library's ABI ID, or else shaderUtils function calls will fail.
78 /// This is packed in to GSH2_ABI_VERSION_CURRENT.
79 #define GSH2_ABI_ID_CURRENT    0xAB800000
80 
81 /// \brief Current ABI major version, as extracted by GSH2_ABI_MAJOR().
82 ///
83 /// The ABI major version
84 /// passed to the library in abi_version must be less than or equal to the library's version, e.g. an application
85 /// compiled against ABI version 3 will work with a version 4 library, but not vice-versa; ABI major changes
86 /// are forward compatible but not backward compatible. An example of such a change would be adding new
87 /// fields to a structure at the end, so as to increase its size but not move any existing fields.
88 ///
89 /// This field is packed in to GSH2_ABI_VERSION_CURRENT.
90 #define GSH2_ABI_MAJOR_CURRENT 1
91 
92 /// \brief Current ABI minor version, as extracted by GSH2_ABI_MINOR().
93 ///
94 /// The ABI minor version
95 /// indicates changes that are both forward and backwards compatible. This means that a newer library must
96 /// provide sensible defaults for any parts of the structure that an older application wouldn't know about (for
97 /// example previously reserved fields that are now in use) and a newer application will work with an older library,
98 /// although in that case some of the new fields will be ignored by the old library (but this must still result in
99 /// correct and functional output).
100 ///
101 /// This field is packed in to GSH2_ABI_CURRENT.
102 #define GSH2_ABI_MINOR_CURRENT 3
103 
104 /// \brief Packed ABI version for the abi_version field. This is normally what applications should
105 /// use to set any abi_version field in structures passed to GSH2 functions. See GSH2_ABI_ID(),
106 /// GSH2_ABI_MAJOR() and GSH2_ABI_MINOR() for what the fields mean.
107 #define GSH2_ABI_VERSION_CURRENT  (GSH2_ABI_ID_CURRENT | (GSH2_ABI_MAJOR_CURRENT<<16) | (GSH2_ABI_MINOR_CURRENT))
108 
109 /// \brief This macro checks to make sure if the ABI ID stored in x matches the current one.
110 #define GSH2_ABI_OK(x) (GSH2_ABI_ID(x) == GSH2_ABI_ID_CURRENT)
111 
112 /// \brief Compatibility macro indicating the original value of the ABI (for tools that wish to
113 /// retain compatibility with the oldest ABI)
114 #define GSH2_ABI_VERSION3  0xAB810003
115 
116 /// \brief Function to return the current ABI version
117 ///
118 /// \return Packed 32 bit ABI ID, MAJOR, and MINOR versions
119 ///
120 /// \donotcall \hostonly \enddonotcall
121 ///
122 GSH2_DECLSPEC u32 GSH2API GSH2GetABIVersion(void);
123 
124 /// \brief Handle to instance of shaderUtils lib (returned from GSH2Initialize)
125 typedef void* GSH2Handle;
126 
127 /// \brief Supported GPU's
128 typedef enum
129 {
130     GPU_VERSION_0,      ///< 0 Ver1
131     GPU_VERSION_1,      ///< 1 Ver2
132     GPU_VERSION_GPU7,   ///< 2 Cafe (GPU7)
133 } GSH2GPUVersion;
134 
135 /// \brief Library setup information
136 typedef struct
137 {
138     GSH2GPUVersion gpu;     // Target gpu
139 } GSH2Setup;
140 
141 /// \brief Supported shader languages
142 typedef enum
143 {
144     SHADERLANG_GLSL,    /// GLSL
145     SHADERLANG_ESSL,    /// ESSL
146 } GSH2ShaderLang;
147 
148 /// \brief Configuration options
149 typedef union
150 {
151     struct
152     {
153         u32 forceUniformBlock : 1;  ///< force uniform block usage
154         u32 dumpShaders       : 1;  ///< dump pre/post optimized file
155         u32 skipSparkDebug    : 1;  ///< do not dump debug data for Spark
156 		u32 optimize          : 1;  ///< obsolete, deprecated in favor of optFlags/optimizeFlags
157 		u32 optFlags          : 1;  ///< if set, GSH2CompileSetup3 field optimizeFlags contains specific flags
158 		u32 getStats          : 1;  ///< if set, GSH2CompileSetup3 fields vs_stats, ps_stats, gs_stats may be present
159     };
160     u32 value;
161 } GSH2Options;
162 
163 
164 /// \brief Information needed to compile the shaders
165 typedef struct
166 {
167     const char*   vs_source;		///< VS shader source code
168     const char*   ps_source;		///< PS shader source code
169     const char*   gs_source;		///< GS shader source code
170     const char**  so_varyings;		///< stream out varyings
171     u32     numSOVaryings;			///< number of stream out varyings
172 
173     GSH2Options     options;		///< configuration options
174     GSH2ShaderLang  lang;			///< shader language
175 } GSH2CompileSetup;
176 
177 /// \brief GPU instruction usage statistics from the AMD compiler
178 typedef struct
179 {
180   /// Total hardware instructions used (control flow + ALU + TEXTURE + NOP)
181   u32   uNumInst;
182 
183   /// Number of hardware GPRs used
184   u32   uNumTempReg;
185 
186   /// Number of hardware clause temporaries used. These are reserved GPRs not used past the end of an ALU clause, and do not count against GPR use.
187   u32   uNumClauseTempReg;
188 
189   /// The GPR pool size for this type of shader. This is the max number of GPRs that any shader can use.
190   u32   uGPRPoolSize;
191 
192   /// Number of ALU Instructions used
193   u32   uNumALUInst;
194 
195   /// Number of TFETCHinstructions / Tx Units used
196   u32   uNumTfetchInst;
197 
198   /// Number of VFETCH instructions used; generally only dynamic indexing on uniform buffers will affect this (most VFETCHes are in the fetch shader).
199   u32   uNumVfetchInst;
200 
201   /// Number of Control flow instructions used. Control flow instructions typically initiate clauses (ALU caluse, texture fetch clause, etc.)
202   u32   uNumCflowInst;
203 
204   /// Number of External (API) HW ALU Constants used (the Cx registers). Mostly used for uniform variables, although 2 seem to be reserved for the compiler.
205   u32   uNumALUConstReg;
206 
207 } GSH2ShaderStats;
208 
209 /// \brief Information needed to compile the shaders; adds more fields for Spark Enhanced Shader Support
210 
211 typedef struct
212 {
213 	// NOTE: only add new fields at the end of the structure
214 	//       (otherwise old tools and new SDKs will not be able to mix)
215     const char*   vs_source;			///< VS shader source code
216     const char*   ps_source;			///< PS shader source code
217     const char*   gs_source;			///< GS shader source code
218     const char**  so_varyings;			///< stream out varyings
219     u32     numSOVaryings;				///< number of stream out varyings
220 
221     GSH2Options     options;			///< configuration options
222     GSH2ShaderLang  lang;				///< shader language
223 
224     const char*   vs_source_filename;   ///< VS shader source code file name
225     const char*   ps_source_filename;   ///< PS shader source code file name
226     const char*   gs_source_filename;   ///< GS shader source code file name
227 
228     const char*   spark_output_dir;     ///< NULL for default; or directory where to write Spark data
229 
230 	// anything below here can only be accessed if the corresponding bit is set in options
231 	// (so we know it's been set up properly by the caller)
232 	u64		optimizeFlags;				///< optimization flags; valid if options.optFlagsPresent is 1.
233 										///< See optflags.h for definitions.
234 	GSH2ShaderStats *ps_stats;			///< shader statistics for pixel shader; valid if options.getStats is 1
235 	GSH2ShaderStats *vs_stats;			///< shader statistics for vertex shader; valid if options.getStats is 1
236 	GSH2ShaderStats *gs_stats;			///< shader statistics for geometry shader; valid if options.getStats is 1
237 
238 } GSH2CompileSetup2;
239 
240 /// \brief Information needed to compile the shaders; adds more fields for compute shaders and future expansion
241 
242 typedef struct
243 {
244 	u32			  abi_version;			///< version of the binary interface to shaderUtils.dll
245     const char*   vs_source;			///< VS shader source code
246     const char*   ps_source;			///< PS shader source code
247     const char*   gs_source;			///< GS shader source code
248     const char**  so_varyings;			///< stream out varyings
249     u32     numSOVaryings;				///< number of stream out varyings
250 
251     GSH2Options     options;			///< configuration options
252     GSH2ShaderLang  lang;				///< shader language
253 
254     const char*   vs_source_filename;   ///< VS shader source code file name
255     const char*   ps_source_filename;   ///< PS shader source code file name
256     const char*   gs_source_filename;   ///< GS shader source code file name
257 
258     const char*   spark_output_dir;     ///< NULL for default; or directory for Spark output
259 
260 	u64		optimizeFlags;				///< optimization flags; valid if options.optFlagsPresent is 1
261 										///< see optflags.h for definitions
262 	GSH2ShaderStats *ps_stats;			///< shader statistics for pixel shader; valid if options.getStats is 1
263 	GSH2ShaderStats *vs_stats;			///< shader statistics for vertex shader; valid if options.getStats is 1
264 	GSH2ShaderStats *gs_stats;			///< shader statistics for geometry shader; valid if options.getStats is 1
265 	GSH2ShaderStats *cs_stats;			///< shader statistics for compute shader; valid if options.getStats is 1
266 
267 	const char*   cs_source;			///< CS shader source code
268     const char*   cs_source_filename;   ///< CS shader source code file name
269 
270 	u64		reserved[8];				///< reserved for future use, set to 0
271 } GSH2CompileSetup3;
272 
273 /// \brief GX2 shaders
274 typedef struct
275 {
276     GX2VertexShader     vs; // VS gx2 shader
277     GX2PixelShader      ps; // PS gx2 shader
278     GX2GeometryShader   gs; // GS gx2 shader
279 } GSH2GX2Program;
280 
281 /// \brief GX2 shaders extended version (includes compute shaders and reserved fields)
282 typedef struct
283 {
284 	u32					abi_version;	///< version of the binary interface to shaderUtils
285     GX2VertexShader     vs;				///< VS gx2 vertex shader
286     GX2PixelShader      ps;				///< PS gx2 pixel shader
287     GX2GeometryShader   gs;				///< GS gx2 geometry shader
288     GX2ComputeShader    cs;				///< CS gx2 compute shader
289 	u32					reserved[7];	///< reserved for future use, set to 0
290 } GSH2GX2Program3;
291 
292 typedef struct
293 {
294     GSH2GX2Program gx2Program;		///< Resulting GX2 shader objects
295 
296     const char* pInfoLog;			///< null terminated string that contains information about the last compilation attempt
297     const char* pVSDump;			///< null terminated string that contains the vertex shader debug dump
298     const char* pGSDump;			///< null terminated string that contains the geometry shader debug dump
299     const char* pPSDump;			///< null terminated string that contains the pixel shader debug dump
300 } GSH2CompileOutput;
301 
302 typedef struct
303 {
304 	u32			abi_version;		///< for binary compatibility between shaderUtils.dll versions
305     GSH2GX2Program3 gx2Program;		///< Resulting GX2 shader objects
306 
307     const char* pInfoLog;			///< null terminated string that contains information about the last compilation attempt
308     const char* pVSDump;			///< null terminated string that contains the vertex shader debug dump
309     const char* pGSDump;			///< null terminated string that contains the geometry shader debug dump
310     const char* pPSDump;			///< null terminated string that contains the pixel shader debug dump
311     const char* pCSDump;			///< null terminated string that contains the compute shader debug dump
312 	u32			reserved[8];		///< reserved for future use, set to 0
313 } GSH2CompileOutput3;
314 
315 /// \brief GSH patching structure, used for offline display list compilation.
316 ///
317 typedef struct
318 {
319     GX2PatchType   type;           ///< Type of GX2 entry to patch
320     u32            byteOffset;     ///< Byte offset from the start of the
321                                    ///  display list to patch
322     u32            assetID;        ///< Reserved for future use, set to 0.
323     u32            objectLoc;      ///< Reserved for future use, set to 0.
324 } GSH2PatchEntry;
325 
326 /// \brief Initializes the instance of shaderUtils library
327 ///
328 /// \note In multi-threaded use, GSH2Initialize() needs to be called n times from the main thread
329 /// to generate n GSH2Handles, where n is the number of application threads. Each handle should
330 /// then be used exclusively in one of the threads in calls to GSH2CompileProgram. Do not use a
331 /// handle across multiple threads.
332 /// \param pSetup Information needed to initialize library
333 ///
334 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
335 ///
336 GSH2_DECLSPEC GSH2Handle GSH2API GSH2Initialize(GSH2Setup* pSetup);
337 
338 /// \brief Destroys the instance of shaderUtils library
339 ///
340 /// \note In multi-threaded use, GSH2Initialize() needs to be called n times from the main thread
341 /// to generate n GSH2Handles, where n is the number of application threads. Each handle should
342 /// then be used exclusively in one of the threads in calls to GSH2CompileProgram. Do not use a
343 /// handle across multiple threads. GSH2Destroy() should be called n times in the main thread for
344 /// cleanup.
345 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
346 ///
347 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
348 ///
349 GSH2_DECLSPEC GX2Boolean GSH2API GSH2Destroy(GSH2Handle h);
350 
351 /// \brief Compile source shaders and store in GX2 shader structures.
352 ///
353 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current
354 /// thread. Handles cannot be shared across multiple threads.
355 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
356 /// \param pSetup Compile setup parameters
357 /// \param pOutput Compiler output data
358 ///
359 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
360 ///
361 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram(GSH2Handle h, GSH2CompileSetup *pSetup, GSH2CompileOutput* pOutput);
362 
363 /// \brief Compile source shaders and store in GX2 shader structures; adds Spark Enhanced Shader Support.
364 ///
365 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current
366 /// thread. Handles cannot be shared across multiple threads.
367 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
368 /// \param pSetup Compile setup parameters with added Spark information
369 /// \param pOutput Compiler output data
370 ///
371 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
372 ///
373 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram2(GSH2Handle h, GSH2CompileSetup2 *pSetup, GSH2CompileOutput* pOutput);
374 
375 /// \brief Compile source shaders and store in GX2 shader structures; adds Compute Shader Support.
376 ///
377 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current
378 /// thread. Handles cannot be shared across multiple threads.
379 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
380 /// \param pSetup Compile setup parameters with added Spark information
381 /// \param pOutput Compiler output data
382 ///
383 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
384 ///
385 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram3(GSH2Handle h, GSH2CompileSetup3 *pSetup, GSH2CompileOutput3* pOutput);
386 
387 /// \brief Release allocated resources for the gx2 shaders
388 ///
389 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
390 /// \param pGx2Program Clean up resources allocated in GSH2CompileProgram
391 ///
392 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
393 ///
394 GSH2_DECLSPEC GX2Boolean GSH2API GSH2DestroyGX2Program(GSH2Handle h, GSH2GX2Program* pGx2Program);
395 
396 /// \brief Release allocated resources for the gx2 shaders (compute shader version)
397 ///
398 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize)
399 /// \param pGx2Program Clean up resources allocated in GSH2CompileProgram
400 ///
401 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall
402 ///
403 GSH2_DECLSPEC GX2Boolean GSH2API GSH2DestroyGX2Program3(GSH2Handle h, GSH2GX2Program3* pGx2Program);
404 
405 /// \brief Calculate the size of a fetch shader.
406 ///
407 /// \param num_attrib number of attribute
408 /// \param fsType The type of fetch shader to generate
409 /// \param tessMode Tesselation mode, only valid if type is not GX2_FETCH_SHADER_TESSELATION_NONE
410 ///
411 /// \donotcall \hostonly \enddonotcall
412 ///
413 GSH2_DECLSPEC u32 GSH2API GSH2CalcFetchShaderSizeEx(u32 num_attrib, GX2FetchShaderType fsType, GX2TessellationMode tessMode);
414 
415 /// \brief Create a fetch shader based on the given attribute stream list.
416 ///
417 /// \param fs User-allocated instance of \ref GX2FetchShader structure
418 /// \param fs_buffer User-allocated aligned buffer for the fetch shader binary code
419 /// \param count     Number of attribute streams
420 /// \param attribs   User-allocated array of \ref GX2AttribStream structures containing information
421 ///                  about all attribute streams
422 /// \param type      The type of fetch shader to generate
423 /// \param tessMode  Tesselation mode, only valid if type is not GX2_FETCH_SHADER_TESSELATION_NONE
424 ///
425 /// \donotcall \hostonly \enddonotcall
426 ///
427 GSH2_DECLSPEC void GSH2API GSH2InitFetchShaderEx(GX2FetchShader* fs, void* fs_buffer, u32 count,
428                                                  const GX2AttribStream* attribs, GX2FetchShaderType type,
429                                                  GX2TessellationMode tessMode);
430 
431 /// \brief Function to return the number of GPRs used by the Vertex Shader program output by GSH2CompileProgram
432 ///
433 /// \param pShader Pointer to Vertex Shader
434 /// \return number of GPRs used by the vertex shader program
435 ///
436 /// \donotcall \hostonly \enddonotcall
437 ///
438 GSH2_DECLSPEC u32 GSH2API GSH2GetVertexShaderGPRs(const GX2VertexShader * pShader);
439 
440 /// \brief Function to return the number of GPRs used by the Geometry Shader program output by GSH2CompileProgram
441 ///
442 /// \param pShader Pointer to Geometry Shader
443 /// \return number of GPRs used by the geometry shader program
444 ///
445 /// \donotcall \hostonly \enddonotcall
446 ///
447 GSH2_DECLSPEC u32 GSH2API GSH2GetGeometryShaderGPRs(const GX2GeometryShader * pShader);
448 
449 /// \brief Function to return the number of GPRs used by the Pixel Shader program output by GSH2CompileProgram
450 ///
451 /// \param  pShader shader Pointer to Pixel Shader
452 /// \return number of GPRs used by the pixel shader program
453 ///
454 /// \donotcall \hostonly \enddonotcall
455 ///
456 GSH2_DECLSPEC u32 GSH2API GSH2GetPixelShaderGPRs(const GX2PixelShader * pShader);
457 
458 /// \brief Function to return the number of stack entries used by the Vertex Shader program output by GSH2CompileProgram
459 ///
460 /// \param pShader Pointer to Vertex Shader
461 /// \return number of stack entries used by the vertex shader program
462 ///
463 /// \donotcall \hostonly \enddonotcall
464 ///
465 GSH2_DECLSPEC u32 GSH2API GSH2GetVertexShaderStackEntries(const GX2VertexShader * pShader);
466 
467 /// \brief Function to return the number of stack entries used by the Geometry Shader program output by GSH2CompileProgram
468 ///
469 /// \param pShader Pointer to Geometry Shader
470 /// \return number of stack entries used by the geometry shader program
471 ///
472 /// \donotcall \hostonly \enddonotcall
473 ///
474 GSH2_DECLSPEC u32 GSH2API GSH2GetGeometryShaderStackEntries(const GX2GeometryShader * pShader);
475 
476 /// \brief Function to return the number of stack entries used by the Pixel Shader program output by GSH2CompileProgram
477 ///
478 /// \param  pShader Pointer to Pixel Shader
479 /// \return number of stack entries used by the pixel shader program
480 ///
481 /// \donotcall \hostonly \enddonotcall
482 ///
483 GSH2_DECLSPEC u32 GSH2API GSH2GetPixelShaderStackEntries(const GX2PixelShader * pShader);
484 
485 /// \brief Output a Display List (DL) containing the GPU commands produced by
486 /// the analogous GX2 API, \ref GX2SetFetchShader.  Also outputs the associated
487 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns
488 /// the size of the DL produced.  After use, this DL must be passed to
489 /// \ref GSH2FreeDL to free the associated memory.
490 ///
491 /// \param pShader GX2FetchShader input used to create DL
492 /// \param displayList DL address created by offline GX2 API
493 /// \param entry patch entry created by offline GX2 API
494 /// \return number of bytes allocated for the DL
495 ///
496 /// \donotcall \hostonly \userheap \enddonotcall
497 ///
498 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetFetchShaderDL(const GX2FetchShader * pShader, void **displayList, GSH2PatchEntry *entry);
499 
500 /// \brief Output a Display List (DL) containing the GPU commands produced by
501 /// the analogous GX2 API, \ref GX2SetGeometryShader.  Also outputs the
502 /// associated \ref GSH2PatchEntry's required for Cafe to patch the DL at runtime.
503 /// Returns the size of the DL produced.  After use, this DL must be passed to
504 /// \ref GSH2FreeDL to free the associated memory.
505 ///
506 /// \param pShader GX2GeometryShader input used to create DL
507 /// \param displayList DL address created by offline GX2 API
508 /// \param entry1 first patch entry created by offline GX2 API
509 /// \param entry2 second patch entry created by offline GX2 API
510 /// \return number of bytes allocated for the DL
511 ///
512 /// \donotcall \hostonly \userheap \enddonotcall
513 ///
514 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetGeometryShaderDL(const GX2GeometryShader * pShader, void **displayList, GSH2PatchEntry *entry1, GSH2PatchEntry *entry2);
515 
516 /// \brief Output a Display List (DL) containing the GPU commands produced by
517 /// the analogous GX2 API, \ref GX2SetPixelShader.  Also outputs the associated
518 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns the size
519 /// of the DL produced.  After use, this DL must be passed to
520 /// \ref GSH2FreeDL to free the associated memory.
521 ///
522 /// \param pShader GX2PixelShader input used to create DL
523 /// \param displayList DL address created by offline GX2 API
524 /// \param entry patch entry created by offline GX2 API
525 /// \return number of bytes allocated for the DL
526 ///
527 /// \donotcall \hostonly \userheap \enddonotcall
528 ///
529 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetPixelShaderDL(const GX2PixelShader * pShader, void **displayList, GSH2PatchEntry *entry);
530 
531 /// \brief Output a Display List (DL) containing the GPU commands produced by
532 /// the analogous GX2 API, \ref GX2SetVertexShader.  Also outputs the associated
533 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns the size
534 /// of the DL produced.  After use, this DL must be passed to
535 /// \ref GSH2FreeDL to free the associated memory.
536 ///
537 /// \param pShader GX2VertexShader input used to create DL
538 /// \param displayList DL address created by offline GX2 API
539 /// \param entry patch entry created by offline GX2 API
540 /// \return number of bytes allocated for the DL
541 ///
542 /// \donotcall \hostonly \userheap \enddonotcall
543 ///
544 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetVertexShaderDL(const GX2VertexShader * pShader, void **displayList, GSH2PatchEntry *entry);
545 
546 /// \brief Output a Display List (DL) containing the GPU commands produced by
547 /// the analogous GX2 API, \ref GX2SetComputeShader.  Also outputs the
548 /// associated GX2PatchEntry required for Cafe to patch the DL at runtime.
549 /// Returns the size of the DL produced.  After use, this DL must be passed to
550 /// \ref GSH2FreeDL to free the associated memory.
551 ///
552 /// \param pShader GX2ComputeShader input used to create DL
553 /// \param displayList DL address created by offline GX2 API
554 /// \param entry patch entry created by offline GX2 API
555 /// \return number of bytes allocated for the DL
556 ///
557 /// \donotcall \hostonly \userheap \enddonotcall
558 ///
559 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetComputeShaderDL(const GX2ComputeShader * pShader, void **displayList, GSH2PatchEntry *entry);
560 
561 /// \brief Frees an offline  Display List (DL) created by GSH2.
562 ///
563 /// \param displayList DL address to be freed
564 ///
565 /// \donotcall \hostonly \userheap \enddonotcall
566 ///
567 GSH2_DECLSPEC void GSH2API GSH2FreeDL(void *displayList);
568 
569 /// @}
570 
571 #if defined(__cplusplus)
572 }
573 #endif
574 
575 
576 #endif  //#ifndef _SHADERUTILS_H
577