In Ogre 2.2 reading data from GPU back to CPU is asynchronous.
More...
#include <OgreAsyncTextureTicket.h>
|
enum | Status { Ready
, Downloading
, Mapped
} |
|
enum | Reason {
Unknown
, FromStorageToSysRam
, FromSysRamToStorage
, GainedResidency
,
LostResidency
, PoolTextureSlotChanged
, ResidentToSysRamSync
, MetadataCacheOutOfDate
,
ExceptionThrown
, FsaaSettingAlteredByApi
, ReadyForRendering
, Deleted
} |
|
|
| AsyncTextureTicket (uint32 width, uint32 height, uint32 depthOrSlices, TextureTypes::TextureTypes textureType, PixelFormatGpu pixelFormatFamily) |
|
| ~AsyncTextureTicket () override |
|
virtual bool | canMapMoreThanOneSlice () const |
| See Image2::convertFromTexture for an example of how to use AyncTextureTicket. More...
|
|
void | download (TextureGpu *textureSrc, uint8 mipLevel, bool accurateTracking, TextureBox *srcBox=0, bool bImmediate=false) |
| Downloads textureSrc into this ticket. More...
|
|
size_t | getBytesPerImage () const |
|
uint32 | getBytesPerRow () const |
|
uint32 | getDepth () const |
| For TypeCube & TypeCubeArray, this value returns 1. More...
|
|
uint32 | getDepthOrSlices () const |
|
uint32 | getHeight () const |
|
uint32 | getNumSlices () const |
| For TypeCube this value returns 6. More...
|
|
PixelFormatGpu | getPixelFormatFamily () const |
|
uint32 | getWidth () const |
|
TextureBox | map (uint32 slice) |
| Maps the buffer for CPU access. More...
|
|
void | notifyTextureChanged (TextureGpu *texture, TextureGpuListener::Reason reason, void *extraData) override |
| TextureGpuListener overload. More...
|
|
virtual bool | queryIsTransferDone () |
|
void | unmap () |
| Unmaps the pointer mapped with map(). More...
|
|
virtual | ~TextureGpuListener () |
|
virtual bool | shouldStayLoaded (TextureGpu *texture) |
| Return true if this TextureGpu should likely stay loaded or else graphical changes could occur. More...
|
|
In Ogre 2.2 reading data from GPU back to CPU is asynchronous.
See TextureGpuManager::createAsyncTextureTicket to generate a ticket. While the async transfer is being performed, you should be doing something else.
- Use queryIsTransferDone to query if the transfer has finished. Beware not all APIs support querying async transfer status. In those cases there is no reliable way to determine when the transfer is done. An almost safe bet is to wait two frames before mapping.
- Call TextureGpuManager::destroyAsyncTextureTicket when you're done with this ticket.
◆ Status
Enumerator |
---|
Ready | |
Downloading | |
Mapped | |
◆ AsyncTextureTicket()
◆ ~AsyncTextureTicket()
Ogre::AsyncTextureTicket::~AsyncTextureTicket |
( |
| ) |
|
|
override |
◆ canMapMoreThanOneSlice()
virtual bool Ogre::AsyncTextureTicket::canMapMoreThanOneSlice |
( |
| ) |
const |
|
inlinevirtual |
◆ download()
void Ogre::AsyncTextureTicket::download |
( |
TextureGpu * |
textureSrc, |
|
|
uint8 |
mipLevel, |
|
|
bool |
accurateTracking, |
|
|
TextureBox * |
srcBox = 0 , |
|
|
bool |
bImmediate = false |
|
) |
| |
Downloads textureSrc into this ticket.
The size (resolution) of this ticket must match exactly of the region to download.
- Parameters
-
textureSrc | Texture to download from. Must be resident. |
mipLevel | Mip level to download. |
accurateTracking | When false, you will be mapping this texture much further along (i.e. after 2-3 frames) Useful when constantly streaming GPU content to the CPU with 3 frames delay. When true, we will accurately track the status of this transfer, which has higher driver overhead. |
srcBox | When nullptr, we'll download the whole texture (its selected mip level) When not nullptr, we'll download the region within the texture. This region must resolution must match exactly that of this ticket (e.g. bytesPerRow may be much bigger than you expect!) |
bImmediate | When bImmediate is true, we will download from the GPU if texture is currently resident and ready; even if there are pending residency changes. If it's not ready, we'll listen for when it is. |
◆ getBytesPerImage()
size_t Ogre::AsyncTextureTicket::getBytesPerImage |
( |
| ) |
const |
◆ getBytesPerRow()
uint32 Ogre::AsyncTextureTicket::getBytesPerRow |
( |
| ) |
const |
◆ getDepth()
uint32 Ogre::AsyncTextureTicket::getDepth |
( |
| ) |
const |
For TypeCube & TypeCubeArray, this value returns 1.
◆ getDepthOrSlices()
uint32 Ogre::AsyncTextureTicket::getDepthOrSlices |
( |
| ) |
const |
◆ getHeight()
uint32 Ogre::AsyncTextureTicket::getHeight |
( |
| ) |
const |
◆ getNumSlices()
uint32 Ogre::AsyncTextureTicket::getNumSlices |
( |
| ) |
const |
For TypeCube this value returns 6.
For TypeCubeArray, value returns numSlices * 6u.
◆ getPixelFormatFamily()
PixelFormatGpu Ogre::AsyncTextureTicket::getPixelFormatFamily |
( |
| ) |
const |
◆ getWidth()
uint32 Ogre::AsyncTextureTicket::getWidth |
( |
| ) |
const |
◆ map()
Maps the buffer for CPU access.
Will stall if transfer from GPU memory to staging area hasn't finished yet. See queryIsTransferDone.
- NOTE: When mapping a texture bigger than 2048x2048; in D3D11 the the returned pointer will return TextureBox::numSlices = 1, In this case you will have to use that slice, unmap this ticket, and map it again with the next slice.
- See Image2::convertFromTexture for an example of how to use AyncTextureTicket
- Parameters
-
slice | First slice to map. Textures below 2048x2048 are guaranteed to be able to access [slice; getNumSlices). Textures above that will only be able to access [slice; slice+1) |
- Returns
- The pointer with the data read from the GPU. Read only.
◆ notifyTextureChanged()
◆ queryIsTransferDone()
virtual bool Ogre::AsyncTextureTicket::queryIsTransferDone |
( |
| ) |
|
|
virtual |
◆ unmap()
void Ogre::AsyncTextureTicket::unmap |
( |
| ) |
|
Unmaps the pointer mapped with map().
The documentation for this class was generated from the following file: