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

Manager class that handles texture objects and texture handle residency, as contexts get created and destroyed through the life time of the application.

In bindless/indirect rendering, we don't need to bind textures.

You retrieve a texture 'handle' (a 64 bit value) from the texture. You can then use this 64 bit handle directly in shaders without binding.

Any number of such values (indicating different textures), can be stored in UBOs, SSBOs, uniforms, etc and accessed in shaders without needing to bind any texture.

This allows you to texture and bind multiple instances of multiple unique geometries all with different textures with very few draw calls (usually one for each state).

To leverage this however, you must do some bookkeeping.

Specifically, each texture 'handle' needs to be made resident in every OpenGL context that you need to use the texture bindlessly.

Conversely, when you are done with the texture, you need to make the handle non-resident in every context you made that handle resident.

Once, all the handles are non-resident, textures can be deleted.

Doing this out of order (e.g. deleting the texture without earlier making it's handles non-resident), etc may cause leaks of both textures and handles per the spec: "Deleting the texture will remove the texture from the name space and make all handles using the texture non - resident in the current context.However, texture or image handles for a deleted texture are not deleted until the underlying texture or sampler object itself is deleted.That deletion won't happen until the object is not bound anywhere and there are no handles using the object that are resident in any context."

This class manages the residency/non-residency of all textures used by the vrv/indirect system To use this class properly: -Always call run, once per context (DtIndirectTextureResidencyManager::run())

-When you create a DtIndirectGlTextureObject, it needs to be made resident immediately, in whichever context you are in. DtIndirectGlTextureObjectManager does this for you internally. (see DtIndirectGlTextureObjectManager::getOrCreate)

-When you are done with the texture, you need to call: DtIndirectTextureResidencyManager::addToQueueToMakeNonResidentInAllGraphicsContexts) DtIndirectGlTextureObjectManager does this for you internally. (see DtIndirectGlTextureObjectManager::removeEntry)

Bindless texturing and handle residency have nothing to do with gpu memory or whether a handle being resident means that texture is resident on gpu and cannot be paged out.

Handle residency is basically a requirement to have a texture being used bindlessly (via casting its texture address handle to a sampler in the shader). Think of it as a 'vao' for a texture

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

Public Member Functions

virtual ~DtIndirectTextureResidencyManager ()
 
virtual void run (unsigned int frameNumber)
 
virtual void addToQueueToMakeNonResidentInAllGraphicsContexts (DtIndirectGlTextureObject *indirectGlTextureObject)
 
virtual void printStatsWhenNoWindows ()
 
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 
virtual ~DtVirtualBaseClass ()
 

Public Attributes

friend DtIndirectTextureResidencyManagerCreator
 

Protected Member Functions

 DtIndirectTextureResidencyManager (DtDe &de, DtIndirectGlTextureObjectManager &parent)
 
virtual void deleteGlTexture (const DtIndirectGlTextureObject *indirectGlTextureObject)
 
virtual void runResidencyOperation (const void *glContext, DtIndirectTextureResidencyOperation operation)
 
virtual void runMakeNonResidentOnTexturesInNonResidentQueue (const void *glContext)
 
virtual bool isInAnyContextForMarkingNonResident (const void *currentGlContext, DtIndirectGlTextureObject *indirectGlTexture)
 
virtual void slot_contextAboutToBeDestroyed (const void *glContext)
 

Protected Attributes

DtIndirectGlTextureObjectManagermyParent
 
DtDemyDe
 
std::unordered_map< const void
*, DtIndirectGraphicsContextData
myGlContextToData
 
tbb::concurrent_unordered_set
< DtIndirectGlTextureObject * > 
myScatchPadSetForResidencyCollection
 
DtSignalConnectionManager myConnections
 

Private Member Functions

 DtIndirectTextureResidencyManager ()=delete
 
 DtIndirectTextureResidencyManager (DtIndirectTextureResidencyManager &)=delete
 
DtIndirectTextureResidencyManageroperator= (DtIndirectTextureResidencyManager &)=delete
 

Constructor & Destructor Documentation

virtual makVrv::DtIndirectTextureResidencyManager::~DtIndirectTextureResidencyManager ( )
virtual
makVrv::DtIndirectTextureResidencyManager::DtIndirectTextureResidencyManager ( DtDe de,
DtIndirectGlTextureObjectManager parent 
)
protected
makVrv::DtIndirectTextureResidencyManager::DtIndirectTextureResidencyManager ( )
privatedelete

not allowed

makVrv::DtIndirectTextureResidencyManager::DtIndirectTextureResidencyManager ( DtIndirectTextureResidencyManager )
privatedelete

not allowed

Member Function Documentation

DtIndirectTextureResidencyManager& makVrv::DtIndirectTextureResidencyManager::operator= ( DtIndirectTextureResidencyManager )
privatedelete

not allowed

virtual void makVrv::DtIndirectTextureResidencyManager::run ( unsigned int  frameNumber)
virtual

This will actually just run once for each gc, each frame.

virtual void makVrv::DtIndirectTextureResidencyManager::addToQueueToMakeNonResidentInAllGraphicsContexts ( DtIndirectGlTextureObject indirectGlTextureObject)
virtual

When an indirect texture is to be deleted, it needs to be first put on the queue to be made non-resident in all graphics contexts. This function puts it on the queue to be made non-resident. It also indicates an intent to delete, because an indirect texture is never used without being resident, After texture is made non-resident in all contexts, this manager will delete the texture. This deletion can happen in any gl context for the run call and is ok since textures are shared across all contexts.

virtual void makVrv::DtIndirectTextureResidencyManager::printStatsWhenNoWindows ( )
virtual

for debugging. When there are no windows, there should actually be no textures in the vrv system after this manager has run. Since they all will have been made non-resident, and then deleted.

virtual void makVrv::DtIndirectTextureResidencyManager::deleteGlTexture ( const DtIndirectGlTextureObject indirectGlTextureObject)
protectedvirtual

delete the underlying gl texture

virtual void makVrv::DtIndirectTextureResidencyManager::runResidencyOperation ( const void *  glContext,
DtIndirectTextureResidencyOperation  operation 
)
protectedvirtual

make the texture resident/non-resident in the passed in context

virtual void makVrv::DtIndirectTextureResidencyManager::runMakeNonResidentOnTexturesInNonResidentQueue ( const void *  glContext)
protectedvirtual

run make non-resident on the queue for textures to be marked non-resident in the gl context

virtual bool makVrv::DtIndirectTextureResidencyManager::isInAnyContextForMarkingNonResident ( const void *  currentGlContext,
DtIndirectGlTextureObject indirectGlTexture 
)
protectedvirtual

internal check

virtual void makVrv::DtIndirectTextureResidencyManager::slot_contextAboutToBeDestroyed ( const void *  glContext)
protectedvirtual

slot for when context is destroyed It is called via connection to DtOsgToGlContextTracker::signal_contextAboutToBeDestroyed

Member Data Documentation

friend makVrv::DtIndirectTextureResidencyManager::DtIndirectTextureResidencyManagerCreator
DtIndirectGlTextureObjectManager& makVrv::DtIndirectTextureResidencyManager::myParent
protected
DtDe& makVrv::DtIndirectTextureResidencyManager::myDe
protected
std::unordered_map<const void*, DtIndirectGraphicsContextData> makVrv::DtIndirectTextureResidencyManager::myGlContextToData
protected
tbb::concurrent_unordered_set<DtIndirectGlTextureObject*> makVrv::DtIndirectTextureResidencyManager::myScatchPadSetForResidencyCollection
protected
DtSignalConnectionManager makVrv::DtIndirectTextureResidencyManager::myConnections
protected

for handling context destroyed event


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

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)