nicegraf
|
Data Fields | |
uint32_t | binding |
uint32_t | stride |
ngf_vertex_input_rate | input_rate |
Specifies a vertex buffer binding. A vertex buffer binding may be thought of as a slot to which a vertex attribute buffer can be bound. An ngf_graphics_pipeline may have several such slots, which are addressed by their indices. Vertex attribute buffers can be bound to these slots with ngf_cmd_bind_attrib_buffer. The binding also partly defines how the contents of the bound buffer is interpreted - via ngf_vertex_buf_binding_desc::stride and ngf_vertex_buf_binding_desc::input_rate
uint32_t ngf_vertex_buf_binding_desc::binding |
Index of the binding that this structure describes.
ngf_vertex_input_rate ngf_vertex_buf_binding_desc::input_rate |
Specifies whether attributes are read from the bound buffer per-vetex or per-instance.
uint32_t ngf_vertex_buf_binding_desc::stride |
Specifies the distance (in bytes) between the starting bytes of two consecutive attribute values.
As an example, assume the buffer contains data for a single attribute, such as the position of a vertex in three-dimensional space. Each component of the position is a 32-bit floating point number. The values are laid out in memory one after another:
In this case, the stride is 3*4 = 12 bytes - the distance from the beginning of the first attribute to the beginning of the next attribute is equal to the size of one attribute value.
Now consider a different case, where we have two attributes: a three-dimensional position and an RGB color, and the buffer first lists all the attribute values for the first vertex, then all attribute values for the second vertex and so on:
In this case, the position of the next vertex does not immediately follow the position previous one - there is the value of the color attribute in between. In this case, assuming the attribute components use a 32-bit floating point, the stride would have to be 3 * 4 + 3 * 4 = 24
bytes.