12 #include <osg/FrameStamp>
27 #define CPU_SIDE_COMPILATION 1
28 #include <../data/shaders/indirect/GeometrySpecification.h>
36 #include <unordered_set>
48 class DtIndirectGeometryRegistrar;
49 class DtInstanceContainer;
50 class DtOsgShaderFilesCache;
51 class DtIndirectCullProgram;
52 class DtCpuCullingHelper;
53 class DtOsgLightPointManager;
54 class DtGlDeleteObjectManager;
55 class DtCoreGlBufferCreator;
56 class DtIndirectClearBufferProgram;
57 class DtIndirectModelInfo;
58 class DtIndirectGlTextureObject;
59 class DtIndirectGlTextureObjectManager;
60 class DtGpuCullingTcsUserData;
61 class DtThreadCameraStreamDataManager;
114 typedef std::set<osg::observer_ptr<const osg::Camera> >
CameraSet;
140 virtual void setRegistrarInvalid(
void);
143 virtual void setDebug(
bool debug);
151 virtual void updateGpuBuffers(
bool amortizeTextures);
155 virtual void modelIdsToNumInstancesChanged(
void);
158 virtual void updatePerInstancePerGeomBuffers(
const MapIntToInt& modelIdsToNumInstances,
const osg::Camera* camera);
165 ,
const osg::FrameStamp* frameStamp
170 ,
const osg::Camera* camera
171 ,
bool& outputInstanceBufferChanged);
174 static bool setUpOutputFormatAndBindings();
177 static void unsetUpOutputFormatAndBindings();
183 virtual bool bindGpuOutputInstanceBuffersWithAddressRange(
const osg::Camera* camera)
const;
190 virtual bool bindCommandBufferAndSsbos(
const DtGlBuffer* gpuDofTransformBuffer
194 ,
const osg::Camera* camera);
197 virtual void unbindCommandBufferAndSsbos(
const osg::Camera* camera);
203 virtual void bindGpuOutputInstanceBufferDebug(
const osg::Camera* camera)
const;
207 virtual void unbindGpuOutputInstanceBufferDebug(
const osg::Camera* camera)
const;
212 virtual bool bindIndirectThingsDebug(
const DtGlBuffer* gpuDofTransformBuffer,
const osg::Camera* camera);
215 virtual void unbindIndirectThingsDebug(
const osg::Camera* camera);
219 virtual bool useInstanceCount(
void)
const;
223 virtual int numDrawCommands(
const osg::Camera* camera)
const;
226 virtual void releaseGLObjects(
void);
229 virtual void reloadShaders()
const;
232 virtual bool buffersInitializedForCamera(
const osg::Camera* camera)
const;
235 virtual unsigned int maxNumInstances(
void)
const;
241 virtual const std::vector<InstancesOffsetAndNumOfInstances>& instancesOffsetAndNumInstances(
void)
const;
244 virtual bool readyToUpdateAndGpuBuffersNeedUpdate()
const;
247 virtual bool gpuBuffersNeedUpdate()
const;
250 virtual bool textureUpdateDirty()
const;
253 virtual void setTextureUpdateDirty(
bool flag);
256 virtual bool perGeomInstanceDataDirty()
const;
259 virtual void setPerGeomInstanceDataDirty(
bool flag);
262 virtual bool instancesInvalidatedDirty()
const;
265 virtual void invalidateInstance(
int instanceId,
int offset,
int size);
268 virtual const DtGlBuffer* gpuInputPerGeomInstancesBuffer(
void)
const;
271 virtual const DtGlBuffer* gpuMaterialsBuffer()
const;
274 virtual void fillOutputInstances(std::vector<
DtVector4<int> >& outputInstances,
const osg::Camera* camera)
const;
280 virtual void setName(
const std::string& name);
283 virtual const std::string& name(
void)
const;
287 virtual void updateGpuInputPerGeomInstancesBufferByInvalidating();
292 virtual void updateGpuGeometrySpecificationsBuffer();
293 virtual void updateGpuMaterialsBuffer();
294 virtual void updateGpuInputPerGeomInstancesBuffer();
295 virtual void updateGpuLightPointBuffers();
299 virtual void clearStateIdCommandCountBuffer();
300 virtual void clearLightSourceIndexOutputBuffer(
unsigned int maxNumLightSources,
DtGpuCullingTcsUserData* userData);
305 virtual void updateGpuTexturesBuffer(
bool amortizeTextures);
308 virtual void updateInstancesOffsetAndInstances(
const MapIntToInt& modelIdsToNumInstances);
311 virtual void updateInstancesOffsetAndInstancesBuffer(
void);
314 virtual void updateStateIdToMaxNumCommands(
const MapIntToInt& modelIdsToNumInstances);
317 virtual void updateStateIdToMaxNumCommandsBuffer(
void);
320 virtual void deleteBuffers(
void);
323 virtual void flushSingleCameraSet(
CameraSet& cameraSet);
330 virtual void releaseGlObjectsDecrementUsersAndUnLoadIfNecessary();
unsigned int myMaxNumInstancesPreCulling
Definition: DtGpuCulling.h:374
Contains the DtCullShaderConfig class declaration.
DtCoreGlBufferCreator & myDtCoreGlBufferCreator
Definition: DtGpuCulling.h:409
bool myPerGeomInstanceDataDirty
Definition: DtGpuCulling.h:342
static const int theGpuOutputInstanceOffsetInPerInstanceDataBufferIndex
Definition: DtGpuCulling.h:415
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:336
DtMaterial class declaration.
DtGlBuffer * myGpuInstancesOffsetAndNumInstancesBuffer
Definition: DtGpuCulling.h:372
const DtInstanceContainer & myInstanceContainer
Definition: DtGpuCulling.h:338
Contains makVrv::DtIndirectInstancesInvalidated class.
DtOsgLightPointManager & myLightPointManager
Definition: DtGpuCulling.h:390
std::vector< InstancesOffsetAndNumOfInstances > myInstancesOffsetAndNumInstances
Definition: DtGpuCulling.h:371
static const int theGpuOutputInstanceBufferDebugIndex
Definition: DtGpuCulling.h:416
DtIndirectClearBufferProgram * myClearBufferProgram
Definition: DtGpuCulling.h:418
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::vector< DrawElementsIndirectBindlessCommandNV > myBindlessIndexAndVertexBuffers
the bindless vertex and index buffers
Definition: DtGpuCulling.h:353
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:60
This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with Dt...
Definition: DtGpuCulling.h:87
int myOffset
Definition: DtGpuCulling.h:107
Indirect geometry can have multiple models and their corresponding ids registered in it...
Definition: DtIndirectGeometryRegistrar.h:109
voidpf void uLong size
Definition: ioapi.h:39
Contains makVrv::DtFirstTextureStreamedModelAndIndexTracker class.
int myOffset
Definition: DtGpuCulling.h:94
DtGlBuffer * myGpuStateIdToMaxNumCommandsBuffer
Definition: DtGpuCulling.h:383
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtGpuCulling.h:422
std::vector< StateIdOffsetAndMaxCommands > VectorStateIdOffsetAndMaxCommands
Definition: DtGpuCulling.h:111
Contains the DtGpuCullingTcsUserData class declaration.
bool operator==(const InstancesOffsetAndNumOfInstances &rhs) const
Definition: DtGpuCulling.h:97
DtGlBuffer * myBindlessIndexAndVertexBuffersBuffer
The gpu buffer holding the same above info.
Definition: DtGpuCulling.h:356
VectorInts myGeomSpecIndexToCommandIndex
Definition: DtGpuCulling.h:387
DtIndirectInstancesInvalidated myInstancesInvalidated
Definition: DtGpuCulling.h:343
shader configuration storage class. Has 3 available options which are described in the constructor's ...
Definition: DtCullShaderConfig.h:21
DtModelIdAndStreamedBytesTracker mySpecBufferTracker
Definition: DtGpuCulling.h:402
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:341
DtFirstTextureStreamedModelAndIndexTracker myFirstTextureStreamedModelAndIndexTracker
Keep track of the first model and what index to start using bindless textures.
Definition: DtGpuCulling.h:396
This represents per camera (tcs) specific data for DtGpuCulling.
Definition: DtGpuCullingTcsUserData.h:23
DtThreadCameraStreamDataManager & myTcsDataManager
Definition: DtGpuCulling.h:430
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
Contains the DtIndirectEffectTexturesTemplate class declaration.
DtGlBuffer * myGpuSpecIndexToCommandIndexBuffer
Definition: DtGpuCulling.h:388
DtIndirectEffectTexturesTemplate myCurrentEffectTextureState
Definition: DtGpuCulling.h:410
holds a set of the instances that need to be invalidated in the instance buffers
Definition: DtIndirectInstancesInvalidated.h:20
Definition: DtModelIdAndStreamedBytesTracker.h:18
unsigned int myLastNumUniqueGeometriesForGpuTextures
Definition: DtGpuCulling.h:398
unsigned int myMaxNumInstances
Definition: DtGpuCulling.h:375
unsigned int myLastNumEffectTextures
Definition: DtGpuCulling.h:397
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:432
DtGlBuffer * myGpuMaterialsBuffer
The spec buffer containing Materials for all the models/lods of the passed in instances.
Definition: DtGpuCulling.h:360
static std::thread::id theMainThreadId
Definition: DtGpuCulling.h:428
Contains makVrv::DtIndirectModelSubGeometry class.
structure for holding an offset of an instance type (model id), and number of those instances ...
Definition: DtGpuCulling.h:92
DtIndirectCullProgram * myCullProgram
Definition: DtGpuCulling.h:367
unsigned int myMaxNumLightSources
Definition: DtGpuCulling.h:377
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:95
DtModelIdAndStreamedBytesTracker myMaterialBufferTracker
Definition: DtGpuCulling.h:401
DtGlBuffer * myGpuStateIdToCommandCountBuffer
Definition: DtGpuCulling.h:384
const DtCullShaderConfig myCullShaderConfig
Definition: DtGpuCulling.h:369
DtVirtualBaseClassCreator< DtGpuCulling, DtInstanceContainer &, const DtCullShaderConfig & > DtGpuCullingCreator
creator
Definition: DtGpuCulling.h:64
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:346
int myNumGeometries
Definition: DtGpuCulling.h:405
std::string myName
Definition: DtGpuCulling.h:412
DtGlBuffer * myGpuGeometrySpecificationsBuffer
The spec buffer containing GeometrySpecifications for all the models/lods of the passed in instances...
Definition: DtGpuCulling.h:350
DtIndirectMaterialVector myMaterials
c++ buffer that holds the same info
Definition: DtGpuCulling.h:363
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:118
std::unordered_set< DtIndirectModelInfo * > myModelsBeingUsed
Definition: DtGpuCulling.h:420
This class clears buffers using compute shader Theoretically, there are performance gains to be achie...
Definition: DtIndirectClearBufferProgram.h:33
DtGlBuffer * myGpuTexturesBuffer
Definition: DtGpuCulling.h:365
bool myTextureUpdateDirty
Definition: DtGpuCulling.h:399
Contains DLL export macros.
DtDe & myDe
Definition: DtGpuCulling.h:392
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
Definition: DtGpuCulling.h:426
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
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
static const int theGpuOutputInstanceBufferIndex
Definition: DtGpuCulling.h:414
int myStreamedGeometryOffsetIdx
Definition: DtGpuCulling.h:404
Definition: DtFirstTextureStreamedModelAndIndexTracker.h:16
CameraSet myModelIdsToNumInstancesChanged
Definition: DtGpuCulling.h:407
std::set< osg::observer_ptr< const osg::Camera > > CameraSet
Definition: DtGpuCulling.h:114
voidpf uLong offset
Definition: ioapi.h:42
std::unordered_set< DtIndirectGlTextureObject * > myIndirectTexturesBeingUsed
Definition: DtGpuCulling.h:424
Contains makVrv::DtIndirectViewParameters class.
bool myRegistrarValid
Definition: DtGpuCulling.h:337
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:380
Contains the per Model info which the indirect module needs It is owned by the Indirect geometry regi...
Definition: DtIndirectModelInfo.h:55
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:108
Contains makVrv::DtModelIdAndStreamedBytesTracker class.
const char * creatorTypeName< DtGpuCulling >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtGpuCulling.h:71
structure for holding an offset of a command of a given type (state id) and the number of commands of...
Definition: DtGpuCulling.h:105