CrystalSpace

Public API Reference

csShaderProgram Class Reference
[Common Plugin Classes]

Base class for iShaderProgram plugins. More...

#include <csplugincommon/shader/shaderprogram.h>

Inheritance diagram for csShaderProgram:

List of all members.

Classes

struct  ProgramParam
 Program parameter, either a SV reference or a const value. More...
struct  ProgramSource
 Information to obtain the program source data. 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.
csShaderVariableGetParamSV (const csShaderVariableStack &stack, const ProgramParam &param)
 Resolve the SV of a ProgramParam.
bool ParseCommon (iDocumentNode *child)
 Parse common properties and variablemapping.
bool ParseProgramNode (iDocumentNode *child, ProgramSource &parsedSource)
 Parse a program node.
bool ParseProgramParam (iDocumentNode *node, ProgramParam &param, uint types=~0)
 Parse program parameter node.



float GetParamFloatVal (const csShaderVariableStack &stack, const ProgramParam &param, float defVal)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
bool GetParamFloatVal (const csShaderVariableStack &stack, const ProgramParam &param, float *result)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
csReversibleTransform GetParamTransformVal (const csShaderVariableStack &stack, const ProgramParam &param, const csReversibleTransform &defVal)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
bool GetParamTransformVal (const csShaderVariableStack &stack, const ProgramParam &param, csReversibleTransform *result)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
csVector4 GetParamVectorVal (const csShaderVariableStack &stack, const ProgramParam &param, const csVector4 &defVal)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
bool GetParamVectorVal (const csShaderVariableStack &stack, const ProgramParam &param, csVector4 *result)
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
csPtr< iDataBufferGetProgramData ()
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
csPtr< iDataBufferGetProgramData (ProgramSource &programSource)
 Get the raw program data.
iDocumentNodeGetProgramNode ()
 Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.
iDocumentNodeGetProgramNode (ProgramSource &programSource)
 Get the program node.

Protected Attributes

csString description
 Program description.
bool doVerbose
 Whether the shader program should report additional information during runtime.
ProgramSource programSource
 Program source information parsed by ParseCommon().
csSafeCopyArray< VariableMapEntryvariablemap
 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  
 

A token list entry.

More...
static void CS_INIT_TOKEN_TABLE_NAME (csStringHash &t)
 A token list entry.

Detailed Description

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.


Member Enumeration Documentation

Expected/accepted types for a program parameter.

Definition at line 270 of file shaderprogram.h.


Member Function Documentation

void csShaderProgram::DumpProgramInfo ( csString output  )  [protected]

Dump all program info to output.

void csShaderProgram::DumpVariableMappings ( csString output  )  [protected]

Dump variable mapping.

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 516 of file shaderprogram.h.

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 504 of file shaderprogram.h.

csShaderVariable* csShaderProgram::GetParamSV ( const csShaderVariableStack stack,
const ProgramParam param 
) [inline, protected]

Resolve the SV of a ProgramParam.

Definition at line 444 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 496 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 484 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 476 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 464 of file shaderprogram.h.

csPtr<iDataBuffer> csShaderProgram::GetProgramData (  )  [inline, protected]

Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.

Definition at line 432 of file shaderprogram.h.

csPtr<iDataBuffer> csShaderProgram::GetProgramData ( ProgramSource programSource  )  [protected]

Get the raw program data.

If a program file is specified will return the the program file data unparsed.

iDocumentNode* csShaderProgram::GetProgramNode (  )  [inline, protected]

Query the value of a ProgramParam variable by reading the constant or resolving the shader variable.

Definition at line 423 of file shaderprogram.h.

iDocumentNode* csShaderProgram::GetProgramNode ( ProgramSource programSource  )  [protected]

Get the program node.

If a program file is specified will attempt to parse the program file.

virtual void csShaderProgram::GetUsedShaderVars ( csBitArray bits  )  const [virtual]

Request all shader variables used by a certain shader ticket.

Parameters:
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::ParseProgramNode ( iDocumentNode child,
ProgramSource parsedSource 
) [protected]

Parse a program node.

bool csShaderProgram::ParseProgramParam ( iDocumentNode node,
ProgramParam param,
uint  types = ~0 
) [inline, protected]

Parse program parameter node.

See also:
ProgramParamParser::ParseProgramParam

Definition at line 338 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 530 of file shaderprogram.h.


Member Data Documentation

Program description.

Definition at line 389 of file shaderprogram.h.

bool csShaderProgram::doVerbose [protected]

Whether the shader program should report additional information during runtime.

Definition at line 411 of file shaderprogram.h.

Program source information parsed by ParseCommon().

Definition at line 405 of file shaderprogram.h.

Variable mappings.

Definition at line 369 of file shaderprogram.h.


The documentation for this class was generated from the following file:

Generated for Crystal Space 2.1 by doxygen 1.6.1