IGpuBuffer
Description
- Derived from
- Extended by
-
GpuBufferBase abstract
IIndexBuffer
IVertexBuffer
A GPU buffer, storing elements of fixed size, typically stored in high-performance memory.
Buffer data is written in binary form, usually in a structured format (for example, a vertex buffer). A buffer may have an element size of zero (see ElementSize). In this case, the buffer has an undefined structure and is used as a raw byte buffer. The behaviour of buffer updates depends on the ResourceAccessPattern of the buffer and the used GpuUpdateFlag:
| Discard | NoOverwrite ---------+---------+------------ Static | - | - ---------+---------+------------ Dynamic | (A) | (A) ---------+---------------------- Mappable | (B) | (C)
Buffer updates behave like this:
-
(A)
Only the content in the update region is discarded. All other content remains valid. -
(B)
The whole content is discarded and must be specified again subsequently. -
(C)
The existing content remains valid and may be updated without stalling the GPU. However, the application must ensure that no data gets updated while the GPU is still using it.
When creating a non-static GPU buffer, the specified GpuBufferFlags fully determine the ResourceAccessPattern:
-
If GpuBufferFlags.Map is present, the resource access pattern will be ResourceAccessPattern.Mappable.
-
Otherwise, the resource access pattern will be ResourceAccessPattern.Dynamic.
Static GPU buffers are immutable and always have the resource access pattern ResourceAccessPattern.Static.
Public / Methods
BufferMap
Maps a region of this buffer for writing.
This is the preferred way of updating a GPU buffer with ResourceAccessPattern.Mappable access.
This method can also be used on GPU buffers with ResourceAccessPattern.Dynamic access. In this case, the implementing class will transparently map the API calls to BufferUpdate, doing one call per consecutive run of prepared buffer ranges, see BufferPrepare.
- See also
BufferPrepare
Prepares the buffer that has been returned by BufferMap for writing to a range of elements resp. bytes.
This method may only be called between calls to BufferMap and BufferUnmap.
- See also
BufferUnmap
Unmaps a this buffer.
Calling BufferUnmap on an immutable buffer or without a prior call to BufferMap does not have any effect, the method just returns silently.
- See also
BufferUpdate
Updates a range of elements in the buffer.
To prevent an overflow in the GPU buffer, the given data will be truncated by reducing the count in parameter, if necessary. The calling code is responsible for preventing a buffer underflow of values in.
This is the preferred way of updating a GPU buffer with ResourceAccessPattern.Dynamic access.
This method can also be used on GPU buffers with ResourceAccessPattern.Mappable access. In this case, the implementing class will transparently map the API calls to BufferMap, BufferPrepare and BufferUnmap.
- See also
BufferUpdateArray
Updates a range of 32-bit integer values in the buffer.
This method assumes that this buffer has an element size of 4 bytes. If the buffer has a different element size, it will return silently. This method is usually used in conjunction with IIndexBuffers, which always have an element size of 4 bytes.
To prevent an overflow in the GPU buffer, the given data will be truncated by reducing the count in parameter, if necessary. The calling code is responsible for preventing a buffer underflow of values in.
This is the preferred way of updating a GPU buffer with ResourceAccessPattern.Dynamic access.
This method can also be used on GPU buffers with ResourceAccessPattern.Mappable access. In this case, the implementing class will transparently map the API calls to BufferMap, BufferPrepare and BufferUnmap.