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

Vaos are OpenGL context specific. They need to be deleted in the context they are created in. Deleting them in a context they are not created in can cause crashes:

Example 1: a vao id in one context representing draw calls state for 1 model/renderable (say 'a') may refer to another vao id in another context for another mesh/renderable altogether (say 'b') So deleting the one for 'a' depending on which context you were in, while actually meaning to delete the one for 'b' can cause the render for 'a' to corrupt or cause a crash

Example 2: a vao id, in one context may not be a legitimate vao id in another context at all. So deleting that vao in the other context can cause OpenGL errors or crashes.

Similarly, Fbos are OpenGL context specific. All of the above applies almost word for word for Fbos. Except that Fbos encapsulate render to texture state, not buffer attributes, bindings like the vao does.

Buffers in VRV are shared across contexts (currently). So, you could actually delete them anywhere. There is a problem with this approach however, because destructors (or releaseGlObjects) on objects (models, etc) holding these can be called from: -a thread that is not the main thread and no associated OpenGL context -a thread (main or otherwise) where the OpenGL context is not active

So, for these 3 classes of OpenGL objects, once you are done with them, you need to call these methods: -DtGlDeleteObjectManager::addVaoToDelete -DtGlDeleteObjectManager::addFboToDelete -DtGlDeleteObjectManager::addBufferHandleToDelete

DtGlDeleteObjectManager::run via DtMainThreadJobsManager once per context This allows this manager to delete the Fbos and Vaos in the right context. This allows this manager to delete the buffers for whichever context is the 1st one active when run is called per tick, per context. (context does not matter, buffers are shared across contexts currently)

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

Public Types

enum  ObjectType { VAO = 0, FBO = 1 }
 

Public Member Functions

virtual ~DtGlDeleteObjectManager ()
 
 DtGlDeleteObjectManager ()=delete
 
DtGlDeleteObjectManageroperator= (const DtGlDeleteObjectManager &rhs)=delete
 
 DtGlDeleteObjectManager (const DtGlDeleteObjectManager &rhs)=delete
 
virtual void run (unsigned int frameNumber)
 
virtual void addVaoToDelete (const DtGlVaoAndContext &vao)
 
virtual void addFboToDelete (const DtGlFboAndContext &fbo)
 
virtual void addBufferHandleToDelete (unsigned int bufferId, bool isMapped=false)
 
virtual void addProgramToDelete (unsigned int programId)
 
virtual void addGlResourceToDelete (DtGlObject *resource)
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Static Public Member Functions

static DtGlDeleteObjectManagerinstance (DtDe &de)
 

Protected Member Functions

 DtGlDeleteObjectManager (DtDe &de)
 
virtual void slot_contextAboutToBeDestroyed (const void *glContext)
 
virtual void deleteObjects (const void *glContext)
 
virtual void deleteObjects (const void *glContext, std::unordered_map< const void *, std::unordered_set< unsigned int > > &map, ObjectType type)
 
virtual void deleteDtGlObjects (const void *glContext)
 
virtual void addObject (std::unordered_map< const void *, std::unordered_set< unsigned int > > &map, const DtGlObjectAndContext &objectAndContext, ObjectType type)
 
virtual void deleteBuffers (void)
 
virtual void deletePrograms (void)
 
virtual void checkMapOnShutdown (std::unordered_map< const void *, std::unordered_set< unsigned int > > &map, ObjectType type)
 

Protected Attributes

DtOsgToGlContextTrackermyOsgToGlContextTracker
 
DtIndirectLogmyIndirectLog
 
DtDemyDe
 
DtSignalConnectionManager myConnections
 
std::unordered_map< const void
*, std::unordered_set
< unsigned int > > 
myVaosToDelete
 
std::unordered_map< const void
*, std::unordered_set
< unsigned int > > 
myFbosToDelete
 
std::unordered_map< const void
*, std::unordered_set
< DtGlObject * > > 
myDtGlObjectsToDelete
 
std::unordered_set< unsigned intmyGlBuffersToDelete
 
std::unordered_set< unsigned intmyGlBuffersToUnmap
 
std::unordered_set< unsigned intmyProgramIdsToDelete
 
boost::mutex myMutex
 
DtGlBufferMemoryTrackermyGlBufferMemoryTracker = nullptr
 

Member Enumeration Documentation

Enumerator
VAO 
FBO 

Constructor & Destructor Documentation

virtual makVrv::DtGlDeleteObjectManager::~DtGlDeleteObjectManager ( )
virtual

destructor

makVrv::DtGlDeleteObjectManager::DtGlDeleteObjectManager ( )
delete

not allowed

makVrv::DtGlDeleteObjectManager::DtGlDeleteObjectManager ( const DtGlDeleteObjectManager rhs)
delete

not allowed

makVrv::DtGlDeleteObjectManager::DtGlDeleteObjectManager ( DtDe de)
protected

only creator can create

Member Function Documentation

static DtGlDeleteObjectManager& makVrv::DtGlDeleteObjectManager::instance ( DtDe de)
static

Access the singleton instance.

DtGlDeleteObjectManager& makVrv::DtGlDeleteObjectManager::operator= ( const DtGlDeleteObjectManager rhs)
delete

not allowed

virtual void makVrv::DtGlDeleteObjectManager::run ( unsigned int  frameNumber)
virtual

run once for every context

virtual void makVrv::DtGlDeleteObjectManager::addVaoToDelete ( const DtGlVaoAndContext vao)
virtual

add a vao to delete

virtual void makVrv::DtGlDeleteObjectManager::addFboToDelete ( const DtGlFboAndContext fbo)
virtual

add a fbo to delete

virtual void makVrv::DtGlDeleteObjectManager::addBufferHandleToDelete ( unsigned int  bufferId,
bool  isMapped = false 
)
virtual

add a buffer to delete isMapped - set to true if buffer is currently mapped

virtual void makVrv::DtGlDeleteObjectManager::addProgramToDelete ( unsigned int  programId)
virtual

add a program to delete

virtual void makVrv::DtGlDeleteObjectManager::addGlResourceToDelete ( DtGlObject resource)
virtual

add a generic DtGlResource to delete

virtual void makVrv::DtGlDeleteObjectManager::slot_contextAboutToBeDestroyed ( const void *  glContext)
protectedvirtual

slot for when a context is about to be destroyed This is used to delete the vao

virtual void makVrv::DtGlDeleteObjectManager::deleteObjects ( const void *  glContext)
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::deleteObjects ( const void *  glContext,
std::unordered_map< const void *, std::unordered_set< unsigned int > > &  map,
ObjectType  type 
)
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::deleteDtGlObjects ( const void *  glContext)
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::addObject ( std::unordered_map< const void *, std::unordered_set< unsigned int > > &  map,
const DtGlObjectAndContext objectAndContext,
ObjectType  type 
)
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::deleteBuffers ( void  )
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::deletePrograms ( void  )
protectedvirtual

internal

virtual void makVrv::DtGlDeleteObjectManager::checkMapOnShutdown ( std::unordered_map< const void *, std::unordered_set< unsigned int > > &  map,
ObjectType  type 
)
protectedvirtual

internal

Member Data Documentation

DtOsgToGlContextTracker& makVrv::DtGlDeleteObjectManager::myOsgToGlContextTracker
protected
DtIndirectLog& makVrv::DtGlDeleteObjectManager::myIndirectLog
protected
DtDe& makVrv::DtGlDeleteObjectManager::myDe
protected
DtSignalConnectionManager makVrv::DtGlDeleteObjectManager::myConnections
protected

for handling context destroyed event

std::unordered_map<const void*, std::unordered_set<unsigned int> > makVrv::DtGlDeleteObjectManager::myVaosToDelete
protected
std::unordered_map<const void*, std::unordered_set<unsigned int> > makVrv::DtGlDeleteObjectManager::myFbosToDelete
protected
std::unordered_map<const void*, std::unordered_set<DtGlObject*> > makVrv::DtGlDeleteObjectManager::myDtGlObjectsToDelete
protected
std::unordered_set<unsigned int> makVrv::DtGlDeleteObjectManager::myGlBuffersToDelete
protected

list of handles to delete and potentially unmap if mapped

std::unordered_set<unsigned int> makVrv::DtGlDeleteObjectManager::myGlBuffersToUnmap
protected
std::unordered_set<unsigned int> makVrv::DtGlDeleteObjectManager::myProgramIdsToDelete
protected
boost::mutex makVrv::DtGlDeleteObjectManager::myMutex
protected
DtGlBufferMemoryTracker* makVrv::DtGlDeleteObjectManager::myGlBufferMemoryTracker = nullptr
protected

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

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)