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 DtGpuArenaUploadState;
61 class DtIndirectGeometryRegistrar;
62 class DtCullShaderConfig;
65 class DtOsgCullVisitorParameters;
67 class DtVirtualProgramCache;
69 class DtIndirectDrawComponent;
70 class DtIndirectDefaultDrawComponent;
71 class DtIndirectLightPointDrawComponent;
72 class DtIndirectDebugCullComponent;
74 class DtIndirectSwitchManager;
75 class DtIndirectDofManager;
76 class DtIndirectLodManager;
77 class DtIndirectUvOffsetManager;
78 class DtIndirectPerInstanceDataManager;
79 class DtIndirectShaderConstants;
80 class DtOsgLightPointManager;
81 class DtIndirectRunTimeSettings;
83 class DtIndirectVaoManager;
85 class DtCoordinateSystem;
89 class DtIndirectShaderManager;
92 class DtIndirectGeometry;
151 virtual void doShutdown();
157 virtual void cancelShutdown();
160 virtual bool isShutdown()
const;
163 virtual void setName(
const std::string& name)
override;
181 virtual const char* className()
const;
186 virtual void drawImplementation(osg::RenderInfo& renderInfo)
const;
190 virtual void debugDrawImplementation(osg::RenderInfo& renderInfo,
191 const osg::Matrixd& modelViewMatrix);
205 virtual int addInstance(
int modelId,
const osg::Matrixd& xForm,
float modelScale,
float modelRadius,
int lightPointGroupId
207 ,
const std::string& trackName
208 ,
bool defaultVisibility =
true );
211 virtual void setInstanceOtherData0(
int instanceIdIndirect,
const Vector4_32& data);
213 virtual Vector4_32 instanceOtherData0(
int instanceIdIndirect)
const;
219 virtual void accept(osg::NodeVisitor& nv);
222 virtual void setParent(
const osg::Group* parent);
229 virtual void setRegistrarInvalid(
void);
232 virtual void releaseGLObjects(osg::State* state)
const override;
235 virtual void accept(osg::PrimitiveFunctor& functor)
const override;
240 virtual void setupIndirectShaders();
244 virtual const osg::Geode* parentGeode(
void)
const;
245 virtual osg::Geode* parentGeode(
void);
251 virtual void setLocalOriginTransform(
const osg::Matrixd& localOriginTransform);
256 virtual const osg::Matrixd& localOriginTransform()
const;
259 virtual bool actuallyAddQueuedUpInstances(
bool backgroundThreadLoadWaitForLock =
false );
262 virtual void launchOneTimeInitOp();
275 virtual void perCameraUpdateAndCull(
const osg::Camera* camera,
const osg::Matrix& modelViewMatrix,
276 const osg::FrameStamp* frameStamp,
const osg::Camera* viewCamera);
283 virtual void fillViewParameters(
DtIndirectViewParameters& destViewParameters,
const osg::Matrix& modelViewMatrix,
const osg::Camera* osgCamera)
const;
288 const osg::Camera* viewCamera)
const;
296 virtual bool readyToRender(
const int instanceIdInIndirect)
const;
300 virtual bool hasQueuedInstances(
void )
const;
303 virtual bool allInstancesAreToBeDeleted()
const;
308 virtual bool instanceEverAdded(
void)
const;
312 virtual int numValidInstances(
void)
const;
325 virtual const unsigned int id(
void )
const;
332 virtual void update(
const osg::FrameStamp* frameStamp);
341 : myInstanceIdIndirect(-1)
342 , myContainerInstanceId(-1)
378 : myQueuedInstanceCount(0)
379 , myInstancesDroppedBogusModel(0)
380 , myInstancesRequeuedModelNotFound(0)
381 , myAddInstanceActualFailures(0)
382 , myLastSuccessfulAddFrame(0)
383 , myAddAttemptEarlyOuts(0)
385 , myInProgressInstanceMoves(0)
443 virtual void debugOnlyInstanceSnapshot(std::vector<DebugInstanceSnapshotEntry>& outEntries)
const;
458 virtual bool debugOnlyGetInstanceTransforms(
int instanceIdIndirect,
459 osg::Matrixd& outWorldTransform, osg::Matrixd& outLocalTransform)
const;
472 virtual bool debugOnlyGetPerGeomInstances(
int instanceIdIndirect,
473 std::vector<PerGeomInstance>& outPerGeomInstances)
const;
488 static void setTrackObjects(
bool val);
490 static bool trackObjects(
void);
494 static int numIndirectGeometries(
void);
507 static void initializeDtDeKeyedInstances(
DtDe& de);
510 static int numUpdateGpuBuffersRanThisFrame();
514 static void clearNumUpdateGpuBuffersRanThisFrame();
518 virtual void submitOneTimeOpForFrame();
528 virtual void registerUpdateComponent();
532 virtual void unregisterUpdateComponent()
const;
541 virtual void setupShadersIfNecessary();
545 virtual void setupDebugUniforms();
549 virtual void installDefaultMaterial(osg::StateSet* ss);
552 virtual void slot_reloadShaders();
557 virtual void updateIndicesCount(
const DtIndirectModelInfo& modelInfo,
int instanceContainerIndex);
560 virtual void updateModelIdsToInstances(
int modelId,
int instanceId,
bool add);
563 virtual void drawFromCommandBuffer(osg::RenderInfo& renderInfo,
const DtIndirectViewParameters& viewParameters,
const osg::Camera* camera
564 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass,
bool viaExternalRenderer)
const;
567 virtual void syncViewParametersToGpu(
596 virtual void updateInstanceVisibilityLightPointMaxDistanceActual(
const DtIndirectGeometryInstance& instance,
int outInstanceIndex);
609 virtual void reloadShadersIfNecessary(
void)
const;
612 virtual void adjustDofConstraintsIfNecessary(osgSim::DOFTransform* clone);
619 virtual bool hasLightPoints(
void)
const;
622 virtual bool hasDepthOnly(
void)
const;
625 virtual bool isDepthOnly(
int stateId)
const;
628 virtual void nullOutDrawComponents(
void);
631 virtual void initDrawComponents(
void);
636 virtual void setPureSignalBasedUpdates(
bool val);
639 virtual void initializeUbosIfNecessary(osg::RenderInfo& renderInfo)
const;
642 virtual void slot_coordinateSystemChanged();
645 virtual void trackInstanceLifeTime(
int instanceIdInIndirectGeometry
647 ,
const std::string& trackName);
650 virtual std::pair<bool, std::string> trackInfo(
int instanceIdInIndirectGeometry)
const;
653 virtual void drawImplementation(osg::RenderInfo& renderInfo,
const osg::Matrixd& modelViewMatrix
654 ,
bool isLightBin,
bool isDepthBin,
bool isShadowPass)
const;
662 virtual bool disableExternalRenderForSensorFx(
const osg::Camera* camera)
const;
667 virtual bool useExternalRenderer(
const osg::Camera* camera)
const;
670 virtual std::string modelName(
int instanceId)
const;
699 mutable std::atomic<unsigned int> myDebugInstancesDroppedBogusModel{0};
703 mutable std::atomic<unsigned int> myDebugInstancesRequeuedModelNotFound{0};
704 mutable std::atomic<unsigned int> myDebugAddInstanceActualFailures{0};
705 mutable std::atomic<unsigned int> myDebugLastSuccessfulAddFrame{0};
706 mutable std::atomic<unsigned int> myDebugAddAttemptEarlyOuts{0};
795 mutable int myGpuShaderUboBinding = -1;
unsigned int myNumTextCoordArrays
Definition: DtIndirectGeometry.h:725
Contains the DtCullShaderConfig class declaration.
unsigned int myLastCullFrame
The last frame this geometry was updated by the cull / per-camera path (from myLastFrameUpdated). If this value is not advancing between polls, the geometry is not being visited and a non-empty instance queue is deferred by design, not stuck.
Definition: DtIndirectGeometry.h:417
std::atomic< bool > myIsShutdown
Definition: DtIndirectGeometry.h:676
MapIntToInt myInstancesToModelIds
Definition: DtIndirectGeometry.h:713
This manages the draw components (shader vp wrappers) for combinations of DtIndirectEffectTexturesTem...
Definition: DtIndirectShaderManager.h:50
DtIndirectFadeParameters myFadeParameters
Definition: DtIndirectGeometry.h:768
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:787
structure to count total number of DtIndirectGeometrys in the system
Definition: DtIndirectGeometry.h:823
unsigned int myInstancesDroppedBogusModel
Instances silently discarded because the model info had zero geometry specifications ("bogus model" p...
Definition: DtIndirectGeometry.h:396
static TotalCounter theTotalCounter
Definition: DtIndirectGeometry.h:834
std::unordered_map< int, int > MapIndirectIdToInstanceContainerId
Map of instances' id in indirect geometry to their id in the instance container.
Definition: DtIndirectGeometry.h:762
unsigned int myInProgressInstanceMoves
Current number of cell-to-cell instance moves that have this geometry as the move SOURCE and are wait...
Definition: DtIndirectGeometry.h:427
Contains makVrv::DtIndirectGeometrySubType declaration.
DtIndirectPerInstanceDataManager * myPerInstanceDataManager
Definition: DtIndirectGeometry.h:749
#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:71
int myContainerInstanceId
The instance id in the instance container.
Definition: DtIndirectGeometry.h:353
Definition: DtIndirectDebugCullComponent.h:45
DtIndirectLodManager * myLodManager
Definition: DtIndirectGeometry.h:747
std::atomic< bool > myUpdateComponentRegistered
Definition: DtIndirectGeometry.h:690
This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with Dt...
Definition: DtGpuCulling.h:91
std::atomic< unsigned int > myIdNumbers
Definition: DtIndirectGeometry.h:832
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:111
DtIndirectLightPointDrawComponent * myLightPointDrawComponent
Definition: DtIndirectGeometry.h:774
boost::shared_mutex myInstanceMutex
Definition: DtIndirectGeometry.h:758
std::atomic< int > myRunningInstanceId
Definition: DtIndirectGeometry.h:771
osg::Matrixd myLocalOriginTransformMatrix
Definition: DtIndirectGeometry.h:729
A class that represents setting that are runtime tweakable/toggleable.
Definition: DtIndirectRunTimeSettings.h:29
DtVirtualBaseClassCreator< DtIndirectGeometry, const DtCullShaderConfig &, const DtIndirectGeometrySubType &, const bool & > DtIndirectGeometryCreator
creator
Definition: DtIndirectGeometry.h:94
DtOsgLightPointManager & myLightPointManager
Definition: DtIndirectGeometry.h:798
Contains makVrv::DtIndirectModelScalingAlgorithm enumeration.
int myInstanceIdIndirect
The instance id in the indirect geometry.
Definition: DtIndirectGeometry.h:350
unsigned int myId
a unique id for the geometry
Definition: DtIndirectGeometry.h:740
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:756
handles the lods for all the indirect geometry. sets up and runs a compute shader prepass for process...
Definition: DtIndirectLodManager.h:55
osg::ref_ptr< DtIndirectGeometryRegistrar > myRegistrar
pointer to the (external) registrar
Definition: DtIndirectGeometry.h:693
unsigned int myAddAttemptEarlyOuts
Number of times actuallyAddQueuedUpInstances early-outed on the main thread because the registrar was...
Definition: DtIndirectGeometry.h:411
DtSignalConnectionManager myConnections
Definition: DtIndirectGeometry.h:727
osg::ref_ptr< osg::StateSet > myLightPointDrawStateSet
Definition: DtIndirectGeometry.h:784
DtIndirectShaderManager & myIndirectShaderManager
Definition: DtIndirectGeometry.h:810
DtDe & myDe
Definition: DtIndirectGeometry.h:800
bool myMutableOutputInstancesBuffersChanged
Internal variable that tracks whether the output instance buffers via the culling got changed (resize...
Definition: DtIndirectGeometry.h:792
const char * creatorTypeName< DtIndirectGeometry >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometry.h:101
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:709
static bool theTrackObjects
Definition: DtIndirectGeometry.h:820
friend DtIndirectGeometryCreator
Definition: DtIndirectGeometry.h:125
DtIndirectDebugCullComponent * myIndirectDebugCullComponent
Definition: DtIndirectGeometry.h:775
This class allows us to draw all indirect geometries one after the other with minimal state changes...
Definition: DtIndirectGeometryRenderer.h:63
This class inherits from.
Definition: DtIndirectGeometry.h:122
MapIntToInt myModelIDsToInstances
Definition: DtIndirectGeometry.h:711
const osg::Camera * myLastCamera
Definition: DtIndirectGeometry.h:766
unsigned int myLastFrameUpdated
Definition: DtIndirectGeometry.h:765
MapIndirectIdToInstanceContainerId myMapIndirectIdToInstanceContainerId
Definition: DtIndirectGeometry.h:763
static int theNumUpdateGpuBuffersRanThisFrame
Definition: DtIndirectGeometry.h:845
handles the dof nodes for all the indirect geometry. Sets up the default state of osg::Dof...
Definition: DtIndirectDofManager.h:66
Debug-only. Snapshot of queue health counters for this geometry.
Definition: DtIndirectGeometry.h:375
unsigned int myAddInstanceActualFailures
Number of times addInstanceActual returned false.
Definition: DtIndirectGeometry.h:403
DtIndirectVaoManager & myVaoManager
This is de-referenced here for speed.
Definition: DtIndirectGeometry.h:737
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:46
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:843
Manages and tracks memory usage statistics for GPU resource upload operations.
Definition: DtGpuArenaUploadState.h:39
This class manages the vaos for indirect.
Definition: DtIndirectVaoManager.h:34
bool myIsTracked
Whether lifetime tracking is active for this instance.
Definition: DtIndirectGeometry.h:359
const bool myManagesIndividualInstances
Definition: DtIndirectGeometry.h:718
std::unordered_map< int, std::string > myInstancesBeingTracked
Definition: DtIndirectGeometry.h:808
struct for holding the fade parameters used by the indirect rendering cull compute shader ...
Definition: DtIndirectFadeParameters.h:17
DebugInstanceSnapshotEntry()
Definition: DtIndirectGeometry.h:340
std::map< int, int > myInstanceContainerIdToNumIndices
Definition: DtIndirectGeometry.h:734
std::string myTrackName
The lifetime tracking name, if tracked.
Definition: DtIndirectGeometry.h:365
int myNumIndicesAcrossAllModels
number of indices across all unique models across instances
Definition: DtIndirectGeometry.h:733
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
unsigned int myLastSuccessfulAddFrame
Frame number of the last successful instance add.
Definition: DtIndirectGeometry.h:406
DtIndirectSwitchManager * mySwitchManager
Definition: DtIndirectGeometry.h:745
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:696
Contains makVrv::DtIndirectAnnotationAndUvOffset class.
DtIndirectUvOffsetManager * myUvOffsetManager
Definition: DtIndirectGeometry.h:748
bool myMutableShadersSetup
Definition: DtIndirectGeometry.h:751
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
Debug-only. One entry in a debug instance snapshot.
Definition: DtIndirectGeometry.h:338
Base class to provide boost signal/slot management.
DtIndirectGeometrySubType mySubType
The geometry subtype, for filtering in debugging tools.
Definition: DtIndirectGeometry.h:430
const DtIndirectGeometrySubType myGeometrySubType
Definition: DtIndirectGeometry.h:715
boost::shared_lock< boost::shared_mutex > InstanceMutexReadLock
Definition: DtIndirectGeometry.h:757
DtIndirectGeometrySubType
Definition: DtIndirectGeometrySubType.h:16
unsigned int myQueuedInstanceCount
Approximate current size of myQueueInstancesToAdd.
Definition: DtIndirectGeometry.h:392
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:817
std::mutex myUpdateComponentMutex
Definition: DtIndirectGeometry.h:689
handles the uv offsets for all the indirect geometry. Sets up the default state of the uv offset...
Definition: DtIndirectUvOffsetManager.h:50
DtInstanceContainer myInstanceContainer
container for all the instances registered here
Definition: DtIndirectGeometry.h:743
std::atomic< int > myTotalCount
Definition: DtIndirectGeometry.h:831
handles data that is specified per instance. Currently only the blend color from the DtOsgArticulated...
Definition: DtIndirectPerInstanceDataManager.h:65
osg::ref_ptr< osg::StateSet > myDefaultDrawStateSet
Definition: DtIndirectGeometry.h:781
Contains DLL export macros.
bool myMutableShouldReloadShaders
FIXME should be a static but currently the cull shader is per indirect.
Definition: DtIndirectGeometry.h:754
DtIndirectEffectTexturesTemplate myEffectTexturesState
the accumulated effect textures' state which represents the superset of all effect textures cumulativ...
Definition: DtIndirectGeometry.h:724
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
This is a helper class to manage sets of perGeomInstance objects associated with a model instance...
Definition: DtInstanceContainer.h:39
std::unordered_map< int, Vector4_32 > myMapInstanceToOtherData0
Maps an instance id to the other data0 for that instance.
Definition: DtIndirectGeometry.h:841
Definition: DtIndirectShaderConstants.h:42
int myModelId
The model id associated with this instance.
Definition: DtIndirectGeometry.h:356
const bool myIsTerrainPatch
Definition: DtIndirectGeometry.h:716
Contains the DtIndirectGeometryRegistrar class declaration.
Contains makVrv::DtIndirectViewParameters class.
Contains makVrv::DtInstanceContainer.
const bool mySensorFxLoaded
Definition: DtIndirectGeometry.h:812
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
std::mutex myShutdownQueueMutex
Serializes queue pushes in addInstance against the shutdown flag transition in doShutdown. Guarantees that after doShutdown returns, no further instances can be queued: a producer either pushed before the flag was set (visible to the caller of doShutdown via hasQueuedInstances) or observes the flag and gets -1 back, in which case it must re-fetch the cell from the grid. This mutex is performant because it is uncontended except during the rare add-vs-page-out race that it is intended to handle.
Definition: DtIndirectGeometry.h:685
std::string myModelName
The model name associated with this instance.
Definition: DtIndirectGeometry.h:362
DebugQueueHealthSnapshot()
Definition: DtIndirectGeometry.h:377
DtIndirectDefaultDrawComponent * myDefaultDrawComponent
Definition: DtIndirectGeometry.h:773
Contains the per Model info which the indirect module needs These objects are owned by the Indirect g...
Definition: DtIndirectModelInfo.h:68
DtIndirectDofManager * myDofManager
Definition: DtIndirectGeometry.h:746
Contains makVrv::DtIndirectFadeParameters class.
class to draw a subset of light points of an indirect geometry
Definition: DtIndirectLightPointDrawComponent.h:52
unsigned int myInstancesRequeuedModelNotFound
Instances pushed back onto the queue because the model info was not found in the registrar yet...
Definition: DtIndirectGeometry.h:400