VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtGlDeleteObjectManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright(c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 #include <vrvOsg/vrvOsg.h>
11 
15 
16 #include <boost/thread/mutex.hpp>
17 
18 #include <unordered_set>
19 #include <unordered_map>
20 
21 namespace makVrv
22 {
23  class DtDe;
24  class DtOsgToGlContextTracker;
25  class DtIndirectLog;
26  class DtGlBufferMemoryTracker;
27 
59  {
60  public:
62  {
63  VAO = 0, FBO = 1
64  };
65 
66  public:
68  static DtGlDeleteObjectManager& instance(DtDe& de);
69 
71  virtual ~DtGlDeleteObjectManager();
72 
74  DtGlDeleteObjectManager() = delete;
76  DtGlDeleteObjectManager& operator=(const DtGlDeleteObjectManager& rhs) = delete;
79 
80  protected:
83 
84  public:
86  virtual void run(unsigned int frameNumber);
87 
89  virtual void addVaoToDelete(const DtGlVaoAndContext& vao);
90 
92  virtual void addFboToDelete(const DtGlFboAndContext& fbo);
93 
96  virtual void addBufferHandleToDelete(unsigned int bufferId, bool isMapped = false);
97 
99  virtual void addProgramToDelete(unsigned int programId);
100 
102  virtual void addGlResourceToDelete(DtGlObject* resource);
103  protected:
106  virtual void slot_contextAboutToBeDestroyed(const void* glContext);
107 
109  virtual void deleteObjects(const void* glContext);
110 
112  virtual void deleteObjects(const void* glContext, std::unordered_map<const void*, std::unordered_set<unsigned int> >& map, ObjectType type);
113 
115  virtual void deleteDtGlObjects(const void* glContext);
116 
118  virtual void addObject(std::unordered_map<const void*, std::unordered_set<unsigned int> >& map, const DtGlObjectAndContext& objectAndContext, ObjectType type);
119 
121  virtual void deleteBuffers(void);
122 
124  virtual void deletePrograms(void);
125 
127  virtual void checkMapOnShutdown(std::unordered_map<const void*, std::unordered_set<unsigned int> >& map, ObjectType type);
128 
129  protected:
131 
133 
135 
138 
139  std::unordered_map<const void*, std::unordered_set<unsigned int> > myVaosToDelete;
140 
141  std::unordered_map<const void*, std::unordered_set<unsigned int> > myFbosToDelete;
142 
143  std::unordered_map<const void*, std::unordered_set<DtGlObject*> > myDtGlObjectsToDelete;
144 
146  std::unordered_set<unsigned int> myGlBuffersToDelete;
147  std::unordered_set<unsigned int> myGlBuffersToUnmap;
148 
149  std::unordered_set<unsigned int> myProgramIdsToDelete;
150 
151  boost::mutex myMutex;
152 
153  DtGlBufferMemoryTracker* myGlBufferMemoryTracker = nullptr;
154  };
155 }
156 
std::unordered_map< const void *, std::unordered_set< unsigned int > > myFbosToDelete
Definition: DtGlDeleteObjectManager.h:141
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
DtIndirectLog & myIndirectLog
Definition: DtGlDeleteObjectManager.h:132
This class tracks gl contexts as they are created/destroyed per window creation/destruction. It is also what clients should hook to via signal_contextAboutToBeDestroyed for context destruction cleanup.
Definition: DtOsgToGlContextTracker.h:28
A Generic object that needs clean up in the right context (the one it was created in) This can be use...
Definition: DtGlObjects.h:30
std::unordered_map< const void *, std::unordered_set< DtGlObject * > > myDtGlObjectsToDelete
Definition: DtGlDeleteObjectManager.h:143
std::tuple< unsigned int, const void * > DtGlVaoAndContext
a vao and the context it was created in
Definition: DtGlObjects.h:22
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::tuple< unsigned int, const void * > DtGlObjectAndContext
an OpenGL object and the context it was created in
Definition: DtGlObjects.h:25
DtDe & myDe
Definition: DtGlDeleteObjectManager.h:134
std::unordered_set< unsigned int > myProgramIdsToDelete
Definition: DtGlDeleteObjectManager.h:149
std::tuple< unsigned int, const void * > DtGlFboAndContext
an fbo and the context it was created in
Definition: DtGlObjects.h:19
Encapsulates an opengl object and the context it was created in.
std::unordered_set< unsigned int > myGlBuffersToUnmap
Definition: DtGlDeleteObjectManager.h:147
Contains makVrv::DtVirtualBaseClass class.
boost::mutex myMutex
Definition: DtGlDeleteObjectManager.h:151
This class is used to track buffers&#39; memory as they are created/deleted.
Definition: DtGlBufferMemoryTracker.h:81
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
ObjectType
Definition: DtGlDeleteObjectManager.h:61
std::unordered_set< unsigned int > myGlBuffersToDelete
list of handles to delete and potentially unmap if mapped
Definition: DtGlDeleteObjectManager.h:146
DtOsgToGlContextTracker & myOsgToGlContextTracker
Definition: DtGlDeleteObjectManager.h:130
DtSignalConnectionManager myConnections
for handling context destroyed event
Definition: DtGlDeleteObjectManager.h:137
This class is specifically used by the indirect system It&#39;s separate so that it doesn&#39;t interfere wit...
Definition: DtIndirectLog.h:30
Base class to provide boost signal/slot management.
Vaos are OpenGL context specific. They need to be deleted in the context they are created in...
Definition: DtGlDeleteObjectManager.h:58
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
std::unordered_map< const void *, std::unordered_set< unsigned int > > myVaosToDelete
Definition: DtGlDeleteObjectManager.h:139

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)