Commit 00ba176c by Chris Forbes

Factor out vertex attribute binding from Draw*::play

I'm about to build some more on top of this; don't want to write it multiple times. Change-Id: I9ca84536f47b886e9f03edcaa6dc5dfe6e34091d Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26688Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Presubmit-Ready: Chris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 5851ef46
......@@ -185,6 +185,21 @@ struct IndexBufferBind : public CommandBuffer::Command
const VkIndexType indexType;
};
void CommandBuffer::ExecutionState::bindVertexInputs(sw::Context& context, int firstVertex)
{
for(uint32_t i = 0; i < MAX_VERTEX_INPUT_BINDINGS; i++)
{
auto &attrib = context.input[i];
if (attrib.count)
{
const auto &vertexInput = vertexInputBindings[attrib.binding];
Buffer *buffer = Cast(vertexInput.buffer);
attrib.buffer = buffer ? buffer->getOffsetPointer(
attrib.offset + vertexInput.offset + attrib.stride * firstVertex) : nullptr;
}
}
}
void CommandBuffer::ExecutionState::bindAttachments()
{
// Binds all the attachments for the current subpass
......@@ -230,17 +245,7 @@ struct Draw : public CommandBuffer::Command
executionState.pipelines[VK_PIPELINE_BIND_POINT_GRAPHICS]);
sw::Context context = pipeline->getContext();
for(uint32_t i = 0; i < MAX_VERTEX_INPUT_BINDINGS; i++)
{
auto &attrib = context.input[i];
if (attrib.count)
{
const auto &vertexInput = executionState.vertexInputBindings[attrib.binding];
Buffer *buffer = Cast(vertexInput.buffer);
attrib.buffer = buffer ? buffer->getOffsetPointer(
attrib.offset + vertexInput.offset + attrib.stride * firstVertex) : nullptr;
}
}
executionState.bindVertexInputs(context, firstVertex);
context.pushConstants = executionState.pushConstants;
......@@ -279,17 +284,7 @@ struct DrawIndexed : public CommandBuffer::Command
executionState.pipelines[VK_PIPELINE_BIND_POINT_GRAPHICS]);
sw::Context context = pipeline->getContext();
for(uint32_t i = 0; i < MAX_VERTEX_INPUT_BINDINGS; i++)
{
auto &attrib = context.input[i];
if (attrib.count)
{
const auto &vertexInput = executionState.vertexInputBindings[attrib.binding];
Buffer *buffer = Cast(vertexInput.buffer);
attrib.buffer = buffer ? buffer->getOffsetPointer(
attrib.offset + vertexInput.offset + attrib.stride * vertexOffset) : nullptr;
}
}
executionState.bindVertexInputs(context, vertexOffset);
context.pushConstants = executionState.pushConstants;
......
......@@ -23,6 +23,7 @@
namespace sw
{
class Context;
class Renderer;
}
......@@ -139,6 +140,7 @@ public:
VkIndexType indexType;
void bindAttachments();
void bindVertexInputs(sw::Context& context, int firstVertex);
};
void submit(CommandBuffer::ExecutionState& executionState);
......
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