OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::MetalStagingBuffer Class Referencefinal

A staging buffer is a buffer that resides on the GPU and be written to/from both CPU & GPU However the access in both cases is limited. More...

#include <OgreMetalStagingBuffer.h>

+ Inheritance diagram for Ogre::MetalStagingBuffer:

Public Member Functions

 MetalStagingBuffer (size_t internalBufferStart, size_t sizeBytes, VaoManager *vaoManager, bool uploadOnly, id< MTLBuffer > vboName, MetalDevice *device)
 
 ~MetalStagingBuffer () override
 
size_t _asyncDownload (BufferPacked *source, size_t srcOffset, size_t srcLength) override
 Copies the GPU data in BufferPacked to the StagingBuffer so that it can be later read by the CPU using an AsyncTicket. More...
 
size_t _asyncDownloadV1 (v1::MetalHardwareBufferCommon *source, size_t srcOffset, size_t srcLength)
 
void _cancelDownload (size_t offset, size_t sizeBytes) override
 Releases memory assigned to a download that hasn't been mapped yet, to make space for another _asyncDownload call. More...
 
void _notifyDeviceStalled ()
 
void _unmapToV1 (v1::MetalHardwareBufferCommon *hwBuffer, size_t lockStart, size_t lockSize)
 
bool canDownload (size_t length) const override
 Checks if this staging buffer has enough free space to use _asyncDownload. More...
 
void cleanUnfencedHazards ()
 
id< MTLBuffer > getBufferName () const
 
StagingStallType uploadWillStall (size_t sizeBytes) override
 Returns true if our next call to map() with the same parameters will stall. More...
 
- Public Member Functions inherited from Ogre::StagingBuffer
 StagingBuffer (size_t internalBufferStart, size_t sizeBytes, VaoManager *vaoManager, bool uploadOnly)
 
virtual ~StagingBuffer ()
 
const void * _mapForRead (size_t offset, size_t sizeBytes)
 Maps the buffer for read acces for the CPU. More...
 
void addReferenceCount ()
 Adds a reference count to the StagingBuffer. More...
 
uint64 getLastUsedTimestamp () const
 Returns the time in millisecond when the ref. count became 0. More...
 
uint32 getLifetimeThreshold () const
 Returns the time in milliseconds in which a StagingBuffer should live with a reference count of 0 before being deleted. More...
 
MappingState getMappingState () const
 
size_t getMaxSize ()
 
int16 getReferenceCount () const
 
uint32 getUnfencedTimeThreshold () const
 Returns the time in milliseconds in which a StagingBuffer should hazards unfenced while with a reference count of 0. More...
 
bool getUploadOnly () const
 When true, this buffer can only be used for uploading to GPU. More...
 
void * map (size_t sizeBytes)
 Maps the given amount of bytes. More...
 
void removeReferenceCount ()
 Decreases the reference count by one. More...
 
void unmap (const Destination &destination)
 Unmaps the mapped region and copies the data to the given region. More...
 
void unmap (const Destination *destinations, size_t numDestinations)
 
void unmap (const DestinationVec &destinations)
 Unmaps the mapped region and copies the data to multiple buffers. More...
 

Additional Inherited Members

- Public Types inherited from Ogre::StagingBuffer
typedef vector< Destination >::type DestinationVec
 

Detailed Description

A staging buffer is a buffer that resides on the GPU and be written to/from both CPU & GPU However the access in both cases is limited.

GPUs can only copy (i.e. memcpy) to another real buffer (can't be used directly as i.e. texture or vertex buffer) and CPUs can only map it. In other words, a staging buffer is an intermediate buffer to transfer data between CPU & GPU

Constructor & Destructor Documentation

◆ MetalStagingBuffer()

Ogre::MetalStagingBuffer::MetalStagingBuffer ( size_t  internalBufferStart,
size_t  sizeBytes,
VaoManager vaoManager,
bool  uploadOnly,
id< MTLBuffer >  vboName,
MetalDevice device 
)

◆ ~MetalStagingBuffer()

Ogre::MetalStagingBuffer::~MetalStagingBuffer ( )
override

Member Function Documentation

◆ _asyncDownload()

size_t Ogre::MetalStagingBuffer::_asyncDownload ( BufferPacked source,
size_t  srcOffset,
size_t  srcLength 
)
overridevirtual

Copies the GPU data in BufferPacked to the StagingBuffer so that it can be later read by the CPU using an AsyncTicket.

See also
AsyncTicket.
Remarks
For internal use. May throw if it can't handle the request (i.e. requested size is too big, or too many _asyncDownload operations are pending until calling _mapForRead)
See also
canDownload mUploadOnly must be true.
Parameters
sourceThe buffer to copy from.
srcOffsetThe offset, in bytes, of the buffer to copy from.
srcLengthThe size in bytes, of the data to transfer to this staging buffer.
Returns
The offset in bytes that will be used by
See also
_mapForRead

Implements Ogre::StagingBuffer.

◆ _asyncDownloadV1()

size_t Ogre::MetalStagingBuffer::_asyncDownloadV1 ( v1::MetalHardwareBufferCommon source,
size_t  srcOffset,
size_t  srcLength 
)

◆ _cancelDownload()

void Ogre::MetalStagingBuffer::_cancelDownload ( size_t  offset,
size_t  sizeBytes 
)
overridevirtual

Releases memory assigned to a download that hasn't been mapped yet, to make space for another _asyncDownload call.

Useful when you suddenly don't intend to call _mapForRead.

Reimplemented from Ogre::StagingBuffer.

◆ _notifyDeviceStalled()

void Ogre::MetalStagingBuffer::_notifyDeviceStalled ( )

◆ _unmapToV1()

void Ogre::MetalStagingBuffer::_unmapToV1 ( v1::MetalHardwareBufferCommon hwBuffer,
size_t  lockStart,
size_t  lockSize 
)

◆ canDownload()

bool Ogre::MetalStagingBuffer::canDownload ( size_t  length) const
overridevirtual

Checks if this staging buffer has enough free space to use _asyncDownload.

Otherwise such function would raise an exception.

Remarks
mUploadOnly must be true. It is the counter side of
See also
uploadWillStall
Parameters
lengthThe size in bytes that need to be downloaded.

Reimplemented from Ogre::StagingBuffer.

◆ cleanUnfencedHazards()

void Ogre::MetalStagingBuffer::cleanUnfencedHazards ( )

◆ getBufferName()

id<MTLBuffer> Ogre::MetalStagingBuffer::getBufferName ( ) const
inline

◆ uploadWillStall()

StagingStallType Ogre::MetalStagingBuffer::uploadWillStall ( size_t  sizeBytes)
overridevirtual

Returns true if our next call to map() with the same parameters will stall.

See also
StagingStallType
Remarks
Not all RenderSystems can accurately give this information and will always return STALL_PARTIAL (i.e. GLES2) The chances of getting a STALL_FULL get higher as sizeBytes gets closer to this->getMaxSize() mUploadOnly must be false. It is the counter side of
See also
canDownload

Reimplemented from Ogre::StagingBuffer.


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