diff options
author | SonicMastr | 2020-10-16 19:22:50 -0500 |
---|---|---|
committer | Reiko Asakura | 2020-10-16 19:22:50 -0500 |
commit | 83bbd3ee5326300f317e9b345fddb0067e7bdd10 (patch) | |
tree | 37d023553a80d732cacb9769ceb7d0e64db95ab4 | |
parent | Add psp2/audiocodec.h (diff) | |
download | vds-libraries-83bbd3ee5326300f317e9b345fddb0067e7bdd10.tar.gz |
Added ShaccCg Headers
https://github.com/DolceSDK/headers/pull/12
-rw-r--r-- | include/user/shacccg.h | 213 | ||||
-rw-r--r-- | include/user/shacccg/paramquery.h | 527 | ||||
-rw-r--r-- | include/user/shacccg/types.h | 448 | ||||
-rw-r--r-- | nids/SceShaccCg.yml | 38 |
4 files changed, 1226 insertions, 0 deletions
diff --git a/include/user/shacccg.h b/include/user/shacccg.h new file mode 100644 index 0000000..14ce8b8 --- /dev/null +++ b/include/user/shacccg.h @@ -0,0 +1,213 @@ +#ifndef _DOLCESDK_PSP2_SHACCCG_H_ +#define _DOLCESDK_PSP2_SHACCCG_H_ + +#include "psp2/shacccg/types.h" +#include "psp2/shacccg/paramquery.h" +#include "psp2common/types.h" + +#ifdef __cplusplus +extern "C" { +#endif // def __cplusplus + +/////////////////////////////////////////////////////////////////////////////// +// Typedefs +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Describes the output of dependency generation. + + @ingroup shacccg +*/ +typedef struct SceShaccCgDependencyOutput { + SceInt32 dependencyTargetCount; ///< The number of dependencies. + const SceChar8* const *dependencyTargets; ///< The individual target rules. + SceInt32 diagnosticCount; ///< The number of diagnostics. + const SceShaccCgDiagnosticMessage *diagnostics; ///< The diagnostic message array. +} SceShaccCgDependencyOutput; + +/** @brief Describes the output of a compilation process. + + On failure, programData will be 0 and the diagnosticCount will be non-zero. + On success, programData will be non-zero and one or more non-error + diagnostics may be present. + + @ingroup shacccg +*/ +typedef struct SceShaccCgCompileOutput { + const SceUInt8 *programData; ///< The compiled program binary data. + SceInt32 programSize; ///< The compiled program size. + SceInt32 diagnosticCount; ///< The number of diagnostics. + const SceShaccCgDiagnosticMessage *diagnostics; ///< The diagnostic message array. +} SceShaccCgCompileOutput; + +/** @brief Describes the output of a preprocessor process. + + On failure, program will be 0 and the diagnosticCount will be non-zero. + On success, program will be non-zero and one or more non-error + diagnostics may be present. + + @ingroup shacccg +*/ +typedef struct SceShaccCgPreprocessOutput { + const SceChar8 *program; ///< The preprocessor output. + SceInt32 programSize; ///< The preprocessor output size. + SceInt32 diagnosticCount; ///< The number of diagnostics. + const SceShaccCgDiagnosticMessage *diagnostics; ///< The diagnostic message array. +} SceShaccCgPreprocessOutput; + +/////////////////////////////////////////////////////////////////////////////// +// Functions +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Compiles a Cg program for PSP2 + + Compiles a program for PSP2 using the options provided. + + @param[in] options + Indicates the compile options for compiling a program. + Also doubles as a session id where multiple compiles are being run. + + @param[in] callbacks + Defines the callbacks to be used for file system access. If not provided, + the default file system of the OS will be used (optional). + + @param[in] userData + Opaque pointer to user data that will be passed back to callbacks. + + @return + A SceShaccCgCompileOutput object, containing the binary and sdb + outputs of the compile. Must be destroyed using + sceShaccCgDestroyCompileOutput. If 0 is returned, the input arguments were + malformed. + + @ingroup shacccg +*/ +SceShaccCgCompileOutput const* sceShaccCgCompileProgram( + const SceShaccCgCompileOptions *options, + const SceShaccCgCallbackList *callbacks, + ScePVoid userData); + +/** @brief Releases all allocations associated with a compiled program. + + @param[in] output + The result from a call to sceShaccCgCompileProgram, to be destroyed. + + @ingroup shacccg +*/ +SceVoid sceShaccCgDestroyCompileOutput( + SceShaccCgCompileOutput const *output); + +/** @brief Preprocesses a Cg program for PSP2 + + Compiles a program for PSP2 using the options provided. Callbacks may be + provided, but are optional. (see note on struct SceShaccCgCallbackList) + + @param options + Indicates the compile options for preprocessing a program. + Also doubles as a session id where multiple compiles are being run. + + @param callbacks + Defines the callbacks to be used for file system access. If not provided, + the default PSP2 file system will be used (optional). + + @param userData + Opaque pointer to user data that will be passed back to callbacks. + + @param emitLineDirectives + Indicates whether to emit #line directives in the output. + + @param emitComments + Indicates whether to retain comments in the output. + + @return + A SceShaccCgPreprocessOutput object, containing the UTF-8 encoded + text of the preprocessed program. Must be destroyed using + sceShaccCgDestroyPreprocessOutput. If 0 is returned the input arguments were + malformed. + + @ingroup shacccg +*/ +SceShaccCgPreprocessOutput const* sceShaccCgPreprocessProgram( + const SceShaccCgCompileOptions *options, + const SceShaccCgCallbackList *callbacks, + ScePVoid userData, + SceInt32 emitLineDirectives, + SceInt32 emitComments); + +/** @brief Releases all allocations associated with a compiled program. + + @param[in] output + The result from a call to sceShaccCgPreprocessProgram, to be destroyed. + + @ingroup shacccg +*/ +SceVoid sceShaccCgDestroyPreprocessOutput( + SceShaccCgPreprocessOutput const *output); + +/** @brief Generates dependency information for a program. + + Generates dependency information for the given compilation options. + + @param[in] options + Indicates the compile options for generating the file dependencies for a + program. Also doubles as a session id where multiple compiles are being run. + + @param[in] callbacks + Defines the callbacks to be used for file system access. If not provided, + the default PSP2 file system will be used (optional). + + @param userData + Opaque pointer to user data that will be passed back to callbacks. + + @param[in] targetName + The name of the main target rule. Because we have no concept of the final + binary name at this point, this must always be provided. + + @param[in] emitPhonies + Non-zero indicates that phony dependencies should be generated. + + @return + A SceShaccCgDependencyOutput object, containing a list of file names and + their dependent files. Should be destroyed using + sceShaccCgDestroyDependencyOutput. If 0 is returned, the input arguments + were malformed. + + @ingroup shacccg +*/ +SceShaccCgDependencyOutput const* sceShaccCgGenerateDependencies( + const SceShaccCgCompileOptions *options, + const SceShaccCgCallbackList *callbacks, + ScePVoid userData, + const SceChar8 *targetName, + SceInt32 emitPhonies); + +/** @brief Releases all allocations associated with the dependency output. + + @param[in] output + The result from a call to sceShaccCgGenerateDependencies, to be destroyed. + + @ingroup shacccg +*/ +SceVoid sceShaccCgDestroyDependencyOutput( + SceShaccCgDependencyOutput const *output); + +/** @brief Sets memory allocation callbacks + + Sets memory allocation callbacks for SceShaccCg library + + @param[in] memAlloc + Function used for memory allocation. + + @param[in] memFree + Function used to free memory. + + @ingroup shacccg +*/ +SceInt32 sceShaccCgSetMemAllocator( + SceShaccCgMemAllocator memAlloc, + SceShaccCgMemFree memFree); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DOLCESDK_PSP2_SHACCCG_H_ */ diff --git a/include/user/shacccg/paramquery.h b/include/user/shacccg/paramquery.h new file mode 100644 index 0000000..3969330 --- /dev/null +++ b/include/user/shacccg/paramquery.h @@ -0,0 +1,527 @@ +#ifndef _DOLCESDK_PSP2_SHACCCG_PARAMQUERY_H_ +#define _DOLCESDK_PSP2_SHACCCG_PARAMQUERY_H_ + +#include "psp2common/types.h" + +#ifdef __cplusplus +extern "C" { +#endif // def __cplusplus + +/////////////////////////////////////////////////////////////////////////////// +// Forward declarations +/////////////////////////////////////////////////////////////////////////////// +typedef void const * SceShaccCgParameter; +typedef struct SceShaccCgCompileOutput SceShaccCgCompileOutput; + +/////////////////////////////////////////////////////////////////////////////// +// Constants +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Classifies shader parameter class + + @ingroup shacccg +*/ +typedef enum SceShaccCgParameterClass { + SCE_SHACCCG_PARAMETERCLASS_INVALID = 0x00, ///< An invalid parameter class. + SCE_SHACCCG_PARAMETERCLASS_SCALAR = 0x01, ///< Scalar parameter class. + SCE_SHACCCG_PARAMETERCLASS_VECTOR = 0x02, ///< Vector parameter class. + SCE_SHACCCG_PARAMETERCLASS_MATRIX = 0x03, ///< Matrix parameter class. + SCE_SHACCCG_PARAMETERCLASS_STRUCT = 0x04, ///< Struct parameter class. + SCE_SHACCCG_PARAMETERCLASS_ARRAY = 0x05, ///< Array parameter class. + SCE_SHACCCG_PARAMETERCLASS_SAMPLER = 0x06, ///< Sampler parameter class. + SCE_SHACCCG_PARAMETERCLASS_UNIFORMBLOCK = 0x07 ///< Uniform Block parameter class. +} SceShaccCgParameterClass; + +/** @brief Classifies shader parameter data format + + @ingroup shacccg +*/ +typedef enum SceShaccCgParameterBaseType { + SCE_SHACCCG_BASETYPE_INVALID = 0x00, ///< An invalid format. + SCE_SHACCCG_BASETYPE_FLOAT = 0x01, ///< Full precision 32-bit floating point. + SCE_SHACCCG_BASETYPE_HALF = 0x02, ///< Half precision 16-bit floating point. + SCE_SHACCCG_BASETYPE_FIXED = 0x03, ///< 2.8 fixed point precision. + SCE_SHACCCG_BASETYPE_BOOL = 0x04, ///< Boolean value. + SCE_SHACCCG_BASETYPE_CHAR = 0x05, ///< Signed char (8-bit) value. + SCE_SHACCCG_BASETYPE_UCHAR = 0x06, ///< Unsigned char (8-bit) value. + SCE_SHACCCG_BASETYPE_SHORT = 0x07, ///< Signed short (16-bit) value. + SCE_SHACCCG_BASETYPE_USHORT = 0x08, ///< Unsigned short (16-bit) value. + SCE_SHACCCG_BASETYPE_INT = 0x09, ///< Signed int (32-bit) value. + SCE_SHACCCG_BASETYPE_UINT = 0x0a, ///< Unsigned int (32-bit) value. + SCE_SHACCCG_BASETYPE_SAMPLER1D = 0x0b, ///< 1D sampler + SCE_SHACCCG_BASETYPE_ISAMPLER1D = 0x0c, ///< 1D signed integer sampler + SCE_SHACCCG_BASETYPE_USAMPLER1D = 0x0d, ///< 1D unsigned integer sampler + SCE_SHACCCG_BASETYPE_SAMPLER2D = 0x0e, ///< 2D sampler + SCE_SHACCCG_BASETYPE_ISAMPLER2D = 0x0f, ///< 2D signed integer sampler + SCE_SHACCCG_BASETYPE_USAMPLER2D = 0x10, ///< 2D unsigned integer sampler + SCE_SHACCCG_BASETYPE_SAMPLERCUBE = 0x11, ///< Cube sampler + SCE_SHACCCG_BASETYPE_ISAMPLERCUBE = 0x12, ///< Cube signed integer sampler + SCE_SHACCCG_BASETYPE_USAMPLERCUBE = 0x13, ///< Cube unsigned integer sampler + SCE_SHACCCG_BASETYPE_ARRAY = 0x17, ///< An array + SCE_SHACCCG_BASETYPE_STRUCT = 0x18, ///< A structure + SCE_SHACCCG_BASETYPE_UNIFORMBLOCK = 0x19 ///< A uniform block +} SceShaccCgParameterBaseType; + + +/////////////////////////////////////////////////////////////////////////////// +// Structs +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Classifies matrix memory layout + + @ingroup shacccg +*/ +typedef enum SceShaccCgParameterMemoryLayout +{ + SCE_SHACCCG_MEMORYLAYOUT_INVALID, ///< Invalid memory layout + SCE_SHACCCG_MEMORYLAYOUT_COLUMN_MAJOR, ///< Column major memory layout + SCE_SHACCCG_MEMORYLAYOUT_ROW_MAJOR ///< Row major memory layout +} SceShaccCgParameterMemoryLayout; + +/** @brief Classifies shader parameter variability + + @ingroup shacccg +*/ +typedef enum SceShaccCgParameterVariability +{ + SCE_SHACCCG_VARIABILITY_INVALID, ///< Invalid variability + SCE_SHACCCG_VARIABILITY_VARYING, ///< Parameter is varying + SCE_SHACCCG_VARIABILITY_UNIFORM ///< Parameter is uniform +} SceShaccCgParameterVariability; + +/** @brief Classifies shader parameter direction + + @ingroup shacccg +*/ +typedef enum SceShaccCgParameterDirection +{ + SCE_SHACCCG_DIRECTION_INVALID, ///< Invalid direction + SCE_SHACCCG_DIRECTION_IN, ///< Parameter is input + SCE_SHACCCG_DIRECTION_OUT ///< Parameter is output +} SceShaccCgParameterDirection; + + +/////////////////////////////////////////////////////////////////////////////// +// Functions +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Start parameter enumeration. + + Start parameter enumeration. + + @param[in] prog + The output of a successful shader compilation. + + @return + A SceShaccCgParameter object representing the first parameter in the shader. + If 0 is returned, the input argument was malformed or the shader has no public + symbols. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetFirstParameter( + SceShaccCgCompileOutput const* prog); + +/** @brief Access the next parameter in the global list of shader parameter. + + Access the next parameter in the global list of shader parameter. + + @param[in] param + The current parameter object. + + @return + A SceShaccCgParameter object representing the next parameter, or NULL if there are + no more parameters. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetNextParameter( + SceShaccCgParameter param); + +/** @brief Find a parameter by its name. + + Find a parameter by its name. + + @param[in] prog + The output of a successful shader compilation. + + @param[in] name + The name of the parameter. + + @return + A SceShaccCgParameter object representing the parameter or NULL if the + parameter was not found. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetParameterByName( + SceShaccCgCompileOutput const* prog, + SceChar8 const *name); + +/** @brief Returns the name of a parameter. + + Returns the name of a parameter. + + @param[in] param + The parameter object. + + @return + A NULL terminated string containing the name of the parameter + + @ingroup shacccg +*/ +const SceChar8 *sceShaccCgGetParameterName( + SceShaccCgParameter param); + +/** @brief Returns the semantic of a parameter. + + Returns the semantic of a parameter. + + @param[in] param + The parameter object. + + @return + A NULL terminated string containing the semantic of the parameter or NULL + if no semantic was declared + + @ingroup shacccg +*/ +const SceChar8 *sceShaccCgGetParameterSemantic( + SceShaccCgParameter param); + +/** @brief Returns the user declared type of a parameter. + + Returns the user declared type of a parameter. + + @param[in] param + The parameter object. + + @return + A NULL terminated string containing the user declared type of the parameter or NULL + if no user declared type was used + + @ingroup shacccg +*/ +const SceChar8 *sceShaccCgGetParameterUserType( + SceShaccCgParameter param); + +/** @brief Returns the parameter class. + + Returns the parameter class. + + @param[in] param + The parameter object. + + @return + The SceShaccCgParameterClass value this parameter is part of. + + @ingroup shacccg +*/ +SceShaccCgParameterClass sceShaccCgGetParameterClass( + SceShaccCgParameter param); + +/** @brief Returns the parameter variability. + + Returns the parameter variability. + + @param[in] param + The parameter object. + + @return + The SceShaccCgParameterVariability value for the parameter. + + @ingroup shacccg +*/ +SceShaccCgParameterVariability sceShaccCgGetParameterVariability( + SceShaccCgParameter param); + +/** @brief Returns the parameter direction. + + Returns the parameter direction. + + @param[in] param + The parameter object. + + @return + The SceShaccCgParameterDirection value for the parameter. + + @ingroup shacccg +*/ +SceShaccCgParameterDirection sceShaccCgGetParameterDirection( + SceShaccCgParameter param); + +/** @brief Returns the parameter base type. + + Returns the parameter base type. + + @param[in] param + The parameter object. + + @return + The SceShaccCgParameterBaseType value for the parameter. + + @ingroup shacccg +*/ +SceShaccCgParameterBaseType sceShaccCgGetParameterBaseType( + SceShaccCgParameter param); + +/** @brief Returns true if the parameter is referenced. + + Returns true if the parameter is referenced. + + @param[in] param + The parameter object. + + @return + 1 if the value is referenced, otherwise return 0 if the parameter is dead. + + @ingroup shacccg +*/ +SceInt32 sceShaccCgIsParameterReferenced( + SceShaccCgParameter param); + +/** @brief Returns the hw resource index of the parameter. + + Returns the hw resource index of the parameter. + + @param[in] param + The parameter object. + + @return + The resource index or a value of -1 if no resource is assigned to this parameter. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetParameterResourceIndex( + SceShaccCgParameter param); + +/** @brief Returns the buffer index of the parameter. + + Returns the buffer index of the parameter. + + @param[in] param + The parameter object. + + @return + The buffer index or a value of -1 if no buffer is assigned to this parameter. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetParameterBufferIndex( + SceShaccCgParameter param); + +/** @brief Returns true if the parameter is __regformat. + + Returns true if the parameter is __regformat. + + @param[in] param + The parameter object. + + @return + 1 if the value is __regformat, otherwise return 0. + + @ingroup shacccg +*/ +SceInt32 sceShaccCgIsParameterRegFormat( + SceShaccCgParameter param); + +/** @brief Returns the first member for a struct parameter. + + Returns the first member for a struct parameter. + + @param[in] param + The parameter object. + + @return + The parameter object for the first member of a struct or NULL if the parameter was + malformed. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetFirstStructParameter( + SceShaccCgParameter param); + +/** @brief Returns the first member for a uniform block parameter. + + Returns the first member for a uniform block parameter. + + @param[in] param + The parameter object. + + @return + The parameter object for the first member of a uniform block or NULL if the parameter was + malformed. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetFirstUniformBlockParameter( + SceShaccCgParameter param); + +/** @brief Returns the size of an array. + + Returns the size of an array. + + @param[in] param + The parameter object. + + @return + The size of an array parameter in terms of the number of elements. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetArraySize( + SceShaccCgParameter param); + +/** @brief Returns the parameter for an array element. + + Returns the parameter for an array element. + + @param[in] aparam + The array parameter object. + + @param[in] index + The array index. + + @return + The parameter object for the element associated with the array index. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetArrayParameter( + SceShaccCgParameter aparam, + uint32_t index); + +/** @brief Returns the vector width for a vector parameter. + + Returns the vector width for a vector parameter. + + @param[in] param + The vector parameter object. + + @return + The width of the vector parameter. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetParameterVectorWidth( + SceShaccCgParameter param); + +/** @brief Returns the number of columns for a matrix parameter. + + Returns the number of columns for a matrix parameter. + + @param[in] param + The matrix parameter object. + + @return + The number of columns for a matrix parameter + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetParameterColumns( + SceShaccCgParameter param); + +/** @brief Returns the number of rows for a matrix parameter. + + Returns the number of rows for a matrix parameter. + + @param[in] param + The matrix parameter object. + + @return + The number of rows for a matrix parameter + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetParameterRows( + SceShaccCgParameter param); + +/** @brief Returns the memory layout for a matrix parameter. + + Returns the memory layout for a matrix parameter. + + @param[in] param + The matrix parameter object. + + @return + The SceShaccCgParameterMemoryLayout for the matrix parameter. + + @ingroup shacccg +*/ +SceShaccCgParameterMemoryLayout sceShaccCgGetParameterMemoryLayout( + SceShaccCgParameter param); + +/** @brief Returns the parameter for a row of a matrix parameter. + + Returns the parameter for a row of a matrix parameter. + + @param[in] param + The matrix parameter object. + + @param[in] index + The row index. + + @return + The parameter object for the row paramater. + + @ingroup shacccg +*/ +SceShaccCgParameter sceShaccCgGetRowParameter( + SceShaccCgParameter param, + uint32_t index); + +/** @brief Returns the query format component count for a sampler parameter. + + Returns the query format component count for a sampler parameter. + + @param[in] param + The sampler parameter object. + + @return + The query format component count. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetSamplerQueryFormatWidth( + SceShaccCgParameter param); + +/** @brief Returns the number of different precisions used to as query format for sampler parameter. + + Returns the number of different precisions used to as query format for sampler parameter. + + @param[in] param + The sampler parameter object. + + @return + count of different precisions used to as query format. + + @ingroup shacccg +*/ +SceUInt32 sceShaccCgGetSamplerQueryFormatPrecisionCount( + SceShaccCgParameter param); + +/** @brief Returns query precision format for a sampler parameter. + + Returns query precision format for a sampler parameter. + + @param[in] param + The sampler parameter object. + + @param[in] index + The index of the precision format. + + @return + query precision format. + + @ingroup shacccg +*/ +SceShaccCgParameterBaseType sceShaccCgGetSamplerQueryFormatPrecision( + SceShaccCgParameter param, + SceUInt32 index); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DOLCESDK_PSP2_SHACCCG_PARAMQUERY_H_ */ diff --git a/include/user/shacccg/types.h b/include/user/shacccg/types.h new file mode 100644 index 0000000..81465d3 --- /dev/null +++ b/include/user/shacccg/types.h @@ -0,0 +1,448 @@ +#ifndef _DOLCESDK_PSP2_SHACCCG_TYPES_H_ +#define _DOLCESDK_PSP2_SHACCCG_TYPES_H_ + +#include "psp2common/types.h" + +#ifdef __cplusplus +extern "C" { +#endif // def __cplusplus + + +/////////////////////////////////////////////////////////////////////////////// +// Forward declarations +/////////////////////////////////////////////////////////////////////////////// + +typedef struct SceShaccCgCompileOptions SceShaccCgCompileOptions; +typedef struct SceShaccCgSourceFile SceShaccCgSourceFile; +typedef struct SceShaccCgSourceLocation SceShaccCgSourceLocation; + +/////////////////////////////////////////////////////////////////////////////// +// Typedefs +/////////////////////////////////////////////////////////////////////////////// + +/** @brief A callback used when the compiler needs to open a file. + + The includedFrom location will either be 0, if a primary file is being + opened, or it will point to the location of the #include directive. + If the file could not be opened, 0 is returned and errorString will be + updated to point to a representative message, explaining why the file + could not be opened. + On success, a non-zero pointer is returned. The caller takes ownership, + calling SceShaccCgCallbackReleaseFile when the returned SceShaccCgSourceFile + is no longer required. + + @param[in] fileName + The absolute path of the file to be opened. + + @param[in] includedFrom + The include location. Set to 0 for a primary file. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @param[out] errorString + If 0 is returned and this pointer is non-zero, this output param should + be updated to contain a diagnostic message. + + @return + A SceShaccCgSourceFile object to be destroyed later with + SceShaccCgCallbackReleaseFile. + + @ingroup shacccg +*/ +typedef SceShaccCgSourceFile* (*SceShaccCgCallbackOpenFile)( + const SceChar8 *fileName, + const SceShaccCgSourceLocation *includedFrom, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData, + const SceChar8 **errorString); + +/** @brief A callback used when the compiler needs to release file data. + + This function is used to release memory that was previously allocated as + part of a call to SceShaccCgCallbackOpenFile. This will be called once per + "fileName" associated with that SceShaccCgSourceFile object when the + resources for the compile session are released. + + @param[in] file + The SceShaccCgSourceFile object to be destroyed. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @ingroup shacccg +*/ +typedef void (*SceShaccCgCallbackReleaseFile)( + const SceShaccCgSourceFile *file, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData); + +/** @brief A callback used to search for a named file. + + This function will search in all provided paths for the named file. If the + file could not be located, 0 is returned and errorString will have been + updated to a representative message, explaining why the file could not be + located. + On success, a non-zero string is returned. The caller takes ownership and + will release the allocation via the SceShaccCgCallbackReleaseFileName + callback. + + @param[in] fileName + The name of the file to be located. + + @param[in] includedFrom + The location of the include directive. Set to 0 for primary files. + + @param[in] searchPathCount + The number of search paths provided via 'searchPaths'. + + @param[in] searchPaths + The array of search paths. The size is provided via 'searchPathCount'. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @param[out] errorString + If 0 is returned and if this pointer is non-zero, it should be updated + to contain a diagnostic message. + + @return + A relative or absolute path to the file or 0 if the file could not be + located. + + @ingroup shacccg +*/ +typedef const char* (*SceShaccCgCallbackLocateFile)( + const SceChar8 *fileName, + const SceShaccCgSourceLocation *includedFrom, + SceUInt32 searchPathCount, + const SceChar8 *const*searchPaths, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData, + const SceChar8 **errorString); + +/** @brief A callback used to retrieve the absolute path name for a given file. + + Files are uniquely identified by absolute paths. If two include files lead + to the same absolute path, the previously found file is used and no call + to SceShaccCgCallbackOpenFile will be made. This function allows for a + translation from a relative path scheme to an absolute path scheme. + + If there is no valid absolute path for the given file, 0 should be returned. + If a non-zero string is returned, the caller takes ownership and will release + the allocation via the SceShaccCgCallbackReleaseFileName callback. + This string will be the name passed to SceShaccCgCallbackOpenFile. + + @param[in] fileName + The (possibly relative) file path for an include file, as provided + by SceShaccCgCallbackLocateFile. + + @param[in] includedFrom + The location of the include directive. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @return + The absolute file path or 0 if the file could not be located. + + @ingroup shacccg +*/ +typedef const char* (*SceShaccCgCallbackAbsolutePath)( + const SceChar8 *fileName, + const SceShaccCgSourceLocation *includedFrom, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData); + +/** @brief A callback for the compiler to release a file name. + + This function is used to release memory that was previously allocated as + part of a call to SceShaccCgCallbackLocateFile or + SceShaccCgCallbackAbsolutePath. + + @param[in] fileName + The file name string to be destroyed. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @ingroup shacccg +*/ +typedef void (*SceShaccCgCallbackReleaseFileName)( + const SceChar8 *fileName, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData); + +/** @brief Provides date information for the named file. + + If the date attributes could not be read, 0 is returned and the results + will be considered invalid. + On success, timeLastStatusChange and timeLastModified will have been + updated and a non-zero value is returned. + The time values are encoded as time_t. + + @param[in] file + A file object returned from SceShaccCgCallbackOpenFile. + + @param[in] includedFrom + The location of the include directive. + + @param[in] compileOptions + The original options pointer used to invoke this compile. + + @param[in] userData + Opaque pointer to user data. + + @param[out] timeLastStatusChange + A pointer to the time of last status change (i.e. creationTime). + + @param[out] timeLastModified + A pointer to the time of last modification. + + @return + Non-zero for success, 0 on failure. + + @ingroup shacccg +*/ +typedef SceInt32 (*SceShaccCgCallbackFileDate)( + const SceShaccCgSourceFile *file, + const SceShaccCgSourceLocation *includedFrom, + const SceShaccCgCompileOptions *compileOptions, + ScePVoid userData, + SceInt64 *timeLastStatusChange, ///< using time_t + SceInt64 *timeLastModified); ///< using time_t + +/** @brief A callback used when the compiler needs to allocate memory. + + This function is used to allocate memory. Memory must be 8 bytes aligned. + + @param[in] memSize + Memory size. + + @ingroup shacccg +*/ +typedef ScePVoid (*SceShaccCgMemAllocator)( + SceSize memSize); + +/** @brief A callback used when the compiler needs to free memory. + + This function is used to free memory. + + @param[in] memPtr + Pointer to a memory block previously allocated with SceShaccCgMemAllocator + + @ingroup shacccg +*/ +typedef SceVoid (*SceShaccCgMemFree)( + ScePVoid ptr); + +/////////////////////////////////////////////////////////////////////////////// +// Constants +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Classifies the severity of a diagnostic + + @ingroup shacccg +*/ +typedef enum SceShaccCgDiagnosticLevel { + SCE_SHACCCG_DIAGNOSTIC_LEVEL_INFO, ///< Informational message + SCE_SHACCCG_DIAGNOSTIC_LEVEL_WARNING, ///< Warning + SCE_SHACCCG_DIAGNOSTIC_LEVEL_ERROR ///< Error +} SceShaccCgDiagnosticLevel; + +/** @brief Classifies the target profiles + + @ingroup shacccg +*/ +typedef enum SceShaccCgTargetProfile { + SCE_SHACCCG_PROFILE_VP, ///< vertex program + SCE_SHACCCG_PROFILE_FP ///< fragment program +} SceShaccCgTargetProfile; + +/** @brief Classifies default callbacks + + @ingroup shacccg +*/ +typedef enum SceShaccCgCallbackDefaults { + SCE_SHACCCG_SYSTEM_FILES, ///< Default callback functions for using system files and paths. + SCE_SHACCCG_TRIVIAL ///< Default callback functions for using only the "openFile" callback. +} SceShaccCgCallbackDefaults; + +/** @brief Classifies language + + @ingroup shacccg +*/ +typedef enum SceShaccCgLocale { + SCE_SHACCCG_ENGLISH, ///< English language setting. + SCE_SHACCCG_JAPANESE ///< Japanese language setting. +} SceShaccCgLocale; + + +/////////////////////////////////////////////////////////////////////////////// +// Structs +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Describes a source file + + @note If the source file is referenced only through a #line directive, + the compiler will generate a SceShaccCgSourceFile object with a + NULL 'text' field and a 'size' field of 0. + @ingroup shacccg +*/ +typedef struct SceShaccCgSourceFile { + const SceChar8 *fileName; ///< The relative or absolute name of the file. + const SceChar8 *text; ///< The contents of the source file. + SceUInt32 size; ///< The size of the 'text' array in bytes. +} SceShaccCgSourceFile; + + +/** @brief Describes a location in the source code. + + @ingroup shacccg +*/ +typedef struct SceShaccCgSourceLocation { + const SceShaccCgSourceFile *file; ///< The file containing the location. + SceUInt32 lineNumber; ///< The line number of the location. + SceUInt32 columnNumber; ///< The column number of the location. +} SceShaccCgSourceLocation; + +/** @brief Describes the input data for a compilation job. + + @ingroup shacccg +*/ +typedef struct SceShaccCgCompileOptions { + const SceChar8 *mainSourceFile; ///< The main Cg source file to compile. 0 + SceShaccCgTargetProfile targetProfile; ///< The target profile. 4 + const SceChar8 *entryFunctionName; ///< The name of the entry function. Usually "main". 8 + SceUInt32 searchPathCount; ///< The number of search paths for include files. c + const SceChar8* const *searchPaths; ///< The search paths for include files. 10 + SceUInt32 macroDefinitionCount; ///< The number of macro definitions provided. 14 + const SceChar8* const *macroDefinitions; ///< The macro definitions in the form: MACRONAME or MACRONAME=VALUE 18 + SceUInt32 includeFileCount; ///< The number of files to force include. 1c + const SceChar8* const *includeFiles; ///< The files to include before the main source file. 20 + SceUInt32 suppressedWarningsCount; ///< The number of warnings to suppressed. 24 + const SceUInt32 *suppressedWarnings; ///< The id numbers of the warnings to be suppressed. 28 + + SceShaccCgLocale locale; ///< The language to use in diagnostics. 2c + + SceInt32 useFx; ///< Equivalent to -fx if non-zero, -nofx otherwise. 30 + SceInt32 noStdlib; ///< Equivalent to -nostdlib if non-zero. 34 + + SceInt32 optimizationLevel; ///< Equivalent to -O?. Valid range is 0-4. 38 + SceInt32 useFastmath; ///< Equivalent to -fastmath if non-zero. 3c + SceInt32 useFastprecision; ///< Equivalent to -fastprecision if non-zero. 40 + SceInt32 useFastint; ///< Equivalent to -fastint if non-zero. 44 + SceInt32 positionInvariant; ///< Equivalent to -invpos if non-zero. 48 + + SceInt32 warningsAsErrors; ///< Equivalent to -Werror if non-zero. 4c + SceInt32 performanceWarnings; ///< Equivalent to -Wperf if non-zero. 50 + SceInt32 warningLevel; ///< Equivalent to -W?. Valid range is 0-4. 54 + SceInt32 pedantic; ///< Equivalent to -pedantic if non-zero. 58 + SceInt32 pedanticError; ///< Equivalent to -pedantic-error if non-zero. 5c + SceInt32 xmlCache; ///< Equivalent to -xmlcache if non-zero. 60 + SceInt32 stripSymbols; ///< When set to non zero compilation will produce a stripped gxp file 64 +} SceCgcCompileOptions; + +/** @brief Lists the user defined callbacks for compiler operations. + + The SceShaccCgCallbackList structure is used in each of + sceShaccCgCompileProgram, SceShaccCgPreprocessProgram and + sceShaccCgGenerateDependencies in the same fashion. + In order to initialize instances of this structure, please always use + sceShaccCgInitializeCallbackList. + + For details regarding the individual callbacks, please refer to their + respective documentations. + + @ingroup shacccg +*/ +typedef struct SceShaccCgCallbackList { + SceShaccCgCallbackOpenFile openFile; ///< The callback used to open a file. + SceShaccCgCallbackReleaseFile releaseFile; ///< The callback used to release an opened file (optional). + SceShaccCgCallbackLocateFile locateFile; ///< The callback used to indicate a file exists (optional). + SceShaccCgCallbackAbsolutePath absolutePath; ///< The callback used to indicate the absolute path of a file (optional). + SceShaccCgCallbackReleaseFileName releaseFileName; ///< The callback used to release an absolute path string (optional). + SceShaccCgCallbackFileDate fileDate; ///< The callback used to indicate file modification date (optional). +} SceShaccCgCallbackList; + +/** @brief Describes a single compiler diagnostic. + + @ingroup shacccg +*/ +typedef struct SceShaccCgDiagnosticMessage { + SceShaccCgDiagnosticLevel level; ///< The severity of the diagnostic. + SceUInt32 code; ///< A unique code for each kind of diagnostic. + const SceShaccCgSourceLocation *location; ///< The location for which the diagnostic is reported (optional). + const SceChar8 *message; ///< The diagnostic message. +} SceShaccCgDiagnosticMessage; + + +/////////////////////////////////////////////////////////////////////////////// +// Functions for initializing common types +/////////////////////////////////////////////////////////////////////////////// + +/** @brief Initializes the compile options with the default values. + + The following fields must be initialized by the user: + - mainSourceFile + - targetProfile + + All other fields may be left in the state set by this function. + + @param[out] options + The option structure that should be initialized. + + @ingroup shacccg +*/ +SceVoid sceShaccCgInitializeCompileOptions( + SceShaccCgCompileOptions *options); + +/** @brief Initializes the callback list with the default values. + + There are two kinds of defaults available: + - SCE_SHACCCG_SYSTEM_FILES uses the native file system of the operating + system in the same manner as the command-line version of shacccg. + This is the default behavior if no callback structure is provided for + a compilation/pre-processing/dependency job. + - SCE_SHACCCG_TRIVIAL provides placeholder implementations of all callbacks + but 'openFile'. The latter must always be provided by the user. + + In the trivial case, the following defaults will be used: + - releaseFile: Does nothing. + - locateFile: Returns the same path it was called with. + - absolutePath: Returns the same path it was called with. + - releaseFileName: Does nothing. + - fileDate: Returns the current time. + + @param[in] callbacks + The callbacks structure to be initialized. + + @param[in] defaults + Indicates which set of default callbacks to initialize from. + + @ingroup shacccg +*/ +SceVoid sceShaccCgInitializeCallbackList( + SceShaccCgCallbackList *callbacks, + SceShaccCgCallbackDefaults defaults); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _DOLCESDK_PSP2_SHACCCG_TYPES_H_ */ diff --git a/nids/SceShaccCg.yml b/nids/SceShaccCg.yml new file mode 100644 index 0000000..0a99912 --- /dev/null +++ b/nids/SceShaccCg.yml @@ -0,0 +1,38 @@ +modules: + SceShaccCg: + nid: 0x6C3C7547 + libraries: + SceShaccCg: + nid: 0xA05BBEBB + functions: + sceShaccCgCompileProgram: 0x66814F35 + sceShaccCgDestroyCompileOutput: 0xAA82EF0C + sceShaccCgGetArrayParameter: 0xBB703EE1 + sceShaccCgGetArraySize: 0xB4AC9943 + sceShaccCgGetFirstParameter: 0x17223BEB + sceShaccCgGetFirstStructParameter: 0x648739F3 + sceShaccCgGetFirstUniformBlockParameter: 0x56BFA825 + sceShaccCgGetNextParameter: 0x46FA0303 + sceShaccCgGetParameterBaseType: 0x7B2CF324 + sceShaccCgGetParameterBufferIndex: 0xD4378DB1 + sceShaccCgGetParameterByName: 0x6FB40CA9 + sceShaccCgGetParameterClass: 0xDF3DDCFD + sceShaccCgGetParameterColumns: 0x7BC25091 + sceShaccCgGetParameterDirection: 0xF4BAB902 + sceShaccCgGetParameterMemoryLayout: 0xEF8D59D6 + sceShaccCgGetParameterName: 0x4595A388 + sceShaccCgGetParameterResourceIndex: 0x6BB58825 + sceShaccCgGetParameterRows: 0x2654E73A + sceShaccCgGetParameterSemantic: 0xA7930FF6 + sceShaccCgGetParameterUserType: 0x152971B1 + sceShaccCgGetParameterVariability: 0xDAD4AAE4 + sceShaccCgGetParameterVectorWidth: 0x0205DE96 + sceShaccCgGetRowParameter: 0x07DDFC78 + sceShaccCgGetSamplerQueryFormatPrecision: 0xA067C481 + sceShaccCgGetSamplerQueryFormatPrecisionCount: 0x268FAEE9 + sceShaccCgGetSamplerQueryFormatWidth: 0xA56B1A5B + sceShaccCgInitializeCallbackList: 0xA8C2C1C8 + sceShaccCgInitializeCompileOptions: 0x3B58AFA0 + sceShaccCgIsParameterReferenced: 0x0E1285A6 + sceShaccCgIsParameterRegFormat: 0xA13A8A1E + sceShaccCgSetMemAllocator: 0x6F01D573 |