VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
makVrv::DtGlBufferMemoryTracker Class Reference

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.

Inheritance diagram for makVrv::DtGlBufferMemoryTracker:
Inheritance graph
[legend]

Public Member Functions

 DtGlBufferMemoryTracker ()
 
virtual ~DtGlBufferMemoryTracker ()
 
 DtGlBufferMemoryTracker (const DtGlBufferMemoryTracker &)=delete
 
DtGlBufferMemoryTrackeroperator= (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
 

Constructor & Destructor Documentation

makVrv::DtGlBufferMemoryTracker::DtGlBufferMemoryTracker ( )

constructor

virtual makVrv::DtGlBufferMemoryTracker::~DtGlBufferMemoryTracker ( )
virtual

destructor

makVrv::DtGlBufferMemoryTracker::DtGlBufferMemoryTracker ( const DtGlBufferMemoryTracker )
delete

not allowed

Member Function Documentation

DtGlBufferMemoryTracker& makVrv::DtGlBufferMemoryTracker::operator= ( const DtGlBufferMemoryTracker )
delete

not allowed

virtual void makVrv::DtGlBufferMemoryTracker::bufferSizeChanged ( DtGlBuffer buffer)
overridevirtual

signaled when buffer size changed

Implements makVrv::DtGlBufferListener.

virtual void makVrv::DtGlBufferMemoryTracker::bufferResidencyChanging ( DtGlBuffer buffer,
bool  resident 
)
overridevirtual

signaled when buffer size changed

Implements makVrv::DtGlBufferListener.

virtual void makVrv::DtGlBufferMemoryTracker::bufferDeleted ( DtGlBuffer buffer)
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)

virtual void makVrv::DtGlBufferMemoryTracker::printMap ( std::map< DtBufferType, DtBufferTypeProperties > &  aMap)
protectedvirtual

internal

std::string makVrv::DtGlBufferMemoryTracker::bufferName ( unsigned int  id) const
protected

get the name of the buffer

Member Data Documentation

std::map<DtBufferType, DtBufferTypeProperties> makVrv::DtGlBufferMemoryTracker::myMapBuffersToProperties
protected

memory for specific buffer types, whether they are bindless or not

std::map<DtBufferType, DtBufferTypeProperties> makVrv::DtGlBufferMemoryTracker::myMapBuffersToPropertiesBindless
protected

memory for specific buffer types, bindless

std::unordered_map<unsigned int, int> makVrv::DtGlBufferMemoryTracker::myTrackedBuffers
protected
std::unordered_map<unsigned int, int> makVrv::DtGlBufferMemoryTracker::myTrackedBuffersBindless
protected

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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)