OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::HlmsBufferManager Class Reference

Managing constant and texture buffers for sending shader parameters is a very similar process to most Hlms implementations using them. More...

#include <OgreHlmsBufferManager.h>

+ Inheritance diagram for Ogre::HlmsBufferManager:

Public Member Functions

 HlmsBufferManager (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
 
 ~HlmsBufferManager () override
 
void _changeRenderSystem (RenderSystem *newRs) override
 
void frameEnded () override
 Called when the frame has fully ended (ALL passes have been executed to all RTTs) More...
 
void postCommandBufferExecution (CommandBuffer *commandBuffer) override
 This gets called after executing the command buffer. More...
 
void preCommandBufferExecution (CommandBuffer *commandBuffer) override
 This gets called right before executing the command buffer. More...
 
HlmsCache preparePassHash (const Ogre::CompositorShadowNode *shadowNode, bool casterPass, bool dualParaboloid, SceneManager *sceneManager) override
 Called every frame by the Render Queue to cache the properties needed by this pass. More...
 
void setTextureBufferDefaultSize (size_t defaultSize)
 Changes the default suggested size for the texture buffer. More...
 
- Public Member Functions inherited from Ogre::Hlms
 Hlms (HlmsTypes type, const String &typeName, Archive *dataFolder, ArchiveVec *libraryFolders)
 
virtual ~Hlms ()
 
void _addDatablockCustomPieceFile (const String &filename, const String &resourceGroup)
 See HlmsDatablock::setCustomPieceCodeFromMemory & HlmsDatablock::setCustomPieceFile. More...
 
CachedCustomPieceFileStatus _addDatablockCustomPieceFile (const String &filename, const String &resourceGroup, const uint64 sourceCodeHash[2])
 
void _addDatablockCustomPieceFileFromMemory (const String &filename, const String &sourceCode)
 
void _clearShaderCache ()
 
virtual void _collectSamplerblocks (set< const HlmsSamplerblock * >::type &outSamplerblocks, const HlmsDatablock *datablock) const
 
void _compileShaderFromPreprocessedSource (const RenderableCache &mergedCache, const String source[NumShaderTypes], const uint32 shaderCounter, size_t tid)
 
int32 _getProperty (size_t tid, IdString key, int32 defaultVal=0) const
 
virtual void _loadJson (const rapidjson::Value &jsonValue, const HlmsJson::NamedBlocks &blocks, HlmsDatablock *datablock, const String &resourceGroup, HlmsJsonListener *listener, const String &additionalTextureExtension) const
 Loads datablock values from a JSON value. More...
 
void _notifyManager (HlmsManager *manager)
 
virtual void _saveJson (const HlmsDatablock *datablock, String &outString, HlmsJsonListener *listener, const String &additionalTextureExtension) const
 
void _setNumThreads (size_t numThreads)
 
void _setProperty (size_t tid, IdString key, int32 value)
 For debugging stuff. I.e. the Command line uses it for testing manually set properties. More...
 
void _setShadersGenerated (uint32 shadersGenerated)
 
void _setTextureReg (size_t tid, ShaderType shaderType, const char *texName, int32 texUnit)
 
void _tagShaderCodeCacheUpToDate ()
 
virtual void analyzeBarriers (BarrierSolver &barrierSolver, ResourceTransitionArray &resourceTransitions, Camera *renderingCamera, const bool bCasterPass)
 
virtual void calculateHashFor (Renderable *renderable, uint32 &outHash, uint32 &outCasterHash)
 Called by the renderable when either it changes the material, or its properties change (e.g., the mesh's uvs are stripped) More...
 
void compileShaderCode (ShaderCodeCache &codeCache, uint32 shaderCounter, size_t tid)
 Compiles input properties and adds it to the shader code cache. More...
 
void compileStubEntry (const HlmsCache &passCache, HlmsCache *reservedStubEntry, QueuedRenderable queuedRenderable, uint32 renderableHash, uint32 finalHash, size_t tid)
 Called by ParallelHlmsCompileQueue to finish the job started in getMaterial() More...
 
HlmsDatablockcreateDatablock (IdString name, const String &refName, const HlmsMacroblock &macroblockRef, const HlmsBlendblock &blendblockRef, const HlmsParamVec &paramVec, bool visibleToManager=true, const String &filename=BLANKSTRING, const String &resourceGroup=BLANKSTRING)
 Creates a unique datablock that can be shared by multiple renderables. More...
 
void destroyAllDatablocks ()
 Destroys all datablocks created with createDatablock(). More...
 
void destroyDatablock (IdString name)
 Destroys a datablocks given its name. More...
 
virtual uint32 fillBuffersFor (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, uint32 lastTextureHash)=0
 Fills the constant buffers. More...
 
virtual uint32 fillBuffersForV1 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer)=0
 
virtual uint32 fillBuffersForV2 (const HlmsCache *cache, const QueuedRenderable &queuedRenderable, bool casterPass, uint32 lastCacheHash, CommandBuffer *commandBuffer)=0
 
uint16 getAreaLightsApproxLimit () const
 
uint16 getAreaLightsLtcLimit () const
 
HlmsDatablockgetDatablock (IdString name) const
 Finds an existing datablock based on its name (. More...
 
const DatablockCustomPieceFilegetDatablockCustomPieceData (int32 filenameHashId) const
 Returns all the data we know about filenameHashId. Can be nullptr if not found. More...
 
const StringgetDatablockCustomPieceFileNameStr (int32 filenameHashId) const
 
const HlmsDatablockMapgetDatablockMap () const
 Returns all datablocks owned by this Hlms, including the default one. More...
 
ArchivegetDataFolder ()
 
HlmsDatablockgetDefaultDatablock () const
 Datablock to use when another datablock failed or none was specified. More...
 
bool getFastShaderBuildHack () const
 Returns true if shaders are being compiled with Fast Shader Build Hack (D3D11 only) More...
 
void getFilenameAndResourceGroup (IdString name, String const **outFilename, String const **outResourceGroup) const
 Returns the filaname & resource group a datablock was created from, and is associated with its hashed name (this was passed as in createDatablock()). More...
 
HlmsManagergetHlmsManager () const
 
HlmsListenergetListener () const
 Returns the current listener. More...
 
const HlmsCachegetMaterial (HlmsCache const *lastReturnedValue, const HlmsCache &passCache, const QueuedRenderable &queuedRenderable, bool casterPass, ParallelHlmsCompileQueue *parallelQueue)
 Retrieves an HlmsCache filled with the GPU programs to be used by the given renderable. More...
 
uint32 getMaterialSerial01 (uint32 lastReturnedValue, const HlmsCache &passCache, const size_t passCacheIdx, const QueuedRenderable &queuedRenderable, bool casterPass, ParallelHlmsCompileQueue &parallelQueue)
 This is extremely similar to getMaterial() except it's been designed to be always in parallel and to be used by warm_up passes. More...
 
uint16 getMaxNonCasterDirectionalLights () const
 
const StringgetNameStr (IdString name) const
 Returns the string name associated with its hashed name (this was passed as refName in createDatablock()). More...
 
uint8 getParticleSystemConstSlot () const
 
uint8 getParticleSystemSlot () const
 
const LibraryVecgetPiecesLibrary () const
 
ArchiveVec getPiecesLibraryAsArchiveVec () const
 
PrecisionMode getPrecisionMode () const
 Returns requested precision mode (i.e., value passed to setPrecisionMode) See getSupportedPrecisionMode. More...
 
RenderSystemgetRenderSystem () const
 
const ShaderCodeCacheVec & getShaderCodeCache () const
 
const StringgetShaderProfile () const
 
IdString getShaderSyntax () const
 
bool getStaticBranchingLights () const
 
PrecisionMode getSupportedPrecisionMode () const
 Some GPUs don't support all precision modes. More...
 
void getTemplateChecksum (uint64 outHash[2]) const
 
HlmsTypes getType () const
 
IdString getTypeName () const
 
const StringgetTypeNameStr () const
 
bool isDatablockCustomPieceFileCacheable (int32 filenameHashId) const
 
bool isShaderCodeCacheDirty () const
 Users can check this function to tell if HlmsDiskCache needs saving. More...
 
bool parseOffline (const String &filename, String &inBuffer, String &outBuffer, size_t tid)
 For standalone parsing. More...
 
virtual void reloadFrom (Archive *newDataFolder, ArchiveVec *libraryFolders=0)
 Destroys all the cached shaders and in the next opportunity will recreate them from the new location. More...
 
void saveAllTexturesFromDatablocks (const String &folderPath, set< String >::type &savedTextures, bool saveOitd, bool saveOriginal, HlmsTextureExportListener *listener)
 
void setAreaLightForwardSettings (uint16 areaLightsApproxLimit, uint16 areaLightsLtcLimit)
 Area lights use regular Forward. More...
 
void setDebugOutputPath (bool enableDebugOutput, bool outputProperties, const String &path=BLANKSTRING)
 Call to output the automatically generated shaders (which are usually made from templates) on the given folder for inspection, analyzing, debugging, etc. More...
 
void setListener (HlmsListener *listener)
 Sets a listener to extend an existing Hlms implementation's with custom code, without having to rewrite it or modify the source code directly. More...
 
void setMaxNonCasterDirectionalLights (uint16 maxLights)
 Non-caster directional lights are hardcoded into shaders. More...
 
void setPrecisionMode (PrecisionMode precisionMode)
 Sets the precision mode of Hlms. More...
 
virtual void setStaticBranchingLights (bool staticBranchingLights)
 By default shadow-caster spot and point lights are hardcoded into shaders. More...
 

Additional Inherited Members

- Public Types inherited from Ogre::Hlms
enum  CachedCustomPieceFileStatus { CCPFS_Success , CCPFS_OutOfDate , CCPFS_CriticalError }
 
typedef std::map< int32, DatablockCustomPieceFileDatablockCustomPieceFileMap
 
typedef std::map< IdString, DatablockEntryHlmsDatablockMap
 
typedef vector< Library >::type LibraryVec
 
enum  LightGatheringMode { LightGatherForward , LightGatherForwardPlus , LightGatherDeferred , LightGatherNone }
 
enum  PrecisionMode { PrecisionFull32 , PrecisionMidf16 , PrecisionRelaxed }
 
- Static Public Member Functions inherited from Ogre::Hlms
static void _setHasParticleFX2Plugin (bool bHasPfx2Plugin)
 
static bool findParamInVec (const HlmsParamVec &paramVec, IdString key, String &inOut)
 Finds the parameter with key 'key' in the given 'paramVec'. More...
 
static int32 getProperty (const HlmsPropertyVec &properties, IdString key, int32 defaultVal=0)
 Utility helper, mostly useful to HlmsListener implementations. More...
 
static bool hasParticleFX2Plugin ()
 
static void setProperty (HlmsPropertyVec &properties, IdString key, int32 value)
 Utility helper, mostly useful to HlmsListener implementations. More...
 
- Static Public Attributes inherited from Ogre::Hlms
static constexpr size_t kNoTid = 0u
 For single-threaded operations. More...
 

Detailed Description

Managing constant and texture buffers for sending shader parameters is a very similar process to most Hlms implementations using them.

This class offers the shared functionality for them, such as

  1. Rebinding buffers when necessary, with the right offsets and sizes.
  2. Requesting more memory.
  3. Mapping it.

Constructor & Destructor Documentation

◆ HlmsBufferManager()

Ogre::HlmsBufferManager::HlmsBufferManager ( HlmsTypes  type,
const String typeName,
Archive dataFolder,
ArchiveVec libraryFolders 
)

◆ ~HlmsBufferManager()

Ogre::HlmsBufferManager::~HlmsBufferManager ( )
override

Member Function Documentation

◆ _changeRenderSystem()

void Ogre::HlmsBufferManager::_changeRenderSystem ( RenderSystem newRs)
overridevirtual

Reimplemented from Ogre::Hlms.

Reimplemented in Ogre::HlmsUnlit, and Ogre::HlmsPbs.

◆ frameEnded()

void Ogre::HlmsBufferManager::frameEnded ( )
overridevirtual

Called when the frame has fully ended (ALL passes have been executed to all RTTs)

Reimplemented from Ogre::Hlms.

Reimplemented in Ogre::HlmsUnlit, and Ogre::HlmsPbs.

◆ postCommandBufferExecution()

void Ogre::HlmsBufferManager::postCommandBufferExecution ( CommandBuffer commandBuffer)
overridevirtual

This gets called after executing the command buffer.

Reimplemented from Ogre::Hlms.

Reimplemented in Ogre::HlmsPbs.

◆ preCommandBufferExecution()

void Ogre::HlmsBufferManager::preCommandBufferExecution ( CommandBuffer commandBuffer)
overridevirtual

This gets called right before executing the command buffer.

Reimplemented from Ogre::Hlms.

◆ preparePassHash()

HlmsCache Ogre::HlmsBufferManager::preparePassHash ( const Ogre::CompositorShadowNode shadowNode,
bool  casterPass,
bool  dualParaboloid,
SceneManager sceneManager 
)
overridevirtual

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 calculateHashFor(), 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)

Reimplemented from Ogre::Hlms.

Reimplemented in Ogre::HlmsUnlit, and Ogre::HlmsPbs.

◆ setTextureBufferDefaultSize()

void Ogre::HlmsBufferManager::setTextureBufferDefaultSize ( size_t  defaultSize)

Changes the default suggested size for the texture buffer.

Actual size may be lower if the GPU can't honour the request.


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