instancedVertexLayout property

  1. @override
VertexLayoutDescriptor? get instancedVertexLayout

The explicit pipeline vertex layout this geometry's vertex shader expects, or null for the shader bundle's default interleaved layout.

A non-null layout signals the encoders that the shader consumes the model transform from the instance-rate vertex buffer (slot 1) rather than a per-draw uniform, so every draw must bind an instance buffer.

Implementation

@override
VertexLayoutDescriptor? get instancedVertexLayout {
  final base = _isDeInterleaved
      ? kUnskinnedSoAColorLayout
      : kUnskinnedInstancedLayout;
  if (!hasCustomAttributes) return base;
  // Splice the custom attribute buffers in before the trailing instance-rate
  // model-transform buffer, so their slots follow the built-in streams and
  // the instance buffer stays at the last slot (vertexStreamCount).
  return VertexLayoutDescriptor(
    buffers: [
      ...base.buffers.sublist(0, base.buffers.length - 1),
      ...customAttributeBuffers,
      base.buffers.last,
    ],
  );
}