vkCmdDraw implementation
Piped all the information from the vertex buffers and
the pipeline to the renderer to perform a draw.
In order for the renderer and the context to have proper
lifetimes, they both reside in the Queue object for now.
Bug b/118619338
Change-Id: Ifa03acd13ceb065a856b50f2cffadd4ee6b9a163
Reviewed-on: https://swiftshader-review.googlesource.com/c/23111
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkCommandBuffer.cpp b/src/Vulkan/VkCommandBuffer.cpp
index d2a50af..6be7df8 100644
--- a/src/Vulkan/VkCommandBuffer.cpp
+++ b/src/Vulkan/VkCommandBuffer.cpp
@@ -13,9 +13,12 @@
// limitations under the License.
#include "VkCommandBuffer.hpp"
+#include "VkBuffer.hpp"
#include "VkFramebuffer.hpp"
#include "VkImage.hpp"
+#include "VkPipeline.hpp"
#include "VkRenderpass.hpp"
+#include "Device/Renderer.hpp"
#include <cstring>
@@ -123,7 +126,23 @@
void play(CommandBuffer::ExecutionState& executionState)
{
- UNIMPLEMENTED();
+ GraphicsPipeline* pipeline = static_cast<GraphicsPipeline*>(
+ Cast(executionState.pipelines[VK_PIPELINE_BIND_POINT_GRAPHICS]));
+
+ sw::Context context = pipeline->getContext();
+ for(uint32_t i = 0; i < MAX_VERTEX_INPUT_BINDINGS; i++)
+ {
+ const auto& vertexInput = executionState.vertexInputBindings[i];
+ Buffer* buffer = Cast(vertexInput.buffer);
+ context.input[i].buffer = buffer ? buffer->map(vertexInput.offset) : nullptr;
+ }
+
+ executionState.renderer->setContext(context);
+ executionState.renderer->setScissor(pipeline->getScissor());
+ executionState.renderer->setViewport(pipeline->getViewport());
+ executionState.renderer->setBlendConstant(pipeline->getBlendConstants());
+
+ executionState.renderer->draw(context.drawType, 0, pipeline->computePrimitiveCount(vertexCount));
}
uint32_t vertexCount;