OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::GpuResource Class Reference

#include <OgreGpuResource.h>

+ Inheritance diagram for Ogre::GpuResource:

Public Member Functions

 GpuResource (GpuPageOutStrategy::GpuPageOutStrategy pageOutStrategy, VaoManager *vaoManager, IdString name)
virtual ~GpuResource ()
void _addPendingResidencyChanges (uint32 value)
void _setNextResidencyStatus (GpuResidency::GpuResidency nextResidency)
GpuPageOutStrategy::GpuPageOutStrategy getGpuPageOutStrategy () const
IdString getName () const
virtual String getNameStr () const
 Retrieves a user-friendly name. More...
GpuResidency::GpuResidency getNextResidencyStatus () const
 When getResidencyStatus() != getNextResidencyStatus(), residency changes happen in the main thread, while some preparation may be happening in the background. More...
uint32 getPendingResidencyChanges () const
 Returns the number of pending residency changes. More...
GpuResidency::GpuResidency getResidencyStatus () const

Constructor & Destructor Documentation

◆ GpuResource()

Ogre::GpuResource::GpuResource ( GpuPageOutStrategy::GpuPageOutStrategy  pageOutStrategy,
VaoManager vaoManager,
IdString  name 

◆ ~GpuResource()

virtual Ogre::GpuResource::~GpuResource ( )

Member Function Documentation

◆ _addPendingResidencyChanges()

void Ogre::GpuResource::_addPendingResidencyChanges ( uint32  value)

◆ _setNextResidencyStatus()

void Ogre::GpuResource::_setNextResidencyStatus ( GpuResidency::GpuResidency  nextResidency)

◆ getGpuPageOutStrategy()

GpuPageOutStrategy::GpuPageOutStrategy Ogre::GpuResource::getGpuPageOutStrategy ( ) const

◆ getName()

IdString Ogre::GpuResource::getName ( ) const

◆ getNameStr()

virtual String Ogre::GpuResource::getNameStr ( ) const

Retrieves a user-friendly name.


Reimplemented in Ogre::TextureGpu.

◆ getNextResidencyStatus()

GpuResidency::GpuResidency Ogre::GpuResource::getNextResidencyStatus ( ) const

When getResidencyStatus() != getNextResidencyStatus(), residency changes happen in the main thread, while some preparation may be happening in the background.

For example when a texture is not resident but getNextResidencyStatus says it will, a background thread is loading the texture file from disk, but the actual transition won't happen until the main thread changes it. You can call texture->waitForData() which will stall, as the main thread will be communicating back and forth with the background to see if it's ready; and when it is, the main thread will perform the transition inside waitForData

Likewise, if that texture is resident but will soon not be, it is still legal to access its contents as long as you access them from the main thread before that main thread changes the residency. This gives you a strong serialization guarantee, but be careful with async tickets such as AsyncTextureTickets:

If you call AsyncTextureTicket *asyncTicket = textureManager->createAsyncTextureTicket( ... ); assert( texture->getResidencyStatus() == GpuResidency::Resident ); ... do something else that calls Ogre functionality ... assert( texture->getResidencyStatus() == GpuResidency::Resident ); asyncTicket->download( texture, mip, true ); Then the second assert may trigger because that "do something else" ended up calling a function inside Ogre that finalized the transition. Once you've called download and the resource was still Resident, you are safe that your data integrity will be kept.

Beware of the ABA problem. If the following transitions are scheduled: OnStorage -> Resident -> OnStorage Then both getResidencyStatus & getNextResidencyStatus will return OnStorage. Use GpuResource::getPendingResidencyChanges to fix the ABA problem.

◆ getPendingResidencyChanges()

uint32 Ogre::GpuResource::getPendingResidencyChanges ( ) const

Returns the number of pending residency changes.

Residency changes may not be immediate and thus be delayed (e.g. see TextureGpu::scheduleTransitionTo).

When this value is 0 it implies that mResidencyStatus == mNextResidencyStatus

◆ getResidencyStatus()

GpuResidency::GpuResidency Ogre::GpuResource::getResidencyStatus ( ) const

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