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  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.
csPtr< iDataBufferGetProgramData ()
 Get the raw program data.
iDocumentNodeGetProgramNode ()
 Get the program node.
bool ParseCommon (iDocumentNode *child)
 Parse common properties and variablemapping.
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.

Protected Attributes

csString description
 Program description.
bool doVerbose
 Whether the shader program should report additional information during runtime.
csRef< iFileprogramFile
 File the program is loaded from (if any).
csString programFileName
 Filename of program.
csRef< iDocumentNodeprogramNode
 iDocumentNode the program is loaded from
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 492 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 480 of file shaderprogram.h.

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

Resolve the SV of a ProgramParam.

Definition at line 420 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 472 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 460 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 452 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 440 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.

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::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 506 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 403 of file shaderprogram.h.

File the program is loaded from (if any).

Definition at line 394 of file shaderprogram.h.

Filename of program.

Definition at line 397 of file shaderprogram.h.

iDocumentNode the program is loaded from

Definition at line 392 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.0 by doxygen 1.6.1