OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Ogre::Hlms Class Reference

HLMS stands for "High Level Material System". More...

#include <OgreHlms.h>

+ Inheritance diagram for Ogre::Hlms:
+ Collaboration diagram for Ogre::Hlms:

Classes

struct  Expression
 

Public Member Functions

 Hlms (Archive *dataFolder)
 
virtual ~Hlms ()
 
void _setProperty (IdString key, int32 value)
 For debugging stuff. I.e. the Command line uses it for testing manually set properties. More...
 
virtual void calculateHashFor (Renderable *renderable, const HlmsParamVec &params, uint32 &outHash, uint32 &outCasterHash)
 Called by the renderable when either it changes the material, or its properties change (e.g. More...
 
const HlmsCachegetMaterial (const HlmsCache &passCache, Renderable *renderable, MovableObject *movableObject, bool casterPass)
 Retrieves an HlmsCache filled with the GPU programs to be used by the given renderable. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void * operator new[] (size_t sz)
 
virtual HlmsCache preparePassHash (const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager)
 Called every frame by the Render Queue to cache the properties needed by this pass. More...
 

Protected Types

enum  ExpressionType { EXPR_OPERATOR_OR, EXPR_OPERATOR_AND, EXPR_OBJECT, EXPR_VAR }
 
typedef std::vector< ExpressionExpressionVec
 
typedef std::map< IdString,
String
PiecesMap
 

Protected Member Functions

void addRenderableCache (uint32 hash, const HlmsPropertyVec &renderableSetProperties)
 
const HlmsCacheaddShaderCache (uint32 hash, GpuProgramPtr &vertexShader, GpuProgramPtr &geometryShader, GpuProgramPtr &tesselationHullShader, GpuProgramPtr &tesselationDomainShader, GpuProgramPtr &pixelShader)
 
virtual uint32 calculateRenderableHash (void) const
 calculateHashFor More...
 
bool collectPieces (const String &inBuffer, String &outBuffer)
 
const HlmsCachecreateShaderCacheEntry (uint32 renderableHash, const HlmsCache &passCache, uint32 finalHash)
 
void enumeratePieceFiles (void)
 Populates all mPieceFiles with all files in mDataFolder with suffix ending in piece_vs - Vertex Shader piece_ps - Pixel Shader piece_gs - Geometry Shader piece_hs - Hull Shader piece_ds - Domain Shader Case insensitive. More...
 
bool evaluateExpression (SubStringRef &outSubString, bool &outSyntaxError) const
 
bool evaluateExpressionRecursive (ExpressionVec &expression, bool &outSyntaxError) const
 
int32 getProperty (IdString key, int32 defaultVal=0) const
 
const HlmsCachegetRenderableCache (uint32 hash) const
 
const HlmsCachegetShaderCache (uint32 hash) const
 
bool insertPieces (String &inBuffer, String &outBuffer) const
 
bool parse (const String &inBuffer, String &outBuffer) const
 
bool parseCounter (const String &inBuffer, String &outBuffer)
 
bool parseForEach (const String &inBuffer, String &outBuffer) const
 
bool parseProperties (String &inBuffer, String &outBuffer) const
 
void setCommonProperties ()
 Inserts common properties about the current Renderable, such as hlms_skeleton hlms_uv_count, etc. More...
 
void setProperty (IdString key, int32 value)
 

Static Protected Member Functions

static size_t calculateLineCount (const String &buffer, size_t idx)
 
static size_t calculateLineCount (const SubStringRef &subString)
 
static void copy (String &outBuffer, const SubStringRef &inSubString, size_t length)
 
static size_t evaluateExpressionEnd (const SubStringRef &outSubString)
 
static void evaluateParamArgs (SubStringRef &outSubString, StringVector &outArgs, bool &outSyntaxError)
 
static void findBlockEnd (SubStringRef &outSubString, bool &syntaxError)
 
static size_t findNextCharacter (const String &buffer, size_t startPos, char character)
 Goes through 'buffer', starting from startPos (inclusive) looking for the given character while skipping whitespace. More...
 
static bool findParamInVec (const HlmsParamVec &paramVec, IdString key, String &inOut)
 Finds the parameter with key 'key' in the given 'paramVec'. More...
 
static void repeat (String &outBuffer, const SubStringRef &inSubString, size_t length, size_t passNum, const String &counterVar)
 

Protected Attributes

ArchivemDataFolder
 
StringVector mPieceFiles [5]
 
PiecesMap mPieces
 
HlmsCacheVec mRenderableCache
 
HlmsPropertyVec mSetProperties
 
HlmsCacheVec mShaderCache
 

Private Types

enum  ShaderType {
  VertexShader, PixelShader, GeometryShader, HullShader,
  DomainShader, NumShaderTypes
}
 

Detailed Description

HLMS stands for "High Level Material System".

Definition at line 46 of file OgreHlms.h.

Member Typedef Documentation

typedef std::vector<Expression> Ogre::Hlms::ExpressionVec
protected

Definition at line 107 of file OgreHlms.h.

typedef std::map<IdString, String> Ogre::Hlms::PiecesMap
protected

Definition at line 62 of file OgreHlms.h.

Member Enumeration Documentation

Enumerator
EXPR_OPERATOR_OR 
EXPR_OPERATOR_AND 
EXPR_OBJECT 
EXPR_VAR 

Definition at line 88 of file OgreHlms.h.

enum Ogre::Hlms::ShaderType
private
Enumerator
VertexShader 
PixelShader 
GeometryShader 
HullShader 
DomainShader 
NumShaderTypes 

Definition at line 48 of file OgreHlms.h.

Constructor & Destructor Documentation

Ogre::Hlms::Hlms ( Archive dataFolder)
virtual Ogre::Hlms::~Hlms ( )
virtual

Member Function Documentation

void Ogre::Hlms::_setProperty ( IdString  key,
int32  value 
)
inline

For debugging stuff. I.e. the Command line uses it for testing manually set properties.

Definition at line 213 of file OgreHlms.h.

void Ogre::Hlms::addRenderableCache ( uint32  hash,
const HlmsPropertyVec renderableSetProperties 
)
protected
const HlmsCache* Ogre::Hlms::addShaderCache ( uint32  hash,
GpuProgramPtr vertexShader,
GpuProgramPtr geometryShader,
GpuProgramPtr tesselationHullShader,
GpuProgramPtr tesselationDomainShader,
GpuProgramPtr pixelShader 
)
protected
virtual void Ogre::Hlms::calculateHashFor ( Renderable renderable,
const HlmsParamVec params,
uint32 outHash,
uint32 outCasterHash 
)
virtual

Called by the renderable when either it changes the material, or its properties change (e.g.

the mesh' uvs are stripped)

Parameters
renderableThe renderable the material will be used on.
movableObjectThe MovableObject the material will be used on (usually the parent of renderable)
Returns
A hash. This hash references property parameters that are already cached.

Referenced by Ogre::Renderable::setHlms().

static size_t Ogre::Hlms::calculateLineCount ( const String buffer,
size_t  idx 
)
staticprotected
static size_t Ogre::Hlms::calculateLineCount ( const SubStringRef subString)
staticprotected
virtual uint32 Ogre::Hlms::calculateRenderableHash ( void  ) const
protectedvirtual

calculateHashFor

bool Ogre::Hlms::collectPieces ( const String inBuffer,
String outBuffer 
)
protected
static void Ogre::Hlms::copy ( String outBuffer,
const SubStringRef inSubString,
size_t  length 
)
staticprotected
const HlmsCache* Ogre::Hlms::createShaderCacheEntry ( uint32  renderableHash,
const HlmsCache passCache,
uint32  finalHash 
)
protected
void Ogre::Hlms::enumeratePieceFiles ( void  )
protected

Populates all mPieceFiles with all files in mDataFolder with suffix ending in piece_vs - Vertex Shader piece_ps - Pixel Shader piece_gs - Geometry Shader piece_hs - Hull Shader piece_ds - Domain Shader Case insensitive.

bool Ogre::Hlms::evaluateExpression ( SubStringRef outSubString,
bool &  outSyntaxError 
) const
protected
static size_t Ogre::Hlms::evaluateExpressionEnd ( const SubStringRef outSubString)
staticprotected
bool Ogre::Hlms::evaluateExpressionRecursive ( ExpressionVec expression,
bool &  outSyntaxError 
) const
protected
static void Ogre::Hlms::evaluateParamArgs ( SubStringRef outSubString,
StringVector outArgs,
bool &  outSyntaxError 
)
staticprotected
static void Ogre::Hlms::findBlockEnd ( SubStringRef outSubString,
bool &  syntaxError 
)
staticprotected
static size_t Ogre::Hlms::findNextCharacter ( const String buffer,
size_t  startPos,
char  character 
)
staticprotected

Goes through 'buffer', starting from startPos (inclusive) looking for the given character while skipping whitespace.

If any character other than whitespace or EOLs if found returns String::npos

Returns
String::npos if not found or wasn't the next character. If found, the position in the buffer, from start
static bool Ogre::Hlms::findParamInVec ( const HlmsParamVec paramVec,
IdString  key,
String inOut 
)
staticprotected

Finds the parameter with key 'key' in the given 'paramVec'.

If found, outputs the value to 'inOut', otherwise leaves 'inOut' as is.

Returns
True if the key was found (inOut was modified), false otherwise
Remarks
Assumes paramVec is sorted by key.
const HlmsCache* Ogre::Hlms::getMaterial ( const HlmsCache passCache,
Renderable renderable,
MovableObject movableObject,
bool  casterPass 
)

Retrieves an HlmsCache filled with the GPU programs to be used by the given renderable.

If the shaders have already been created (i.e. whether for this renderable, or another one) it gets them from a cache. Otherwise we create it. It assumes that renderable->setHlms( this, parameters ) has already called.

Parameters
passCacheThe cache returned by .
renderableThe renderable the caller wants us to give the shaders.
movableObjectThe MovableObject owner of the renderable (we need it to know if renderable should cast shadows)
casterPassTrue if this pass is the shadow mapping caster pass, false otherwise
Returns
Structure containing all necessary shaders
int32 Ogre::Hlms::getProperty ( IdString  key,
int32  defaultVal = 0 
) const
protected
const HlmsCache* Ogre::Hlms::getRenderableCache ( uint32  hash) const
protected
const HlmsCache* Ogre::Hlms::getShaderCache ( uint32  hash) const
protected
bool Ogre::Hlms::insertPieces ( String inBuffer,
String outBuffer 
) const
protected
template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

Definition at line 96 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

Definition at line 102 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 108 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

Definition at line 113 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 119 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

Definition at line 68 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

Definition at line 73 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

Definition at line 79 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

Definition at line 86 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

Definition at line 91 of file OgreMemoryAllocatedObject.h.

bool Ogre::Hlms::parse ( const String inBuffer,
String outBuffer 
) const
protected
bool Ogre::Hlms::parseCounter ( const String inBuffer,
String outBuffer 
)
protected
bool Ogre::Hlms::parseForEach ( const String inBuffer,
String outBuffer 
) const
protected
bool Ogre::Hlms::parseProperties ( String inBuffer,
String outBuffer 
) const
protected
virtual HlmsCache Ogre::Hlms::preparePassHash ( const Ogre::CompositorShadowNode shadowNode,
bool  casterPass,
bool  dualParaboloid,
SceneManager sceneManager 
)
virtual

Called every frame by the Render Queue to cache the properties needed by this pass.

i.e. Number of PSSM splits, number of shadow casting lights, etc

Parameters
shadowNodeThe shadow node currently in effect. Can be null.
Returns
A hash and cached property parameters. Unlike , the cache must be kept by the caller and not by us (because it may change every frame and is one for the whole pass, but Mesh' properties usually stay consistent through its lifetime but may differ per mesh)
static void Ogre::Hlms::repeat ( String outBuffer,
const SubStringRef inSubString,
size_t  length,
size_t  passNum,
const String counterVar 
)
staticprotected
void Ogre::Hlms::setCommonProperties ( )
protected

Inserts common properties about the current Renderable, such as hlms_skeleton hlms_uv_count, etc.

void Ogre::Hlms::setProperty ( IdString  key,
int32  value 
)
protected

Member Data Documentation

Archive* Ogre::Hlms::mDataFolder
protected

Definition at line 66 of file OgreHlms.h.

StringVector Ogre::Hlms::mPieceFiles[5]
protected

Definition at line 67 of file OgreHlms.h.

PiecesMap Ogre::Hlms::mPieces
protected

Definition at line 64 of file OgreHlms.h.

HlmsCacheVec Ogre::Hlms::mRenderableCache
protected

Definition at line 59 of file OgreHlms.h.

HlmsPropertyVec Ogre::Hlms::mSetProperties
protected

Definition at line 63 of file OgreHlms.h.

HlmsCacheVec Ogre::Hlms::mShaderCache
protected

Definition at line 60 of file OgreHlms.h.


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