VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectLodManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2025 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <vrvOsg/vrvOsg.h>
16 
18 
19 #include <vrvMath/DtVector3.h>
21 
22 #include <osg/Vec3>
23 #include <osg/Matrix>
24 #include <osg/Camera>
25 #include <osg/observer_ptr>
26 
27 #include <deque>
28 #include <vector>
29 #include <map>
30 
31 namespace makVrv
32 {
33  class DtDe;
34  class DtGlBuffer;
35  class DtIndirectViewParameters;
36  class DtIndirectLodProgram;
37  class DtIndirectClearBufferProgram;
38  class DtGlDeleteObjectManager;
39 
42 
45 
47  template <>
48  inline const char* creatorTypeName<DtIndirectLodManager>(void) { return "DtIndirectLodManagerCreator"; }
49 
56  {
57  public:
58 
62  #define CPU_SIDE_COMPILATION 1
63  #include <../data/shaders/indirect/LodInfoBuffer.h>
64  #undef CPU_SIDE_COMPILATION
65 
66  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
67  typedef std::pair<NodeObserverPtr, IndirectLodInfo> NodeLodInfoPair;
68  typedef std::deque<IndirectLodInfo> DequeIndirectLodInfos;
69  typedef std::deque<NodeLodInfoPair> DequeIndirectLodInfoPairs;
70  typedef std::vector<DequeIndirectLodInfos> DequeIndirectLodInfoArray;
71 
74  {
75  public:
76  void operator()(IndirectLodInfo& info);
77  };
78 
80 
81  public:
84 
86  virtual ~DtIndirectLodManager();
87  protected:
90 
91  private:
93  DtIndirectLodManager() = delete;
95  DtIndirectLodManager(const DtIndirectLodManager &other) = delete;
97  DtIndirectLodManager &operator=(const DtIndirectLodManager &other) = delete;
98 
99  public:
100 
102  virtual void releaseGLObjects(osg::State* state) const;
103 
105  virtual void addLodStacks(std::vector<PerGeomInstance*>& perGeomInstances, int containerInstanceId,
106  const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfoArray& lodStacks,
107  const osg::Matrix& inverselocalOriginMatrix);
108 
110  virtual void removeLodStacks(int containerInstanceId);
111 
114  virtual void processLods(const DtIndirectViewParameters& viewParameters,
115  const DtGlBuffer* gpuDofTransformBuffer, const DtGlBuffer* gpuDofModelScaleBuffer,
116  const DtGlBuffer* gpuInputPerGeomInstancesBuffer, const unsigned int instancesToProcess,
117  const osg::Camera* currentCamera);
118 
121  virtual const DtGlBuffer* gpuLodVisibleBuffer(const osg::Camera* currentCamera) const;
122 
124  virtual void reloadShaders() const;
125 
127  virtual void printInfo();
128 
129  protected:
130 
134  virtual void addLodStack(int& indexIntoVectorIndirectLodInfos,
135  const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfos& lodStack,
136  const osg::Matrix& inverselocalOriginMatrix, int containerInstanceId);
137 
139  virtual void updateLodBuffersIfNecessary(unsigned int instancesToProcess);
140 
142  virtual void deleteBuffers();
143 
145  virtual void tearDownBuffers() const;
146 
149  virtual void flushGpuLodVisibleBuffers();
150 
151  protected:
152 
155 
158  std::map<int, std::pair<int, int> > myInstanceIdToPairIndices;
159 
162 
164  typedef std::map<osg::observer_ptr<const osg::Camera>, DtGlBuffer*> CameraToBufferMap;
166 
167  typedef std::vector<osg::observer_ptr<const osg::Camera> > CameraVector;
169 
170  mutable bool myMutableLodInfoDirty;
171 
173 
175 
177  };
178 
179 }
initializer/invalidator for lod info
Definition: DtIndirectLodManager.h:73
VectorIndirectLodInfos myIndirectLodInfos
This is a memory pool for all the lod infos for all instances managed by this manager.
Definition: DtIndirectLodManager.h:154
DtVirtualBaseClassCreator< DtIndirectLodManager > DtIndirectLodManagerCreator
creator
Definition: DtIndirectLodManager.h:41
parent manager class for all Indirect managers. Managers handle information about a specific feature ...
Definition: DtIndirectManager.h:25
const char * creatorTypeName< DtIndirectLodManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectLodManager.h:48
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains makVrv::DtIndirectManager class.
DtIndirectLodProgram * myMutableLodProgram
Definition: DtIndirectLodManager.h:172
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectLodManager.h:66
CameraToBufferMap myGpuLodVisibleBufferMap
Definition: DtIndirectLodManager.h:165
handles the lods for all the indirect geometry. sets up and runs a compute shader prepass for process...
Definition: DtIndirectLodManager.h:55
std::vector< DequeIndirectLodInfos > DequeIndirectLodInfoArray
Definition: DtIndirectLodManager.h:70
3 dimensional vector
bool myMutableLodInfoDirty
Definition: DtIndirectLodManager.h:170
CameraVector myActiveCameras
Definition: DtIndirectLodManager.h:168
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtIndirectLodManager.h:176
singleton class that wraps indirect lod gpu shader.
Definition: DtIndirectLodProgram.h:72
std::vector< osg::observer_ptr< const osg::Camera > > CameraVector
Definition: DtIndirectLodManager.h:167
DtReusableMemoryVector< IndirectLodInfo, IndirectLodInfoInvalidator > VectorIndirectLodInfos
Definition: DtIndirectLodManager.h:79
DtGlBuffer * myGpuLodInfoBuffer
The buffer containing all the lod infos for all instances managed by this manager.
Definition: DtIndirectLodManager.h:161
friend DtIndirectLodManagerCreator
only creator can create
Definition: DtIndirectLodManager.h:83
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
Contains makVrv::DtReusableMemoryVector class.
Vaos are OpenGL context specific. They need to be deleted in the context they are created in...
Definition: DtGlDeleteObjectManager.h:58
std::map< int, std::pair< int, int > > myInstanceIdToPairIndices
This maps from instance container instance id to the start and end indices in the myIndirectLodInfos ...
Definition: DtIndirectLodManager.h:158
This class clears buffers using compute shader Theoretically, there are performance gains to be achie...
Definition: DtIndirectClearBufferProgram.h:33
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::deque< NodeLodInfoPair > DequeIndirectLodInfoPairs
Definition: DtIndirectLodManager.h:69
std::map< osg::observer_ptr< const osg::Camera >, DtGlBuffer * > CameraToBufferMap
The buffer containing a bool for each instance to know if it should be drawn or not.
Definition: DtIndirectLodManager.h:164
std::deque< IndirectLodInfo > DequeIndirectLodInfos
Definition: DtIndirectLodManager.h:68
DtPerGeomInstance class declaration.
std::pair< NodeObserverPtr, IndirectLodInfo > NodeLodInfoPair
Definition: DtIndirectLodManager.h:67
DtIndirectClearBufferProgram * myMutableClearBufferProgram
Definition: DtIndirectLodManager.h:174

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)