VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometry.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
19 #include <vrvOsg/DtGlVaoManager.h>
20 
23 
25 #include <boost/signals2.hpp>
26 
27 #include <osg/Drawable>
28 #include <osg/Uniform>
29 #include <osg/OperationThread>
30 
31 #include <boost/unordered_map.hpp>
32 #include <tbb/atomic.h>
33 #include <tbb/concurrent_queue.h>
34 
35 #include <string>
36 
37 #define INDIRECTGEOMETRY_CONSTRUCT_DESTRUCT_DEBUG 0
38 
39 namespace osg
40 {
41  class NodeVisitor;
42  class State;
43 }
44 
45 namespace osgEarth {
46  class VirtualProgram;
47 };
48 
49 namespace makVrv
50 {
51  class DtIndirectGeometryRegistrar;
52  class DtCullShaderConfig;
53  class DtGpuCullingAndLod;
54  class DtGlBuffer;
55  class DtOsgShaderFilesCache;
56  class DtTerrainPatchObjectManager;
57  class DtOsgCullVisitor;
58  class DtIndirectGeometryInitMainThreadJob;
59  class DtIndirectGeometryUpdateBuffersMainThreadJob;
60  class DtGLDeleteObjectManager;
61 
69  class DT_DLL_VRVOSG DtIndirectGeometry : public osg::Drawable
70  {
71  public:
73  DtIndirectGeometry(bool terrainPatch, const DtIndirectFadeParameters& fadeParameters);
74 
75  protected:
77  virtual ~DtIndirectGeometry();
78 
79  private:
83  DtIndirectGeometry &operator=(const DtIndirectGeometry &other);
84 
85  public:
86 
88  virtual void setName(const std::string& name);
89 
97  virtual void setRegistrar(DtIndirectGeometryRegistrar* registrar);
98 
100  virtual DtIndirectGeometryRegistrar* registrar();
101 
103  virtual void setCullShaderConfig(const DtCullShaderConfig& cullShaderConfig);
104 
106  virtual const char* className() const;
107 
111  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
112 
114  virtual unsigned int rebuildRegistrar(osg::RenderInfo& renderInfo) const;
115 
118  virtual void addInstance(const DtIndirectGeometryInstance& instance);
119 
122  virtual void addInstance(int modelId, const osg::Matrixd& xForm);
123 
125  virtual void removeAllInstances(void);
126 
130  virtual void accept(osg::NodeVisitor& nv);
131 
133  virtual void setParent(const osg::Group* parent);
134 
138  virtual void setDebugDrawString(const std::string& drawString);
139 
145  virtual void setRegistrarInvalid(void);
146 
148  virtual void releaseGLObjects(osg::State* state) const;
149 
151  virtual void accept(osg::PrimitiveFunctor& functor) const;
152 
154  void setupIndirect(DtDe &de);
155 
158  virtual const osg::Geode* parentGeode(void) const;
159  virtual osg::Geode* parentGeode(void);
161 
165  virtual void setLocalOriginTransform(const osg::Matrixd& localOriginTransform);
166 
170  virtual osg::Matrixd& localOriginTransform();
171 
173  virtual bool actuallyAddQueuedUpInstances(void);
174 
176  virtual void launchMainThreadJobAndWait(DtDe& de, DtOsgRenderer& renderer);
177 
179  virtual boost::condition_variable & waitCondition();
180 
182  virtual void updateGpuInstanceBuffers(osg::RenderInfo& renderInfo);
183 
186 
187  protected:
188 
191  virtual bool addInstanceActual(const DtIndirectGeometryInstance& instance);
192 
197  virtual GLuint getOrCreateAndRecordVAO(osg::State* state) const;
198  virtual void recordVAO(GLuint vao) const;
200 
204  virtual void setupShadersIfNecessary(DtDe& de);
205 
208  virtual void setupDebugUniforms(DtDe& de);
209 
211  virtual void installIndirectRenderingProgram(DtOsgShaderFilesCache* shaderFilesCache,
212  const std::string& shaderFolderPath, osg::StateSet* ss, DtDe& de) const;
213 
216  virtual void installDefaultMaterial(osg::StateSet* ss);
217 
219  virtual void slot_reloadShaders();
220 
224  virtual void updateIndicesCount(const DtAggregateModelInfo& modelInfo);
225 
228  virtual void createCullingAndLodIfNecessary(DtDe& de);
229 
232  virtual void createManagersIfNecessary(DtDe& de);
233 
234  virtual void drawFromCommandBuffer(osg::RenderInfo& renderInfo) const;
235 
237  virtual void reloadShadersIfNecessary(void) const;
238 
239  protected:
242  static osgEarth::VirtualProgram * findCachedVirtualProgram(const std::string& vp_hash);
243  static void cacheVirtualProgram(const std::string& vp_hash, osgEarth::VirtualProgram* virtualProgram);
244  static void clearVirtualProgramCache();
246 
247 
248  protected:
251 
253  tbb::concurrent_queue<DtIndirectGeometryInstance> myQueueInstancesToAdd;
254 
256 
258 
259  std::string myDrawString;
260 
262 
268 
270  boost::signals2::connection myConnection;
271 
273 
277 
280 
282 
284 
285 #if INDIRECTGEOMETRY_CONSTRUCT_DESTRUCT_DEBUG
286  static tbb::atomic<int> myRefCount;
287 #endif
288 
290 
293 
294  mutable unsigned int myMutableLastFrameRebuilt;
295  mutable unsigned int myMutableLastFrameTexturesUpdated;
296 
298 
301 
302  mutable bool myMutableShadersSetup;
303 
304 
305  protected:
308 
309  boost::condition_variable myWaitCondition;
310  boost::mutex myWaitMutex;
311 
313  typedef std::map<std::string, VirtualProgramRef> StringVpMap;
315 
316  boost::mutex myInternalsMutex;
317 
320 
322  };
323 
326  {
327  public:
330 
332  virtual ~DtIndirectGeometryCreator();
333 
334  private:
338  DtIndirectGeometryCreator &operator=(const DtIndirectGeometryCreator& other);
339 
340  public:
342  virtual DtIndirectGeometry* create(bool terrainPatch, const DtIndirectFadeParameters& fadeParameters) const;
343 
346  static DtIndirectGeometryCreator& instance(DtDe& de);
347 
349  static const std::string& theClassName();
350  protected:
352  };
353 }
boost::signals2::connection myConnection
Definition: DtIndirectGeometry.h:270
boost::condition_variable myWaitCondition
Definition: DtIndirectGeometry.h:309
Contains the DtCullShaderConfig class declaration.
DtCullShaderConfig myCullShaderConfig
Definition: DtIndirectGeometry.h:300
std::map< std::string, VirtualProgramRef > StringVpMap
Definition: DtIndirectGeometry.h:313
DtIndirectFadeParameters myFadeParameters
Definition: DtIndirectGeometry.h:321
The DtOsgRenderer is the component responsible for rendering 3D images onto the screen via OpenSceneG...
Definition: DtOsgRenderer.h:125
Virtual base class.
Definition: DtVirtualBaseClass.h:22
non virtual container class for holding the information needed to create an indirect geometry instanc...
Definition: DtIndirectGeometryInstance.h:25
struct for holding the fade parameters used by the indirect rendering cull compute shader ...
Definition: DtGpuCullingAndLodDefines.h:21
Manager that provides direct access to the terrain patch objects in use in a display engine also hand...
Definition: DtTerrainPatchObjectManager.h:38
DtInstanceContainer myMutableInstanceContainer
container for all the instances registered here
Definition: DtIndirectGeometry.h:292
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
handles the switches for all the indirect geometry.
Definition: DtIndirectSwitchManager.h:52
DtTerrainPatchObjectManager * myTerrainPatchObjectManager
Definition: DtIndirectGeometry.h:281
unsigned int myMutableLastFrameRebuilt
Definition: DtIndirectGeometry.h:294
creator for DtIndirectGeometry
Definition: DtIndirectGeometry.h:325
bool myLastMissingTextureColorOn
Definition: DtIndirectGeometry.h:279
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:101
DtGlVaoManager * myVaoManager
Definition: DtIndirectGeometry.h:283
osg::Matrixd myLocalOriginTransformMatrix
Definition: DtIndirectGeometry.h:272
bool myIsTerrainPatch
Definition: DtIndirectGeometry.h:261
unsigned int GLuint
Definition: DtGlTextureBufferObject.h:17
shader configuration storage class.
Definition: DtCullShaderConfig.h:19
Definition: DtOsgShaderFilesCache.h:22
std::map< int, int > MapIntToInt
Definition: DtCommonTypes.h:25
osg::ref_ptr< DtIndirectGeometryUpdateBuffersMainThreadJob > myMainThreadUpdateBuffersJob
Definition: DtIndirectGeometry.h:319
handles the lods for all the indirect geometry.
Definition: DtIndirectLodManager.h:79
osg::ref_ptr< DtIndirectGeometryRegistrar > myRegistrar
pointer to the (external) registrar
Definition: DtIndirectGeometry.h:250
osg::ref_ptr< osgEarth::VirtualProgram > VirtualProgramRef
Definition: DtIndirectGeometry.h:312
osg::ref_ptr< DtIndirectGeometryInitMainThreadJob > myMainThreadInitJob
Definition: DtIndirectGeometry.h:318
bool myReloadSlotConnected
Definition: DtIndirectGeometry.h:269
DtIndirectSwitchManager * myMutableSwitchManager
Definition: DtIndirectGeometry.h:297
DtIndirectGeometryInstance.
Contains makVrv::DtVirtualBaseClass class.
This class inherits from osg::Drawable, which allows us to hook into our indirect engine to render us...
Definition: DtIndirectGeometry.h:69
MapIntToInt myModelIDsToInstances
Definition: DtIndirectGeometry.h:257
contains the Per Model info which DtAggregatedGeometry needs It is owned by the Indirect geometry reg...
Definition: DtAggregatedGeometry.h:47
DtIndirectLodManager * myMutableLodManager
Definition: DtIndirectGeometry.h:299
bool myLastDebugIndirectColorOn
Definition: DtIndirectGeometry.h:278
boost::mutex myInternalsMutex
Definition: DtIndirectGeometry.h:316
DtIndirectRenderingParameters myMutableIrParams
Definition: DtIndirectGeometry.h:289
Class per frame that must be passed to the DtICullingAndLOD It indicates what would have changed (ins...
Definition: DtGpuCullingAndLodDefines.h:94
Declarations for classes used in DtICullingAndLOD.
Contains makVrv::DtIndirectSwitchManager class.
int myNumIndicesAcrossAllModels
number of indices across all unique models across instances
Definition: DtIndirectGeometry.h:276
responsible for initializing the indirect buffers in the main thread
Definition: DtIndirectGeometryInitMainThreadJob.h:30
tbb::concurrent_queue< DtIndirectGeometryInstance > myQueueInstancesToAdd
addInstance may be called from multiple threads. Hence, concurrent queue
Definition: DtIndirectGeometry.h:253
bool myMutableShadersSetup
Definition: DtIndirectGeometry.h:302
DtDe & myDe
Definition: DtIndirectGeometry.h:351
This class is used to manage an opengl vertex array object (VAO) dealing with multiple opengl context...
Definition: DtGlVaoManager.h:49
Contains makVrv::DtIndirectLodManager class.
unsigned int myMutableLastFrameTexturesUpdated
Definition: DtIndirectGeometry.h:295
Contains DLL export macros.
bool myMutableShouldReloadShaders
FIXME should be a static but currently the cull shader is per indirect.
Definition: DtIndirectGeometry.h:307
DtIndirectEffectTexturesTemplate myEffectTexturesState
the accumulated effect textures&#39; state which represents the superset of all effect textures cumulativ...
Definition: DtIndirectGeometry.h:267
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
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:27
std::string myDrawString
Definition: DtIndirectGeometry.h:259
boost::mutex myWaitMutex
Definition: DtIndirectGeometry.h:310
DtGpuCullingAndLod * myCullingAndLOD
Definition: DtIndirectGeometry.h:255
Contains the DtGlVaoManager class declaration.
Contains the DtIndirectGeometryRegistrar class declaration.
Contains makVrv::DtInstanceContainer.
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:38
static StringVpMap theVirtualProgramMap
Definition: DtIndirectGeometry.h:314
This class is a component of the DtIndirectGeometry It inputs are: -&gt; the instances registered with Dt...
Definition: DtGpuCullingAndLod.h:50

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)