struct Draw : public CommandBuffer::Command
{
- Draw(uint32_t pVertexCount) : vertexCount(pVertexCount)
+ Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
+ : vertexCount(vertexCount), instanceCount(instanceCount), firstVertex(firstVertex), firstInstance(firstInstance)
{
}
{
const auto& vertexInput = executionState.vertexInputBindings[i];
Buffer* buffer = Cast(vertexInput.buffer);
- context.input[i].buffer = buffer ? buffer->getOffsetPointer(vertexInput.offset) : nullptr;
+ context.input[i].buffer = buffer ? buffer->getOffsetPointer(vertexInput.offset + context.input[i].stride * firstVertex) : nullptr;
}
executionState.renderer->setContext(context);
executionState.renderer->setViewport(pipeline->getViewport());
executionState.renderer->setBlendConstant(pipeline->getBlendConstants());
- executionState.renderer->draw(context.drawType, 0, pipeline->computePrimitiveCount(vertexCount));
+ const uint32_t primitiveCount = pipeline->computePrimitiveCount(vertexCount);
+ const uint32_t lastInstance = firstInstance + instanceCount - 1;
+ for(uint32_t instance = firstInstance; instance <= lastInstance; instance++)
+ {
+ executionState.renderer->setInstanceID(instance);
+ executionState.renderer->draw(context.drawType, 0, primitiveCount);
+ }
}
uint32_t vertexCount;
+ uint32_t instanceCount;
+ uint32_t firstVertex;
+ uint32_t firstInstance;
};
struct ImageToImageCopy : public CommandBuffer::Command
void CommandBuffer::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
{
- if(instanceCount > 1 || firstVertex != 0 || firstInstance != 0)
- {
- UNIMPLEMENTED();
- }
-
- addCommand<Draw>(vertexCount);
+ addCommand<Draw>(vertexCount, instanceCount, firstVertex, firstInstance);
}
void CommandBuffer::drawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)