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::DtGpuArena Class Reference

Top-level pre-draw osg::Operation registered on the OSG viewer that coordinates all GPU work requiring an active GL context.

DtGpuArena manages three categories of GPU work:

The same DtGpuArenaUploadState budget context flows through all categories so that byte-upload accounting and budget enforcement are consistent.

See Also
DtGpuOperation, DtGpuArenaUploadState
Inheritance diagram for makVrv::DtGpuArena:
Inheritance graph
[legend]

Public Member Functions

virtual ~DtGpuArena ()
 
virtual void operator() (osg::Object *obj) override
 
virtual void addOneTimeInitOp (DtIndirectGeometry *indirectGeometry)
 
virtual void addOneTimeInitOpForNextFrame (DtIndirectGeometry *indirectGeometry)
 
virtual void addPersistentOp (DtGpuOperation *op)
 
virtual void removePersistentOp (DtGpuOperation *op)
 
virtual unsigned int uploadMemoryBudget () const
 
virtual unsigned int statsUploadedBufferMemory () const
 
virtual unsigned int statsUploadedTextureMemory () const
 
virtual size_t statsBufferUpdatesRemaining () const
 
virtual size_t statsOneTimeOpsRemaining () const
 
virtual void addOneTimeGpuOp (std::unique_ptr< DtGpuOperation > op)
 
virtual size_t statsGpuOpsRemaining () const
 

Public Attributes

friend DtGpuArenaCreator
 

Protected Member Functions

 DtGpuArena (DtDe &de)
 
virtual void update ()
 
virtual void slot_gpuArenaUploadMemoryBudgetChanged (int megabytes)
 
virtual void processOneTimeInitOperations ()
 
virtual void transferNextFrameOneTimeInitOps ()
 
virtual void processOneTimeGpuOps ()
 

Protected Attributes

DtDe & myDe
 
DtThreadCameraStreamDataManager & myTcsDataManager
 
const std::string myName
 
std::vector< osg::observer_ptr
< DtIndirectGeometry > > 
myNextFrameOneTimeInitOps
 
std::mutex myOneTimeInitOpsMutex
 
std::deque< osg::observer_ptr
< DtIndirectGeometry > > 
myOneTimeInitOps
 
std::list< DtGpuOperation * > myPersistentOperations
 
DtSignalConnectionManager myConnections
 
DtOsgToGlContextTracker & myOsgToGlContextTracker
 
DtIndirectGlTextureObjectManager & myIndirectGlTextureObjectManager
 
DtGlDeleteObjectManager & myGlDeleteObjectManager
 
DtGpuArenaUserDataCreator & myGpuArenaUserDataCreator
 
unsigned int myLastUpdateFrameNumber
 
unsigned int myUploadMemoryBudget
 
unsigned int myStatsUploadedBufferMemory
 
unsigned int myStatsUploadedTextureMemory
 
size_t myStatsBufferUpdatesRemaining
 
std::atomic< size_t > myStatsOneTimeOpsRemaining
 
std::mutex myOneTimeGpuOpsMutex
 
std::deque< std::unique_ptr
< DtGpuOperation > > 
myOneTimeGpuOps
 
std::atomic< size_t > myStatsGpuOpsRemaining
 
DtGpuArenaUploadState * myUploadState
 

Private Member Functions

 DtGpuArena ()=delete
 
DtGpuArena & operator= (const DtGpuArena &rhs)=delete
 
 DtGpuArena (const DtGpuArena &rhs)=delete
 

Constructor & Destructor Documentation

virtual makVrv::DtGpuArena::~DtGpuArena ( )
virtual

destructor

makVrv::DtGpuArena::DtGpuArena ( DtDe &  de)
protected

constructor

makVrv::DtGpuArena::DtGpuArena ( )
privatedelete

not allowed

makVrv::DtGpuArena::DtGpuArena ( const DtGpuArena &  rhs)
privatedelete

not allowed

Member Function Documentation

DtGpuArena& makVrv::DtGpuArena::operator= ( const DtGpuArena &  rhs)
privatedelete

not allowed

virtual void makVrv::DtGpuArena::operator() ( osg::Object *  obj)
overridevirtual

OSG pre-draw callback; executed once per OpenGL context per frame.

May be called from multiple threads simultaneously when OSG is in ThreadPerContext mode. All GL work dispatched here is context-bound.

Parameters
objThe OSG graphics context object passed by the operation thread.
virtual void makVrv::DtGpuArena::addOneTimeInitOp ( DtIndirectGeometry *  indirectGeometry)
virtual

Queue a one-time geometry-buffer init operation (legacy indirect-geometry path).

Thread-safe; may be called from any thread. The operation is executed on the render thread during the next pre-draw pass via processOneTimeInitOperations().

Parameters
indirectGeometryThe indirect-geometry object whose buffers need initializing on the GPU. Must not be null.
virtual void makVrv::DtGpuArena::addOneTimeInitOpForNextFrame ( DtIndirectGeometry *  indirectGeometry)
virtual

Queue a one-time geometry-buffer init operation for the next frame rather than the current one.

Use this when geometry is not yet ready for the current pre-draw pass. Ops are transferred into the active queue by transferNextFrameOneTimeInitOps().

Parameters
indirectGeometryThe indirect-geometry object to initialize next frame.
virtual void makVrv::DtGpuArena::addPersistentOp ( DtGpuOperation *  op)
virtual

Register a persistent GPU operation to run once per GL context per frame.

Parameters
opNon-owning pointer to the operation. The caller retains ownership and must ensure the operation outlives its registration.
Note
Not thread-safe; call only from the main thread.
virtual void makVrv::DtGpuArena::removePersistentOp ( DtGpuOperation *  op)
virtual

Unregister a persistent GPU operation previously added with addPersistentOp().

Parameters
opThe operation to remove. Has no effect if the operation is not registered.
Note
Not thread-safe; call only from the main thread.
virtual unsigned int makVrv::DtGpuArena::uploadMemoryBudget ( ) const
virtual

Returns the per-frame upload memory budget for this arena.

Returns
Upload budget in bytes. Default is 32 MB. Controlled by slot_gpuArenaUploadMemoryBudgetChanged().
virtual unsigned int makVrv::DtGpuArena::statsUploadedBufferMemory ( ) const
virtual

Returns the bytes of buffer data uploaded to the GPU this frame.

Returns
Bytes uploaded; reset to zero at the start of each pre-draw pass.
virtual unsigned int makVrv::DtGpuArena::statsUploadedTextureMemory ( ) const
virtual

Returns the bytes of texture data uploaded to the GPU this frame.

Returns
Bytes uploaded; reset to zero at the start of each pre-draw pass.
virtual size_t makVrv::DtGpuArena::statsBufferUpdatesRemaining ( ) const
virtual

Returns the number of indirect-geometry buffer operations still pending.

Returns
Count of ops remaining in the one-time init queue.
virtual size_t makVrv::DtGpuArena::statsOneTimeOpsRemaining ( ) const
virtual

Returns the number of DtIndirectGeometry one-time init ops pending.

Returns
Count of ops remaining in the indirect-geometry init queue.
virtual void makVrv::DtGpuArena::addOneTimeGpuOp ( std::unique_ptr< DtGpuOperation >  op)
virtual

Queue a one-time GPU operation to be executed on the render thread during the next pre-draw pass. Thread-safe.

All ops in this queue receive the per-frame DtGpuArenaUploadState via DtGpuOperation::execute(state&), so they can read the budget and credit their byte usage to statsUploadedTextureMemory / statsUploadedBufferMemory.

Warning
The current implementation drains the entire queue every frame and does NOT enforce the upload memory budget. If statsUploadedTextureMemory regularly exceeds uploadMemoryBudget(), implement budget-aware re-queueing here (mirror DtGpuArena::processOneTimeInitOperations() which lets DtIndirectGeometry push itself back).
Parameters
opHeap-allocated op; ownership transfers to the arena.
virtual size_t makVrv::DtGpuArena::statsGpuOpsRemaining ( ) const
virtual

Returns the number of one-time GPU ops currently pending in the queue.

virtual void makVrv::DtGpuArena::update ( )
protectedvirtual

Pre-tick update hook; called each simulation tick before the frame renders. Resets per-frame stats and prepares the arena for the next pre-draw pass.

virtual void makVrv::DtGpuArena::slot_gpuArenaUploadMemoryBudgetChanged ( int  megabytes)
protectedvirtual

Update the per-frame upload memory budget.

Controls the total bytes of indirect-geometry and texture data that may be uploaded per frame. Used by DtGpuArena::operator()() during the pre-draw pass.

Parameters
megabytesNew budget in megabytes. Default is 32.
virtual void makVrv::DtGpuArena::processOneTimeInitOperations ( )
protectedvirtual

Drain and execute all pending one-time indirect-geometry init operations. Called once per frame from operator()().

virtual void makVrv::DtGpuArena::transferNextFrameOneTimeInitOps ( )
protectedvirtual

Move next-frame indirect-geometry init ops into the active queue. Called at the start of each pre-draw pass before processOneTimeInitOperations().

virtual void makVrv::DtGpuArena::processOneTimeGpuOps ( )
protectedvirtual

Drain and execute all pending one-time GPU ops. Uses swap-then-release locking so producers do not block on GL execution. Each op receives the per-frame upload state.

Member Data Documentation

friend makVrv::DtGpuArena::DtGpuArenaCreator
DtDe& makVrv::DtGpuArena::myDe
protected
DtThreadCameraStreamDataManager& makVrv::DtGpuArena::myTcsDataManager
protected
const std::string makVrv::DtGpuArena::myName
protected
std::vector< osg::observer_ptr<DtIndirectGeometry> > makVrv::DtGpuArena::myNextFrameOneTimeInitOps
protected
std::mutex makVrv::DtGpuArena::myOneTimeInitOpsMutex
protected
std::deque< osg::observer_ptr<DtIndirectGeometry> > makVrv::DtGpuArena::myOneTimeInitOps
protected
std::list<DtGpuOperation*> makVrv::DtGpuArena::myPersistentOperations
protected
DtSignalConnectionManager makVrv::DtGpuArena::myConnections
protected
DtOsgToGlContextTracker& makVrv::DtGpuArena::myOsgToGlContextTracker
protected
DtIndirectGlTextureObjectManager& makVrv::DtGpuArena::myIndirectGlTextureObjectManager
protected
DtGlDeleteObjectManager& makVrv::DtGpuArena::myGlDeleteObjectManager
protected
DtGpuArenaUserDataCreator& makVrv::DtGpuArena::myGpuArenaUserDataCreator
protected
unsigned int makVrv::DtGpuArena::myLastUpdateFrameNumber
protected
unsigned int makVrv::DtGpuArena::myUploadMemoryBudget
protected
unsigned int makVrv::DtGpuArena::myStatsUploadedBufferMemory
protected

Bytes of buffer data uploaded to GPU this frame; reset each frame.

unsigned int makVrv::DtGpuArena::myStatsUploadedTextureMemory
protected

Bytes of texture data uploaded to GPU this frame; reset each frame.

size_t makVrv::DtGpuArena::myStatsBufferUpdatesRemaining
protected

Number of indirect-geometry buffer operations still pending.

std::atomic<size_t> makVrv::DtGpuArena::myStatsOneTimeOpsRemaining
protected

Number of DtIndirectGeometry one-time init ops pending in the queue.

std::mutex makVrv::DtGpuArena::myOneTimeGpuOpsMutex
protected

Guards myOneTimeGpuOps against concurrent enqueue and drain.

std::deque<std::unique_ptr<DtGpuOperation> > makVrv::DtGpuArena::myOneTimeGpuOps
protected

Thread-safe queue of one-time GPU ops; drained each pre-draw pass.

std::atomic<size_t> makVrv::DtGpuArena::myStatsGpuOpsRemaining
protected

Number of one-time GPU ops pending in myOneTimeGpuOps.

DtGpuArenaUploadState* makVrv::DtGpuArena::myUploadState
protected

Per-frame upload budget and stats; owned by this arena.


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)