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

Indirect geometry can have multiple models and their corresponding ids registered in it, via multiple threads. When this happens, the geometry specs/bindless textures need to be updated/maintained in a form that DtIndirectGeometry can use and consume to further upload pertinent information to the GPU. This class manages the registration and the rebuild of the interim GPU data needed The registrar rebuild can be triggered by one (or more) DtIndirectGeometry'ies (when they get drawn). This is done when they are drawn because a context is present at that point (because we are generating GPU data here).

The general use case of a 'registrar' is that the DtIndirectGeometryLayerManager creates a single registrar for a layer. This enables several DtIndirectGeometry instances within the layer to efficiently share the same registrar (and hence share the models/textures) CDB is a slightly different use case. In the case of Geo Typical layers, the use case is the same as the general use case. In the case of Geo Specific layers, it merits a single indirect geometry to be associated with a single registrar. This is wholly on account of the nature of the CDB data base itself Generally speaking, geospecific tiles (and hence indirect rendering geometries), hardly ever share models/textures, so creating a common registrar per layer is hugely wasteful as well as slow (given how IndirectRendering works). So one is created per tile/indirect geometry and this mapping maintained by the cdb pager Indirect Rendering works best when multiple models can be combined into a single Vertex Buffer, Index Buffer and the textures are in an array of bindless texture addresses. This allows us to fold what would be multiple binds of vertex buffers, index buffers & texture binds per instance, per model into a single indirect draw call for a tile The registrar allows us to register such models that the instances within the DtIndirectGeometry contain We have generalized the concept of a 'model' for this purpose. A 'model' is a top level node (coming from say reading an flt file) An lod is of a model is also a top level node (coming from say reading an flt file) For example, f the original file has 3 lods, then we need to 3 lods of that single model with the top level nodes for those 3 lods Several such models can be registered here

Inheritance diagram for makVrv::DtIndirectGeometryRegistrar:
Inheritance graph
[legend]

Classes

class  RegisterModelOp
 

Public Member Functions

virtual void setName (const std::string &name)
 
virtual void queueUpRegisterModel (int modelId, osg::ref_ptr< const osg::Node > model, const std::string &modelFileName, const std::string &modelDefName, bool cullFaceEnabled=false, const DtIndirectPolygonOffset &polygonOffset=DtIndirectPolygonOffset(0.0f, 0.0f), bool daylightControlled=false)
 
virtual void processRegisterModelQueue (DtOsgRenderer *renderer)
 
virtual bool beingProcessed ()
 
virtual unsigned int rebuildIfNeeded (const osg::GraphicsContext *gc)
 
virtual unsigned int numModelsInQueue () const
 
virtual int numModels (void) const
 
virtual int modelId (int index) const
 
virtual int numGeometriesForModelID (int modelId) const
 
virtual bool isModelDownloaded (int modelId) const
 
virtual const DtIndirectModelInfofindModelInfoForModelId (int modelId) const
 
virtual const
DtIndirectModelInfoContainer
aggregatedGeometry () const
 
virtual
DtIndirectModelInfoContainer
aggregatedGeometry ()
 
virtual const
DtIndirectTextureCollectionPolicy
textureCollectionPolicy (void) const
 
virtual
DtIndirectTextureProcessor
textureProcessor ()
 
virtual const
DtIndirectEffectTexturesTemplate
effectTexturesState (void) const
 
virtual
DtIndirectGeometryStateManager
stateManager (void) const
 
virtual GLenum indicesType (void) const
 
virtual void releaseGLObjects (osg::State *state) const
 
virtual bool registeredModelsDirty () const
 
virtual void drainModelQueue (DtOsgRenderer *renderer)
 
virtual void setPagerHandlesModelLoading (bool value)
 
virtual bool pagerHandlesModelLoading ()
 
virtual int numTexCoordArrays (void) const
 
virtual boost::mutex & addingModelsMutex ()
 
virtual bool supportsPartialTextureUnloading (void) const
 
virtual bool supportsPartialBuffersUnloading (void) const
 
virtual void modelsToBeReloaded (const std::unordered_set< int > &models)
 
virtual void unloadUnreferencedTextures (void)
 
virtual void trackTexturesAndModels (const std::unordered_set< int > &models, bool reloading)
 
virtual void findModelInfosThatUseThisImageFileForItsTextures (std::set< DtIndirectModelInfo * > &modelInfos, const std::string &absoluteFileName) const
 

Protected Types

typedef tbb::concurrent_queue
< RegisterModelOp
QueueRegisterModelOps
 

Protected Member Functions

 DtIndirectGeometryRegistrar (DtDe &de, const std::string &textureCollectionPolicyName, const DtIndirectLimitTextureStrategy &limitTextureStrategy, bool supportsPartialTextureUnloading, bool supportsPartialBuffersUnloading)
 
virtual ~DtIndirectGeometryRegistrar ()
 
virtual void registerModel (int modelId, osg::ref_ptr< const osg::Node > model, const std::string &modelFileName, const std::string &modelDefName, bool daylightControlled, bool cullFaceEnabled=true, const DtIndirectPolygonOffset &polygonOffset=DtIndirectPolygonOffset(0.0f, 0.0f))
 

Protected Attributes

friend DtIndirectGeometryRegistrarCreator
 
DtIndirectModelInfoContainermyModelInfoContainer
 
DtIndirectEffectTexturesTemplate myEffectTexturesState
 
bool myPagerHandlesModelLoading
 
QueueRegisterModelOps myQueueRegisterModelOps
 
DtIndirectTextureCollectionPolicymyTextureCollectionPolicy
 
osg::ref_ptr
< DtIndirectTextureProcessor
myTextureProcessor
 
bool myRegisteredModelsDirty
 
unsigned int myLastRebuildNumber
 
DtIndirectGeometryAggregatormyAggregator
 
tbb::atomic< boolmyBeingProcessed
 
boost::mutex myAddingModelsMutex
 
DtIndirectGeometryStateManager myMutableStateContainer
 
DtDemyDe
 
DtOsgShaderManagermyShaderManager
 
std::map< osg::ref_ptr
< osg::Texture >, std::set
< int > > 
myTextureToModelsThatAreUsingIt
 
std::unordered_map
< std::string, std::set< int > > 
myImagesToModelsThatAreUsingIt
 
const bool mySupportsPartialTextureUnloading
 
const bool mySupportsPartialBuffersUnloading
 

Private Member Functions

 DtIndirectGeometryRegistrar ()=delete
 
 DtIndirectGeometryRegistrar (const DtIndirectGeometryRegistrar &other)=delete
 
 DtIndirectGeometryRegistrar (const DtIndirectGeometryRegistrar &lhs, const osg::CopyOp &copyop)=delete
 
DtIndirectGeometryRegistraroperator= (const DtIndirectGeometryRegistrar &other)=delete
 

Member Typedef Documentation

Constructor & Destructor Documentation

makVrv::DtIndirectGeometryRegistrar::DtIndirectGeometryRegistrar ( DtDe de,
const std::string &  textureCollectionPolicyName,
const DtIndirectLimitTextureStrategy limitTextureStrategy,
bool  supportsPartialTextureUnloading,
bool  supportsPartialBuffersUnloading 
)
protected

CTOR with de is used with the creator for DtIndirectGeometryRegistrar.

virtual makVrv::DtIndirectGeometryRegistrar::~DtIndirectGeometryRegistrar ( )
protectedvirtual

DTOR.

makVrv::DtIndirectGeometryRegistrar::DtIndirectGeometryRegistrar ( )
privatedelete

Default Constructor not implemented.

makVrv::DtIndirectGeometryRegistrar::DtIndirectGeometryRegistrar ( const DtIndirectGeometryRegistrar other)
privatedelete

Copy Constructor not implemented – Copy Not Allowed.

makVrv::DtIndirectGeometryRegistrar::DtIndirectGeometryRegistrar ( const DtIndirectGeometryRegistrar lhs,
const osg::CopyOp &  copyop 
)
privatedelete

Copy Constructor not implemented – Copy Not Allowed.

Member Function Documentation

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

Assignment Operator Not implemented – Assignment Not Allowed.

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

set a name. useful for debugging

virtual void makVrv::DtIndirectGeometryRegistrar::queueUpRegisterModel ( int  modelId,
osg::ref_ptr< const osg::Node >  model,
const std::string &  modelFileName,
const std::string &  modelDefName,
bool  cullFaceEnabled = false,
const DtIndirectPolygonOffset polygonOffset = DtIndirectPolygonOffset(0.0f, 0.0f),
bool  daylightControlled = false 
)
virtual
virtual void makVrv::DtIndirectGeometryRegistrar::processRegisterModelQueue ( DtOsgRenderer renderer)
virtual

Should be called in the cull and processes any queued up models that are registered, 

can also be called in a background thread

virtual bool makVrv::DtIndirectGeometryRegistrar::beingProcessed ( )
virtual

accessor for if this is getting processed in a background thread.

virtual unsigned int makVrv::DtIndirectGeometryRegistrar::rebuildIfNeeded ( const osg::GraphicsContext *  gc)
virtual

invoked via the main thread by one (or multiple indirect geometries)

virtual unsigned int makVrv::DtIndirectGeometryRegistrar::numModelsInQueue ( ) const
virtual

gets the number of models in the queue to be registered

virtual int makVrv::DtIndirectGeometryRegistrar::numModels ( void  ) const
virtual

number of models registered here

virtual int makVrv::DtIndirectGeometryRegistrar::modelId ( int  index) const
virtual

the actual model id of the model with index

virtual int makVrv::DtIndirectGeometryRegistrar::numGeometriesForModelID ( int  modelId) const
virtual

the number of geometries for the model

virtual bool makVrv::DtIndirectGeometryRegistrar::isModelDownloaded ( int  modelId) const
virtual

if the model has been copied to the video card.

virtual const DtIndirectModelInfo* makVrv::DtIndirectGeometryRegistrar::findModelInfoForModelId ( int  modelId) const
virtual

find the info for the model null if not found

virtual const DtIndirectModelInfoContainer* makVrv::DtIndirectGeometryRegistrar::aggregatedGeometry ( ) const
virtual

gets the underlying geometry that this registrar adds data to

virtual DtIndirectModelInfoContainer* makVrv::DtIndirectGeometryRegistrar::aggregatedGeometry ( )
virtual

gets the underlying geometry that this registrar adds data to. non-const version

virtual const DtIndirectTextureCollectionPolicy& makVrv::DtIndirectGeometryRegistrar::textureCollectionPolicy ( void  ) const
virtual

Access the texture collection policy.

virtual DtIndirectTextureProcessor& makVrv::DtIndirectGeometryRegistrar::textureProcessor ( )
virtual

Access the texture processor.

virtual const DtIndirectEffectTexturesTemplate& makVrv::DtIndirectGeometryRegistrar::effectTexturesState ( void  ) const
virtual

Get the cumulative effect textures state for all the models/geometries that this registrar has registered.

virtual DtIndirectGeometryStateManager& makVrv::DtIndirectGeometryRegistrar::stateManager ( void  ) const
virtual

access the states' container

virtual GLenum makVrv::DtIndirectGeometryRegistrar::indicesType ( void  ) const
virtual

the indices' type (unsigned short or unsigned int, usually unsigned int)

virtual void makVrv::DtIndirectGeometryRegistrar::releaseGLObjects ( osg::State *  state) const
virtual

release the openGL objects that have been created by this registrar state is unused but there to maintain the same style as all the other releaseGLObject calls in osg and vantage state can be NULL and it will still cleanup correctly.

virtual bool makVrv::DtIndirectGeometryRegistrar::registeredModelsDirty ( ) const
virtual

are the models in this registrar dirty marked true when a model has been added to the queue to be added

virtual void makVrv::DtIndirectGeometryRegistrar::drainModelQueue ( DtOsgRenderer renderer)
virtual

loads all the data in myQueueRegisterModelOps will copy data asynchronously

virtual void makVrv::DtIndirectGeometryRegistrar::setPagerHandlesModelLoading ( bool  value)
virtual

needed if this is the 1st lod loading in the main thread then set to false.

virtual bool makVrv::DtIndirectGeometryRegistrar::pagerHandlesModelLoading ( )
virtual
virtual int makVrv::DtIndirectGeometryRegistrar::numTexCoordArrays ( void  ) const
virtual

the cumulative number of texture coordinate arrays across all geometries registered

virtual boost::mutex& makVrv::DtIndirectGeometryRegistrar::addingModelsMutex ( )
virtual

protects the addition of models

virtual bool makVrv::DtIndirectGeometryRegistrar::supportsPartialTextureUnloading ( void  ) const
virtual

whether partial texture unloading is supported (gt only)

virtual bool makVrv::DtIndirectGeometryRegistrar::supportsPartialBuffersUnloading ( void  ) const
virtual

whether partial buffer unloading is supported (gt only)

virtual void makVrv::DtIndirectGeometryRegistrar::modelsToBeReloaded ( const std::unordered_set< int > &  models)
virtual

indicate that these models' textures (that were unloaded earlier) will be needed again. This is necessary so that we can internally updated textures' references that are used by models This has no effect if the registrar does not support partial unloading (supportsPartialTextureUnloading==false in constructor)

virtual void makVrv::DtIndirectGeometryRegistrar::unloadUnreferencedTextures ( void  )
virtual

Unload textures that are not used by any models Textures are shared across models If a model is unloaded, it may be still used by a model that has not been unloaded So, unlike a model's buffers (unloadModelBuffers), we cannot just unload the textures it references So, use this instead. This has no effect if the registrar does not support partial unloading (supportsPartialTextureUnloading==false in constructor)

virtual void makVrv::DtIndirectGeometryRegistrar::trackTexturesAndModels ( const std::unordered_set< int > &  models,
bool  reloading 
)
virtual

update map of textures to models that are using it

virtual void makVrv::DtIndirectGeometryRegistrar::findModelInfosThatUseThisImageFileForItsTextures ( std::set< DtIndirectModelInfo * > &  modelInfos,
const std::string &  absoluteFileName 
) const
virtual

Given an absolute image file name, return which models currently use this image file in its textures.

virtual void makVrv::DtIndirectGeometryRegistrar::registerModel ( int  modelId,
osg::ref_ptr< const osg::Node >  model,
const std::string &  modelFileName,
const std::string &  modelDefName,
bool  daylightControlled,
bool  cullFaceEnabled = true,
const DtIndirectPolygonOffset polygonOffset = DtIndirectPolygonOffset(0.0f, 0.0f) 
)
protectedvirtual

actually register it in the main thread called from rebuildIfNeeded, which is in turn called from main thread

Member Data Documentation

friend makVrv::DtIndirectGeometryRegistrar::DtIndirectGeometryRegistrarCreator
protected

friend class creator so that DtIndirectGeometryRegistrar can only be created by the creator

DtIndirectModelInfoContainer* makVrv::DtIndirectGeometryRegistrar::myModelInfoContainer
protected
DtIndirectEffectTexturesTemplate makVrv::DtIndirectGeometryRegistrar::myEffectTexturesState
protected
bool makVrv::DtIndirectGeometryRegistrar::myPagerHandlesModelLoading
protected
QueueRegisterModelOps makVrv::DtIndirectGeometryRegistrar::myQueueRegisterModelOps
protected
DtIndirectTextureCollectionPolicy* makVrv::DtIndirectGeometryRegistrar::myTextureCollectionPolicy
protected
osg::ref_ptr<DtIndirectTextureProcessor> makVrv::DtIndirectGeometryRegistrar::myTextureProcessor
protected
bool makVrv::DtIndirectGeometryRegistrar::myRegisteredModelsDirty
mutableprotected
unsigned int makVrv::DtIndirectGeometryRegistrar::myLastRebuildNumber
protected
DtIndirectGeometryAggregator* makVrv::DtIndirectGeometryRegistrar::myAggregator
protected
tbb::atomic<bool> makVrv::DtIndirectGeometryRegistrar::myBeingProcessed
protected
boost::mutex makVrv::DtIndirectGeometryRegistrar::myAddingModelsMutex
protected
DtIndirectGeometryStateManager makVrv::DtIndirectGeometryRegistrar::myMutableStateContainer
mutableprotected

mutable since it is needed to be used in drawImplementaion for the indirect geometry not private so it can be used by derived classes

DtDe& makVrv::DtIndirectGeometryRegistrar::myDe
protected

DtDe reference.

DtOsgShaderManager& makVrv::DtIndirectGeometryRegistrar::myShaderManager
protected
std::map< osg::ref_ptr<osg::Texture>, std::set<int> > makVrv::DtIndirectGeometryRegistrar::myTextureToModelsThatAreUsingIt
protected

map of texture to the set of models that refer to the texture

std::unordered_map< std::string, std::set<int> > makVrv::DtIndirectGeometryRegistrar::myImagesToModelsThatAreUsingIt
protected

map of absolute image file names to models that use it

const bool makVrv::DtIndirectGeometryRegistrar::mySupportsPartialTextureUnloading
protected
const bool makVrv::DtIndirectGeometryRegistrar::mySupportsPartialBuffersUnloading
protected

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

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)