Commit d9e364cf by Alexis Hetu Committed by Alexis Hétu

Support for instanceCount, firstVertex and firstInstance in Draw

The simple Draw command now supports all of the input parameters. Bug b/118619338 Change-Id: I51c3680dcc6497296e00000ad3e80f302629af3c Reviewed-on: https://swiftshader-review.googlesource.com/c/24049Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 85bd613c
......@@ -140,7 +140,8 @@ struct VertexBufferBind : public CommandBuffer::Command
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)
{
}
......@@ -154,7 +155,7 @@ struct Draw : public CommandBuffer::Command
{
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);
......@@ -162,10 +163,19 @@ struct Draw : public CommandBuffer::Command
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
......@@ -737,12 +747,7 @@ void CommandBuffer::waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPi
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment