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) 2022 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
16 
17 #include <vrvMath/DtVector3.h>
19 
20 #include <osg/Vec3>
21 #include <osg/Matrix>
22 #include <osg/Camera>
23 #include <osg/observer_ptr>
24 
25 #include <deque>
26 #include <vector>
27 #include <map>
28 
29 namespace makVrv
30 {
31  class DtDe;
32  class DtGlBuffer;
33  class DtIndirectViewParameters;
34  class DtIndirectLodProgram;
35  class DtInstanceContainer;
36  class DtIndirectClearBufferProgram;
37  class DtGlDeleteObjectManager;
38 
41 
44 
46  template <>
47  inline const char* creatorTypeName<DtIndirectLodManager>(void) { return "DtIndirectLodManagerCreator"; }
48 
55  {
56  public:
57 
61  #define CPU_SIDE_COMPILATION 1
62  #include <../data/shaders/indirect/LodInfoBuffer.h>
63  #undef CPU_SIDE_COMPILATION
64 
65  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
66  typedef std::pair<NodeObserverPtr, IndirectLodInfo> NodeLodInfoPair;
67  typedef std::deque<IndirectLodInfo> DequeIndirectLodInfos;
68  typedef std::deque<NodeLodInfoPair> DequeIndirectLodInfoPairs;
69  typedef std::vector<DequeIndirectLodInfos> DequeIndirectLodInfoArray;
70 
73  {
74  public:
75  void operator()(IndirectLodInfo& info);
76  };
77 
80  {
81  public:
82  IndirectLodInfoRemovalPredicate(int start, int end);
83  bool operator()(const IndirectLodInfo& info) const;
84 
87  };
88 
90 
91  public:
94 
96  virtual ~DtIndirectLodManager();
97  protected:
100 
101  private:
103  DtIndirectLodManager() = delete;
105  DtIndirectLodManager(const DtIndirectLodManager &other) = delete;
107  DtIndirectLodManager &operator=(const DtIndirectLodManager &other) = delete;
108 
109  public:
110 
112  virtual void releaseGLObjects(osg::State* state) const;
113 
115  virtual void addLodStacks(int perGeomInstanceIndex, int numGeoms, const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfoArray& lodStacks, const osg::Matrix& inverselocalOriginMatrix, int instanceId);
116 
118  virtual void removeLodStacks(int instanceId);
119 
122  virtual void processLods(const DtIndirectViewParameters& viewParameters
123  , const DtGlBuffer* gpuDofTransformBuffer
124  , const DtGlBuffer* gpuDofModelScaleBuffer
125  , const DtGlBuffer* gpuInputPerGeomInstancesBuffer
126  , const osg::Camera* currentCamera);
127 
130  virtual const DtGlBuffer* gpuLodVisibleBuffer(const osg::Camera* currentCamera) const;
131 
133  virtual void reloadShaders() const;
134 
136  virtual void printInfo();
137 
138  protected:
139 
143  virtual void addLodStack(int perGeomInstanceIndex, int& indexIntoVectorIndirectLodInfos, const DequeIndirectLodInfos& parentLodStack, const DequeIndirectLodInfos& lodStack, const osg::Matrix& inverselocalOriginMatrix);
144 
146  virtual void updateLodBuffersIfNecessary();
147 
149  virtual void deleteBuffers(void);
150 
152  virtual void tearDownBuffers(void) const;
153 
156  virtual void flushGpuLodVisibleBuffers();
157 
158  protected:
159 
161 
164 
166  typedef std::map<osg::observer_ptr<const osg::Camera>, DtGlBuffer*> CameraToBufferMap;
168 
169  typedef std::vector<osg::observer_ptr<const osg::Camera> > CameraVector;
171 
172  mutable bool myMutableLodInfoDirty;
173 
175 
177 
179 
180  std::map<int, std::pair<int, int> > myInstanceIdToPairIndices;
181 
183  };
184 
185 }
initializer/invalidator for lod info
Definition: DtIndirectLodManager.h:72
VectorIndirectLodInfos myIndirectLodInfos
Definition: DtIndirectLodManager.h:160
parent manager class for all Indirect managers. Managers handle information about a specific feature ...
Definition: DtIndirectManager.h:26
const char * creatorTypeName< DtIndirectLodManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectLodManager.h:47
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains makVrv::DtIndirectManager class.
DtVirtualBaseClassCreator< DtIndirectLodManager, DtInstanceContainer & > DtIndirectLodManagerCreator
creator
Definition: DtIndirectLodManager.h:40
DtIndirectLodProgram * myMutableLodProgram
Definition: DtIndirectLodManager.h:174
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectLodManager.h:65
CameraToBufferMap myGpuLodVisibleBufferMap
Definition: DtIndirectLodManager.h:167
handles the lods for all the indirect geometry. sets up and runs a compute shader prepass for process...
Definition: DtIndirectLodManager.h:54
std::vector< DequeIndirectLodInfos > DequeIndirectLodInfoArray
Definition: DtIndirectLodManager.h:69
3 dimensional vector
bool myMutableLodInfoDirty
Definition: DtIndirectLodManager.h:172
CameraVector myActiveCameras
Definition: DtIndirectLodManager.h:170
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtIndirectLodManager.h:182
singleton class that wraps indirect lod gpu shader.
Definition: DtIndirectLodProgram.h:72
unsigned int myMaxPerGeomInstanceId
Definition: DtIndirectLodManager.h:178
const int myStartPerGeomInstanceIndex
Definition: DtIndirectLodManager.h:85
std::vector< osg::observer_ptr< const osg::Camera > > CameraVector
Definition: DtIndirectLodManager.h:169
const int myEndPerGeomInstanceIndex
Definition: DtIndirectLodManager.h:86
DtGlBuffer * myGpuLodInfoBuffer
The buffer containing all the lod infos for all instances managed by this manager.
Definition: DtIndirectLodManager.h:163
friend DtIndirectLodManagerCreator
only creator can create
Definition: DtIndirectLodManager.h:93
removal predicate for lod infos (checks to see if the model ids match.
Definition: DtIndirectLodManager.h:79
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
Definition: DtIndirectLodManager.h:180
This class clears buffers using compute shader Theoretically, there are performance gains to be achie...
Definition: DtIndirectClearBufferProgram.h:33
DtReusableMemoryVector< IndirectLodInfo, IndirectLodInfoInvalidator, IndirectLodInfoRemovalPredicate > VectorIndirectLodInfos
Definition: DtIndirectLodManager.h:89
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:68
Helper class to manage instances This class allows you to add a DtInstance_64 Internally, however it stores this as a DtInstance (which the GPU can directly read)
Definition: DtInstanceContainer.h:31
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:166
std::deque< IndirectLodInfo > DequeIndirectLodInfos
Definition: DtIndirectLodManager.h:67
std::pair< NodeObserverPtr, IndirectLodInfo > NodeLodInfoPair
Definition: DtIndirectLodManager.h:66
DtIndirectClearBufferProgram * myMutableClearBufferProgram
Definition: DtIndirectLodManager.h:176

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)