bindVertexBuffer method
- BufferView bufferView, {
- int slot = 0,
Binds bufferView as the vertex buffer at the given slot.
slot selects which vertex-buffer binding the data appears at,
matching the corresponding VertexBuffer declared on the active
pipeline's VertexLayout. The default of 0 matches the default
layout declared by a shader bundle, which is what every single-buffer
call site expects. To bind multiple structure-of-arrays vertex
buffers, call this method once per slot.
The number of vertices to draw is passed separately, to draw.
Sparse bindings are not supported. Every slot in [0, highestBound]
must have been bound before draw or drawIndexed is called,
otherwise they throw a StateError naming the unbound slots. Slots
can be bound in any order.
slot must be in [0, 16) (the current Flutter GPU limit for vertex
buffer bindings). Some devices may also impose a lower limit on the
total number of vertex attributes used by a single pipeline.
Implementation
void bindVertexBuffer(BufferView bufferView, {int slot = 0}) {
if (slot < 0 || slot >= _kMaxVertexBufferSlots) {
throw RangeError.range(
slot,
0,
_kMaxVertexBufferSlots - 1,
'slot',
'bindVertexBuffer slot must be in [0, $_kMaxVertexBufferSlots)',
);
}
_boundVertexSlotsMask |= 1 << slot;
if (slot > _maxBoundVertexSlot) {
_maxBoundVertexSlot = slot;
}
bufferView.buffer._bindAsVertexBuffer(
this,
bufferView.offsetInBytes,
bufferView.lengthInBytes,
slot,
);
}