![]() |
VR-Forces Developer's Guide
|
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

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 | |
| DtIndirectGlTextureObjectManager & | myParent |
| DtDe & | myDe |
| std::unordered_map< const void *, DtIndirectGraphicsContextData > | myGlContextToData |
| tbb::concurrent_unordered_set < DtIndirectGlTextureObject * > | myScatchPadSetForResidencyCollection |
| DtSignalConnectionManager | myConnections |
Private Member Functions | |
| DtIndirectTextureResidencyManager ()=delete | |
| DtIndirectTextureResidencyManager (DtIndirectTextureResidencyManager &)=delete | |
| DtIndirectTextureResidencyManager & | operator= (DtIndirectTextureResidencyManager &)=delete |
|
virtual |
|
protected |
|
privatedelete |
not allowed
|
privatedelete |
not allowed
|
privatedelete |
not allowed
This will actually just run once for each gc, each frame.
|
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 |
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.
|
protectedvirtual |
delete the underlying gl texture
|
protectedvirtual |
make the texture resident/non-resident in the passed in context
|
protectedvirtual |
run make non-resident on the queue for textures to be marked non-resident in the gl context
|
protectedvirtual |
internal check
|
protectedvirtual |
slot for when context is destroyed It is called via connection to DtOsgToGlContextTracker::signal_contextAboutToBeDestroyed
| friend makVrv::DtIndirectTextureResidencyManager::DtIndirectTextureResidencyManagerCreator |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
for handling context destroyed event