VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions
makVrv::DtGpuCulling Class Reference

This class is a component of the DtIndirectGeometry It inputs are: -> the instances registered with DtIndirectGeometry -> the viewing parameters (view matrix, projection matrix, etc) -> the indirect registrar (so that it can generate gpu data for -> the models of the instances from the interim data accessible -> via the registrar It outputs are: -> Tndirect command buffer -> The count of the indirect commands -> The input instances shuffled around/culled/lod'ed reflecting -> their order within the indirect command buffer generated -> It will also (optionally) do culling and lod.

Classes

struct  InstancesOffsetAndNumOfInstances
 
struct  StateIdOffsetAndMaxCommands
 

Public Types

using VectorStateIdOffsetAndMaxCommands = std::vector< StateIdOffsetAndMaxCommands >
 
using CameraSet = std::set< osg::observer_ptr< const osg::Camera > >
 
using MapStateToGeometrySpecIndices = std::map< int, VectorInts >
 

Public Member Functions

virtual ~DtGpuCulling ()
 
virtual void setRegistrar (DtIndirectGeometryRegistrar *registrar)
 
virtual void setRegistrarInvalid ()
 
virtual void setDebug (bool debug)
 
virtual const DtCullShaderConfig & cullShaderConfig () const
 
virtual bool updateGpuBuffers (DtGpuArenaUploadState &uploadState)
 
virtual void modelIdsToNumInstancesChanged ()
 
virtual unsigned int updatePerInstancePerGeomBuffers (const MapIntToInt &modelIdsToNumInstances, const osg::Camera *camera, unsigned int currentFrame)
 
virtual void doCulling (const DtIndirectViewParameters &viewParameters, const osg::FrameStamp *frameStamp, const DtGlBuffer *gpuLodVisibleBuffer, const DtGlBuffer *gpuDofTransformBuffer, const DtGlBuffer *gpuSwitchStateBuffer, const DtGlBuffer *gpuPerInstanceDataBuffer, const osg::Camera *camera, bool &outputInstanceBufferChanged)
 
virtual bool bindGpuOutputInstanceBuffersWithAddressRange (const osg::Camera *camera) const
 
virtual bool bindCommandBufferAndSsbos (const DtGlBuffer *gpuDofTransformBuffer, const DtGlBuffer *gpuDofModelScaleBuffer, const DtGlBuffer *gpuUvOffsetBuffer, const DtGlBuffer *gpuPerInstanceDataBuffer, const osg::Camera *camera)
 
virtual void unbindCommandBufferAndSsbos (const osg::Camera *camera)
 
virtual void bindGpuOutputInstanceBufferDebug (const osg::Camera *camera) const
 
virtual void unbindGpuOutputInstanceBufferDebug (const osg::Camera *camera) const
 
virtual bool bindIndirectThingsDebug (const DtGlBuffer *gpuDofTransformBuffer, const osg::Camera *camera)
 
virtual void unbindIndirectThingsDebug (const osg::Camera *camera)
 
virtual bool useInstanceCount () const
 
virtual int numDrawCommands (const osg::Camera *camera) const
 
virtual void releaseGLObjects ()
 
virtual void reloadShaders () const
 
virtual bool buffersInitializedForCamera (const osg::Camera *camera) const
 
virtual unsigned int maxNumInstances () const
 
virtual unsigned int numGeometrySpecifications () const
 
virtual const
VectorStateIdOffsetAndMaxCommands & 
stateIdOffsetAndMaxCommands () const
 
virtual const std::vector
< InstancesOffsetAndNumOfInstances > & 
instancesOffsetAndNumInstances () const
 
virtual bool readyToUpdateAndGpuBuffersNeedUpdate () const
 
virtual bool gpuBuffersNeedUpdate () const
 
virtual bool textureUpdateDirty () const
 
virtual void setTextureUpdateDirty (bool flag)
 
virtual bool geometryAndMaterialsDirty () const
 
virtual void setGeometryAndMaterialsDirty (bool flag)
 
virtual bool instancesInvalidatedDirty () const
 
virtual void invalidateInstance (int instanceId)
 
virtual const DtGlBuffer * gpuInputPerGeomInstancesBuffer () const
 
virtual const DtGlBuffer * gpuMaterialsBuffer () const
 
virtual void fillOutputInstances (std::vector< DtVector4< int > > &outputInstances, const osg::Camera *camera) const
 
virtual const
DtIndirectEffectTexturesTemplate & 
currentEffectTexturesState () const
 
virtual void setName (const std::string &name)
 
virtual const std::string & name () const
 

Static Public Member Functions

static bool setUpOutputFormatAndBindings ()
 
static void unsetUpOutputFormatAndBindings ()
 

Public Attributes

friend DtGpuCullingCreator
 

Protected Member Functions

 DtGpuCulling (DtDe &de, DtInstanceContainer &container, const DtCullShaderConfig &)
 
virtual void buildStateToGeometrySpecIndicesMap (const std::vector< DtGeometrySpecification > &geometrySpecifications, const std::vector< InstancesOffsetAndNumOfInstances > &instancesOffsetAndNumInstances, MapStateToGeometrySpecIndices &outIndices, int &outMaxStateId) const
 
virtual void populateIndirectDrawBuffersByState (const int numGeometries, MapStateToGeometrySpecIndices &mapStateToSpecIndices, DtGpuCullingTcsUserData *userData)
 
virtual void updateStateIdToMaxNumCommands (const MapStateToGeometrySpecIndices &mapStateToSpecIndices, int maxStateId)
 
void accumulateStateIdToMaxCommands (const DtGeometrySpecVector &locations, const int numInstances, std::unordered_map< int, int > &stateIdToMaxCommands, int &maxStateId) const
 
virtual bool processGpuBufferUploadsForModelInfo (DtIndirectModelInfo *info, DtGpuArenaUploadState &uploadState)
 
virtual void updateGpuTexturesBuffer (DtGpuArenaUploadState &uploadState)
 
virtual bool processModelTextures (const DtIndirectModelInfo *modelInfo, GLuint64 *stagingBuffer, int &texturesIndex, int numTextures, const std::vector< int > &offsetLookup, DtGpuArenaUploadState &uploadState, int sizeOfGpuTextureStructure, int sizeGpuTextureBuffersRequired, int &numTexturesStillDownloading)
 
virtual bool processEffectTexturesForGeometry (const DtIndirectGeometryTextures &texturesForThisGeometry, GLuint64 *stagingBuffer, int texturesIndex, int numTextures, const std::vector< int > &offsetLookup, DtGpuArenaUploadState &uploadState, int &numTexturesStillDownloading)
 
virtual int updateEffectTextureState ()
 
virtual int updateGeometryCountState ()
 
virtual void buildEffectTextureOffsetLookup (std::vector< int > &offsetLookup) const
 
virtual void updateInstancesOffsetAndInstances (const MapIntToInt &modelIdsToNumInstances)
 
virtual void updateInstancesOffsetAndInstancesBuffer ()
 
virtual void updateStateIdToMaxNumCommands (const MapIntToInt &modelIdsToNumInstances)
 
virtual void updateStateIdToMaxNumCommandsBuffer ()
 
virtual void deleteBuffers ()
 
virtual void flushSingleCameraSet (CameraSet &cameraSet)
 
virtual void incrementUsers (DtIndirectModelInfo *info)
 
virtual void releaseGlObjectsDecrementUsersAndUnLoadIfNecessary ()
 
virtual DtGpuCullingTcsUserData * getOrCreate (const osg::Camera *camera)
 
virtual bool debugCullingActive () const
 
virtual void updateGpuInputData (unsigned int currentFrame)
 
virtual void updateGpuInputPerGeomInstancesBuffer ()
 
virtual bool updateMaterialsAndGeometrySpecifications (DtGpuArenaUploadState &uploadState)
 
virtual void transferMaterialsAndGeometrySpecificationsToGpuBuffers (size_t numUniqueGeometries, DtGpuArenaUploadState &uploadState)
 
virtual void updateGpuLightPointBuffers ()
 
virtual void updateGpuIndirectBuffersInstanceCount (const MapIntToInt &modelIdsToNumInstances, DtGpuCullingTcsUserData *userData)
 
virtual void updateGpuIndirectBuffersNonInstanceCount (const MapIntToInt &modelIdsToNumInstances, DtGpuCullingTcsUserData *userData)
 
virtual void clearGpuIndirectBuffer (DtGpuCullingTcsUserData *userData)
 
virtual void clearStateIdCommandCountBuffer ()
 
virtual void clearLightSourceIndexOutputBuffer (unsigned int maxNumLightSources, DtGpuCullingTcsUserData *userData)
 

Protected Attributes

DtIndirectGeometryRegistrar * myRegistrar
 
bool myRegistrarValid
 
const DtInstanceContainer & myInstanceContainer
 
DtGlBuffer * myGpuInputPerGeomInstancesBuffer
 
DtIndirectInstancesInvalidated myInstancesInvalidated
 
bool myGeometryAndMaterialsDirty
 
std::vector
< DtGeometrySpecification > 
myGeometrySpecifications
 
DtGlBuffer * myGpuGeometrySpecificationsBuffer
 
std::vector
< DrawElementsIndirectBindlessCommandNV > 
myBindlessIndexAndVertexBuffers
 
DtGlBuffer * myBindlessIndexAndVertexBuffersBuffer
 
DtGlBuffer * myGpuMaterialsBuffer
 
DtIndirectMaterialVector myMaterials
 
DtGlBuffer * myGpuTexturesBuffer
 
DtIndirectCullProgram * myCullProgram
 
const DtCullShaderConfig myCullShaderConfig
 
std::vector
< InstancesOffsetAndNumOfInstances > 
myInstancesOffsetAndNumInstances
 
DtGlBuffer * myGpuInstancesOffsetAndNumInstancesBuffer
 
unsigned int myMaxNumInstancesPreCulling
 
unsigned int myMaxNumInstances
 
unsigned int myMaxNumLightSources
 
unsigned int myLastGpuInputDataFrame
 
VectorStateIdOffsetAndMaxCommands myStateIdToMaxNumCommands
 
DtGlBuffer * myGpuStateIdToMaxNumCommandsBuffer
 
DtGlBuffer * myGpuStateIdToCommandCountBuffer
 
VectorInts myGeomSpecIndexToCommandIndex
 
DtGlBuffer * myGpuSpecIndexToCommandIndexBuffer
 
DtOsgLightPointManager & myLightPointManager
 
DtDe & myDe
 
DtFirstTextureStreamedModelAndIndexTracker myFirstTextureStreamedModelAndIndexTracker
 
unsigned int myLastNumEffectTextures
 
unsigned int myLastNumUniqueGeometriesForGpuTextures
 
bool myTextureUpdateDirty
 
DtModelIdAndStreamedBytesTracker mySpecBufferTracker
 
CameraSet myModelIdsToNumInstancesChanged
 
DtCoreGlBufferCreator & myDtCoreGlBufferCreator
 
DtIndirectEffectTexturesTemplate myCurrentEffectTextureState
 
std::string myName
 
DtIndirectClearBufferProgram * myClearBufferProgram
 
std::unordered_set
< DtIndirectModelInfo * > 
myModelsBeingUsed
 
DtGlDeleteObjectManager & myGlDeleteObjectManager
 
std::unordered_set
< DtIndirectGlTextureObject * > 
myIndirectTexturesBeingUsed
 
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
 
DtThreadCameraStreamDataManager & myTcsDataManager
 
DtGpuCullingTcsUserDataCreator & myUserDataCreator
 

Static Protected Attributes

static const int theGpuOutputInstanceBufferIndex
 
static const int theGpuOutputInstanceOffsetInPerInstanceDataBufferIndex
 
static const int theGpuOutputInstanceBufferDebugIndex
 
static std::thread::id theMainThreadId
 

Private Member Functions

 DtGpuCulling ()=delete
 
 DtGpuCulling (const DtGpuCulling &other)=delete
 
DtGpuCulling & operator= (const DtGpuCulling &other)=delete
 

Member Typedef Documentation

using makVrv::DtGpuCulling::CameraSet = std::set<osg::observer_ptr<const osg::Camera> >

All the culling output buffers need to be per camera so shadows passes work.

map of state id to vector of geometry spec indices

Constructor & Destructor Documentation

virtual makVrv::DtGpuCulling::~DtGpuCulling ( )
virtual

destructor

makVrv::DtGpuCulling::DtGpuCulling ( DtDe &  de,
DtInstanceContainer &  container,
const DtCullShaderConfig &   
)
protected

CTOR. only creator can create.

makVrv::DtGpuCulling::DtGpuCulling ( )
privatedelete

not allowed

makVrv::DtGpuCulling::DtGpuCulling ( const DtGpuCulling &  other)
privatedelete

not allowed

Member Function Documentation

DtGpuCulling& makVrv::DtGpuCulling::operator= ( const DtGpuCulling &  other)
privatedelete

not allowed

virtual void makVrv::DtGpuCulling::setRegistrar ( DtIndirectGeometryRegistrar *  registrar)
virtual

set the registrar

virtual void makVrv::DtGpuCulling::setRegistrarInvalid ( )
virtual

invalidate the registrar. happens for gs cells

virtual void makVrv::DtGpuCulling::setDebug ( bool  debug)
virtual

set the compute shader to debug

virtual const DtCullShaderConfig& makVrv::DtGpuCulling::cullShaderConfig ( ) const
virtual

get the compute shader config

virtual bool makVrv::DtGpuCulling::updateGpuBuffers ( DtGpuArenaUploadState &  uploadState)
virtual

updateGpuBuffers

Parameters
uploadState- tracks the upload stats for the GPU arena. (modified by this method)
virtual void makVrv::DtGpuCulling::modelIdsToNumInstancesChanged ( )
virtual

indicate to the culling that model ids to num instances changed so that internal maps get updated

virtual unsigned int makVrv::DtGpuCulling::updatePerInstancePerGeomBuffers ( const MapIntToInt &  modelIdsToNumInstances,
const osg::Camera *  camera,
unsigned int  currentFrame 
)
virtual

Updates per-instance and per-geometry buffers for the given camera. Performs a full GPU input PerGeomInstance buffer update if needed. returns the number of PerGeomInstances that will be processed by culling.

virtual void makVrv::DtGpuCulling::doCulling ( const DtIndirectViewParameters &  viewParameters,
const osg::FrameStamp *  frameStamp,
const DtGlBuffer *  gpuLodVisibleBuffer,
const DtGlBuffer *  gpuDofTransformBuffer,
const DtGlBuffer *  gpuSwitchStateBuffer,
const DtGlBuffer *  gpuPerInstanceDataBuffer,
const osg::Camera *  camera,
bool &  outputInstanceBufferChanged 
)
virtual

Do the culling (view frustum, lod, switch)

Parameters
viewParametersThe view parameters for culling.
frameStampThe current OSG frame stamp.
gpuLodVisibleBufferBuffer containing LOD visibility results.
gpuDofTransformBufferBuffer containing DOF transform data.
gpuSwitchStateBufferBuffer containing switch state data.
gpuPerInstanceDataBufferBuffer containing per-instance data.
cameraThe OSG camera used for this culling pass.
outputInstanceBufferChangedindicates whether output instance buffers that get get bound were determined to need resize and were resized, and because of that the gpu address also likely changed (which should trigger an external re-generation of the vao which uses these)
static bool makVrv::DtGpuCulling::setUpOutputFormatAndBindings ( )
static

bind the output instance buffer

static void makVrv::DtGpuCulling::unsetUpOutputFormatAndBindings ( )
static

unbind the output instance buffer format and bindings

virtual bool makVrv::DtGpuCulling::bindGpuOutputInstanceBuffersWithAddressRange ( const osg::Camera *  camera) const
virtual

For bindless, bind the output buffers from the culling with buffer address range This is because in bindless, the main buffers are via indirect bindless call (which is internally a buffer address range bind). You can't mix and match regular buffer binds and vertex buffer unified memory style (buffer address range)

virtual bool makVrv::DtGpuCulling::bindCommandBufferAndSsbos ( const DtGlBuffer *  gpuDofTransformBuffer,
const DtGlBuffer *  gpuDofModelScaleBuffer,
const DtGlBuffer *  gpuUvOffsetBuffer,
const DtGlBuffer *  gpuPerInstanceDataBuffer,
const osg::Camera *  camera 
)
virtual

bind the indirect command buffer and the count buffer returns false if handle is 0. Can happen if the buffer hasn't been re-created yet (e.g. when the context is deleted and recreated), depending on the job/frame syc this can happen a few frames later

virtual void makVrv::DtGpuCulling::unbindCommandBufferAndSsbos ( const osg::Camera *  camera)
virtual

unbind the indirect command buffer and the count buffer

virtual void makVrv::DtGpuCulling::bindGpuOutputInstanceBufferDebug ( const osg::Camera *  camera) const
virtual

Bind the buffer containing the output instances of the cull shader with debugging. This is the buffer representing the non-switched otu & non-loded out instances (all non view frustum culled instances).

virtual void makVrv::DtGpuCulling::unbindGpuOutputInstanceBufferDebug ( const osg::Camera *  camera) const
virtual

Unbind the buffer containing the output instances of the cull shader with debugging.

virtual bool makVrv::DtGpuCulling::bindIndirectThingsDebug ( const DtGlBuffer *  gpuDofTransformBuffer,
const osg::Camera *  camera 
)
virtual

bind the debug indirect command buffer, dof transform buffer and the specs buffer This allows us to draw all instances that are not switched out, lod'ed out (all non view frustum culled instances)

virtual void makVrv::DtGpuCulling::unbindIndirectThingsDebug ( const osg::Camera *  camera)
virtual

unbind the debug indirect command buffer, dof transform buffer and the specs buffer

virtual bool makVrv::DtGpuCulling::useInstanceCount ( ) const
virtual

whether we are optimizing for shared models (useInstanceCount()=true) or unique models (useInstanceCount()=false), across instances

virtual int makVrv::DtGpuCulling::numDrawCommands ( const osg::Camera *  camera) const
virtual

The number of draw commands generated. Is a value between [0, DtIndirectGeoUtils::getMaxDrawCountNoCullingNoLod()], inclusive.

virtual void makVrv::DtGpuCulling::releaseGLObjects ( )
virtual

release the GL objects for the GpuCulling compute shader

virtual void makVrv::DtGpuCulling::reloadShaders ( ) const
virtual

destroy the cull program and shader if they exists so they can be recreated next frame.

virtual bool makVrv::DtGpuCulling::buffersInitializedForCamera ( const osg::Camera *  camera) const
virtual

check to see if the buffers for this camera have been initialized.

virtual unsigned int makVrv::DtGpuCulling::maxNumInstances ( ) const
virtual

get the max number of instances that can possibly be rendered if none are culled out.

virtual unsigned int makVrv::DtGpuCulling::numGeometrySpecifications ( ) const
virtual

get the current geometry specifications count.

virtual const VectorStateIdOffsetAndMaxCommands& makVrv::DtGpuCulling::stateIdOffsetAndMaxCommands ( ) const
virtual

get the map of the state id to their offset/number

virtual const std::vector<InstancesOffsetAndNumOfInstances>& makVrv::DtGpuCulling::instancesOffsetAndNumInstances ( ) const
virtual

access the instances offset and num of instances map

virtual bool makVrv::DtGpuCulling::readyToUpdateAndGpuBuffersNeedUpdate ( ) const
virtual

helper function to decide if a job should be launched

virtual bool makVrv::DtGpuCulling::gpuBuffersNeedUpdate ( ) const
virtual

is anything in the buffers dirty?

virtual bool makVrv::DtGpuCulling::textureUpdateDirty ( ) const
virtual

are there textures that still need updating.

virtual void makVrv::DtGpuCulling::setTextureUpdateDirty ( bool  flag)
virtual

inform that textures are dirty

virtual bool makVrv::DtGpuCulling::geometryAndMaterialsDirty ( ) const
virtual

is geometry and materials data dirty?

virtual void makVrv::DtGpuCulling::setGeometryAndMaterialsDirty ( bool  flag)
virtual

set the geometry and materials data dirty

virtual bool makVrv::DtGpuCulling::instancesInvalidatedDirty ( ) const
virtual

were any instances invalidated?

virtual void makVrv::DtGpuCulling::invalidateInstance ( int  instanceId)
virtual

invalidate an instance

virtual const DtGlBuffer* makVrv::DtGpuCulling::gpuInputPerGeomInstancesBuffer ( ) const
virtual

Accessor for the gpu per geom instances buffer.

virtual const DtGlBuffer* makVrv::DtGpuCulling::gpuMaterialsBuffer ( ) const
virtual

Accessor for the gpu materials buffer.

virtual void makVrv::DtGpuCulling::fillOutputInstances ( std::vector< DtVector4< int > > &  outputInstances,
const osg::Camera *  camera 
) const
virtual

For debugging. Get the values of the output instances computed by the compute shader.

virtual const DtIndirectEffectTexturesTemplate& makVrv::DtGpuCulling::currentEffectTexturesState ( ) const
virtual

get the current effect texture state as it was after the last time the textures were sent down

virtual void makVrv::DtGpuCulling::setName ( const std::string &  name)
virtual

set a name on this (useful for debugging)

virtual const std::string& makVrv::DtGpuCulling::name ( ) const
virtual

get the name on this (useful for debugging)

virtual void makVrv::DtGpuCulling::updateGpuInputData ( unsigned int  currentFrame)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::updateGpuInputPerGeomInstancesBuffer ( )
protectedvirtual

Updates the GPU buffer containing per-geometry instance data for all instances. Performs a full buffer update, replacing the buffer contents with the latest instance data.

virtual bool makVrv::DtGpuCulling::updateMaterialsAndGeometrySpecifications ( DtGpuArenaUploadState &  uploadState)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::transferMaterialsAndGeometrySpecificationsToGpuBuffers ( size_t  numUniqueGeometries,
DtGpuArenaUploadState &  uploadState 
)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::updateGpuLightPointBuffers ( )
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::updateGpuIndirectBuffersInstanceCount ( const MapIntToInt &  modelIdsToNumInstances,
DtGpuCullingTcsUserData *  userData 
)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::updateGpuIndirectBuffersNonInstanceCount ( const MapIntToInt &  modelIdsToNumInstances,
DtGpuCullingTcsUserData *  userData 
)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::clearGpuIndirectBuffer ( DtGpuCullingTcsUserData *  userData)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::clearStateIdCommandCountBuffer ( )
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::clearLightSourceIndexOutputBuffer ( unsigned int  maxNumLightSources,
DtGpuCullingTcsUserData *  userData 
)
protectedvirtual

Buffer update and management functions for GPU culling.

update the various buffers that are fed to the cull shader -> if new models came in -> if textures became available (they can be asynchronously available, e.g. via osg ico) -> if the number of instances changed Prepares/syncs the current input data associated with the PerGeometryInstance container and Registrar to ensure that the GPU input buffer reflects the latest instance data.

virtual void makVrv::DtGpuCulling::buildStateToGeometrySpecIndicesMap ( const std::vector< DtGeometrySpecification > &  geometrySpecifications,
const std::vector< InstancesOffsetAndNumOfInstances > &  instancesOffsetAndNumInstances,
MapStateToGeometrySpecIndices &  outIndices,
int &  outMaxStateId 
) const
protectedvirtual

Builds a map of state IDs to geometry specification indices. (outIndices) Computes the maximum state ID encountered. (outMaxStateId)

virtual void makVrv::DtGpuCulling::populateIndirectDrawBuffersByState ( const int  numGeometries,
MapStateToGeometrySpecIndices &  mapStateToSpecIndices,
DtGpuCullingTcsUserData *  userData 
)
protectedvirtual

Populates the indirect draw command buffers based on the given state-to-geometry-spec-indices map.

virtual void makVrv::DtGpuCulling::updateStateIdToMaxNumCommands ( const MapStateToGeometrySpecIndices &  mapStateToSpecIndices,
int  maxStateId 
)
protectedvirtual

Updates the state ID to max number of commands mapping based on the given parameters. This is used when useInstanceCount() is true.

void makVrv::DtGpuCulling::accumulateStateIdToMaxCommands ( const DtGeometrySpecVector &  locations,
const int  numInstances,
std::unordered_map< int, int > &  stateIdToMaxCommands,
int &  maxStateId 
) const
protected

Accumulates the maximum number of commands per state ID from the given geometry specifications and instances. non-virtual due to being internal inner-loop helper for performance.

virtual bool makVrv::DtGpuCulling::processGpuBufferUploadsForModelInfo ( DtIndirectModelInfo *  info,
DtGpuArenaUploadState &  uploadState 
)
protectedvirtual

Allows the given model info to process its gpu buffer uploads.

Parameters
infoThe model info to process.
uploadState- tracks the upload stats for the GPU arena. (modified by this method)
virtual void makVrv::DtGpuCulling::updateGpuTexturesBuffer ( DtGpuArenaUploadState &  uploadState)
protectedvirtual

The buffer containing the bindless textures' addresses of the model textures This method use several helper methods to improve readability.

Parameters
uploadState- tracks the upload stats for the GPU arena. (modified by this method)
virtual bool makVrv::DtGpuCulling::processModelTextures ( const DtIndirectModelInfo *  modelInfo,
GLuint64 *  stagingBuffer,
int &  texturesIndex,
int  numTextures,
const std::vector< int > &  offsetLookup,
DtGpuArenaUploadState &  uploadState,
int  sizeOfGpuTextureStructure,
int  sizeGpuTextureBuffersRequired,
int &  numTexturesStillDownloading 
)
protectedvirtual

Process model textures for a given model info. Returns true on success. False indicates an error occured. Helper for updateGpuTexturesBuffer.

virtual bool makVrv::DtGpuCulling::processEffectTexturesForGeometry ( const DtIndirectGeometryTextures &  texturesForThisGeometry,
GLuint64 *  stagingBuffer,
int  texturesIndex,
int  numTextures,
const std::vector< int > &  offsetLookup,
DtGpuArenaUploadState &  uploadState,
int &  numTexturesStillDownloading 
)
protectedvirtual

Process effect textures for a given geometry's textures. Returns true if total memory budget was exceeded. Helper for updateGpuTexturesBuffer.

virtual int makVrv::DtGpuCulling::updateEffectTextureState ( )
protectedvirtual

Update the effect texture state template to reflect the current state of effect textures. Returns the number of effect textures. Helper for updateGpuTexturesBuffer.

virtual int makVrv::DtGpuCulling::updateGeometryCountState ( )
protectedvirtual

Checks if the number of unique geometries has changed and if so, updates the cached value and marks the texture update as dirty. Returns the number of unique geometries for GPU textures. Helper for updateGpuTexturesBuffer.

virtual void makVrv::DtGpuCulling::buildEffectTextureOffsetLookup ( std::vector< int > &  offsetLookup) const
protectedvirtual

Builds a lookup vector of effect texture offsets using the registrar. Fills offsetLookup with effect texture types, where offsetLookup[i] gives the type for effect texture index i. Helper for updateGpuTexturesBuffer.

virtual void makVrv::DtGpuCulling::updateInstancesOffsetAndInstances ( const MapIntToInt &  modelIdsToNumInstances)
protectedvirtual

update the myInstancesOffsetAndNumInstances vector so it is ready to be used

virtual void makVrv::DtGpuCulling::updateInstancesOffsetAndInstancesBuffer ( )
protectedvirtual

update the myGpuInstancesOffsetAndNumInstancesBuffer

virtual void makVrv::DtGpuCulling::updateStateIdToMaxNumCommands ( const MapIntToInt &  modelIdsToNumInstances)
protectedvirtual

update the myStateIdToMaxNumCommands with the correct max state instances for each state

virtual void makVrv::DtGpuCulling::updateStateIdToMaxNumCommandsBuffer ( )
protectedvirtual

update the myGpuStateIdToMaxNumCommandsBuffer with the correct max state instances for each state

virtual void makVrv::DtGpuCulling::deleteBuffers ( )
protectedvirtual

delete buffers

virtual void makVrv::DtGpuCulling::flushSingleCameraSet ( CameraSet &  cameraSet)
protectedvirtual

flush a single camera set.

virtual void makVrv::DtGpuCulling::incrementUsers ( DtIndirectModelInfo *  info)
protectedvirtual

increment the users (this gpu culling) called in the model streaming loop

virtual void makVrv::DtGpuCulling::releaseGlObjectsDecrementUsersAndUnLoadIfNecessary ( )
protectedvirtual

called via release gl objects

virtual DtGpuCullingTcsUserData* makVrv::DtGpuCulling::getOrCreate ( const osg::Camera *  camera)
protectedvirtual

internal

virtual bool makVrv::DtGpuCulling::debugCullingActive ( ) const
protectedvirtual

Returns true if debug culling is active and should be used. */.

Member Data Documentation

friend makVrv::DtGpuCulling::DtGpuCullingCreator
DtIndirectGeometryRegistrar* makVrv::DtGpuCulling::myRegistrar
protected
bool makVrv::DtGpuCulling::myRegistrarValid
protected
const DtInstanceContainer& makVrv::DtGpuCulling::myInstanceContainer
protected
DtGlBuffer* makVrv::DtGpuCulling::myGpuInputPerGeomInstancesBuffer
protected

contains switch states/ lod info

DtIndirectInstancesInvalidated makVrv::DtGpuCulling::myInstancesInvalidated
protected
bool makVrv::DtGpuCulling::myGeometryAndMaterialsDirty
protected
std::vector<DtGeometrySpecification> makVrv::DtGpuCulling::myGeometrySpecifications
protected

c++ buffer that holds the same info

DtGlBuffer* makVrv::DtGpuCulling::myGpuGeometrySpecificationsBuffer
protected

The spec buffer containing GeometrySpecifications for all the models/lods of the passed in instances.

std::vector<DrawElementsIndirectBindlessCommandNV> makVrv::DtGpuCulling::myBindlessIndexAndVertexBuffers
protected

the bindless vertex and index buffers

DtGlBuffer* makVrv::DtGpuCulling::myBindlessIndexAndVertexBuffersBuffer
protected

The gpu buffer holding the same above info.

DtGlBuffer* makVrv::DtGpuCulling::myGpuMaterialsBuffer
protected

The spec buffer containing Materials for all the models/lods of the passed in instances.

DtIndirectMaterialVector makVrv::DtGpuCulling::myMaterials
protected

c++ buffer that holds the same info

DtGlBuffer* makVrv::DtGpuCulling::myGpuTexturesBuffer
protected
DtIndirectCullProgram* makVrv::DtGpuCulling::myCullProgram
protected
const DtCullShaderConfig makVrv::DtGpuCulling::myCullShaderConfig
protected
std::vector<InstancesOffsetAndNumOfInstances> makVrv::DtGpuCulling::myInstancesOffsetAndNumInstances
protected
DtGlBuffer* makVrv::DtGpuCulling::myGpuInstancesOffsetAndNumInstancesBuffer
protected
unsigned int makVrv::DtGpuCulling::myMaxNumInstancesPreCulling
protected
unsigned int makVrv::DtGpuCulling::myMaxNumInstances
protected
unsigned int makVrv::DtGpuCulling::myMaxNumLightSources
protected
unsigned int makVrv::DtGpuCulling::myLastGpuInputDataFrame
protected
VectorStateIdOffsetAndMaxCommands makVrv::DtGpuCulling::myStateIdToMaxNumCommands
protected
DtGlBuffer* makVrv::DtGpuCulling::myGpuStateIdToMaxNumCommandsBuffer
protected
DtGlBuffer* makVrv::DtGpuCulling::myGpuStateIdToCommandCountBuffer
protected
VectorInts makVrv::DtGpuCulling::myGeomSpecIndexToCommandIndex
protected
DtGlBuffer* makVrv::DtGpuCulling::myGpuSpecIndexToCommandIndexBuffer
protected
DtOsgLightPointManager& makVrv::DtGpuCulling::myLightPointManager
protected
DtDe& makVrv::DtGpuCulling::myDe
protected
DtFirstTextureStreamedModelAndIndexTracker makVrv::DtGpuCulling::myFirstTextureStreamedModelAndIndexTracker
protected

Keep track of the first model and what index to start using bindless textures.

unsigned int makVrv::DtGpuCulling::myLastNumEffectTextures
protected
unsigned int makVrv::DtGpuCulling::myLastNumUniqueGeometriesForGpuTextures
protected
bool makVrv::DtGpuCulling::myTextureUpdateDirty
protected
DtModelIdAndStreamedBytesTracker makVrv::DtGpuCulling::mySpecBufferTracker
protected
CameraSet makVrv::DtGpuCulling::myModelIdsToNumInstancesChanged
protected
DtCoreGlBufferCreator& makVrv::DtGpuCulling::myDtCoreGlBufferCreator
protected
DtIndirectEffectTexturesTemplate makVrv::DtGpuCulling::myCurrentEffectTextureState
protected
std::string makVrv::DtGpuCulling::myName
protected
const int makVrv::DtGpuCulling::theGpuOutputInstanceBufferIndex
staticprotected
const int makVrv::DtGpuCulling::theGpuOutputInstanceOffsetInPerInstanceDataBufferIndex
staticprotected
const int makVrv::DtGpuCulling::theGpuOutputInstanceBufferDebugIndex
staticprotected
DtIndirectClearBufferProgram* makVrv::DtGpuCulling::myClearBufferProgram
protected
std::unordered_set<DtIndirectModelInfo*> makVrv::DtGpuCulling::myModelsBeingUsed
protected
DtGlDeleteObjectManager& makVrv::DtGpuCulling::myGlDeleteObjectManager
protected
std::unordered_set<DtIndirectGlTextureObject*> makVrv::DtGpuCulling::myIndirectTexturesBeingUsed
protected
DtIndirectGlTextureObjectManager& makVrv::DtGpuCulling::myIndirectGlTextureObjectManager
protected
std::thread::id makVrv::DtGpuCulling::theMainThreadId
staticprotected
DtThreadCameraStreamDataManager& makVrv::DtGpuCulling::myTcsDataManager
protected
DtGpuCullingTcsUserDataCreator& makVrv::DtGpuCulling::myUserDataCreator
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)