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 // 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 u32 getBuildTimeStats : 1; ///< if set, GSH2CompileSetup3 field bt_stats is present 160 }; 161 u32 value; 162 } GSH2Options; 163 164 165 /// \brief Information needed to compile the shaders 166 typedef struct 167 { 168 const char* vs_source; ///< VS shader source code 169 const char* ps_source; ///< PS shader source code 170 const char* gs_source; ///< GS shader source code 171 const char** so_varyings; ///< stream out varyings 172 u32 numSOVaryings; ///< number of stream out varyings 173 174 GSH2Options options; ///< configuration options 175 GSH2ShaderLang lang; ///< shader language 176 } GSH2CompileSetup; 177 178 /// \brief GPU instruction usage statistics from the AMD compiler 179 typedef struct 180 { 181 /// Total hardware instructions used (control flow + ALU + TEXTURE + NOP) 182 u32 uNumInst; 183 184 /// Number of hardware GPRs used 185 u32 uNumTempReg; 186 187 /// 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. 188 u32 uNumClauseTempReg; 189 190 /// The GPR pool size for this type of shader. This is the max number of GPRs that any shader can use. 191 u32 uGPRPoolSize; 192 193 /// Number of ALU Instructions used 194 u32 uNumALUInst; 195 196 /// Number of TFETCHinstructions / Tx Units used 197 u32 uNumTfetchInst; 198 199 /// Number of VFETCH instructions used; generally only dynamic indexing on uniform buffers will affect this (most VFETCHes are in the fetch shader). 200 u32 uNumVfetchInst; 201 202 /// Number of Control flow instructions used. Control flow instructions typically initiate clauses (ALU caluse, texture fetch clause, etc.) 203 u32 uNumCflowInst; 204 205 /// Number of external and internal HW ALU Constants used. This includes uniform variables and also internal constants generated by the compiler; the number of internal constants is difficult to predict. 206 u32 uNumALUConstReg; 207 208 } GSH2ShaderStats; 209 210 211 /// \brief Shader compiler build time statistics 212 typedef struct 213 { 214 /// number of members of elapsed fields 215 int elapsedCount; 216 217 /// Time taken in various compiler passes (in milliseconds) 218 double elapsed[GSH2_BT_NUMITEMS]; 219 220 } GSH2BuildTimeStats; 221 222 /// \brief Information needed to compile the shaders; adds more fields for Spark Enhanced Shader Support 223 224 typedef struct 225 { 226 // NOTE: only add new fields at the end of the structure 227 // (otherwise old tools and new SDKs will not be able to mix) 228 const char* vs_source; ///< VS shader source code 229 const char* ps_source; ///< PS shader source code 230 const char* gs_source; ///< GS shader source code 231 const char** so_varyings; ///< stream out varyings 232 u32 numSOVaryings; ///< number of stream out varyings 233 234 GSH2Options options; ///< configuration options 235 GSH2ShaderLang lang; ///< shader language 236 237 const char* vs_source_filename; ///< VS shader source code file name 238 const char* ps_source_filename; ///< PS shader source code file name 239 const char* gs_source_filename; ///< GS shader source code file name 240 241 const char* spark_output_dir; ///< NULL for default; or directory where to write Spark data 242 243 // anything below here can only be accessed if the corresponding bit is set in options 244 // (so we know it's been set up properly by the caller) 245 u64 optimizeFlags; ///< optimization flags; valid if options.optFlagsPresent is 1. 246 ///< See optflags.h for definitions. 247 GSH2ShaderStats *ps_stats; ///< shader statistics for pixel shader; valid if options.getStats is 1 248 GSH2ShaderStats *vs_stats; ///< shader statistics for vertex shader; valid if options.getStats is 1 249 GSH2ShaderStats *gs_stats; ///< shader statistics for geometry shader; valid if options.getStats is 1 250 251 } GSH2CompileSetup2; 252 253 /// \brief Information needed to compile the shaders; adds more fields for compute shaders and future expansion 254 255 typedef struct 256 { 257 u32 abi_version; ///< version of the binary interface to shaderUtils.dll 258 const char* vs_source; ///< VS shader source code 259 const char* ps_source; ///< PS shader source code 260 const char* gs_source; ///< GS shader source code 261 const char** so_varyings; ///< stream out varyings 262 u32 numSOVaryings; ///< number of stream out varyings 263 264 GSH2Options options; ///< configuration options 265 GSH2ShaderLang lang; ///< shader language 266 267 const char* vs_source_filename; ///< VS shader source code file name 268 const char* ps_source_filename; ///< PS shader source code file name 269 const char* gs_source_filename; ///< GS shader source code file name 270 271 const char* spark_output_dir; ///< NULL for default; or directory for Spark output 272 273 u64 optimizeFlags; ///< optimization flags; valid if options.optFlagsPresent is 1 274 ///< see optflags.h for definitions 275 GSH2ShaderStats *ps_stats; ///< shader statistics for pixel shader; valid if options.getStats is 1 276 GSH2ShaderStats *vs_stats; ///< shader statistics for vertex shader; valid if options.getStats is 1 277 GSH2ShaderStats *gs_stats; ///< shader statistics for geometry shader; valid if options.getStats is 1 278 GSH2ShaderStats *cs_stats; ///< shader statistics for compute shader; valid if options.getStats is 1 279 280 const char* cs_source; ///< CS shader source code 281 const char* cs_source_filename; ///< CS shader source code file name 282 283 GSH2BuildTimeStats *bt_stats; ///< shader compiler build time statistics 284 u64 reserved[7]; ///< reserved for future use, set to 0 285 } GSH2CompileSetup3; 286 287 /// \brief GX2 shaders 288 typedef struct 289 { 290 GX2VertexShader vs; // VS gx2 shader 291 GX2PixelShader ps; // PS gx2 shader 292 GX2GeometryShader gs; // GS gx2 shader 293 } GSH2GX2Program; 294 295 /// \brief GX2 shaders extended version (includes compute shaders and reserved fields) 296 typedef struct 297 { 298 u32 abi_version; ///< version of the binary interface to shaderUtils 299 GX2VertexShader vs; ///< VS gx2 vertex shader 300 GX2PixelShader ps; ///< PS gx2 pixel shader 301 GX2GeometryShader gs; ///< GS gx2 geometry shader 302 GX2ComputeShader cs; ///< CS gx2 compute shader 303 u32 reserved[7]; ///< reserved for future use, set to 0 304 } GSH2GX2Program3; 305 306 typedef struct 307 { 308 GSH2GX2Program gx2Program; ///< Resulting GX2 shader objects 309 310 const char* pInfoLog; ///< null terminated string that contains information about the last compilation attempt 311 const char* pVSDump; ///< null terminated string that contains the vertex shader debug dump 312 const char* pGSDump; ///< null terminated string that contains the geometry shader debug dump 313 const char* pPSDump; ///< null terminated string that contains the pixel shader debug dump 314 } GSH2CompileOutput; 315 316 typedef struct 317 { 318 u32 abi_version; ///< for binary compatibility between shaderUtils.dll versions 319 GSH2GX2Program3 gx2Program; ///< Resulting GX2 shader objects 320 321 const char* pInfoLog; ///< null terminated string that contains information about the last compilation attempt 322 const char* pVSDump; ///< null terminated string that contains the vertex shader debug dump 323 const char* pGSDump; ///< null terminated string that contains the geometry shader debug dump 324 const char* pPSDump; ///< null terminated string that contains the pixel shader debug dump 325 const char* pCSDump; ///< null terminated string that contains the compute shader debug dump 326 u32 reserved[8]; ///< reserved for future use, set to 0 327 } GSH2CompileOutput3; 328 329 /// \brief GSH patching structure, used for offline display list compilation. 330 /// 331 typedef struct 332 { 333 GX2PatchType type; ///< Type of GX2 entry to patch 334 u32 byteOffset; ///< Byte offset from the start of the 335 /// display list to patch 336 u32 assetID; ///< Reserved for future use, set to 0. 337 u32 objectLoc; ///< Reserved for future use, set to 0. 338 } GSH2PatchEntry; 339 340 /// \brief Initializes the instance of shaderUtils library 341 /// 342 /// \note In multi-threaded use, GSH2Initialize() needs to be called n times from the main thread 343 /// to generate n GSH2Handles, where n is the number of application threads. Each handle should 344 /// then be used exclusively in one of the threads in calls to GSH2CompileProgram. Do not use a 345 /// handle across multiple threads. 346 /// \param pSetup Information needed to initialize library 347 /// 348 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 349 /// 350 GSH2_DECLSPEC GSH2Handle GSH2API GSH2Initialize(GSH2Setup* pSetup); 351 352 /// \brief Destroys the instance of shaderUtils library 353 /// 354 /// \note In multi-threaded use, GSH2Initialize() needs to be called n times from the main thread 355 /// to generate n GSH2Handles, where n is the number of application threads. Each handle should 356 /// then be used exclusively in one of the threads in calls to GSH2CompileProgram. Do not use a 357 /// handle across multiple threads. GSH2Destroy() should be called n times in the main thread for 358 /// cleanup. 359 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 360 /// 361 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 362 /// 363 GSH2_DECLSPEC GX2Boolean GSH2API GSH2Destroy(GSH2Handle h); 364 365 /// \brief Compile source shaders and store in GX2 shader structures. 366 /// 367 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current 368 /// thread. Handles cannot be shared across multiple threads. 369 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 370 /// \param pSetup Compile setup parameters 371 /// \param pOutput Compiler output data 372 /// 373 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 374 /// 375 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram(GSH2Handle h, GSH2CompileSetup *pSetup, GSH2CompileOutput* pOutput); 376 377 /// \brief Compile source shaders and store in GX2 shader structures; adds Spark Enhanced Shader Support. 378 /// 379 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current 380 /// thread. Handles cannot be shared across multiple threads. 381 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 382 /// \param pSetup Compile setup parameters with added Spark information 383 /// \param pOutput Compiler output data 384 /// 385 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 386 /// 387 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram2(GSH2Handle h, GSH2CompileSetup2 *pSetup, GSH2CompileOutput* pOutput); 388 389 /// \brief Compile source shaders and store in GX2 shader structures; adds Compute Shader Support. 390 /// 391 /// \note In multi-threaded use, the handle (h param) should be used exclusively by the current 392 /// thread. Handles cannot be shared across multiple threads. 393 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 394 /// \param pSetup Compile setup parameters with added Spark information 395 /// \param pOutput Compiler output data 396 /// 397 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 398 /// 399 GSH2_DECLSPEC GX2Boolean GSH2API GSH2CompileProgram3(GSH2Handle h, GSH2CompileSetup3 *pSetup, GSH2CompileOutput3* pOutput); 400 401 /// \brief Release allocated resources for the gx2 shaders 402 /// 403 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 404 /// \param pGx2Program Clean up resources allocated in GSH2CompileProgram 405 /// 406 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 407 /// 408 GSH2_DECLSPEC GX2Boolean GSH2API GSH2DestroyGX2Program(GSH2Handle h, GSH2GX2Program* pGx2Program); 409 410 /// \brief Release allocated resources for the gx2 shaders (compute shader version) 411 /// 412 /// \param h handle to instance of shaderUtils lib (returned from GSH2Initialize) 413 /// \param pGx2Program Clean up resources allocated in GSH2CompileProgram 414 /// 415 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 416 /// 417 GSH2_DECLSPEC GX2Boolean GSH2API GSH2DestroyGX2Program3(GSH2Handle h, GSH2GX2Program3* pGx2Program); 418 419 /// \brief Calculate the size of a fetch shader. 420 /// 421 /// \param num_attrib number of attribute 422 /// \param fsType The type of fetch shader to generate 423 /// \param tessMode Tessellation mode, only valid if type is not \ref GX2_FETCH_SHADER_TESSELATION_NONE 424 /// 425 /// \donotcall \hostonly \enddonotcall 426 /// 427 GSH2_DECLSPEC u32 GSH2API GSH2CalcFetchShaderSizeEx(u32 num_attrib, GX2FetchShaderType fsType, GX2TessellationMode tessMode); 428 429 /// \brief Create a fetch shader based on the given attribute stream list. 430 /// 431 /// \param fs User-allocated instance of \ref GX2FetchShader structure 432 /// \param fs_buffer User-allocated aligned buffer for the fetch shader binary code 433 /// \param count Number of attribute streams 434 /// \param attribs User-allocated array of \ref GX2AttribStream structures containing information 435 /// about all attribute streams 436 /// \param type The type of fetch shader to generate 437 /// \param tessMode Tessellation mode, only valid if type is not \ref GX2_FETCH_SHADER_TESSELATION_NONE 438 /// 439 /// \donotcall \hostonly \enddonotcall 440 /// 441 GSH2_DECLSPEC void GSH2API GSH2InitFetchShaderEx(GX2FetchShader* fs, void* fs_buffer, u32 count, 442 const GX2AttribStream* attribs, GX2FetchShaderType type, 443 GX2TessellationMode tessMode); 444 445 /// \brief Function to return the number of GPRs used by the Vertex Shader program output by GSH2CompileProgram 446 /// 447 /// \param pShader Pointer to Vertex Shader 448 /// \return number of GPRs used by the vertex shader program 449 /// 450 /// \donotcall \hostonly \enddonotcall 451 /// 452 GSH2_DECLSPEC u32 GSH2API GSH2GetVertexShaderGPRs(const GX2VertexShader * pShader); 453 454 /// \brief Function to return the number of GPRs used by the Geometry Shader program output by GSH2CompileProgram 455 /// 456 /// \param pShader Pointer to Geometry Shader 457 /// \return number of GPRs used by the geometry shader program 458 /// 459 /// \donotcall \hostonly \enddonotcall 460 /// 461 GSH2_DECLSPEC u32 GSH2API GSH2GetGeometryShaderGPRs(const GX2GeometryShader * pShader); 462 463 /// \brief Function to return the number of GPRs used by the Pixel Shader program output by GSH2CompileProgram 464 /// 465 /// \param pShader shader Pointer to Pixel Shader 466 /// \return number of GPRs used by the pixel shader program 467 /// 468 /// \donotcall \hostonly \enddonotcall 469 /// 470 GSH2_DECLSPEC u32 GSH2API GSH2GetPixelShaderGPRs(const GX2PixelShader * pShader); 471 472 /// \brief Function to return the number of stack entries used by the Vertex Shader program output by GSH2CompileProgram 473 /// 474 /// \param pShader Pointer to Vertex Shader 475 /// \return number of stack entries used by the vertex shader program 476 /// 477 /// \donotcall \hostonly \enddonotcall 478 /// 479 GSH2_DECLSPEC u32 GSH2API GSH2GetVertexShaderStackEntries(const GX2VertexShader * pShader); 480 481 /// \brief Function to return the number of stack entries used by the Geometry Shader program output by GSH2CompileProgram 482 /// 483 /// \param pShader Pointer to Geometry Shader 484 /// \return number of stack entries used by the geometry shader program 485 /// 486 /// \donotcall \hostonly \enddonotcall 487 /// 488 GSH2_DECLSPEC u32 GSH2API GSH2GetGeometryShaderStackEntries(const GX2GeometryShader * pShader); 489 490 /// \brief Function to return the number of stack entries used by the Pixel Shader program output by GSH2CompileProgram 491 /// 492 /// \param pShader Pointer to Pixel Shader 493 /// \return number of stack entries used by the pixel shader program 494 /// 495 /// \donotcall \hostonly \enddonotcall 496 /// 497 GSH2_DECLSPEC u32 GSH2API GSH2GetPixelShaderStackEntries(const GX2PixelShader * pShader); 498 499 /// \brief Output a Display List (DL) containing the GPU commands produced by 500 /// the analogous GX2 API, \ref GX2SetFetchShader. Also outputs the associated 501 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns 502 /// the size of the DL produced. After use, this DL must be passed to 503 /// \ref GSH2FreeDL to free the associated memory. 504 /// 505 /// \param pShader GX2FetchShader input used to create DL 506 /// \param displayList DL address created by offline GX2 API 507 /// \param entry patch entry created by offline GX2 API 508 /// \return number of bytes allocated for the DL 509 /// 510 /// \donotcall \hostonly \userheap \enddonotcall 511 /// 512 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetFetchShaderDL(const GX2FetchShader * pShader, void **displayList, GSH2PatchEntry *entry); 513 514 /// \brief Output a Display List (DL) containing the GPU commands produced by 515 /// the analogous GX2 API, \ref GX2SetGeometryShader. Also outputs the 516 /// associated \ref GSH2PatchEntry's required for Cafe to patch the DL at runtime. 517 /// Returns the size of the DL produced. After use, this DL must be passed to 518 /// \ref GSH2FreeDL to free the associated memory. 519 /// 520 /// \param pShader GX2GeometryShader input used to create DL 521 /// \param displayList DL address created by offline GX2 API 522 /// \param entry1 first patch entry created by offline GX2 API 523 /// \param entry2 second patch entry created by offline GX2 API 524 /// \return number of bytes allocated for the DL 525 /// 526 /// \donotcall \hostonly \userheap \enddonotcall 527 /// 528 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetGeometryShaderDL(const GX2GeometryShader * pShader, void **displayList, GSH2PatchEntry *entry1, GSH2PatchEntry *entry2); 529 530 /// \brief Output a Display List (DL) containing the GPU commands produced by 531 /// the analogous GX2 API, \ref GX2SetPixelShader. Also outputs the associated 532 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns the size 533 /// of the DL produced. After use, this DL must be passed to 534 /// \ref GSH2FreeDL to free the associated memory. 535 /// 536 /// \param pShader GX2PixelShader input used to create DL 537 /// \param displayList DL address created by offline GX2 API 538 /// \param entry patch entry created by offline GX2 API 539 /// \return number of bytes allocated for the DL 540 /// 541 /// \donotcall \hostonly \userheap \enddonotcall 542 /// 543 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetPixelShaderDL(const GX2PixelShader * pShader, void **displayList, GSH2PatchEntry *entry); 544 545 /// \brief Output a Display List (DL) containing the GPU commands produced by 546 /// the analogous GX2 API, \ref GX2SetVertexShader. Also outputs the associated 547 /// \ref GSH2PatchEntry required for Cafe to patch the DL at runtime. Returns the size 548 /// of the DL produced. After use, this DL must be passed to 549 /// \ref GSH2FreeDL to free the associated memory. 550 /// 551 /// \param pShader GX2VertexShader input used to create DL 552 /// \param displayList DL address created by offline GX2 API 553 /// \param entry patch entry created by offline GX2 API 554 /// \return number of bytes allocated for the DL 555 /// 556 /// \donotcall \hostonly \userheap \enddonotcall 557 /// 558 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetVertexShaderDL(const GX2VertexShader * pShader, void **displayList, GSH2PatchEntry *entry); 559 560 /// \brief Output a Display List (DL) containing the GPU commands produced by 561 /// the analogous GX2 API, \ref GX2SetComputeShader. Also outputs the 562 /// associated GX2PatchEntry required for Cafe to patch the DL at runtime. 563 /// Returns the size of the DL produced. After use, this DL must be passed to 564 /// \ref GSH2FreeDL to free the associated memory. 565 /// 566 /// \param pShader GX2ComputeShader input used to create DL 567 /// \param displayList DL address created by offline GX2 API 568 /// \param entry patch entry created by offline GX2 API 569 /// \return number of bytes allocated for the DL 570 /// 571 /// \donotcall \hostonly \userheap \enddonotcall 572 /// 573 GSH2_DECLSPEC u32 GSH2API GSH2CreateSetComputeShaderDL(const GX2ComputeShader * pShader, void **displayList, GSH2PatchEntry *entry); 574 575 /// \brief Frees an offline Display List (DL) created by GSH2. 576 /// 577 /// \param displayList DL address to be freed 578 /// 579 /// \donotcall \hostonly \userheap \enddonotcall 580 /// 581 GSH2_DECLSPEC void GSH2API GSH2FreeDL(void *displayList); 582 583 /// \brief Print build time statistics to a file. 584 /// 585 /// \param pFileName Name of file to contain the statistics. 586 /// \param pStats Pointer to build time statistics 587 /// \param bAppend If GX2_TRUE, append the current times to the ones already in the file; 588 /// otherwise overwrite the file. 589 /// 590 /// \donotcall \notthreadsafe \hostonly \userheap \enddonotcall 591 /// 592 GSH2_DECLSPEC GX2Boolean GSH2API GSH2PrintBuildTimeStats(const char *pFileName, GSH2BuildTimeStats *pStats, GX2Boolean bAppend); 593 594 /// @} 595 596 #if defined(__cplusplus) 597 } 598 #endif 599 600 601 #endif //#ifndef _SHADERUTILS_H 602