30 #include <matrix/vlTaitBryan.h>
32 #include <osg/Drawable>
33 #include <osg/Uniform>
34 #include <osg/StateSet>
35 #include <osg/OperationThread>
36 #include <osgSim/MultiSwitch>
38 #include <tbb/concurrent_queue.h>
39 #include <boost/thread/condition_variable.hpp>
40 #include <boost/thread/shared_mutex.hpp>
44 #include <unordered_map>
45 #include <unordered_set>
60 class DtIndirectGeometryRegistrar;
61 class DtCullShaderConfig;
64 class DtOsgCullVisitorParameters;
66 class DtVirtualProgramCache;
68 class DtIndirectDrawComponent;
69 class DtIndirectDefaultDrawComponent;
70 class DtIndirectLightPointDrawComponent;
71 class DtIndirectDebugCullComponent;
73 class DtIndirectSwitchManager;
74 class DtIndirectDofManager;
75 class DtIndirectLodManager;
76 class DtIndirectUvOffsetManager;
77 class DtIndirectPerInstanceDataManager;
78 class DtIndirectShaderConstants;
79 class DtOsgLightPointManager;
80 class DtIndirectRunTimeSettings;
82 class DtIndirectVaoManager;
84 class DtCoordinateSystem;
88 class DtIndirectShaderManager;
91 class DtIndirectGeometry;
146 virtual void setName(
const std::string& name)
override;
164 virtual const char* className()
const;
169 virtual void drawImplementation(osg::RenderInfo& renderInfo)
const;
173 virtual void debugDrawImplementation(osg::RenderInfo& renderInfo,
174 const osg::Matrixd& modelViewMatrix);
188 virtual int addInstance(
int modelId,
const osg::Matrixd& xForm,
float modelScale,
float modelRadius,
int lightPointGroupId
190 ,
const std::string& trackName
191 ,
bool defaultVisibility =
true );
196 virtual void accept(osg::NodeVisitor& nv);
199 virtual void setParent(
const osg::Group* parent);
206 virtual void setRegistrarInvalid(
void);
209 virtual void releaseGLObjects(osg::State* state)
const;
212 virtual void accept(osg::PrimitiveFunctor& functor)
const;
217 virtual void setupIndirectShaders();
221 virtual const osg::Geode* parentGeode(
void)
const;
222 virtual osg::Geode* parentGeode(
void);
228 virtual void setLocalOriginTransform(
const osg::Matrixd& localOriginTransform);
233 virtual const osg::Matrixd& localOriginTransform()
const;
236 virtual bool actuallyAddQueuedUpInstances(
void);
239 virtual void launchOneTimeInitOp();
242 virtual void updateGpuBuffers(
bool amortizeTextures);
251 virtual void perCameraUpdateAndCull(
const osg::Camera* camera,
const osg::Matrix& modelViewMatrix,
const osg::FrameStamp* frameStamp);
254 virtual void fillViewParameters(
DtIndirectViewParameters& destViewParameters,
const osg::Matrix& modelViewMatrix,
const osg::Camera* osgCamera)
const;
262 virtual bool readyToRender(
const int instanceIdInIndirect)
const;
266 virtual bool hasQueuedInstances(
void )
const;
269 virtual bool allInstancesAreToBeDeleted()
const;
274 virtual bool instanceEverAdded(
void)
const;
278 virtual int numValidInstances(
void)
const;
291 virtual const unsigned int id(
void )
const;
295 static void setTrackObjects(
bool val);
297 static bool trackObjects(
void);
301 static int numIndirectGeometries(
void);
314 static void initializeDtDeKeyedInstances(
DtDe& de);
317 static int numUpdateGpuBuffersRanThisFrame();
321 static void clearNumUpdateGpuBuffersRanThisFrame();
331 virtual void setupShadersIfNecessary();
335 virtual void setupDebugUniforms();
339 virtual void installDefaultMaterial(osg::StateSet* ss);
342 virtual void slot_reloadShaders();
347 virtual void updateIndicesCount(
const DtIndirectModelInfo& modelInfo,
int instanceContainerIndex);
350 virtual void updateModelIdsToInstances(
int modelId,
int instanceId,
bool add);
353 virtual void drawFromCommandBuffer(osg::RenderInfo& renderInfo,
const DtIndirectViewParameters& viewParameters,
const osg::Camera* camera
354 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass,
bool viaExternalRenderer)
const;
357 virtual void syncViewParametersToGpu(
386 virtual void updateInstanceVisibilityLightPointMaxDistanceActual(
const DtIndirectGeometryInstance& instance,
int outInstanceIndex);
399 virtual void reloadShadersIfNecessary(
void)
const;
404 virtual void update(
const osg::FrameStamp* frameStamp);
407 virtual void adjustDofConstraintsIfNecessary(osgSim::DOFTransform* clone);
414 virtual bool hasLightPoints(
void)
const;
417 virtual bool hasDepthOnly(
void)
const;
420 virtual bool isDepthOnly(
int stateId)
const;
423 virtual void nullOutDrawComponents(
void);
426 virtual void initDrawComponents(
void);
431 virtual void setPureSignalBasedUpdates(
bool val);
434 virtual void initializeUbosIfNecessary(osg::RenderInfo& renderInfo)
const;
437 virtual void slot_coordinateSystemChanged();
440 virtual void trackInstanceLifeTime(
int instanceIdInIndirectGeometry
442 ,
const std::string& trackName);
445 virtual std::pair<bool, std::string> trackInfo(
int instanceIdInIndirectGeometry)
const;
448 virtual void drawImplementation(osg::RenderInfo& renderInfo,
const osg::Matrixd& modelViewMatrix
449 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass)
const;
457 virtual bool disableExternalRenderForSensorFx(
const osg::Camera* camera)
const;
462 virtual bool useExternalRenderer(
const osg::Camera* camera)
const;
465 virtual std::string modelName(
int instanceId)
const;
562 mutable int myGpuShaderUboBinding = -1;
unsigned int myNumTextCoordArrays
Definition: DtIndirectGeometry.h:490
Contains the DtCullShaderConfig class declaration.
MapIntToInt myInstancesToModelIds
Definition: DtIndirectGeometry.h:478
This manages the draw components (shader vp wrappers) for combinations of DtIndirectEffectTexturesTem...
Definition: DtIndirectShaderManager.h:50
DtIndirectFadeParameters myFadeParameters
Definition: DtIndirectGeometry.h:533
non virtual container class for holding the information needed to create an indirect geometry instanc...
Definition: DtIndirectGeometryInstance.h:26
osg::ref_ptr< osg::StateSet > myDepthOnlyDrawStateSet
Definition: DtIndirectGeometry.h:552
structure to count total number of DtIndirectGeometrys in the system
Definition: DtIndirectGeometry.h:585
static TotalCounter theTotalCounter
Definition: DtIndirectGeometry.h:596
std::unordered_map< int, int > MapIndirectIdToInstanceContainerId
Map of instances' id in indirect geometry to their id in the instance container.
Definition: DtIndirectGeometry.h:527
Contains makVrv::DtIndirectGeometrySubType declaration.
DtIndirectPerInstanceDataManager * myPerInstanceDataManager
Definition: DtIndirectGeometry.h:514
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
handles the switches for all the indirect geometry. Sets up the default state of osg::Switch, osgSim::MultiSwitch, and DtDynamicTerrainSwitchNode. Connects to a signal for the DtDynamicTerrainSwitchNode so it can update the indirect buffer when a switch changes. saves off the node path hash for every switch path that is added. Owned by a DtIndirectGeometry 1:1 This manager's switches get updated per frame via looking at the actual switches/multi-switches
Definition: DtIndirectSwitchManager.h:70
Definition: DtIndirectDebugCullComponent.h:45
DtIndirectLodManager * myLodManager
Definition: DtIndirectGeometry.h:512
This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with Dt...
Definition: DtGpuCulling.h:87
std::atomic< unsigned int > myIdNumbers
Definition: DtIndirectGeometry.h:594
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:109
DtIndirectLightPointDrawComponent * myLightPointDrawComponent
Definition: DtIndirectGeometry.h:539
boost::shared_mutex myInstanceMutex
Definition: DtIndirectGeometry.h:523
std::atomic< int > myRunningInstanceId
Definition: DtIndirectGeometry.h:536
osg::Matrixd myLocalOriginTransformMatrix
Definition: DtIndirectGeometry.h:494
Represents setting that are runtime tweakable/toggleable.
Definition: DtIndirectRunTimeSettings.h:24
DtVirtualBaseClassCreator< DtIndirectGeometry, const DtCullShaderConfig &, const DtIndirectGeometrySubType &, const bool & > DtIndirectGeometryCreator
creator
Definition: DtIndirectGeometry.h:93
DtOsgLightPointManager & myLightPointManager
Definition: DtIndirectGeometry.h:565
Contains makVrv::DtIndirectModelScalingAlgorithm enumeration.
unsigned int myId
a unique id for the geometry
Definition: DtIndirectGeometry.h:505
shader configuration storage class. Has 3 available options which are described in the constructor's ...
Definition: DtCullShaderConfig.h:21
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:128
std::map< int, int > MapIntToInt
Definition: DtCommonTypes.h:25
boost::unique_lock< boost::shared_mutex > InstanceMutexWriteLock
Definition: DtIndirectGeometry.h:521
handles the lods for all the indirect geometry. sets up and runs a compute shader prepass for process...
Definition: DtIndirectLodManager.h:54
osg::ref_ptr< DtIndirectGeometryRegistrar > myRegistrar
pointer to the (external) registrar
Definition: DtIndirectGeometry.h:469
unsigned int myLastFrameUpdateTraversed
Definition: DtIndirectGeometry.h:554
DtSignalConnectionManager myConnections
Definition: DtIndirectGeometry.h:492
osg::ref_ptr< osg::StateSet > myLightPointDrawStateSet
Definition: DtIndirectGeometry.h:549
DtIndirectShaderManager & myIndirectShaderManager
Definition: DtIndirectGeometry.h:577
DtDe & myDe
Definition: DtIndirectGeometry.h:567
bool myMutableOutputInstancesBuffersChanged
Internal variable that tracks whether the output instance buffers via the culling got changed (resize...
Definition: DtIndirectGeometry.h:559
const char * creatorTypeName< DtIndirectGeometry >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometry.h:100
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
DtIndirectGeometryInstance, which holds information for creating an indirect geometry instance...
DtGpuCulling * myGpuCulling
Definition: DtIndirectGeometry.h:474
static bool theTrackObjects
Definition: DtIndirectGeometry.h:582
friend DtIndirectGeometryCreator
Definition: DtIndirectGeometry.h:123
DtIndirectDebugCullComponent * myIndirectDebugCullComponent
Definition: DtIndirectGeometry.h:540
This class allows us to draw all indirect geometries one after the other with minimal state changes...
Definition: DtIndirectGeometryRenderer.h:63
\ ::, which allows us to hook into our indirect engine to render using indirect rendering...
Definition: DtIndirectGeometry.h:120
MapIntToInt myModelIDsToInstances
Definition: DtIndirectGeometry.h:476
const osg::Camera * myLastCamera
Definition: DtIndirectGeometry.h:531
unsigned int myLastFrameUpdated
Definition: DtIndirectGeometry.h:530
MapIndirectIdToInstanceContainerId myMapIndirectIdToInstanceContainerId
Definition: DtIndirectGeometry.h:528
static int theNumUpdateGpuBuffersRanThisFrame
Definition: DtIndirectGeometry.h:604
handles the dof nodes for all the indirect geometry. Sets up the default state of osg::Dof...
Definition: DtIndirectDofManager.h:65
DtIndirectVaoManager & myVaoManager
This is de-referenced here for speed.
Definition: DtIndirectGeometry.h:502
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
This represents per camera+thread data It is used by DtIndirectGeometryRenderer to sort and draw indi...
Definition: DtIndirectGeometryRendererUserData.h:50
const DtIndirectRunTimeSettings & myIndirectRunTimeSettings
Definition: DtIndirectGeometry.h:602
This class manages the vaos for indirect.
Definition: DtIndirectVaoManager.h:34
const bool myManagesIndividualInstances
Definition: DtIndirectGeometry.h:483
std::unordered_map< int, std::string > myInstancesBeingTracked
Definition: DtIndirectGeometry.h:575
struct for holding the fade parameters used by the indirect rendering cull compute shader ...
Definition: DtIndirectFadeParameters.h:17
std::map< int, int > myInstanceContainerIdToNumIndices
Definition: DtIndirectGeometry.h:499
int myNumIndicesAcrossAllModels
number of indices across all unique models across instances
Definition: DtIndirectGeometry.h:498
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
DtIndirectSwitchManager * mySwitchManager
Definition: DtIndirectGeometry.h:510
A generic OpenGL buffer. This can be: -> a vertex buffer -> an index buffer -> a shader storage buffe...
Definition: DtGlBuffer.h:29
tbb::concurrent_queue< DtIndirectGeometryInstance > myQueueInstancesToAdd
addInstance may be called from multiple threads. Hence, concurrent queue
Definition: DtIndirectGeometry.h:472
Contains makVrv::DtIndirectAnnotationAndUvOffset class.
DtIndirectUvOffsetManager * myUvOffsetManager
Definition: DtIndirectGeometry.h:513
bool myMutableShadersSetup
Definition: DtIndirectGeometry.h:516
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
Base class to provide boost signal/slot management.
const DtIndirectGeometrySubType myGeometrySubType
Definition: DtIndirectGeometry.h:480
boost::shared_lock< boost::shared_mutex > InstanceMutexReadLock
Definition: DtIndirectGeometry.h:522
DtIndirectGeometrySubType
Definition: DtIndirectGeometrySubType.h:16
handles the uv offsets for all the indirect geometry. Sets up the default state of the uv offset...
Definition: DtIndirectUvOffsetManager.h:49
DtInstanceContainer myInstanceContainer
container for all the instances registered here
Definition: DtIndirectGeometry.h:508
std::atomic< int > myTotalCount
Definition: DtIndirectGeometry.h:593
handles data that is specified per instance. Currently only the blend color from the DtOsgArticulated...
Definition: DtIndirectPerInstanceDataManager.h:59
osg::ref_ptr< osg::StateSet > myDefaultDrawStateSet
Definition: DtIndirectGeometry.h:546
Contains DLL export macros.
bool myMutableShouldReloadShaders
FIXME should be a static but currently the cull shader is per indirect.
Definition: DtIndirectGeometry.h:519
DtIndirectEffectTexturesTemplate myEffectTexturesState
the accumulated effect textures' state which represents the superset of all effect textures cumulativ...
Definition: DtIndirectGeometry.h:489
Interface class to manage/configure drawing of a subset of rendering components within an indirect ge...
Definition: DtIndirectDrawComponent.h:33
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:72
class to draw a subset of items of an indirect geometry (everything except light points), the default way
Definition: DtIndirectDefaultDrawComponent.h:36
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
Definition: DtIndirectShaderConstants.h:42
const bool myIsTerrainPatch
Definition: DtIndirectGeometry.h:481
Contains the DtIndirectGeometryRegistrar class declaration.
Contains makVrv::DtIndirectViewParameters class.
Contains makVrv::DtInstanceContainer.
const bool mySensorFxLoaded
Definition: DtIndirectGeometry.h:579
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
DtIndirectDefaultDrawComponent * myDefaultDrawComponent
Definition: DtIndirectGeometry.h:538
Contains the per Model info which the indirect module needs It is owned by the Indirect geometry regi...
Definition: DtIndirectModelInfo.h:55
DtIndirectDofManager * myDofManager
Definition: DtIndirectGeometry.h:511
Contains makVrv::DtIndirectFadeParameters class.
class to draw a subset of light points of an indirect geometry
Definition: DtIndirectLightPointDrawComponent.h:52