Skip to content
Snippets Groups Projects
Commit 73ebf0b4 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#105] add recordIndirectDrawcallsToCmdStream

parent 6bc54469
No related branches found
No related tags found
1 merge request!88Resolve "Indirect Draw"
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <vkcv/Handles.hpp> #include <vkcv/Handles.hpp>
#include <vkcv/DescriptorConfig.hpp> #include <vkcv/DescriptorConfig.hpp>
#include <vkcv/PushConstants.hpp> #include <vkcv/PushConstants.hpp>
#include "Buffer.hpp"
namespace vkcv { namespace vkcv {
struct VertexBufferBinding { struct VertexBufferBinding {
...@@ -55,6 +56,15 @@ namespace vkcv { ...@@ -55,6 +56,15 @@ namespace vkcv {
const PushConstants &pushConstants, const PushConstants &pushConstants,
const size_t drawcallIndex); const size_t drawcallIndex);
void recordIndirectDrawcall(
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
const vkcv::Buffer<vk::DrawIndexedIndirectCommand> &drawBuffer,
const uint32_t drawCount,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex);
void InitMeshShaderDrawFunctions(vk::Device device); void InitMeshShaderDrawFunctions(vk::Device device);
struct MeshShaderDrawcall { struct MeshShaderDrawcall {
......
...@@ -52,7 +52,49 @@ namespace vkcv { ...@@ -52,7 +52,49 @@ namespace vkcv {
} }
} }
void recordIndirectDrawcall(
const DrawcallInfo &drawcall,
vk::CommandBuffer cmdBuffer,
const Buffer <vk::DrawIndexedIndirectCommand> &drawBuffer,
const uint32_t drawCount,
vk::PipelineLayout pipelineLayout,
const PushConstants &pushConstants,
const size_t drawcallIndex) {
for (uint32_t i = 0; i < drawcall.mesh.vertexBufferBindings.size(); i++) {
const auto& vertexBinding = drawcall.mesh.vertexBufferBindings[i];
cmdBuffer.bindVertexBuffers(i, vertexBinding.buffer, vertexBinding.offset);
}
for (const auto& descriptorUsage : drawcall.descriptorSets) {
cmdBuffer.bindDescriptorSets(
vk::PipelineBindPoint::eGraphics,
pipelineLayout,
descriptorUsage.setLocation,
descriptorUsage.vulkanHandle,
nullptr);
}
if (pushConstants.getSizePerDrawcall() > 0) {
cmdBuffer.pushConstants(
pipelineLayout,
vk::ShaderStageFlagBits::eAll,
0,
pushConstants.getSizePerDrawcall(),
pushConstants.getDrawcallData(drawcallIndex));
}
if (drawcall.mesh.indexBuffer) {
cmdBuffer.bindIndexBuffer(drawcall.mesh.indexBuffer, 0, getIndexType(drawcall.mesh.indexBitCount));
cmdBuffer.drawIndexedIndirect(drawBuffer.getVulkanHandle(), 0, drawCount , sizeof(vk::DrawIndexedIndirectCommand) );
}
else {
cmdBuffer.drawIndirect(drawBuffer.getVulkanHandle(), 0, drawCount, sizeof(vk::DrawIndexedIndirectCommand) );
}
}
struct MeshShaderFunctions struct MeshShaderFunctions
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment