12 #include <osg/FrameStamp>
27 #define CPU_SIDE_COMPILATION 1
28 #include <../data/shaders/indirect/GeometrySpecification.h>
37 #include <unordered_map>
38 #include <unordered_set>
51 class DtGpuArenaUploadState;
52 class DtIndirectGeometryRegistrar;
53 class DtInstanceContainer;
54 class DtOsgShaderFilesCache;
55 class DtIndirectCullProgram;
56 class DtCpuCullingHelper;
57 class DtOsgLightPointManager;
58 class DtGlDeleteObjectManager;
59 class DtCoreGlBufferCreator;
60 class DtIndirectClearBufferProgram;
61 class DtIndirectModelInfo;
62 class DtIndirectGlTextureObject;
63 class DtIndirectGlTextureObjectManager;
64 class DtGpuCullingTcsUserData;
65 class DtThreadCameraStreamDataManager;
118 using CameraSet = std::set<osg::observer_ptr<const osg::Camera> >;
147 virtual void setRegistrarInvalid();
150 virtual void setDebug(
bool debug);
161 virtual void modelIdsToNumInstancesChanged();
166 virtual unsigned int updatePerInstancePerGeomBuffers(
const MapIntToInt& modelIdsToNumInstances,
167 const osg::Camera* camera,
unsigned int currentFrame);
181 ,
const osg::FrameStamp* frameStamp
186 ,
const osg::Camera* camera
187 ,
bool& outputInstanceBufferChanged);
190 static bool setUpOutputFormatAndBindings();
193 static void unsetUpOutputFormatAndBindings();
199 virtual bool bindGpuOutputInstanceBuffersWithAddressRange(
const osg::Camera* camera)
const;
206 virtual bool bindCommandBufferAndSsbos(
const DtGlBuffer* gpuDofTransformBuffer
210 ,
const osg::Camera* camera);
213 virtual void unbindCommandBufferAndSsbos(
const osg::Camera* camera);
219 virtual void bindGpuOutputInstanceBufferDebug(
const osg::Camera* camera)
const;
223 virtual void unbindGpuOutputInstanceBufferDebug(
const osg::Camera* camera)
const;
228 virtual bool bindIndirectThingsDebug(
const DtGlBuffer* gpuDofTransformBuffer,
const osg::Camera* camera);
231 virtual void unbindIndirectThingsDebug(
const osg::Camera* camera);
235 virtual bool useInstanceCount()
const;
239 virtual int numDrawCommands(
const osg::Camera* camera)
const;
242 virtual void releaseGLObjects();
245 virtual void reloadShaders()
const;
248 virtual bool buffersInitializedForCamera(
const osg::Camera* camera)
const;
251 virtual unsigned int maxNumInstances()
const;
254 virtual unsigned int numGeometrySpecifications()
const;
260 virtual const std::vector<InstancesOffsetAndNumOfInstances>& instancesOffsetAndNumInstances()
const;
263 virtual bool readyToUpdateAndGpuBuffersNeedUpdate()
const;
266 virtual bool gpuBuffersNeedUpdate()
const;
269 virtual bool textureUpdateDirty()
const;
272 virtual void setTextureUpdateDirty(
bool flag);
275 virtual bool geometryAndMaterialsDirty()
const;
278 virtual void setGeometryAndMaterialsDirty(
bool flag);
281 virtual bool instancesInvalidatedDirty()
const;
284 virtual void invalidateInstance(
int instanceId);
287 virtual const DtGlBuffer* gpuInputPerGeomInstancesBuffer()
const;
290 virtual const DtGlBuffer* gpuMaterialsBuffer()
const;
293 virtual void fillOutputInstances(std::vector<
DtVector4<int> >& outputInstances,
const osg::Camera* camera)
const;
299 virtual void setName(
const std::string& name);
302 virtual const std::string& name()
const;
315 virtual void updateGpuInputData(
unsigned int currentFrame);
319 virtual void updateGpuInputPerGeomInstancesBuffer();
322 virtual void transferMaterialsAndGeometrySpecificationsToGpuBuffers(
size_t numUniqueGeometries,
DtGpuArenaUploadState& uploadState);
323 virtual void updateGpuLightPointBuffers();
327 virtual void clearStateIdCommandCountBuffer();
328 virtual void clearLightSourceIndexOutputBuffer(
unsigned int maxNumLightSources,
DtGpuCullingTcsUserData* userData);
334 virtual void buildStateToGeometrySpecIndicesMap(
const std::vector<DtGeometrySpecification>& geometrySpecifications,
335 const std::vector<InstancesOffsetAndNumOfInstances>& instancesOffsetAndNumInstances,
339 virtual void populateIndirectDrawBuffersByState(
const int numGeometries,
348 void accumulateStateIdToMaxCommands(
const DtGeometrySpecVector& locations,
const int numInstances,
349 std::unordered_map<int, int>& stateIdToMaxCommands,
int& maxStateId)
const;
364 virtual bool processModelTextures(
const DtIndirectModelInfo* modelInfo, GLuint64* stagingBuffer,
365 int& texturesIndex,
int numTextures,
const std::vector<int>& offsetLookup,
DtGpuArenaUploadState& uploadState,
366 int sizeOfGpuTextureStructure,
int sizeGpuTextureBuffersRequired,
int& numTexturesStillDownloading);
371 virtual bool processEffectTexturesForGeometry(
373 int texturesIndex,
int numTextures,
const std::vector<int>& offsetLookup,
379 virtual int updateEffectTextureState();
385 virtual int updateGeometryCountState();
391 virtual void buildEffectTextureOffsetLookup(std::vector<int>& offsetLookup)
const;
394 virtual void updateInstancesOffsetAndInstances(
const MapIntToInt& modelIdsToNumInstances);
397 virtual void updateInstancesOffsetAndInstancesBuffer();
400 virtual void updateStateIdToMaxNumCommands(
const MapIntToInt& modelIdsToNumInstances);
403 virtual void updateStateIdToMaxNumCommandsBuffer();
406 virtual void deleteBuffers();
409 virtual void flushSingleCameraSet(
CameraSet& cameraSet);
416 virtual void releaseGlObjectsDecrementUsersAndUnLoadIfNecessary();
422 virtual bool debugCullingActive()
const;
unsigned int myMaxNumInstancesPreCulling
Definition: DtGpuCulling.h:464
Contains the DtCullShaderConfig class declaration.
DtCoreGlBufferCreator & myDtCoreGlBufferCreator
Definition: DtGpuCulling.h:497
static const int theGpuOutputInstanceOffsetInPerInstanceDataBufferIndex
Definition: DtGpuCulling.h:503
Manager for DtThreadCameraStreamData Holds them as cameras come in. Deletes them as cameras go out (v...
Definition: DtThreadCameraStreamDataManager.h:86
DtIndirectGeometryRegistrar * myRegistrar
Definition: DtGpuCulling.h:425
DtMaterial class declaration.
DtGlBuffer * myGpuInstancesOffsetAndNumInstancesBuffer
Definition: DtGpuCulling.h:462
std::map< int, VectorInts > MapStateToGeometrySpecIndices
map of state id to vector of geometry spec indices
Definition: DtGpuCulling.h:121
const DtInstanceContainer & myInstanceContainer
Definition: DtGpuCulling.h:427
unsigned int myLastGpuInputDataFrame
Definition: DtGpuCulling.h:469
Contains makVrv::DtIndirectInstancesInvalidated class.
DtOsgLightPointManager & myLightPointManager
Definition: DtGpuCulling.h:482
std::vector< InstancesOffsetAndNumOfInstances > myInstancesOffsetAndNumInstances
Definition: DtGpuCulling.h:461
static const int theGpuOutputInstanceBufferDebugIndex
Definition: DtGpuCulling.h:504
const char * creatorTypeName< DtGpuCulling >()
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtGpuCulling.h:75
DtIndirectClearBufferProgram * myClearBufferProgram
Definition: DtGpuCulling.h:506
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::vector< DrawElementsIndirectBindlessCommandNV > myBindlessIndexAndVertexBuffers
the bindless vertex and index buffers
Definition: DtGpuCulling.h:443
creator for DtCoreGlBuffer
Definition: DtCoreGlBuffer.h:66
This manager manages the lifetime of the actual gl texture objects (gl unsigned ints) in the indirect...
Definition: DtIndirectGlTextureObjectManager.h:61
This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with Dt...
Definition: DtGpuCulling.h:91
int myOffset
Definition: DtGpuCulling.h:111
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:111
Contains makVrv::DtFirstTextureStreamedModelAndIndexTracker class.
int myOffset
Definition: DtGpuCulling.h:98
DtGlBuffer * myGpuStateIdToMaxNumCommandsBuffer
Definition: DtGpuCulling.h:475
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtGpuCulling.h:510
Contains the DtGpuCullingTcsUserData class declaration.
bool operator==(const InstancesOffsetAndNumOfInstances &rhs) const
Definition: DtGpuCulling.h:101
DtGlBuffer * myBindlessIndexAndVertexBuffersBuffer
The gpu buffer holding the same above info.
Definition: DtGpuCulling.h:446
VectorInts myGeomSpecIndexToCommandIndex
Definition: DtGpuCulling.h:479
DtIndirectInstancesInvalidated myInstancesInvalidated
Definition: DtGpuCulling.h:431
shader configuration storage class. Has 3 available options which are described in the constructor's ...
Definition: DtCullShaderConfig.h:21
DtModelIdAndStreamedBytesTracker mySpecBufferTracker
Definition: DtGpuCulling.h:493
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
DtGlBuffer * myGpuInputPerGeomInstancesBuffer
contains switch states/ lod info
Definition: DtGpuCulling.h:430
DtFirstTextureStreamedModelAndIndexTracker myFirstTextureStreamedModelAndIndexTracker
Keep track of the first model and what index to start using bindless textures.
Definition: DtGpuCulling.h:488
This represents per camera (tcs) specific data for DtGpuCulling.
Definition: DtGpuCullingTcsUserData.h:23
bool myGeometryAndMaterialsDirty
Definition: DtGpuCulling.h:433
DtThreadCameraStreamDataManager & myTcsDataManager
Definition: DtGpuCulling.h:518
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
Contains the DtIndirectEffectTexturesTemplate class declaration.
DtGlBuffer * myGpuSpecIndexToCommandIndexBuffer
Definition: DtGpuCulling.h:480
DtIndirectEffectTexturesTemplate myCurrentEffectTextureState
Definition: DtGpuCulling.h:498
holds a set of the instances that need to be invalidated in the instance buffers
Definition: DtIndirectInstancesInvalidated.h:19
Definition: DtModelIdAndStreamedBytesTracker.h:18
unsigned int myLastNumUniqueGeometriesForGpuTextures
Definition: DtGpuCulling.h:490
unsigned int myMaxNumInstances
Definition: DtGpuCulling.h:465
unsigned int myLastNumEffectTextures
Definition: DtGpuCulling.h:489
std::vector< int > VectorInts
Definition: DtCommonTypes.h:20
handles the running of the compute shader pass for indirect culling, LODing and switches ...
Definition: DtIndirectCullProgram.h:54
DtGpuCullingTcsUserDataCreator & myUserDataCreator
Definition: DtGpuCulling.h:520
DtGlBuffer * myGpuMaterialsBuffer
The spec buffer containing Materials for all the models/lods of the passed in instances.
Definition: DtGpuCulling.h:450
static std::thread::id theMainThreadId
Definition: DtGpuCulling.h:516
This class represents the list of DtIndirectTexturePrototypes belonging to a particular sub-geometry...
Definition: DtIndirectGeometryTextures.h:38
Contains makVrv::DtIndirectModelSubGeometry class.
structure for holding an offset of an instance type (model id), and number of those instances ...
Definition: DtGpuCulling.h:96
Manages and tracks memory usage statistics for GPU resource upload operations.
Definition: DtGpuArenaUploadState.h:39
DtIndirectCullProgram * myCullProgram
Definition: DtGpuCulling.h:457
unsigned int myMaxNumLightSources
Definition: DtGpuCulling.h:467
A generic OpenGL buffer. This can be: -> a vertex buffer -> an index buffer -> a shader storage buffe...
Definition: DtGlBuffer.h:29
int myNumOfInstances
Definition: DtGpuCulling.h:99
DtGlBuffer * myGpuStateIdToCommandCountBuffer
Definition: DtGpuCulling.h:476
const DtCullShaderConfig myCullShaderConfig
Definition: DtGpuCulling.h:459
DtVirtualBaseClassCreator< DtGpuCulling, DtInstanceContainer &, const DtCullShaderConfig & > DtGpuCullingCreator
creator
Definition: DtGpuCulling.h:68
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
std::vector< DtGeometrySpecification > myGeometrySpecifications
c++ buffer that holds the same info
Definition: DtGpuCulling.h:436
std::string myName
Definition: DtGpuCulling.h:500
DtGlBuffer * myGpuGeometrySpecificationsBuffer
The spec buffer containing GeometrySpecifications for all the models/lods of the passed in instances...
Definition: DtGpuCulling.h:440
DtIndirectMaterialVector myMaterials
c++ buffer that holds the same info
Definition: DtGpuCulling.h:453
Vaos are OpenGL context specific. They need to be deleted in the context they are created in...
Definition: DtGlDeleteObjectManager.h:58
friend DtGpuCullingCreator
Definition: DtGpuCulling.h:125
std::unordered_set< DtIndirectModelInfo * > myModelsBeingUsed
Definition: DtGpuCulling.h:508
This class clears buffers using compute shader Theoretically, there are performance gains to be achie...
Definition: DtIndirectClearBufferProgram.h:33
DtGlBuffer * myGpuTexturesBuffer
Definition: DtGpuCulling.h:455
bool myTextureUpdateDirty
Definition: DtGpuCulling.h:491
Contains DLL export macros.
DtDe & myDe
Definition: DtGpuCulling.h:484
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
Definition: DtGpuCulling.h:514
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
This is a helper class to manage sets of perGeomInstance objects associated with a model instance...
Definition: DtInstanceContainer.h:39
static const int theGpuOutputInstanceBufferIndex
Definition: DtGpuCulling.h:502
Definition: DtFirstTextureStreamedModelAndIndexTracker.h:16
CameraSet myModelIdsToNumInstancesChanged
Definition: DtGpuCulling.h:495
std::unordered_set< DtIndirectGlTextureObject * > myIndirectTexturesBeingUsed
Definition: DtGpuCulling.h:512
Contains makVrv::DtIndirectViewParameters class.
std::set< osg::observer_ptr< const osg::Camera > > CameraSet
All the culling output buffers need to be per camera so shadows passes work.
Definition: DtGpuCulling.h:118
bool myRegistrarValid
Definition: DtGpuCulling.h:426
Class that allows you to abstractly register effect texture types the effect texture types are client...
Definition: DtIndirectEffectTexturesTemplate.h:40
VectorStateIdOffsetAndMaxCommands myStateIdToMaxNumCommands
Definition: DtGpuCulling.h:472
Contains the per Model info which the indirect module needs These objects are owned by the Indirect g...
Definition: DtIndirectModelInfo.h:68
std::vector< Material > DtIndirectMaterialVector
Each model type can have a number of geometries, each with an own material.
Definition: DtMaterial.h:46
int myMaxCommands
Definition: DtGpuCulling.h:112
Contains makVrv::DtModelIdAndStreamedBytesTracker class.
std::vector< StateIdOffsetAndMaxCommands > VectorStateIdOffsetAndMaxCommands
Definition: DtGpuCulling.h:115
structure for holding an offset of a command of a given type (state id) and the number of commands of...
Definition: DtGpuCulling.h:109