DrawWriter is a helper around recording draws (to a temporary buffer or directly to a CommandBuffer), particularly when the number of draws is not known ahead of time, or the vertex and instance data is computed at record time and does not have a known size.
To use, construct the DrawWriter with the current pipeline layout or call newPipelineState() on an existing DrawWriter and then bind that matching pipeline. When other dynamic state needs to change between draw calls, notify the DrawWriter using newDynamicState() before recording the modifications. See the listing below for how to append dynamic data or draw with existing buffers
CommandBuffer::draw(vertices)
- dynamic vertex data -> DrawWriter::Vertices(writer) verts; verts.append(n) << ...;
- fixed vertex data -> writer.draw(vertices, {}, vertexCount)
CommandBuffer::drawIndexed(vertices, indices)
- dynamic vertex data -> unsupported
- fixed vertex,index data -> writer.drawIndexed(vertices, indices, indexCount)
CommandBuffer::drawInstances(vertices, instances)
- dynamic instance data + fixed vertex data -> DrawWriter::Instances instances(writer, vertices, {}, vertexCount); instances.append(n) << ...;
- fixed vertex and instance data -> writer.drawInstanced(vertices, vertexCount, instances, instanceCount)
CommandBuffer::drawIndexedInstanced(vertices, indices, instances)
- dynamic instance data + fixed vertex, index data -> DrawWriter::Instances instances(writer, vertices, indices, indexCount); instances.append(n) << ...;
- fixed vertex, index, and instance data -> writer.drawIndexedInstanced(vertices, indices, indexCount, instances, instanceCount)
NOTE: DrawWriter automatically handles failures to find or create a GPU buffer or map it to be writable. All returned VertexWriters will have a non-null pointer to write to, even if it will be discarded due to GPU failure at Recorder::snap() time.
Definition at line 59 of file DrawWriter.h.