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) | (C) ---------+---------------------- 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. -
(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 GPU buffer, the given GpuBufferFlags will be taken into account by the implementation when it chooses a suitable ResourceAccessPattern. However, there is no guarantee that a specific set of buffer flags will yield a certain access pattern.
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 a buffer that cannot be locked (i.e. GpuBufferFlags.Update is not present) 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.