Emergency 2017 Dokumentation  v3.0.1
qsf::PipelineStateCacheManager Class Reference

Pipeline state cache manager. More...

#include <PipelineStateCacheManager.h>

Public Member Functions

PipelineStateCachegetPipelineStateCacheByCombination (const MaterialBlueprint &materialBlueprint, const ShaderProperties &shaderProperties, const DynamicShaderPieces dynamicShaderPieces[Ogre::NumShaderTypes], uint32 ogreHash, bool allowEmergencySynchronousCompilation)
 Request a pipeline state cache instance by combination. More...
 
void clearCache ()
 Clear the pipeline state cache manager. More...
 
void cleanupDirtyCacheParts (const ProgramCacheIds &deletedProgramCacheIds, PipelineStateCacheIds &deletedPipelineStateCacheIds, OgreHlmsCacheHashes &deletedOgreHlmsCacheHashes)
 Cleanup dirty cache parts. More...
 
void serializeCache (BinarySerializer &binarySerializer)
 Serialize the pipeline state cache manager. More...
 
- Public Member Functions inherited from qsf::ElementManager< PipelineStateCacheId, PipelineStateCache, detail::DirectAllocator< PipelineStateCache >, ConsecutiveIdGenerator< uint32 > >
 ElementManager ()
 Default constructor. More...
 
virtual ~ElementManager ()
 Destructor. More...
 
const ElementMapgetElements () const
 Return map of elements. More...
 
PipelineStateCachefindElement (const PipelineStateCacheId &key) const
 Find a specific element by its key in either the element map. More...
 
void reserveElements (size_t numberOfElements)
 Reserve elements. More...
 
PipelineStateCachecreateElement ()
 Create a new element. More...
 
PipelineStateCachecreateElementById (const PipelineStateCacheId &key)
 Create a new element with an enforced given unique element identifier. More...
 
bool insertElement (const PipelineStateCacheId &key, PipelineStateCache &element)
 Insert an element with an enforced given unique element identifier. More...
 
bool destroyElement (const PipelineStateCacheId &key)
 Destroy an element by its key. More...
 
ElementManager< PipelineStateCacheId, PipelineStateCache, detail::DirectAllocator< PipelineStateCache >, ConsecutiveIdGenerator< uint32 > >::ElementMap::iterator destroyElement (typename ElementMap::iterator iterator)
 Destroy an element by iterator. More...
 
void destroyAllElements ()
 Destroy all elements. More...
 
PipelineStateCachegrabElement (const PipelineStateCacheId &key)
 Remove an element from the element manager without destroying it. More...
 
PipelineStateCacheId generateId ()
 Generate a new, unused key. More...
 

Friends

class MaterialBlueprint
 Is creating and using a pipeline cache manager instance. More...
 

Additional Inherited Members

- Public Types inherited from qsf::ElementManager< PipelineStateCacheId, PipelineStateCache, detail::DirectAllocator< PipelineStateCache >, ConsecutiveIdGenerator< uint32 > >
typedef boost::container::flat_map< PipelineStateCacheId, PipelineStateCache * > ElementMap
 
- Protected Member Functions inherited from qsf::ElementManager< PipelineStateCacheId, PipelineStateCache, detail::DirectAllocator< PipelineStateCache >, ConsecutiveIdGenerator< uint32 > >
ElementMapgetElementsWritable ()
 Return map of elements. More...
 
virtual void onElementInsertion (const PipelineStateCacheId &key, PipelineStateCache &element)
 Called whenever an element is inserted into the element map. More...
 
virtual void onElementRemoval (const PipelineStateCacheId &key, PipelineStateCache &element)
 Called whenever an element is actually going to be destroyed. More...
 
- Protected Member Functions inherited from qsf::Manager
 Manager ()
 Default constructor. More...
 
virtual ~Manager ()
 Destructor. More...
 

Detailed Description

Pipeline state cache manager.

Remarks
The pipeline state cache is the top of the shader related cache hierarchy and maps to Direct3D 12, Vulkan, AMD Mantle, Apple Metal and other rendering APIs using pipeline state objects (PSO). The next cache hierarchy level is the program cache which maps to linked monolithic OpenGL programs and is also nice as a collection of shader compiler results which are fed into pipeline states. The next lowest cache hierarchy level is the shader cache (vertex shader, pixel shader etc.) which handles the binary results of the shader compiler. As of January 2016, although claimed to fulfill the OpenGL 4.1 specification, Apples OpenGL implementation used on Mac OS X lacks the feature of receiving the program binary in order to reuse it for the next time instead of fully compiling a program. Hence, at the lowest cache hierarchy, there's a shader source code cache for the build shader source codes so at least this doesn't need to be performed during each program execution.

Sum up of the cache hierarchy:

  • 0: "qsf::PipelineStateCacheManager": Maps to Direct3D 12, AMD Mantle, Apple Metal etc.; managed by material blueprint
  • 1: "qsf::ProgramCacheManager": Maps to linked monolithic OpenGL programs; managed by shader blueprint manager
  • 2: "qsf::ShaderCacheManager": Maps to Direct3D 9 - 11, separate OpenGL shader objects and is still required for Direct3D 12 and other similar designed APIs because the binary shaders are required when creating pipeline state objects; managed by shader blueprint manager
  • 3: "qsf::ShaderSourceCodeCacheManager": Shader source code cache for the build shader source codes, used for e.g. Apples OpenGL implementation lacking of binary program support; managed by shader blueprint manager

The pipeline state cache has two types of IDs:

  • "qsf::PipelineStateSignatureId" -> Result of hashing the material blueprint ID and the shader combination generating shader properties and dynamic shader pieces
  • "qsf::PipelineStateCacheId" -> Includes the hashing the build shader source code Those two types of IDs are required because it's possible that different "qsf::PipelineStateSignatureId" result in one and the same build shader source code of references shaders.
Note
  • One pipeline state cache manager per material blueprint instance
Todo:

Definition at line 93 of file PipelineStateCacheManager.h.

Member Function Documentation

void qsf::PipelineStateCacheManager::cleanupDirtyCacheParts ( const ProgramCacheIds deletedProgramCacheIds,
PipelineStateCacheIds deletedPipelineStateCacheIds,
OgreHlmsCacheHashes deletedOgreHlmsCacheHashes 
)

Cleanup dirty cache parts.

Parameters
[in]deletedProgramCacheIdsIDs of the deleted program caches
[out]deletedPipelineStateCacheIdsReceives the IDs of the deleted pipeline state caches
[out]deletedOgreHlmsCacheHashesReceives the hashes of now invalid OGRE HLMS caches
void qsf::PipelineStateCacheManager::clearCache ( )

Clear the pipeline state cache manager.

PipelineStateCache* qsf::PipelineStateCacheManager::getPipelineStateCacheByCombination ( const MaterialBlueprint materialBlueprint,
const ShaderProperties shaderProperties,
const DynamicShaderPieces  dynamicShaderPieces[Ogre::NumShaderTypes],
uint32  ogreHash,
bool  allowEmergencySynchronousCompilation 
)

Request a pipeline state cache instance by combination.

Parameters
[in]materialBlueprintMaterial blueprint to use
[in]shaderPropertiesShader properties to use
[in]dynamicShaderPiecesDynamic via C++ generated shader pieces to use
[in]ogreHashOGRE hash for usage with "qsf::MaterialBlueprint::getShaderCache()"/"qsf::MaterialBlueprint::addShaderCache()" in order to get an "Ogre::HlmsCache"-instance
[in]allowEmergencySynchronousCompilationAllow emergency synchronous compilation if no fallback could be found? This will result in a runtime hiccup instead of graphics artifacts.
Returns
The requested pipeline state cache instance, null pointer on error, do not destroy the instance
void qsf::PipelineStateCacheManager::serializeCache ( BinarySerializer binarySerializer)

Serialize the pipeline state cache manager.

Friends And Related Function Documentation

friend class MaterialBlueprint
friend

Is creating and using a pipeline cache manager instance.

Definition at line 100 of file PipelineStateCacheManager.h.


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