![]() |
Public API Reference |
![]() |
Base class for iShaderProgram plugins. More...
#include <csplugincommon/shader/shaderprogram.h>
Classes | |
struct | ProgramParam |
Program parameter, either a SV reference or a const value. More... | |
struct | VariableMapEntry |
Holder of variable mapping. More... | |
Public Types | |
enum | ProgramParamType |
Expected/accepted types for a program parameter. More... | |
Public Member Functions | |
virtual void | GetUsedShaderVars (csBitArray &bits) const |
Request all shader variables used by a certain shader ticket. | |
virtual iShaderProgram::CacheLoadResult | LoadFromCache (iHierarchicalCache *cache, iBase *previous, iDocumentNode *programNode, csRef< iString > *failReason=0, csRef< iString > *=0) |
Loads from a cache. | |
virtual int | ResolveTU (const char *) |
When the destination of a texture binding wasn't recognized, the FP is asked whether it can provide a TU number for it. | |
Protected Member Functions | |
void | DumpProgramInfo (csString &output) |
Dump all program info to output. | |
void | DumpVariableMappings (csString &output) |
Dump variable mapping. | |
csShaderVariable * | GetParamSV (const csShaderVariableStack &stack, const ProgramParam ¶m) |
Resolve the SV of a ProgramParam. | |
csPtr< iDataBuffer > | GetProgramData () |
Get the raw program data. | |
iDocumentNode * | GetProgramNode () |
Get the program node. | |
bool | ParseCommon (iDocumentNode *child) |
Parse common properties and variablemapping. | |
bool | ParseProgramParam (iDocumentNode *node, ProgramParam ¶m, uint types=~0) |
Parse program parameter node. | |
bool | GetParamVectorVal (const csShaderVariableStack &stack, const ProgramParam ¶m, csVector4 *result) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
csVector4 | GetParamVectorVal (const csShaderVariableStack &stack, const ProgramParam ¶m, const csVector4 &defVal) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
bool | GetParamTransformVal (const csShaderVariableStack &stack, const ProgramParam ¶m, csReversibleTransform *result) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
csReversibleTransform | GetParamTransformVal (const csShaderVariableStack &stack, const ProgramParam ¶m, const csReversibleTransform &defVal) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
bool | GetParamFloatVal (const csShaderVariableStack &stack, const ProgramParam ¶m, float *result) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
float | GetParamFloatVal (const csShaderVariableStack &stack, const ProgramParam ¶m, float defVal) |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable. | |
Protected Attributes | |
csString | description |
Program description. | |
bool | doVerbose |
Whether the shader program should report additional information during runtime. | |
csRef< iFile > | programFile |
File the program is loaded from (if any) | |
csString | programFileName |
Filename of program. | |
csRef< iDocumentNode > | programNode |
iDocumentNode the program is loaded from | |
csSafeCopyArray< VariableMapEntry > | variablemap |
Variable mappings. | |
Token list helper macros | |
The macros here provide an easy way to automatically build a token list useful for e.g. parsers. The list of tokens have to be declared in an external file, with each token the argument to a 'CS_TOKEN_LIST_TOKEN()' invocation. The name of the file (full path!) has to be put in a macro named CS_TOKEN_ITEM_FILE. Optionally, the name of the function to initialize the token table can be set via CS_INIT_TOKEN_TABLE_NAME; the default is 'InitTokenTable'. In addition to invoking the initialization function to populate the string hash, an enumeration is also created. Elements of the enumeration are named XMLTOKEN_FOO (where 'FOO' represents the argument to CS_TOKEN_LIST_TOKEN()). If you prefer a prefix other than 'XMLTOKEN_', define #CS_TOKEN_LIST_TOKEN_PREFIX with the prefix of your choice. As a convenience, in addition to entries for each CS_TOKEN_LIST_TOKEN invocation, a final item is added to the enumeration with the name provided by #CS_TOKEN_LIST_TOKEN_LAST. If you do not #define this macro, then the name XMLTOKEN_TOKEN_COUNT is given to the last item in the enumeration. This value will equate to the count of items in the enumeration (not including this automatically added item). Note that the client defines CS_TOKEN_ITEM_FILE, CS_INIT_TOKEN_TABLE_NAME, #CS_TOKEN_LIST_TOKEN_PREFIX, and #CS_TOKEN_LIST_TOKEN_LAST, and they will not be undefined by this file; hence, if you want to build multiple token lists, you may redefine those macros and include <cstool/tokenlist.h> again. The code generated by the macros has a dependency on csString, thus the <csutil/csstring.h> header must be included in files that use the token list helpers. Example (from a real-world use): fire.tok: CS_TOKEN_LIST_TOKEN(PALETTE) ... fire.h: #include <csutil/csstring.h> class csFireLoader { csStringHash tokens; #define CS_TOKEN_ITEM_FILE "plugins/proctex/standard/fire.tok" #include "cstool/tokenlist.h" ... }; fire.cpp: csFireLoader::csFireLoader(iBase *p) { InitTokenTable (tokens); // ... } csPtr<iBase> csFireLoader::Parse (iDocumentNode* node, iLoaderContext* ldr_context, iBase* context) { // ... csStringID id = tokens.Request (child->GetValue ()); switch (id) { case XMLTOKEN_PALETTE: // ... break; } // ... } | |
enum | |
static void | CS_INIT_TOKEN_TABLE_NAME (csStringHash &t) |
Base class for iShaderProgram plugins.
Provides basic services such as holding and of parameter mapping information, basic program data and data dumping.
Definition at line 61 of file shaderprogram.h.
Expected/accepted types for a program parameter.
Definition at line 84 of file shaderprogram.h.
void csShaderProgram::DumpProgramInfo | ( | csString & | output | ) | [protected] |
Dump all program info to output.
void csShaderProgram::DumpVariableMappings | ( | csString & | output | ) | [protected] |
Dump variable mapping.
bool csShaderProgram::GetParamFloatVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
float * | result | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 294 of file shaderprogram.h.
float csShaderProgram::GetParamFloatVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
float | defVal | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 306 of file shaderprogram.h.
csShaderVariable* csShaderProgram::GetParamSV | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param | ||
) | [inline, protected] |
Resolve the SV of a ProgramParam.
Definition at line 234 of file shaderprogram.h.
bool csShaderProgram::GetParamTransformVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
csReversibleTransform * | result | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 274 of file shaderprogram.h.
csReversibleTransform csShaderProgram::GetParamTransformVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
const csReversibleTransform & | defVal | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 286 of file shaderprogram.h.
bool csShaderProgram::GetParamVectorVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
csVector4 * | result | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 254 of file shaderprogram.h.
csVector4 csShaderProgram::GetParamVectorVal | ( | const csShaderVariableStack & | stack, |
const ProgramParam & | param, | ||
const csVector4 & | defVal | ||
) | [inline, protected] |
Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
Definition at line 266 of file shaderprogram.h.
csPtr<iDataBuffer> csShaderProgram::GetProgramData | ( | ) | [protected] |
Get the raw program data.
iDocumentNode* csShaderProgram::GetProgramNode | ( | ) | [protected] |
Get the program node.
virtual void csShaderProgram::GetUsedShaderVars | ( | csBitArray & | bits | ) | const [virtual] |
Request all shader variables used by a certain shader ticket.
ticket | The ticket for which to retrieve the information. |
bits | Bit array with one bit for each shader variable set; if a shader variable is used, the bit corresponding to the name of the variable is note set. Please note: first, the array passed in must initially have enough bits for all possible shader variables, it will not be resized - thus a good size would be the number of strings in the shader variable string set. Second, bits corresponding to unused shader variables will not be reset. It is the responsibility of the caller to do so. |
Implements iShaderProgram.
virtual iShaderProgram::CacheLoadResult csShaderProgram::LoadFromCache | ( | iHierarchicalCache * | cache, |
iBase * | previous, | ||
iDocumentNode * | programNode, | ||
csRef< iString > * | failReason = 0 , |
||
csRef< iString > * | cacheTag = 0 |
||
) | [virtual] |
Loads from a cache.
Implements iShaderProgram.
bool csShaderProgram::ParseCommon | ( | iDocumentNode * | child | ) | [protected] |
Parse common properties and variablemapping.
bool csShaderProgram::ParseProgramParam | ( | iDocumentNode * | node, |
ProgramParam & | param, | ||
uint | types = ~0 |
||
) | [inline, protected] |
Parse program parameter node.
Definition at line 152 of file shaderprogram.h.
virtual int csShaderProgram::ResolveTU | ( | const char * | binding | ) | [inline, virtual] |
When the destination of a texture binding wasn't recognized, the FP is asked whether it can provide a TU number for it.
Implements iShaderDestinationResolver.
Definition at line 320 of file shaderprogram.h.
csString csShaderProgram::description [protected] |
Program description.
Definition at line 203 of file shaderprogram.h.
bool csShaderProgram::doVerbose [protected] |
Whether the shader program should report additional information during runtime.
Definition at line 217 of file shaderprogram.h.
csRef<iFile> csShaderProgram::programFile [protected] |
File the program is loaded from (if any)
Definition at line 208 of file shaderprogram.h.
csString csShaderProgram::programFileName [protected] |
Filename of program.
Definition at line 211 of file shaderprogram.h.
csRef<iDocumentNode> csShaderProgram::programNode [protected] |
iDocumentNode the program is loaded from
Definition at line 206 of file shaderprogram.h.
csSafeCopyArray<VariableMapEntry> csShaderProgram::variablemap [protected] |
Variable mappings.
Definition at line 183 of file shaderprogram.h.