Dynamically resizable buffer. More...
#include <DynamicBuffer.hpp>
Public Member Functions | |
DynamicBuffer (IRenderDevice *pDevice, const DynamicBufferCreateInfo &CreateInfo) | |
Initializes the dynamic buffer. | |
IBuffer * | Resize (IRenderDevice *pDevice, IDeviceContext *pContext, Uint64 NewSize, bool DiscardContent=false) |
Resizes the buffer to the new size. | |
IBuffer * | Update (IRenderDevice *pDevice, IDeviceContext *pContext) |
Updates the internal buffer object, initializing or resizing it if necessary. | |
IBuffer * | GetBuffer () const |
Returns a pointer to the buffer object. | |
bool | PendingUpdate () const |
const BufferDesc & | GetDesc () const |
Returns the buffer description. | |
Uint32 | GetVersion () const |
Returns the dynamic buffer version. | |
Uint64 | GetVirtualSize () const |
Returns the logical virtual size of the sparse buffer. | |
Dynamically resizable buffer.
Diligent::DynamicBuffer::DynamicBuffer | ( | IRenderDevice * | pDevice, |
const DynamicBufferCreateInfo & | CreateInfo ) |
Initializes the dynamic buffer.
[in] | pDevice | - Render device that will be used to create the buffer. This parameter may be null (see remarks). |
[in] | CreateInfo | - Create information, see Diligent::DynamicBufferCreateInfo. |
If pDevice
is null, internal buffer creation will be postponed until Update() or Resize() is called.
|
inline |
Returns a pointer to the buffer object.
If the buffer has not been initialized, the method returns null. If the buffer may need to be updated (resized or initialized), use the Update() method.
|
inline |
Returns the dynamic buffer version.
The version is incremented every time a new internal buffer is created.
|
inline |
Returns the logical virtual size of the sparse buffer.
The actual size of the sparse buffer may be larger than the logical size due to alignment requirements. Use GetBuffer()->GetDesc().Size to get the actual size.
|
inline |
Returns true if the buffer must be updated before use (e.g. it has been resized, but internal buffer has not been initialized or updated). When update is not pending, Update() may be called with null device and context.
IBuffer * Diligent::DynamicBuffer::Resize | ( | IRenderDevice * | pDevice, |
IDeviceContext * | pContext, | ||
Uint64 | NewSize, | ||
bool | DiscardContent = false ) |
Resizes the buffer to the new size.
[in] | pDevice | - Render device that will be used create the new internal buffer. This parameter may be null (see remarks). |
[in] | pContext | - Device context that will be used to copy existing contents to the new buffer (for non-sparse buffer), or commit new memory pages (for sparse buffer). This parameter may be null (see remarks). |
[in] | NewSize | - New buffer size. Can be zero. |
[in] | DiscardContent | - Whether to discard previous buffer content. |
The method operation depends on which of pDevice
and pContext
parameters are not null:
pDevice
and pContext
are not null: the new internal buffer is created and existing contents is copied (for non-sparse buffer), or memory pages are committed (for sparse buffer). Update() may be called with both pDevice
and pContext
being null.pDevice
is not null, pContext
is null: internal buffer is created, but existing contents is not copied or memory is not committed. An application must provide non-null device context when calling Update().pDevice
and pContext
are null: internal buffer is not created. An application must provide non-null device and device context when calling Update().Typically pDevice and pContext should be null when the method is called from a worker thread.
If NewSize
is zero, internal buffer will be released.
IBuffer * Diligent::DynamicBuffer::Update | ( | IRenderDevice * | pDevice, |
IDeviceContext * | pContext ) |
Updates the internal buffer object, initializing or resizing it if necessary.
[in] | pDevice | - Render device that will be used to create a new buffer, if necessary (see remarks). |
[in] | pContext | - Device context that will be used to copy existing buffer contents or commit memory pages, if necessary (see remarks). |
If the buffer has been resized, but internal buffer object has not been initialized, pDevice
and pContext
must not be null.
If buffer does not need to be updated (PendingUpdate() returns false), both pDevice
and pContext
may be null.