OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
When mUsedMemory >= mMaxMemory (that is, we've exhausted all our preallocated memory) ArrayMemoryManager will proceed to reallocate all memory. More...
#include <OgreArrayMemoryManager.h>
Public Member Functions | |
virtual void | applyRebase (uint16 level, const MemoryPoolVec &newBasePtrs, const PtrdiffVec &diffsList)=0 |
Called when the manager already grew it's memory pool to honour more node requests. More... | |
virtual void | buildDiffList (uint16 level, const MemoryPoolVec &basePtrs, PtrdiffVec &outDiffsList)=0 |
Called when the manager needs to grow it's memory pool to honour more node requests. More... | |
virtual void | performCleanup (uint16 level, const MemoryPoolVec &basePtrs, size_t const *elementsMemSizes, size_t startInstance, size_t diffInstances)=0 |
Called when too many nodes were destroyed in a non-LIFO fashion. More... | |
When mUsedMemory >= mMaxMemory (that is, we've exhausted all our preallocated memory) ArrayMemoryManager will proceed to reallocate all memory.
The resulting base pointer address may have changed and hence each ArrayVector3, ArrayMatrix4, etc needs to be rebased (alter it's mChunkBase pointer).
It consists in two steps: First build a list of relative differences before deallocation and then apply the new base offseting based on that list. The list is needed because as per C++ standard, once the memory freed, using the pointers is undefined behavior (even freedPtr > someValid pointer is now UB). Most systems using a flat memory model in which case the list wouldn't be needed (since 99% of the times, the ptr is just an integer). However we can't guarantee in which architectures this code will run on.
|
pure virtual |
Called when the manager already grew it's memory pool to honour more node requests.
level | The hierarchy depth level |
newBasePtrs | The new base ptr. |
diffsList | The list built in buildDiffList |
Implemented in Ogre::ObjectMemoryManager, Ogre::NodeMemoryManager, and Ogre::BoneMemoryManager.
|
pure virtual |
Called when the manager needs to grow it's memory pool to honour more node requests.
See the class description on why we need to do this (to avoid C++ undefined behavior)
level | The hierarchy depth level |
basePtrs | The base pointers from each pool so we can calculate the differences |
utDiffsList | The list we'll generate. "outDiffsList" already has enough reserved space |
Implemented in Ogre::ObjectMemoryManager, Ogre::NodeMemoryManager, and Ogre::BoneMemoryManager.
|
pure virtual |
Called when too many nodes were destroyed in a non-LIFO fashion.
Without cleaning up, the scene manager will waste CPU & bandwidth on processing vectors & matrices that are not in use. The more fragmented/unordered those removals were, the worst it is. Try to create everything static first, then dynamic content.
In a way, it's very similar to vector::remove(), as removing an element from the middle means we need to shift everything past that point one place (or more).
level | The hierarchy depth level |
basePtrs | The base ptrs. |
startInstance | The instance to which past that we need to shift |
diffInstances | How many places we need to shift backwards. |
Implemented in Ogre::ObjectMemoryManager, Ogre::NodeMemoryManager, and Ogre::BoneMemoryManager.