VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometryRegistrar.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
21 
23 
24 #include <vrvUtil/signalslib.h>
25 
26 #include <osg/Node>
27 #include <osg/Geometry>
28 #include <osg/Texture>
29 #include <osg/Referenced>
30 
31 #include <tbb/concurrent_queue.h>
32 #include <atomic>
33 #include <tbb/task.h>
34 
35 #include <string>
36 #include <vector>
37 #include <unordered_set>
38 
39 #include <shared_mutex>
40 
41 #define INDIRECTGEOMETRYREGISTRAR_DEBUG 0
42 
43 namespace osgUtil{
44  class CullVisitor;
45 };
46 
47 namespace osgEarth {
48  class VirtualProgram;
49 };
50 
51 namespace makVrv
52 {
53  class DtGlBuffer;
54 
55  class DtIndirectGeometryRegistrar;
56 
57  class DtIndirectTextureCollectionPolicy;
58  class DtIndirectModelInfoContainer;
59 
60  class DtOsgShaderManager;
61 
62  class DtIndirectModelInfo;
63 
64  class DtOsgRenderer;
65 
66 
69 
72 
74  template <>
75  inline const char* creatorTypeName<DtIndirectGeometryRegistrar>(void) { return "DtIndirectGeometryRegistrarCreator"; }
76 
86 
90 
99 
111  class DT_DLL_VRVOSG DtIndirectGeometryRegistrar : public osg::Referenced
112  {
113  protected:
116 
117  protected:
120  , const std::string& textureCollectionPolicyName
121  , const DtIndirectLimitTextureStrategy& limitTextureStrategy
122  );
123 
125  virtual ~DtIndirectGeometryRegistrar();
126 
127  private:
129  DtIndirectGeometryRegistrar() = delete;
130 
133 
135  DtIndirectGeometryRegistrar(const DtIndirectGeometryRegistrar& lhs, const osg::CopyOp& copyop) = delete;
136 
138  DtIndirectGeometryRegistrar& operator=(const DtIndirectGeometryRegistrar& other) = delete;
139  public:
140 
149  {
151  : myModelsInQueue(0)
152  , myBeingProcessed(false)
153  , myTasksEnqueued(0)
154  , myModelsProcessedTotal(0)
155  , myProcessBatchesRun(0)
156  , myCurrentBuildNumber(0)
157  , myRegisteredModelsDirty(false)
158  , myProcessCallsTotal(0)
159  {
160  // intentional noop
161  }
162 
164  unsigned int myModelsInQueue;
165 
168 
172 
175 
178  unsigned int myProcessBatchesRun;
179 
181  unsigned int myCurrentBuildNumber;
182 
185 
191  unsigned int myProcessCallsTotal;
192  };
193 
195  virtual void setName(const std::string& name);
196 
198  virtual const std::string& name() const;
199 
200  virtual void setIndirectGeometryProcessedCallback(std::function<void(const DtIndirectModelRegistrationInfo&)>* createdNodeCallback/*=nullptr*/);
201 
202  // ! Thread safe method - can be called in any paging thread or the main render thread
203  // ! This needs to be 'queued' up because the actual registration can happen when rebuild rebuildIfNeeded
204  // ! is called from somewhere in the main thread (e.g. via the drawImplementation of DtIndirectGeometry)
205  // \param modelId: The model id
206  // \param modelFileName is used only for debugging messages for the aggregator
207  virtual void queueUpRegisterModel(const DtIndirectModelRegistrationInfo& info);
208 
211  virtual void processRegisterModelQueue();
212 
214  virtual void processRegisterModelQueueAsync();
215 
217  virtual bool beingProcessed();
218 
220  virtual bool hasTasksEnqueued();
221 
223  virtual unsigned int updateBuildNumber();
224 
226  virtual unsigned int numModelsInQueue() const;
227 
229  virtual int numModels(void) const;
230 
232  virtual int modelId(int index) const;
233 
235  virtual int numGeometriesForModelID(int modelId) const;
236 
238  virtual bool isModelUploaded(int modelId) const;
239 
242  virtual const DtIndirectModelInfo* findModelInfoForModelId(int modelId) const;
243 
245  virtual const DtIndirectModelInfoContainer* modelInfoContainer() const;
246 
248  virtual DtIndirectModelInfoContainer* modelInfoContainer();
249 
251  virtual const DtIndirectTextureCollectionPolicy& textureCollectionPolicy(void) const;
252 
255  virtual const DtIndirectEffectTexturesTemplate& effectTexturesState(void) const;
256 
258  virtual DtIndirectGeometryStateManager& stateManager(void) const;
259 
261  virtual GLenum indicesType(void) const;
262 
266  virtual void releaseGLObjects(osg::State* state) const;
267 
270  virtual bool registeredModelsDirty() const;
271 
273  virtual void setPagerHandlesModelLoading(bool value);
274  virtual bool pagerHandlesModelLoading();
275 
277  virtual int numTexCoordArrays(void) const;
278 
280  virtual std::shared_timed_mutex& addingModelsMutex();
281 
283  virtual void findModelInfosThatUseThisImageFileForItsTextures(std::set<DtIndirectModelInfo*>& modelInfos, const std::string& absoluteFileName) const;
284 
291  virtual void debugOnlyQueueHealthSnapshot(DebugQueueHealthSnapshot& outSnapshot) const;
292 
293  protected:
296  virtual void registerModel(const DtIndirectModelRegistrationInfo& info);
297 
298  protected:
299 
301 
302  std::function<void(const DtIndirectModelRegistrationInfo&)>* myRegisteredModelCallback;
303 
310 
312 
314 
315  typedef tbb::concurrent_queue<DtIndirectModelRegistrationInfo> QueueRegisterModelOps;
317 
319 
321  unsigned int myCurrentBuildNumber;
322 
324  std::atomic<bool> myBeingProcessed;
325  std::atomic<int> myNumberOfTasksEnqueued;
326  std::shared_timed_mutex myAddingModelsMutex;
327 
331 
334 
336 
338  std::unordered_map< std::string, std::set<int> > myImagesToModelsThatAreUsingIt;
339 
341  mutable std::atomic<unsigned int> myDebugModelsProcessedTotal{0};
345  mutable std::atomic<unsigned int> myDebugProcessBatchesRun{0};
346  mutable std::atomic<unsigned int> myDebugProcessCallsTotal{0};
348  };
349 
350 }
unsigned int myModelsProcessedTotal
Total number of models registered via processRegisterModelQueue.
Definition: DtIndirectGeometryRegistrar.h:174
QueueRegisterModelOps myQueueRegisterModelOps
Definition: DtIndirectGeometryRegistrar.h:316
bool myBeingProcessed
Whether processRegisterModelQueue is currently draining the queue.
Definition: DtIndirectGeometryRegistrar.h:167
std::shared_timed_mutex myAddingModelsMutex
Definition: DtIndirectGeometryRegistrar.h:326
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:111
unsigned int myProcessCallsTotal
Total number of times processRegisterModelQueue was called, including calls rejected by the early-out...
Definition: DtIndirectGeometryRegistrar.h:191
Debug-only. Snapshot of queue health counters for this registrar.
Definition: DtIndirectGeometryRegistrar.h:148
Class that loads and contains a bunch of models registered with the registrar. It is owned by the Ind...
Definition: DtIndirectModelInfoContainer.h:88
DtVirtualBaseClassCreator< DtIndirectGeometryRegistrar, const std::string &, const DtIndirectLimitTextureStrategy & > DtIndirectGeometryRegistrarCreator
creator
Definition: DtIndirectGeometryRegistrar.h:68
Abstract class to look in the stateset and collect textures specified via its template The effect tex...
Definition: DtIndirectTextureCollectionPolicy.h:43
std::function< void(const DtIndirectModelRegistrationInfo &)> * myRegisteredModelCallback
Definition: DtIndirectGeometryRegistrar.h:302
The information required to register a model with the registrar.
Definition: DtIndirectModelRegistrationInfo.h:24
std::unordered_map< std::string, std::set< int > > myImagesToModelsThatAreUsingIt
map of absolute image file names to models that use it
Definition: DtIndirectGeometryRegistrar.h:338
Threading::Mutex myRegisteredModelCallbackMutex
Protects myRegisteredModelCallback only. Single, dedicated purpose: serializes setIndirectGeometryPro...
Definition: DtIndirectGeometryRegistrar.h:309
Indirect rendering works because we are able to combine multiple geometries into a single &#39;aggregated...
Definition: DtIndirectGeometryAggregator.h:90
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
Contains the DtIndirectEffectTexturesTemplate class declaration.
DtIndirectEffectTexturesTemplate myEffectTexturesState
Definition: DtIndirectGeometryRegistrar.h:311
Simple state/glmodes class for handling setting up modes It can now handle generic state modes and at...
Definition: DtIndirectGeometryStateManager.h:31
DtIndirectGeometryAggregator * myAggregator
Definition: DtIndirectGeometryRegistrar.h:323
Contains the DtIndirectGeometryStateManager class declaration.
tbb::concurrent_queue< DtIndirectModelRegistrationInfo > QueueRegisterModelOps
Definition: DtIndirectGeometryRegistrar.h:315
std::atomic< bool > myBeingProcessed
Definition: DtIndirectGeometryRegistrar.h:324
DtDe & myDe
DtDe reference.
Definition: DtIndirectGeometryRegistrar.h:333
DebugQueueHealthSnapshot()
Definition: DtIndirectGeometryRegistrar.h:150
unsigned int myProcessBatchesRun
Total number of times processRegisterModelQueue actually entered its drain loop (won the compare-exch...
Definition: DtIndirectGeometryRegistrar.h:178
OpenThreads::Mutex Mutex
Definition: DtOsgThreadingUtils.h:12
bool myPagerHandlesModelLoading
Definition: DtIndirectGeometryRegistrar.h:313
bool myRegisteredModelsDirty
Definition: DtIndirectGeometryRegistrar.h:320
std::atomic< int > myNumberOfTasksEnqueued
Definition: DtIndirectGeometryRegistrar.h:325
The indirect system uses this in conjunction with the system wide limits (for entity/terrain) to clam...
Definition: DtIndirectLimitTextureStrategy.h:65
Contains makVrv::DtIndirectSwitchManager class.
DtOsgShaderManager injects custom shaders into the scenes, and keeps their uniform parameters set to ...
Definition: DtOsgShaderManager.h:41
unsigned int GLenum
Definition: DtGlTextureBufferObject.h:19
unsigned int myCurrentBuildNumber
Definition: DtIndirectGeometryRegistrar.h:321
Contains makVrv::DtIndirectLodManager class.
unsigned int myModelsInQueue
Approximate current size of the register-model queue.
Definition: DtIndirectGeometryRegistrar.h:164
DtIndirectGeometryStateManager myMutableStateContainer
mutable since it is needed to be used in drawImplementaion for the indirect geometry not private so i...
Definition: DtIndirectGeometryRegistrar.h:330
Contains DLL export macros.
Contains the DtIndirectModelRegistrationInfo class declaration.
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
Contains the DtIndirectGeometryAggregator class declaration.
DtIndirectTextureCollectionPolicy * myTextureCollectionPolicy
Definition: DtIndirectGeometryRegistrar.h:318
int myTasksEnqueued
Number of async tasks currently enqueued via processRegisterModelQueueAsync.
Definition: DtIndirectGeometryRegistrar.h:171
unsigned int myCurrentBuildNumber
The current build number.
Definition: DtIndirectGeometryRegistrar.h:181
DtOsgShaderManager & myShaderManager
Definition: DtIndirectGeometryRegistrar.h:335
friend DtIndirectGeometryRegistrarCreator
friend class creator so that DtIndirectGeometryRegistrar can only be created by the creator ...
Definition: DtIndirectGeometryRegistrar.h:115
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
DtIndirectModelInfoContainer * myModelInfoContainer
Definition: DtIndirectGeometryRegistrar.h:300
bool myRegisteredModelsDirty
Whether the registered models are currently marked dirty.
Definition: DtIndirectGeometryRegistrar.h:184
Contains the per Model info which the indirect module needs These objects are owned by the Indirect g...
Definition: DtIndirectModelInfo.h:68
const char * creatorTypeName< DtIndirectGeometryRegistrar >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometryRegistrar.h:75

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)