OGRE-Next  2.3
Object-Oriented Graphics Rendering Engine
Ogre::MetalUavBufferPacked Class Referencefinal

#include <OgreMetalUavBufferPacked.h>

+ Inheritance diagram for Ogre::MetalUavBufferPacked:

Public Member Functions

 MetalUavBufferPacked (size_t internalBufStartBytes, size_t numElements, uint32 bytesPerElement, uint32 bindFlags, void *initialData, bool keepAsShadow, VaoManager *vaoManager, MetalBufferInterface *bufferInterface, MetalDevice *device)
 
 ~MetalUavBufferPacked () override
 
size_t _getFinalBufferStart () const
 
size_t _getInternalBufferStart () const
 
size_t _getInternalNumElements () const
 
size_t _getInternalTotalSizeBytes () const
 
void _setBufferInterface (BufferInterface *bufferInterface)
 For internal use. More...
 
void _setShadowCopy (void *copy)
 This will not delete the existing shadow copy so it can be used for other purposes if it is not needed call OGRE_FREE_SIMD( m->getShadowCopy(), MEMCATEGORY_GEOMETRY ) before calling this function. More...
 
void advanceFrame ()
 
void bindBufferAllRenderStages (uint16 slot, size_t offset=0)
 
void bindBufferCS (uint16 slot, size_t offset=0, size_t sizeBytes=0) override
 Binds the texture buffer to the given slot in the Vertex/Pixel/Geometry/Hull/Domain/Compute Shader. More...
 
void bindBufferForDescriptor (__unsafe_unretained id< MTLBuffer > *buffers, NSUInteger *offsets, size_t offset)
 
void bindBufferPS (uint16 slot, size_t offset=0, size_t sizeBytes=0)
 
void bindBufferVS (uint16 slot, size_t offset=0, size_t sizeBytes=0)
 
void copyTo (BufferPacked *dstBuffer, size_t dstElemStart=0, size_t srcElemStart=0, size_t srcNumElems=std::numeric_limits< size_t >::max())
 Copies the contents of this buffer to another, using GPU -> GPU transfers. More...
 
void destroyAllBufferViews ()
 See destroyTexBufferView and getAsReadOnlyBufferView, this one does it on all the creates views. More...
 
void destroyReadOnlyBufferView ()
 Frees memory from the view created by getAsReadOnlyBufferView Does nothing if the view wasn't created. More...
 
void destroyTexBufferView (PixelFormatGpu pixelFormat)
 Frees memory from a view created by getAsTexBufferView Does nothing if a view of the given pixel format did not exist. More...
 
ReadOnlyBufferPackedgetAsReadOnlyBufferView ()
 Returns a ReadOnlyBufferPacked for binding to the GPU as a texture w/ read-only access. More...
 
TexBufferPackedgetAsTexBufferView (PixelFormatGpu pixelFormat)
 Returns a TexBufferPacked for binding to the GPU as a texture w/ read-only access. More...
 
BufferInterfacegetBufferInterface () const
 
BufferPackedTypes getBufferPackedType () const override
 Useful to query which one is the derived class. More...
 
BufferType getBufferType () const
 
size_t getBytesPerElement () const
 
MappingState getMappingState () const
 Returns the mapping state. More...
 
size_t getNumElements () const
 
virtual BufferPackedgetOriginalBufferType ()
 If this buffer has been reinterpreted from an UavBufferPacked, returns the original version, otherwise returns 'this'. More...
 
const void * getShadowCopy () const
 
size_t getTotalSizeBytes () const
 
bool isCurrentlyMapped () const
 Returns whether the buffer is currently mapped. More...
 
virtual bool isTextureGpu () const
 
void *RESTRICT_ALIAS_RETURN map (size_t elementStart, size_t elementCount, bool bAdvanceFrame=true)
 Maps the specified region to a pointer the CPU can access. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete (void *ptr, void *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
AsyncTicketPtr readRequest (size_t elementStart, size_t elementCount)
 Async data read request. More...
 
void regressFrame ()
 Performs the opposite of. More...
 
void unmap (UnmapOptions unmapOption, size_t flushStartElem=0, size_t flushSizeElem=0)
 Unmaps or flushes the region mapped with. More...
 
virtual void upload (const void *data, size_t elementStart, size_t elementCount)
 Sends the provided data to the GPU. More...
 

Constructor & Destructor Documentation

◆ MetalUavBufferPacked()

Ogre::MetalUavBufferPacked::MetalUavBufferPacked ( size_t  internalBufStartBytes,
size_t  numElements,
uint32  bytesPerElement,
uint32  bindFlags,
void *  initialData,
bool  keepAsShadow,
VaoManager vaoManager,
MetalBufferInterface bufferInterface,
MetalDevice device 
)

◆ ~MetalUavBufferPacked()

Ogre::MetalUavBufferPacked::~MetalUavBufferPacked ( )
override

Member Function Documentation

◆ _getFinalBufferStart()

size_t Ogre::BufferPacked::_getFinalBufferStart ( ) const
inlineinherited

◆ _getInternalBufferStart()

size_t Ogre::BufferPacked::_getInternalBufferStart ( ) const
inlineinherited

◆ _getInternalNumElements()

size_t Ogre::BufferPacked::_getInternalNumElements ( ) const
inlineinherited

◆ _getInternalTotalSizeBytes()

size_t Ogre::BufferPacked::_getInternalTotalSizeBytes ( ) const
inlineinherited

◆ _setBufferInterface()

void Ogre::BufferPacked::_setBufferInterface ( BufferInterface bufferInterface)
inherited

For internal use.

◆ _setShadowCopy()

void Ogre::BufferPacked::_setShadowCopy ( void *  copy)
inherited

This will not delete the existing shadow copy so it can be used for other purposes if it is not needed call OGRE_FREE_SIMD( m->getShadowCopy(), MEMCATEGORY_GEOMETRY ) before calling this function.

This will also not automatically upload the shadow data to the GPU. The user must call upload or use a staging buffer themselves to achieve this.

◆ advanceFrame()

void Ogre::BufferPacked::advanceFrame ( )
inherited
See also
map. Do NOT call this function more than once per frame, or if you've called map( advanceFrame = true )

◆ bindBufferAllRenderStages()

void Ogre::MetalUavBufferPacked::bindBufferAllRenderStages ( uint16  slot,
size_t  offset = 0 
)

◆ bindBufferCS()

void Ogre::MetalUavBufferPacked::bindBufferCS ( uint16  slot,
size_t  offset = 0,
size_t  sizeBytes = 0 
)
overridevirtual

Binds the texture buffer to the given slot in the Vertex/Pixel/Geometry/Hull/Domain/Compute Shader.

Remarks
Not all RS API separate by shader stage. For best compatibility, don't assign two different buffers at the same slot for different stages (just leave the slot empty on the stages you don't use).
Parameters
slotThe slot to asign this constant buffer. In D3D11 it's called 'slot'. In GLSL it's called it's called 'binding'
offset0-based offset. It is possible to bind a region of the buffer. Offset needs to be aligned. You can query the RS capabilities for the alignment, however 256 bytes is the maximum allowed alignment per the OpenGL specification, making it a safe bet to hardcode.
sizeBytesSize in bytes to bind the tex buffer. When zero, binds from offset until the end of the buffer.

Implements Ogre::UavBufferPacked.

◆ bindBufferForDescriptor()

void Ogre::MetalUavBufferPacked::bindBufferForDescriptor ( __unsafe_unretained id< MTLBuffer > *  buffers,
NSUInteger *  offsets,
size_t  offset 
)

◆ bindBufferPS()

void Ogre::MetalUavBufferPacked::bindBufferPS ( uint16  slot,
size_t  offset = 0,
size_t  sizeBytes = 0 
)

◆ bindBufferVS()

void Ogre::MetalUavBufferPacked::bindBufferVS ( uint16  slot,
size_t  offset = 0,
size_t  sizeBytes = 0 
)

◆ copyTo()

void Ogre::BufferPacked::copyTo ( BufferPacked dstBuffer,
size_t  dstElemStart = 0,
size_t  srcElemStart = 0,
size_t  srcNumElems = std::numeric_limits< size_t >::max() 
)
inherited

Copies the contents of this buffer to another, using GPU -> GPU transfers.

In simple terms it is similar to doing: memcpy( dstBuffer + dstElemStart, this + srcElemStart, srcNumElems );

Remarks
When both src and dst have different values for BufferPacked::getBytesPerElement() then srcNumElems * this->getBytesPerElement() must be divisible by dstBuffer->getBytesPerElement()

If dst has a shadow buffer, then src must have it too.

Parameters
dstBufferBuffer to copy to. Must be of type BT_DEFAULT
dstElemStartThe offset for dstBuffer. It must be in the unit of measure of dstBuffer. e.g. actual offset in bytes is dstElemStart * dstBuffer->getBytesPerElement()
srcElemStartThe offset of this buffer to start from
srcNumElemsThe number of elements to copy, in units of measure of srcBuffer. When this value is out of bounds, it gets clamped. See remarks.

◆ destroyAllBufferViews()

void Ogre::UavBufferPacked::destroyAllBufferViews ( )
inherited

See destroyTexBufferView and getAsReadOnlyBufferView, this one does it on all the creates views.

◆ destroyReadOnlyBufferView()

void Ogre::UavBufferPacked::destroyReadOnlyBufferView ( )
inherited

Frees memory from the view created by getAsReadOnlyBufferView Does nothing if the view wasn't created.

◆ destroyTexBufferView()

void Ogre::UavBufferPacked::destroyTexBufferView ( PixelFormatGpu  pixelFormat)
inherited

Frees memory from a view created by getAsTexBufferView Does nothing if a view of the given pixel format did not exist.

◆ getAsReadOnlyBufferView()

ReadOnlyBufferPacked* Ogre::UavBufferPacked::getAsReadOnlyBufferView ( )
inherited

Returns a ReadOnlyBufferPacked for binding to the GPU as a texture w/ read-only access.

Buffer must've been created with BB_FLAG_READONLY.

Remarks
Don't try to use readRequest or map the returned pointer. All major operations except binding to the shader should be done through the UavBufferPacked.
If this function was already called, it will return the same pointer as the last time, otherwise returns a new pointer
Unlike getAsTexBufferView there is no pixelFormat because the returned pointer will always be format-less (e.g. will use UBO in GL & Vullkan, Structure Buffer in D3D11, etc)
Returns
A ReadOnlyBufferPacked to be used to bind to the different stages. Do not destroy this buffer via VaoManager::destroyReadOnlyBuffer. See UavBufferPacked::destroyReadOnlyBufferView

◆ getAsTexBufferView()

TexBufferPacked* Ogre::UavBufferPacked::getAsTexBufferView ( PixelFormatGpu  pixelFormat)
inherited

Returns a TexBufferPacked for binding to the GPU as a texture w/ read-only access.

Buffer must've been created with BB_FLAG_TEX.

Remarks
Don't try to use readRequest or map the returned pointer. All major operations except binding to the shader should be done through the UavBufferPacked.
If this function was already called, it will return the same pointer as the last time (though performs an O(N) search), otherwise returns a new pointer
Parameters
pixelFormatFormat to reinterpret as. Note some RenderSystems (D3D11, Metal) may severely restrict or ignore this parameter.
Returns
A TexBufferPacked to be used to bind to the different stages. Do not destroy this buffer via VaoManager::destroyTexBuffer. See UavBufferPacked::destroyTexBufferView

◆ getBufferInterface()

BufferInterface* Ogre::BufferPacked::getBufferInterface ( ) const
inlineinherited

◆ getBufferPackedType()

BufferPackedTypes Ogre::UavBufferPacked::getBufferPackedType ( ) const
inlineoverridevirtualinherited

Useful to query which one is the derived class.

Implements Ogre::BufferPacked.

References Ogre::BP_TYPE_UAV.

◆ getBufferType()

BufferType Ogre::BufferPacked::getBufferType ( ) const
inlineinherited

◆ getBytesPerElement()

size_t Ogre::BufferPacked::getBytesPerElement ( ) const
inlineinherited

◆ getMappingState()

MappingState Ogre::BufferPacked::getMappingState ( ) const
inlineinherited

Returns the mapping state.

Note that if you call map with MS_PERSISTENT_INCOHERENT or MS_PERSISTENT_COHERENT, then call unmap( UO_KEEP_PERSISTENT ); the returned value will still be MS_PERSISTENT_INCOHERENT/_COHERENT when persistent mapping is supported. This differs from isCurrentlyMapped

◆ getNumElements()

size_t Ogre::BufferPacked::getNumElements ( ) const
inlineinherited

◆ getOriginalBufferType()

virtual BufferPacked* Ogre::BufferPacked::getOriginalBufferType ( )
virtualinherited

If this buffer has been reinterpreted from an UavBufferPacked, returns the original version, otherwise returns 'this'.

◆ getShadowCopy()

const void* Ogre::BufferPacked::getShadowCopy ( ) const
inlineinherited

◆ getTotalSizeBytes()

size_t Ogre::BufferPacked::getTotalSizeBytes ( ) const
inlineinherited

◆ isCurrentlyMapped()

bool Ogre::BufferPacked::isCurrentlyMapped ( ) const
inherited

Returns whether the buffer is currently mapped.

If you've persistently mapped the buffer and then called unmap( UO_KEEP_PERSISTENT ); this function will return false; which differs from getMappingState's behavior.

◆ isTextureGpu()

virtual bool Ogre::GpuTrackedResource::isTextureGpu ( ) const
inlinevirtualinherited

Reimplemented in Ogre::TextureGpu.

◆ map()

void* RESTRICT_ALIAS_RETURN Ogre::BufferPacked::map ( size_t  elementStart,
size_t  elementCount,
bool  bAdvanceFrame = true 
)
inherited

Maps the specified region to a pointer the CPU can access.

Only dynamic buffers can use this function. The region [elementStart; elementStart + elementCount) will be mapped.

Remarks
You can only map once per frame, regardless of parameters (except for advanceFrame). map( 0, 1 ) followed by map( 1, 1 ); is invalid. If you plan modifying elements 0 and 1; you should call map( 0, 2 )
Note that even if you use persistent mapping, you still need to call
See also
unmap.
Parameters
elementStartStart of the region to be mapped, in elements. Normally you want this to be 0.
elementCountLength of the region to map, in elements.
See also
getNumElements to map the whole range. Can't be 0.
Parameters
bAdvanceFrameWhen true, the Buffer will be usable after unmapping it (or earlier if persistent mapped). However you won't be able to call map() again until the next frame. Calling this with false allows to call map multiple times. However ater calling unmap, you must call advanceFrame. THIS IS ONLY FOR VERY ADVANCED USERS.

◆ operator delete() [1/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

◆ operator delete() [2/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator delete() [3/3]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

◆ operator delete[]() [1/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

◆ operator delete[]() [2/2]

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

◆ operator new() [1/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

◆ operator new() [2/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

◆ operator new() [3/3]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

◆ operator new[]() [1/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

◆ operator new[]() [2/2]

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

◆ readRequest()

AsyncTicketPtr Ogre::BufferPacked::readRequest ( size_t  elementStart,
size_t  elementCount 
)
inherited

Async data read request.

A ticket will be returned. Once the async transfer finishes, you can use the ticket to read the data from CPU. @See AsyncTicket

◆ regressFrame()

void Ogre::BufferPacked::regressFrame ( )
inherited

Performs the opposite of.

See also
advanceFrame. Only call this after having called advanceFrame. i.e. restore the buffer to the state it was before calling advanceFrame.

◆ unmap()

void Ogre::BufferPacked::unmap ( UnmapOptions  unmapOption,
size_t  flushStartElem = 0,
size_t  flushSizeElem = 0 
)
inherited

Unmaps or flushes the region mapped with.

See also
map. Alternatively, you can flush a smaller region (i.e. you didn't know which regions you were to update when mapping, but now that you're done, you know). The region being flushed is [flushStart; flushStart + flushSize)
Parameters
unmapOptionWhen using persistent mapping, UO_KEEP_PERSISTENT will keep the map alive; but you will have to call map again to use it. This requirement allows Ogre to:
  1. Synchronize if needed (avoid mapping a region that is still in use)
  2. Emulate persistent mapping on Hardware/Drivers that don't support it.
flushStartElemIn elements, 0-based index (based on the mapped region) on where to start flushing from. Default is 0.
flushSizeElemThe length of the flushing region, which can't be bigger than 'elementCount' passed to
See also
map. When this value is 0, we flush until the end of the buffer starting from flushStartElem

◆ upload()

virtual void Ogre::BufferPacked::upload ( const void *  data,
size_t  elementStart,
size_t  elementCount 
)
virtualinherited

Sends the provided data to the GPU.

Parameters
dataThe data to transfer to the GPU. Caller is responsible for freeing the pointer. "data" starts at offset zero. i.e. dst[elementStart * mBytesPerElement] = data[0];
elementStartThe start region, usually zero.
elementCountSize, in number of elements, of data. Must be less than @getNumElements - elementStart

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