![]() |
VR-Forces Developer's Guide
|
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)

Public Types | |
| enum | ObjectType { VAO = 0, FBO = 1 } |
Public Member Functions | |
| virtual | ~DtGlDeleteObjectManager () |
| DtGlDeleteObjectManager ()=delete | |
| DtGlDeleteObjectManager & | operator= (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 DtGlDeleteObjectManager & | instance (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 | |
| DtOsgToGlContextTracker & | myOsgToGlContextTracker |
| DtIndirectLog & | myIndirectLog |
| DtDe & | myDe |
| 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 int > | myGlBuffersToDelete |
| std::unordered_set< unsigned int > | myGlBuffersToUnmap |
| std::unordered_set< unsigned int > | myProgramIdsToDelete |
| boost::mutex | myMutex |
| DtGlBufferMemoryTracker * | myGlBufferMemoryTracker = nullptr |
|
virtual |
destructor
|
delete |
not allowed
|
delete |
not allowed
|
protected |
only creator can create
|
static |
Access the singleton instance.
|
delete |
not allowed
run once for every context
|
virtual |
add a vao to delete
|
virtual |
add a fbo to delete
|
virtual |
add a buffer to delete isMapped - set to true if buffer is currently mapped
add a program to delete
|
virtual |
add a generic DtGlResource to delete
|
protectedvirtual |
slot for when a context is about to be destroyed This is used to delete the vao
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protectedvirtual |
internal
|
protected |
|
protected |
|
protected |
|
protected |
for handling context destroyed event
|
protected |
|
protected |
|
protected |
list of handles to delete and potentially unmap if mapped
|
protected |
|
protected |