|
| CVertexBuffer (const char *name, const size_t vertexSize, const Renderer::Backend::IBuffer::Type type, const bool dynamic) |
|
| CVertexBuffer (const char *name, const size_t vertexSize, const Renderer::Backend::IBuffer::Type type, const bool dynamic, const size_t maximumBufferSize) |
|
| ~CVertexBuffer () |
|
void | UploadIfNeeded (Renderer::Backend::IDeviceCommandContext *deviceCommandContext) |
|
void | PrepareForRendering (VBChunk *chunk) |
| Make the vertex data available for the next usage. More...
|
|
void | UpdateChunkVertices (VBChunk *chunk, void *data) |
| Update vertex data for given chunk. Transfers the provided data to the actual OpenGL vertex buffer. More...
|
|
size_t | GetVertexSize () const |
|
size_t | GetBytesReserved () const |
|
size_t | GetBytesAllocated () const |
|
bool | CompatibleVertexType (const size_t vertexSize, const Renderer::Backend::IBuffer::Type type, const bool dynamic) const |
| Returns true if this vertex buffer is compatible with the specified vertex type and intended usage. More...
|
|
void | DumpStatus () const |
|
Renderer::Backend::IBuffer * | GetBuffer () |
|
CVertexBuffer: encapsulation of backend buffers, also supplying some additional functionality for sharing buffers between multiple objects.
The class can be used in two modes, depending on the usage parameter:
Static buffer: Call Allocate() with backingStore = nullptr. Then call UpdateChunkVertices() with any pointer - the data will be immediately copied to the buffer. This should be used for vertex data that rarely changes.
Dynamic buffer: Call Allocate() with backingStore pointing at some memory that will remain valid for the lifetime of the CVertexBuffer. This should be used for vertex data that may change every frame. Rendering is expected to occur in two phases:
- "Prepare" phase: If this chunk is going to be used for rendering during the next rendering phase, you must call PrepareForRendering(). If the vertex data in backingStore has been modified since the last uploading phase, you must call UpdateChunkVertices().
- "Upload" phase: UploadedIfNeeded() can be called (multiple times). The vertex data will be uploaded to the GPU if necessary. It is okay to have multiple prepare/upload cycles per frame (though slightly less efficient), but they must occur sequentially.
bool CVertexBuffer::UseStreaming |
( |
const bool |
dynamic | ) |
|
|
static |
Given the usage flags of a buffer that has been (or will be) allocated:
If true, we assume the buffer is going to be modified on every frame, so we will re-upload the entire buffer every frame using glMapBuffer. This requires the buffer's owner to hold onto its backing store.
If false, we assume it will change rarely, and use direct upload to update it incrementally. The backing store can be freed to save memory.