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 );
194 virtual void setInstanceOtherData0(
int instanceIdIndirect,
const Vector4_32& data);
196 virtual Vector4_32 instanceOtherData0(
int instanceIdIndirect)
const;
202 virtual void accept(osg::NodeVisitor& nv);
205 virtual void setParent(
const osg::Group* parent);
212 virtual void setRegistrarInvalid(
void);
215 virtual void releaseGLObjects(osg::State* state)
const override;
218 virtual void accept(osg::PrimitiveFunctor& functor)
const override;
223 virtual void setupIndirectShaders();
227 virtual const osg::Geode* parentGeode(
void)
const;
228 virtual osg::Geode* parentGeode(
void);
234 virtual void setLocalOriginTransform(
const osg::Matrixd& localOriginTransform);
239 virtual const osg::Matrixd& localOriginTransform()
const;
242 virtual bool actuallyAddQueuedUpInstances(
bool backgroundThreadLoadWaitForLock =
false );
245 virtual void launchOneTimeInitOp();
249 virtual void updateGpuBuffers(
bool amortizeTextures,
size_t& statsObjectsRemaining);
258 virtual void perCameraUpdateAndCull(
const osg::Camera* camera,
const osg::Matrix& modelViewMatrix,
const osg::FrameStamp* frameStamp);
261 virtual void fillViewParameters(
DtIndirectViewParameters& destViewParameters,
const osg::Matrix& modelViewMatrix,
const osg::Camera* osgCamera)
const;
269 virtual bool readyToRender(
const int instanceIdInIndirect)
const;
273 virtual bool hasQueuedInstances(
void )
const;
276 virtual bool allInstancesAreToBeDeleted()
const;
281 virtual bool instanceEverAdded(
void)
const;
285 virtual int numValidInstances(
void)
const;
298 virtual const unsigned int id(
void )
const;
305 virtual void update(
const osg::FrameStamp* frameStamp);
309 static void setTrackObjects(
bool val);
311 static bool trackObjects(
void);
315 static int numIndirectGeometries(
void);
328 static void initializeDtDeKeyedInstances(
DtDe& de);
331 static int numUpdateGpuBuffersRanThisFrame();
335 static void clearNumUpdateGpuBuffersRanThisFrame();
339 virtual void submitOneTimeOpForFrame();
353 virtual void setupShadersIfNecessary();
357 virtual void setupDebugUniforms();
361 virtual void installDefaultMaterial(osg::StateSet* ss);
364 virtual void slot_reloadShaders();
369 virtual void updateIndicesCount(
const DtIndirectModelInfo& modelInfo,
int instanceContainerIndex);
372 virtual void updateModelIdsToInstances(
int modelId,
int instanceId,
bool add);
375 virtual void drawFromCommandBuffer(osg::RenderInfo& renderInfo,
const DtIndirectViewParameters& viewParameters,
const osg::Camera* camera
376 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass,
bool viaExternalRenderer)
const;
379 virtual void syncViewParametersToGpu(
408 virtual void updateInstanceVisibilityLightPointMaxDistanceActual(
const DtIndirectGeometryInstance& instance,
int outInstanceIndex);
421 virtual void reloadShadersIfNecessary(
void)
const;
424 virtual void adjustDofConstraintsIfNecessary(osgSim::DOFTransform* clone);
431 virtual bool hasLightPoints(
void)
const;
434 virtual bool hasDepthOnly(
void)
const;
437 virtual bool isDepthOnly(
int stateId)
const;
440 virtual void nullOutDrawComponents(
void);
443 virtual void initDrawComponents(
void);
448 virtual void setPureSignalBasedUpdates(
bool val);
451 virtual void initializeUbosIfNecessary(osg::RenderInfo& renderInfo)
const;
454 virtual void slot_coordinateSystemChanged();
457 virtual void trackInstanceLifeTime(
int instanceIdInIndirectGeometry
459 ,
const std::string& trackName);
462 virtual std::pair<bool, std::string> trackInfo(
int instanceIdInIndirectGeometry)
const;
465 virtual void drawImplementation(osg::RenderInfo& renderInfo,
const osg::Matrixd& modelViewMatrix
466 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass)
const;
474 virtual bool disableExternalRenderForSensorFx(
const osg::Camera* camera)
const;
479 virtual bool useExternalRenderer(
const osg::Camera* camera)
const;
482 virtual std::string modelName(
int instanceId)
const;
486 virtual void registerUpdateComponent();
583 mutable int myGpuShaderUboBinding = -1;
unsigned int myNumTextCoordArrays
Definition: DtIndirectGeometry.h:511
Contains the DtCullShaderConfig class declaration.
MapIntToInt myInstancesToModelIds
Definition: DtIndirectGeometry.h:499
This manages the draw components (shader vp wrappers) for combinations of DtIndirectEffectTexturesTem...
Definition: DtIndirectShaderManager.h:50
DtIndirectFadeParameters myFadeParameters
Definition: DtIndirectGeometry.h:554
non virtual container class for holding the information needed to create an indirect geometry instanc...
Definition: DtIndirectGeometryInstance.h:26
bool myHasCullTraversedThisFrame
Definition: DtIndirectGeometry.h:602
osg::ref_ptr< osg::StateSet > myDepthOnlyDrawStateSet
Definition: DtIndirectGeometry.h:573
structure to count total number of DtIndirectGeometrys in the system
Definition: DtIndirectGeometry.h:611
static TotalCounter theTotalCounter
Definition: DtIndirectGeometry.h:622
std::unordered_map< int, int > MapIndirectIdToInstanceContainerId
Map of instances' id in indirect geometry to their id in the instance container.
Definition: DtIndirectGeometry.h:548
Contains makVrv::DtIndirectGeometrySubType declaration.
DtIndirectPerInstanceDataManager * myPerInstanceDataManager
Definition: DtIndirectGeometry.h:535
#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:533
This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with Dt...
Definition: DtGpuCulling.h:88
std::atomic< unsigned int > myIdNumbers
Definition: DtIndirectGeometry.h:620
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:111
DtIndirectLightPointDrawComponent * myLightPointDrawComponent
Definition: DtIndirectGeometry.h:560
boost::shared_mutex myInstanceMutex
Definition: DtIndirectGeometry.h:544
std::atomic< int > myRunningInstanceId
Definition: DtIndirectGeometry.h:557
osg::Matrixd myLocalOriginTransformMatrix
Definition: DtIndirectGeometry.h:515
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:586
Contains makVrv::DtIndirectModelScalingAlgorithm enumeration.
unsigned int myId
a unique id for the geometry
Definition: DtIndirectGeometry.h:526
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:542
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:490
DtSignalConnectionManager myConnections
Definition: DtIndirectGeometry.h:513
osg::ref_ptr< osg::StateSet > myLightPointDrawStateSet
Definition: DtIndirectGeometry.h:570
DtIndirectShaderManager & myIndirectShaderManager
Definition: DtIndirectGeometry.h:598
DtDe & myDe
Definition: DtIndirectGeometry.h:588
bool myMutableOutputInstancesBuffersChanged
Internal variable that tracks whether the output instance buffers via the culling got changed (resize...
Definition: DtIndirectGeometry.h:580
bool myUpdateComponentRegistered
Definition: DtIndirectGeometry.h:575
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:23
DtIndirectGeometryInstance, which holds information for creating an indirect geometry instance...
DtGpuCulling * myGpuCulling
Definition: DtIndirectGeometry.h:495
static bool theTrackObjects
Definition: DtIndirectGeometry.h:608
friend DtIndirectGeometryCreator
Definition: DtIndirectGeometry.h:123
DtIndirectDebugCullComponent * myIndirectDebugCullComponent
Definition: DtIndirectGeometry.h:561
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:497
const osg::Camera * myLastCamera
Definition: DtIndirectGeometry.h:552
unsigned int myLastFrameUpdated
Definition: DtIndirectGeometry.h:551
MapIndirectIdToInstanceContainerId myMapIndirectIdToInstanceContainerId
Definition: DtIndirectGeometry.h:549
static int theNumUpdateGpuBuffersRanThisFrame
Definition: DtIndirectGeometry.h:633
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:523
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:631
This class manages the vaos for indirect.
Definition: DtIndirectVaoManager.h:34
const bool myManagesIndividualInstances
Definition: DtIndirectGeometry.h:504
std::unordered_map< int, std::string > myInstancesBeingTracked
Definition: DtIndirectGeometry.h:596
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:520
int myNumIndicesAcrossAllModels
number of indices across all unique models across instances
Definition: DtIndirectGeometry.h:519
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
DtIndirectSwitchManager * mySwitchManager
Definition: DtIndirectGeometry.h:531
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:493
Contains makVrv::DtIndirectAnnotationAndUvOffset class.
DtIndirectUvOffsetManager * myUvOffsetManager
Definition: DtIndirectGeometry.h:534
bool myMutableShadersSetup
Definition: DtIndirectGeometry.h:537
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:501
boost::shared_lock< boost::shared_mutex > InstanceMutexReadLock
Definition: DtIndirectGeometry.h:543
DtIndirectGeometrySubType
Definition: DtIndirectGeometrySubType.h:16
unsigned int myOneTimeOpSubmittedForFrameNumber
The frame number when the one time op was processed Only used when multiple one time ops are required...
Definition: DtIndirectGeometry.h:606
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:529
std::atomic< int > myTotalCount
Definition: DtIndirectGeometry.h:619
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:567
Contains DLL export macros.
bool myMutableShouldReloadShaders
FIXME should be a static but currently the cull shader is per indirect.
Definition: DtIndirectGeometry.h:540
DtIndirectEffectTexturesTemplate myEffectTexturesState
the accumulated effect textures' state which represents the superset of all effect textures cumulativ...
Definition: DtIndirectGeometry.h:510
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:76
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
std::unordered_map< int, Vector4_32 > myMapInstanceToOtherData0
Maps an instance id to the other data0 for that instance.
Definition: DtIndirectGeometry.h:629
Definition: DtIndirectShaderConstants.h:42
const bool myIsTerrainPatch
Definition: DtIndirectGeometry.h:502
Contains the DtIndirectGeometryRegistrar class declaration.
Contains makVrv::DtIndirectViewParameters class.
Contains makVrv::DtInstanceContainer.
const bool mySensorFxLoaded
Definition: DtIndirectGeometry.h:600
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:559
Contains the per Model info which the indirect module needs These objects are owned by the Indirect g...
Definition: DtIndirectModelInfo.h:67
DtIndirectDofManager * myDofManager
Definition: DtIndirectGeometry.h:532
Contains makVrv::DtIndirectFadeParameters class.
class to draw a subset of light points of an indirect geometry
Definition: DtIndirectLightPointDrawComponent.h:52