Home -> IVertexBuffer

Declaration

class IVertexBuffer;

Description

The IVertexBuffer interface represents a buffer containing a set of vertex attributes, suitable to be bound as vertex shader inputs. Vertex attributes are specified by binding VertexAttribute objects to the buffer through the BindVertexAttribute method, prior to calling the AllocateMemory method. Once the AllocateMemory method has been called, the layout and size of the buffer has been fixed, and cannot be changed. Multiple vertex attributes can be bound to the same buffer. Renderable objects can use any attributes from any set of buffers, there is no requirement that all vertex attributes for a single object must come from a single buffer.

ImportantImportant

Buffers may be created either in automatic or manual layout mode. Automatic layout buffers are free to allocate memory using whatever memory layout the renderer determines is optimal, and are easiest for applications to work with. Automatic layout buffers cannot be modified directly, instead the contents of the buffer are set and updated through the SetInitialData and QueueDataUpdate methods on the VertexAttribute objects which are bound to them. Manual layout buffers on the other hand require the application to explicitly specify starting location and stride of each attribute. With the layout explicitly defined however, applications are able to manually write to the buffer using the SetRawInitialData and QueueRawDataUpdate methods, potentially updating the contents of multiple attributes at once. Additionally, an alias of the buffer can be created using the AllocateMemoryWithAlias method, allowing the buffer to be directly written to in shaders, such as a compute shader. To allocate a buffer in automatic layout mode, attach attributes using the BindVertexAttribute method. To allocate a buffer in manual layout mode, attach attributes using the BindVertexAttributeManualLayout method. Unless you require the features provided by manual layout mode, it is recommended to use automatic layout buffers.

ImportantImportant

Note that a single vertex buffer does not necessarily correspond with a single block of allocated memory of the requested size in hardware. Renderers are free to manage physical memory allocation in any way they see fit, and may split or combine buffers, or create multiple buffers for purposes such as staging changes or swapping buffers between frames. From the application perspective, buffers should be defined that group sets of vertex attributes together that are logically related, and that are expected to be used together, and especially modified together or deleted together.

Members

Initialization methods

Name Description
Public member Delete
Schedules the object for deletion. After calling this method, the object will be destroyed after the current frame completes drawing.
Public member AllocateMemory
Attempts to allocate memory for the buffer using the supplied set of vertex attributes
Public member AllocateMemoryWithAlias
Attempts to allocate memory for the buffer, and alias it with an ITexelArray.

Binding methods

Name Description
Public member BindVertexAttribute
Binds the specified VertexAttribute as a member of the buffer
Public member BindVertexAttributeManualLayout
Binds the specified VertexAttribute as a member of the buffer, with a manually defined buffer offset and stride.

Data methods

Name Description
Public member SetRawInitialData
Allows initial data to be set directly for the buffer where manual layout attributes have been bound with the BindVertexAttributeManualLayout method.
Public member QueueRawDataUpdate
Allows data to be written directly to the buffer where manual layout attributes have been bound with the BindVertexAttributeManualLayout method.

See also