OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
HLMS stands for "High Level Material System". More...
#include <OgreHlmsManager.h>
Public Types | |
typedef vector< uint16 >::type | BlockIdxVec |
typedef std::map< IdString, HlmsDatablock * > | HlmsDatablockMap |
typedef map< String, String >::type | ResourceToTexExtensionMap |
Public Member Functions | |
HlmsManager () | |
virtual | ~HlmsManager () |
void | _changeRenderSystem (RenderSystem *newRs) |
void | _datablockAdded (HlmsDatablock *datablock) |
Internal function used by Hlms types to tell us a datablock has been created so that we can return it when the user calls @getDatablock. More... | |
void | _datablockDestroyed (IdString name) |
Internal function to inform us that the datablock with the input name has been destroyed. More... | |
const BlockIdxVec & | _getActiveBlocksIndices (const HlmsBasicBlock &blockType) const |
Gets the indices of active blocks. More... | |
const HlmsBlendblock * | _getBlendblock (uint16 idx) const |
Gets a blendblock based on its index. More... | |
BasicBlock const *const * | _getBlocks (const HlmsBasicBlock &blockType) const |
Gets all blocks of a given type. More... | |
uint16 | _getInputLayoutId (const VertexElement2VecVec &vertexElements, OperationType opType) |
Always returns a unique ID for the given vertexElement / OperationType combination, necessary by Hlms to generate a unique PSO. More... | |
const HlmsMacroblock * | _getMacroblock (uint16 idx) const |
Gets a macroblock based on its index. More... | |
const HlmsSamplerblock * | _getSamplerblock (uint16 idx) const |
Gets a samplerblock based on its index. More... | |
void | addReference (const BasicBlock *block) |
Increments the reference count for the block, despite being const. More... | |
void | destroyBlendblock (const HlmsBlendblock *Blendblock) |
void | destroyDescriptorSetSampler (const DescriptorSetSampler *descSet) |
void | destroyDescriptorSetTexture (const DescriptorSetTexture *descSet) |
void | destroyDescriptorSetTexture2 (const DescriptorSetTexture2 *descSet) |
void | destroyDescriptorSetUav (const DescriptorSetUav *descSet) |
void | destroyMacroblock (const HlmsMacroblock *macroblock) |
Destroys a macroblock created by HlmsManager::getMacroblock. More... | |
void | destroySamplerblock (const HlmsSamplerblock *Samplerblock) |
@See destroyMacroblock More... | |
const HlmsBlendblock * | getBlendblock (const HlmsBlendblock &baseParams) |
See HlmsManager::getMacroblock. More... | |
HlmsCompute * | getComputeHlms () |
HlmsDatablock * | getDatablock (IdString name) const |
Retrieves an exisiting datablock (i.e. More... | |
HlmsDatablock * | getDatablockNoDefault (IdString name) const |
@See getDatablock. More... | |
const HlmsDatablockMap & | getDatablocks () const |
Returns all registered datablocks. More... | |
HlmsDatablock * | getDefaultDatablock () const |
Datablock to use when another datablock failed or none was specified. More... | |
const DescriptorSetSampler * | getDescriptorSetSampler (const DescriptorSetSampler &baseParams) |
const DescriptorSetTexture * | getDescriptorSetTexture (const DescriptorSetTexture &baseParams) |
const DescriptorSetTexture2 * | getDescriptorSetTexture2 (const DescriptorSetTexture2 &baseParams) |
const DescriptorSetUav * | getDescriptorSetUav (const DescriptorSetUav &baseParams) |
Hlms * | getHlms (HlmsTypes type) |
Returns a registered HLMS based on type. May be null. More... | |
Hlms * | getHlms (IdString name) |
Returns a registered HLMS based on name. May be null. More... | |
Real | getLoadingOrder () const override |
Gets the relative loading order of scripts of this type. More... | |
const HlmsMacroblock * | getMacroblock (const HlmsMacroblock &baseParams) |
Creates a macroblock that matches the same parameter as the input. More... | |
HlmsDatablock * | getMaterial (IdString name) const |
Alias function. More... | |
RenderSystem * | getRenderSystem () const |
const HlmsSamplerblock * | getSamplerblock (HlmsSamplerblock baseParams) |
@See getMacroblock. More... | |
const StringVector & | getScriptPatterns () const override |
Gets the file patterns which should be used to find scripts for this class. More... | |
void | loadMaterials (const String &filename, const String &groupName, HlmsJsonListener *listener, const String &additionalTextureExtension) |
Opens a file containing a JSON string to load all Hlms materials from. More... | |
void | operator delete (void *ptr) |
void | operator delete (void *ptr, const char *, int, const char *) |
void | operator delete (void *ptr, void *) |
void | operator delete[] (void *ptr) |
void | operator delete[] (void *ptr, const char *, int, const char *) |
void * | operator new (size_t sz) |
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 *ptr) |
placement operator new More... | |
void * | operator new[] (size_t sz) |
void * | operator new[] (size_t sz, const char *file, int line, const char *func) |
array operator new, with debug line info More... | |
void | parseScript (DataStreamPtr &stream, const String &groupName) override |
Parse a script file. More... | |
void | registerComputeHlms (HlmsCompute *provider) |
void | registerHlms (Hlms *provider, bool deleteOnExit=true) |
Registers an HLMS provider. More... | |
void | saveMaterial (const HlmsDatablock *datablock, const String &filename, HlmsJsonListener *listener, const String &additionalTextureExtension) |
Saves a specific Hlms material at the given file location. More... | |
void | saveMaterials (HlmsTypes hlmsType, const String &filename, HlmsJsonListener *listener, const String &additionalTextureExtension) |
Saves all materials of the registered Hlms at the given file location. More... | |
void | unregisterComputeHlms () |
void | unregisterHlms (HlmsTypes type) |
Unregisters an HLMS provider of the given type. More... | |
void | useDefaultDatablockFrom (HlmsTypes type) |
Public Attributes | |
ResourceToTexExtensionMap | mAdditionalTextureExtensionsPerGroup |
HlmsJsonListener * | mJsonListener |
HLMS stands for "High Level Material System".
HlmsMacroblock & HlmsBlendblock pointers are never recycled when their reference counts reach 0. This allows us to better cache PSOs instead of destroying them every time materials are destroyed.
A user can only create up to OGRE_HLMS_MAX_LIFETIME_MACROBLOCKS & OGRE_HLMS_MAX_LIFETIME_BLENDBLOCKS. If for some reason you need more, increase these values (they're macros) and recompile Ogre
typedef vector<uint16>::type Ogre::HlmsManager::BlockIdxVec |
typedef std::map<IdString, HlmsDatablock*> Ogre::HlmsManager::HlmsDatablockMap |
typedef map<String, String>::type Ogre::HlmsManager::ResourceToTexExtensionMap |
Ogre::HlmsManager::HlmsManager | ( | ) |
|
virtual |
void Ogre::HlmsManager::_changeRenderSystem | ( | RenderSystem * | newRs | ) |
void Ogre::HlmsManager::_datablockAdded | ( | HlmsDatablock * | datablock | ) |
Internal function used by Hlms types to tell us a datablock has been created so that we can return it when the user calls @getDatablock.
void Ogre::HlmsManager::_datablockDestroyed | ( | IdString | name | ) |
Internal function to inform us that the datablock with the input name has been destroyed.
const BlockIdxVec& Ogre::HlmsManager::_getActiveBlocksIndices | ( | const HlmsBasicBlock & | blockType | ) | const |
Gets the indices of active blocks.
const HlmsBlendblock* Ogre::HlmsManager::_getBlendblock | ( | uint16 | idx | ) | const |
Gets a blendblock based on its index.
BasicBlock const* const* Ogre::HlmsManager::_getBlocks | ( | const HlmsBasicBlock & | blockType | ) | const |
Gets all blocks of a given type.
This is an advanced function useful in retrieving all the Macroblocks, all the Blendblocks, and all the Samplerblocks currently in use. Example: Get all macroblocks: const BlockIdxVec &activeMacroblockIdx = mgr->_getActiveBlocksIndices( BLOCK_MACRO ); BasicBlock const * const macroblocks = mgr->_getBlocks( BLOCK_MACRO ); BlockIdxVec::const_iterator itor = activeMacroblockIdx.begin(); BlockIdxVec::const_iterator end = activeMacroblockIdx.end(); while( itor != end ) { const HlmsMacroblock *macroblock = static_cast<const HlmsMacroblock>( macroblocks[*itor] ); ++itor; }
uint16 Ogre::HlmsManager::_getInputLayoutId | ( | const VertexElement2VecVec & | vertexElements, |
OperationType | opType | ||
) |
Always returns a unique ID for the given vertexElement / OperationType combination, necessary by Hlms to generate a unique PSO.
We store the OperationType in the last 6 bits because of v1 reasons, since v1::VertexDeclaration does not store OperationType, thus it cannot cache beforehand, and calling this function from Hlms::calculateHashForV1 would make material asignment to SubEntity more expensive than it is.
That means there 10 bits left for vertexElements, and that's how many different vertex elements you can create (1024).
vertexElements | |
opType |
const HlmsMacroblock* Ogre::HlmsManager::_getMacroblock | ( | uint16 | idx | ) | const |
Gets a macroblock based on its index.
const HlmsSamplerblock* Ogre::HlmsManager::_getSamplerblock | ( | uint16 | idx | ) | const |
Gets a samplerblock based on its index.
void Ogre::HlmsManager::addReference | ( | const BasicBlock * | block | ) |
Increments the reference count for the block, despite being const.
void Ogre::HlmsManager::destroyBlendblock | ( | const HlmsBlendblock * | Blendblock | ) |
void Ogre::HlmsManager::destroyDescriptorSetSampler | ( | const DescriptorSetSampler * | descSet | ) |
void Ogre::HlmsManager::destroyDescriptorSetTexture | ( | const DescriptorSetTexture * | descSet | ) |
void Ogre::HlmsManager::destroyDescriptorSetTexture2 | ( | const DescriptorSetTexture2 * | descSet | ) |
void Ogre::HlmsManager::destroyDescriptorSetUav | ( | const DescriptorSetUav * | descSet | ) |
void Ogre::HlmsManager::destroyMacroblock | ( | const HlmsMacroblock * | macroblock | ) |
Destroys a macroblock created by HlmsManager::getMacroblock.
Blocks are manually reference counted and calling this function will decrease the count.
The internal object (BasicBlock::mRsData) will actually be destroyed when the count reaches 0; however the actual pointer is never deallocated throghout the lifetime of HlmsManager, it is only deactivated.
This guarantees caches of HlmsPso that once a Macroblock is created, its pointer always valid.
When count reaches 0, it will perform an O(N) search but N <= OGRE_HLMS_NUM_MACROBLOCKS
void Ogre::HlmsManager::destroySamplerblock | ( | const HlmsSamplerblock * | Samplerblock | ) |
@See destroyMacroblock
const HlmsBlendblock* Ogre::HlmsManager::getBlendblock | ( | const HlmsBlendblock & | baseParams | ) |
See HlmsManager::getMacroblock.
This is the same for blend states The block's reference count will be increased. Use destroyBlendblock to decrease it.
|
inline |
HlmsDatablock* Ogre::HlmsManager::getDatablock | ( | IdString | name | ) | const |
Retrieves an exisiting datablock (i.e.
material) based on its name, regardless of which HLMS type it belongs to.
name | Unique name of the datablock. Datablock names are unique within the same Hlms type. If two types create a datablock with the same name and both attempt to make it globally visible to this manager, we will throw on creation. |
HlmsDatablock* Ogre::HlmsManager::getDatablockNoDefault | ( | IdString | name | ) | const |
@See getDatablock.
Exactly the same, but returns null pointer if it wasn't found, instead of going fallback to default.
|
inline |
Returns all registered datablocks.
HlmsDatablock* Ogre::HlmsManager::getDefaultDatablock | ( | ) | const |
Datablock to use when another datablock failed or none was specified.
const DescriptorSetSampler* Ogre::HlmsManager::getDescriptorSetSampler | ( | const DescriptorSetSampler & | baseParams | ) |
const DescriptorSetTexture* Ogre::HlmsManager::getDescriptorSetTexture | ( | const DescriptorSetTexture & | baseParams | ) |
const DescriptorSetTexture2* Ogre::HlmsManager::getDescriptorSetTexture2 | ( | const DescriptorSetTexture2 & | baseParams | ) |
const DescriptorSetUav* Ogre::HlmsManager::getDescriptorSetUav | ( | const DescriptorSetUav & | baseParams | ) |
Returns a registered HLMS based on type. May be null.
Returns a registered HLMS based on name. May be null.
|
overridevirtual |
Gets the relative loading order of scripts of this type.
Implements Ogre::ScriptLoader.
const HlmsMacroblock* Ogre::HlmsManager::getMacroblock | ( | const HlmsMacroblock & | baseParams | ) |
Creates a macroblock that matches the same parameter as the input.
If it already exists, returns the existing one.
Macroblocks must be destroyed with destroyMacroblock. Don't try to delete the pointer directly.
Calling this function will increase the reference count of the block. Make sure to call destroyMacroblock after you're done using it; which will decrease the reference count (it won't be actually destroyed until the reference is 0).
Up to 32 different macroblocks are supported at the same time.
VERY IMPORTANT:
You can only create up to OGRE_HLMS_MAX_LIFETIME_MACROBLOCKS different macroblocks throghout the entire lifetime of HlmsManager, EVEN if you call destroyMacroblock on them, as we need to ensure caches of HlmsPso remain valid.
baseParams | A macroblock reference to base the parameters. This reference may live on the stack, on the heap, etc; it's RS-specific data does not have to be filled. e.g. this is fine: HlmsMacroblock myRef; myRef.mDepthCheck = false; HlmsMacroblock *finalBlock = manager->getMacroblock( myRef ); myRef.mRsData == finalBlock.mRsData not necessarily true |
|
inline |
Alias function.
@See getDatablock, as many beginners will probably think of the word "Material" first. Datablock is a more technical (and accurate) name of what it does (it's a block.. of data). Prefer calling getDatablock directly.
|
inline |
const HlmsSamplerblock* Ogre::HlmsManager::getSamplerblock | ( | HlmsSamplerblock | baseParams | ) |
@See getMacroblock.
This is the same for Sampler states
|
inlineoverridevirtual |
Gets the file patterns which should be used to find scripts for this class.
Implements Ogre::ScriptLoader.
void Ogre::HlmsManager::loadMaterials | ( | const String & | filename, |
const String & | groupName, | ||
HlmsJsonListener * | listener, | ||
const String & | additionalTextureExtension | ||
) |
Opens a file containing a JSON string to load all Hlms materials from.
filename | |
groupName |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
operator new, with debug line info
|
inlineinherited |
placement operator new
|
inlineinherited |
|
inlineinherited |
array operator new, with debug line info
|
overridevirtual |
Parse a script file.
stream | Weak reference to a data stream which is the source of the script |
groupName | The name of a resource group which should be used if any resources are created during the parse of this script. |
Implements Ogre::ScriptLoader.
void Ogre::HlmsManager::registerComputeHlms | ( | HlmsCompute * | provider | ) |
void Ogre::HlmsManager::registerHlms | ( | Hlms * | provider, |
bool | deleteOnExit = true |
||
) |
Registers an HLMS provider.
The type is retrieved from the provider. Two providers of the same type cannot be registered at the same time (
provider | The HLMS provider being registered. |
deleteOnExit | True if we should delete the pointer using OGRE_DELETE when the provider is unregistered or when this manager is destroyed. Otherwise it's caller's responsability to free the pointer. |
void Ogre::HlmsManager::saveMaterial | ( | const HlmsDatablock * | datablock, |
const String & | filename, | ||
HlmsJsonListener * | listener, | ||
const String & | additionalTextureExtension | ||
) |
Saves a specific Hlms material at the given file location.
datablock | Datablock/Material to save |
filename | Valid file path. |
void Ogre::HlmsManager::saveMaterials | ( | HlmsTypes | hlmsType, |
const String & | filename, | ||
HlmsJsonListener * | listener, | ||
const String & | additionalTextureExtension | ||
) |
void Ogre::HlmsManager::unregisterComputeHlms | ( | ) |
void Ogre::HlmsManager::unregisterHlms | ( | HlmsTypes | type | ) |
Unregisters an HLMS provider of the given type.
Does nothing if no provider was registered. @See registerHlms for details.
|
inline |
ResourceToTexExtensionMap Ogre::HlmsManager::mAdditionalTextureExtensionsPerGroup |
HlmsJsonListener* Ogre::HlmsManager::mJsonListener |