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

A singleton manager class that manages shader based programs. More...

#include <OgreShaderProgramManager.h>

+ Inheritance diagram for Ogre::RTShader::ProgramManager:
+ Collaboration diagram for Ogre::RTShader::ProgramManager:

Public Member Functions

 ProgramManager ()
 Class default constructor. More...
 
 ~ProgramManager ()
 Class destructor. More...
 
void acquirePrograms (Pass *pass, TargetRenderState *renderState)
 Acquire CPU/GPU programs set associated with the given render state and bind them to the pass. More...
 
void flushGpuProgramsCache ()
 Flush the local GPU programs cache. 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)
 
void releasePrograms (Pass *pass, TargetRenderState *renderState)
 Release CPU/GPU programs set associated with the given render state and pass. More...
 

Static Public Member Functions

static ProgramManagergetSingleton ()
 Override standard Singleton retrieval. More...
 
static ProgramManagergetSingletonPtr ()
 Override standard Singleton retrieval. More...
 

Protected Types

typedef map< String,
GpuProgramPtr >::type 
GpuProgramsMap
 
typedef
GpuProgramsMap::const_iterator 
GpuProgramsMapConstIterator
 
typedef GpuProgramsMap::iterator GpuProgramsMapIterator
 
typedef set< Program * >::type ProgramList
 
typedef ProgramList::iterator ProgramListIterator
 
typedef
ProgramProcessorMap::const_iterator 
ProgramProcessorConstIterator
 
typedef
ProgramProcessorMap::iterator 
ProgramProcessorIterator
 
typedef vector
< ProgramProcessor * >::type 
ProgramProcessorList
 
typedef map< String,
ProgramProcessor * >::type 
ProgramProcessorMap
 
typedef vector
< ProgramWriterFactory * >
::type 
ProgramWriterFactoryList
 
typedef ProgramWriterMap::iterator ProgramWriterIterator
 
typedef map< String,
ProgramWriter * >::type 
ProgramWriterMap
 

Protected Member Functions

void addProgramProcessor (ProgramProcessor *processor)
 Add program processor instance to this manager. More...
 
void bindUniformParameters (Program *pCpuProgram, const GpuProgramParametersSharedPtr &passParams)
 Bind the uniform parameters of a given CPU and GPU program set. More...
 
ProgramcreateCpuProgram (GpuProgramType type)
 Create CPU program . More...
 
void createDefaultProgramProcessors ()
 Create default program processors. More...
 
void createDefaultProgramWriterFactories ()
 Create default program processors. More...
 
GpuProgramPtr createGpuProgram (Program *shaderProgram, ProgramWriter *programWriter, const String &language, const String &profiles, const StringVector &profilesList, const String &cachePath)
 Create GPU program based on the give CPU program. More...
 
bool createGpuPrograms (ProgramSet *programSet)
 Create GPU programs for the given program set based on the CPU programs it contains. More...
 
void destroyCpuProgram (Program *shaderProgram)
 Destroy a CPU program by name. More...
 
void destroyDefaultProgramProcessors ()
 Destroy default program processors. More...
 
void destroyDefaultProgramWriterFactories ()
 Destroy default program processors. More...
 
void destroyGpuProgram (GpuProgramPtr &gpuProgram)
 Destroy a GPU program by name. More...
 
void destroyProgramWriters ()
 Destroy all program writers. More...
 
void flushGpuProgramsCache (GpuProgramsMap &gpuProgramsMap)
 Flush the local GPU programs cache. More...
 
String generateGUID (const String &programString)
 Generates a unique guid value from a string. More...
 
size_t getFragmentShaderCount () const
 Return the number of created fragment shaders. More...
 
size_t getVertexShaderCount () const
 Return the number of created vertex shaders. More...
 
void removeProgramProcessor (ProgramProcessor *processor)
 Remove program processor instance from this manager. More...
 
void synchronizePixelnToBeVertexOut (ProgramSet *programSet)
 Fix the input of the pixel shader to be the same as the output of the vertex shader. More...
 

Protected Attributes

ProgramList mCpuProgramsList
 
ProgramProcessorList mDefaultProgramProcessors
 
GpuProgramsMap mFragmentShaderMap
 
ProgramProcessorMap mProgramProcessorsMap
 
ProgramWriterFactoryList mProgramWriterFactories
 
ProgramWriterMap mProgramWritersMap
 
GpuProgramsMap mVertexShaderMap
 

Static Protected Attributes

static ProgramManagermsSingleton
 

Friends

class ProgramSet
 
class ShaderGenerator
 
class TargetRenderState
 

Detailed Description

A singleton manager class that manages shader based programs.

Definition at line 46 of file OgreShaderProgramManager.h.

Member Typedef Documentation

typedef GpuProgramsMap::const_iterator Ogre::RTShader::ProgramManager::GpuProgramsMapConstIterator
protected

Definition at line 113 of file OgreShaderProgramManager.h.

typedef GpuProgramsMap::iterator Ogre::RTShader::ProgramManager::GpuProgramsMapIterator
protected

Definition at line 112 of file OgreShaderProgramManager.h.

Definition at line 116 of file OgreShaderProgramManager.h.

typedef ProgramList::iterator Ogre::RTShader::ProgramManager::ProgramListIterator
protected

Definition at line 117 of file OgreShaderProgramManager.h.

typedef ProgramProcessorMap::const_iterator Ogre::RTShader::ProgramManager::ProgramProcessorConstIterator
protected

Definition at line 125 of file OgreShaderProgramManager.h.

typedef ProgramProcessorMap::iterator Ogre::RTShader::ProgramManager::ProgramProcessorIterator
protected

Definition at line 124 of file OgreShaderProgramManager.h.

typedef ProgramWriterMap::iterator Ogre::RTShader::ProgramManager::ProgramWriterIterator
protected

Definition at line 119 of file OgreShaderProgramManager.h.

Constructor & Destructor Documentation

Ogre::RTShader::ProgramManager::ProgramManager ( )

Class default constructor.

Ogre::RTShader::ProgramManager::~ProgramManager ( )

Class destructor.

Member Function Documentation

void Ogre::RTShader::ProgramManager::acquirePrograms ( Pass pass,
TargetRenderState renderState 
)

Acquire CPU/GPU programs set associated with the given render state and bind them to the pass.

Parameters
passThe pass to bind the programs to.
renderStateThe render state that describes the program that need to be generated.
void Ogre::RTShader::ProgramManager::addProgramProcessor ( ProgramProcessor processor)
protected

Add program processor instance to this manager.

Parameters
processorThe instance to add.
void Ogre::RTShader::ProgramManager::bindUniformParameters ( Program pCpuProgram,
const GpuProgramParametersSharedPtr passParams 
)
protected

Bind the uniform parameters of a given CPU and GPU program set.

Program* Ogre::RTShader::ProgramManager::createCpuProgram ( GpuProgramType  type)
protected

Create CPU program .

Parameters
typeThe type of the program to create.
void Ogre::RTShader::ProgramManager::createDefaultProgramProcessors ( )
protected

Create default program processors.

void Ogre::RTShader::ProgramManager::createDefaultProgramWriterFactories ( )
protected

Create default program processors.

GpuProgramPtr Ogre::RTShader::ProgramManager::createGpuProgram ( Program shaderProgram,
ProgramWriter programWriter,
const String language,
const String profiles,
const StringVector profilesList,
const String cachePath 
)
protected

Create GPU program based on the give CPU program.

Parameters
shaderProgramThe CPU program instance.
programWriterThe program writer instance.
languageThe target shader language.
profilesThe profiles string for program compilation.
profilesListThe profiles string for program compilation as string list.
cachePathThe output path to write the program into.
bool Ogre::RTShader::ProgramManager::createGpuPrograms ( ProgramSet programSet)
protected

Create GPU programs for the given program set based on the CPU programs it contains.

Parameters
programSetThe program set container.
void Ogre::RTShader::ProgramManager::destroyCpuProgram ( Program shaderProgram)
protected

Destroy a CPU program by name.

Parameters
shaderProgramThe CPU program instance to destroy.
void Ogre::RTShader::ProgramManager::destroyDefaultProgramProcessors ( )
protected

Destroy default program processors.

void Ogre::RTShader::ProgramManager::destroyDefaultProgramWriterFactories ( )
protected

Destroy default program processors.

void Ogre::RTShader::ProgramManager::destroyGpuProgram ( GpuProgramPtr gpuProgram)
protected

Destroy a GPU program by name.

Parameters
gpuProgramThe program to destroy.
void Ogre::RTShader::ProgramManager::destroyProgramWriters ( )
protected

Destroy all program writers.

void Ogre::RTShader::ProgramManager::flushGpuProgramsCache ( )

Flush the local GPU programs cache.

void Ogre::RTShader::ProgramManager::flushGpuProgramsCache ( GpuProgramsMap gpuProgramsMap)
protected

Flush the local GPU programs cache.

Parameters
gpuProgramsMapThe GPU programs cache.
String Ogre::RTShader::ProgramManager::generateGUID ( const String programString)
protected

Generates a unique guid value from a string.

Parameters
programStringstring to generate a hash value for
Returns
A string representing a 128 bit hash value of the original string
size_t Ogre::RTShader::ProgramManager::getFragmentShaderCount ( ) const
inlineprotected

Return the number of created fragment shaders.

Definition at line 208 of file OgreShaderProgramManager.h.

static ProgramManager& Ogre::RTShader::ProgramManager::getSingleton ( )
static

Override standard Singleton retrieval.

Remarks
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.
static ProgramManager* Ogre::RTShader::ProgramManager::getSingletonPtr ( )
static

Override standard Singleton retrieval.

Remarks
Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.
This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.
size_t Ogre::RTShader::ProgramManager::getVertexShaderCount ( ) const
inlineprotected

Return the number of created vertex shaders.

Definition at line 205 of file OgreShaderProgramManager.h.

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.

void Ogre::RTShader::ProgramManager::releasePrograms ( Pass pass,
TargetRenderState renderState 
)

Release CPU/GPU programs set associated with the given render state and pass.

Parameters
passThe pass to release the programs from.
renderStateThe render state holds the programs.
void Ogre::RTShader::ProgramManager::removeProgramProcessor ( ProgramProcessor processor)
protected

Remove program processor instance from this manager.

Parameters
processorThe instance to remove.
void Ogre::RTShader::ProgramManager::synchronizePixelnToBeVertexOut ( ProgramSet programSet)
protected

Fix the input of the pixel shader to be the same as the output of the vertex shader.

Friends And Related Function Documentation

friend class ProgramSet
friend

Definition at line 237 of file OgreShaderProgramManager.h.

friend class ShaderGenerator
friend

Definition at line 239 of file OgreShaderProgramManager.h.

friend class TargetRenderState
friend

Definition at line 238 of file OgreShaderProgramManager.h.

Member Data Documentation

ProgramList Ogre::RTShader::ProgramManager::mCpuProgramsList
protected

Definition at line 222 of file OgreShaderProgramManager.h.

ProgramProcessorList Ogre::RTShader::ProgramManager::mDefaultProgramProcessors
protected

Definition at line 234 of file OgreShaderProgramManager.h.

GpuProgramsMap Ogre::RTShader::ProgramManager::mFragmentShaderMap
protected

Definition at line 232 of file OgreShaderProgramManager.h.

ProgramProcessorMap Ogre::RTShader::ProgramManager::mProgramProcessorsMap
protected

Definition at line 226 of file OgreShaderProgramManager.h.

ProgramWriterFactoryList Ogre::RTShader::ProgramManager::mProgramWriterFactories
protected

Definition at line 228 of file OgreShaderProgramManager.h.

ProgramWriterMap Ogre::RTShader::ProgramManager::mProgramWritersMap
protected

Definition at line 224 of file OgreShaderProgramManager.h.

ProgramManager * Ogre::Singleton< ProgramManager >::msSingleton
staticprotectedinherited

Definition at line 75 of file OgreSingleton.h.

GpuProgramsMap Ogre::RTShader::ProgramManager::mVertexShaderMap
protected

Definition at line 230 of file OgreShaderProgramManager.h.


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