![]() |
VR-Forces 5.0.2 Developer's Guide
|
DtGlBufferMemoryTracker class is used to track memory for buffers to which it is added as a listener.
This class is used to track buffers' (DtGlBuffer) memory as they are created/deleted.
This class is also used to track which amongst those buffers (that it is tracking) have been made resident/non-resident.
Resident memory/Non-resident memory is always a subset of memory of the buffers that are being tracked.
For example, if there are 100 buffers sized 2 Mb each, the total memory in use is 200 Mb. Out of those, if 25 buffers are resident, the total 'resident' memory is 50 Mb.
The difference between resident and in use memory is that a resident memory is not swappable (paged out to the virtual vram/cpu ram or even disk), if it has been declared resident. It must reside on the gpu at all times (until it is made non-resident) Please look at DtGlBuffer::gpuResidentAddress
The way to use this class is make an instance of the class and register any buffers that you want to track the memory of on it using DtGlBuffer::setListener.
The DtGlBuffer takes an abstract DtGlBufferListener that, if set, the buffer, will call DtGlBufferListener::bufferSizeChanged, DtGlBufferListener::bufferResidencyChanging and DtGlBufferListener::bufferDeleted when it resizes/becomes resident/non resident/deleted
This class, since it implements DtGlBufferListener abstract class, will update the memory characteristics (DtBufferTypeProperties) for the buffers it is tracking.
Currently, in vrv, all DtGlBuffers are of type DtCoreGlBuffer (which in turn inherits from DtGlBuffer) DtCoreGlBuffers are created using DtCoreGlBufferCreator. In the DtCoreGlBufferCreator::create, just before it returns the buffer, we set an instance of this class as a listener (if memory tracking has been enabled)
Currently, we want to track all the buffers created on the vrv side, so in the creator we set the same instance of this class as the listener on those buffers. So in this sense this tracker is a singleton for the run of the vrv
The class, since its updating the buffer numbers/types via the signals called from the buffers can be queried at any time using these functions: DtGlBufferMemoryTracker::properties -> all buffers DtGlBufferMemoryTracker::propertiesBindless -> all buffers that became resident/non-resident
Currently, we have hooked up visualizing these properties to Imgui via F4. See DtImGuiLoaderStatsData::updateGpuStats
****Note**** If you wish to track multiple subsets of buffers you can create specific instances of this class for those buffers. Note however though, that a DtGlBuffer (for speed reasons) can have only one listener on it. So this organization into subsets is something that the client must externally do.
Public Member Functions | |
| DtGlBufferMemoryTracker () | |
| virtual | ~DtGlBufferMemoryTracker () |
| DtGlBufferMemoryTracker (const DtGlBufferMemoryTracker &)=delete | |
| DtGlBufferMemoryTracker & | operator= (const DtGlBufferMemoryTracker &)=delete |
| virtual void | bufferSizeChanged (DtGlBuffer *buffer) override |
| virtual void | bufferResidencyChanging (DtGlBuffer *buffer, bool resident) override |
| virtual void | bufferDeleted (DtGlBuffer *buffer) override |
| const std::map< DtBufferType, DtBufferTypeProperties > & | properties (void) const |
| const std::map< DtBufferType, DtBufferTypeProperties > & | propertiesBindless (void) const |
Protected Member Functions | |
| virtual void | printMap (std::map< DtBufferType, DtBufferTypeProperties > &aMap) |
| std::string | bufferName (unsigned int id) const |
Protected Attributes | |
| std::map< DtBufferType, DtBufferTypeProperties > | myMapBuffersToProperties |
| std::map< DtBufferType, DtBufferTypeProperties > | myMapBuffersToPropertiesBindless |
| std::unordered_map< unsigned int, int > | myTrackedBuffers |
| std::unordered_map< unsigned int, int > | myTrackedBuffersBindless |
| makVrv::DtGlBufferMemoryTracker::DtGlBufferMemoryTracker | ( | ) |
constructor
|
virtual |
destructor
|
delete |
not allowed
|
delete |
not allowed
|
overridevirtual |
signaled when buffer size changed
Implements makVrv::DtGlBufferListener.
|
overridevirtual |
signaled when buffer size changed
Implements makVrv::DtGlBufferListener.
|
overridevirtual |
buffer being deleted
Implements makVrv::DtGlBufferListener.
| const std::map<DtBufferType, DtBufferTypeProperties>& makVrv::DtGlBufferMemoryTracker::properties | ( | void | ) | const |
accessor for all buffers
| const std::map<DtBufferType, DtBufferTypeProperties>& makVrv::DtGlBufferMemoryTracker::propertiesBindless | ( | void | ) | const |
accessor for bindless buffers (subset of the buffers above)
|
protectedvirtual |
internal
get the name of the buffer
|
protected |
memory for specific buffer types, whether they are bindless or not
|
protected |
memory for specific buffer types, bindless
|
protected |