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

[#105] change project to indirect draw

parent 8b1633d4
No related branches found
No related tags found
1 merge request!88Resolve "Indirect Draw"
Pipeline #26679 failed
...@@ -19,7 +19,7 @@ void addMeshToIdirectDraw(const std::vector<vkcv::asset::VertexGroup>& meshes, s ...@@ -19,7 +19,7 @@ void addMeshToIdirectDraw(const std::vector<vkcv::asset::VertexGroup>& meshes, s
} }
} }
int main(int argc, const char** argv) { int main(int argc, const char** argv) {
const char* applicationName = "First Mesh"; const char* applicationName = "Indirect draw";
uint32_t windowWidth = 800; uint32_t windowWidth = 800;
uint32_t windowHeight = 600; uint32_t windowHeight = 600;
...@@ -28,7 +28,7 @@ int main(int argc, const char** argv) { ...@@ -28,7 +28,7 @@ int main(int argc, const char** argv) {
applicationName, applicationName,
windowWidth, windowWidth,
windowHeight, windowHeight,
true false
); );
vkcv::Core core = vkcv::Core::create( vkcv::Core core = vkcv::Core::create(
...@@ -61,6 +61,14 @@ int main(int argc, const char** argv) { ...@@ -61,6 +61,14 @@ int main(int argc, const char** argv) {
vertexBuffer.fill(mesh.vertexGroups[0].vertexBuffer.data); vertexBuffer.fill(mesh.vertexGroups[0].vertexBuffer.data);
std::vector<vk::DrawIndexedIndirectCommand> indexedIndirectCommands;
addMeshToIdirectDraw(mesh.vertexGroups, indexedIndirectCommands);
vkcv::Buffer<vk::DrawIndexedIndirectCommand> indirectBuffer = core.createBuffer<vk::DrawIndexedIndirectCommand>(vkcv::BufferType::INDIRECT, indexedIndirectCommands.size() * sizeof(vk::DrawIndexedIndirectCommand), vkcv::BufferMemoryType::DEVICE_LOCAL);
indirectBuffer.fill(indexedIndirectCommands);
auto indexBuffer = core.createBuffer<uint8_t>( auto indexBuffer = core.createBuffer<uint8_t>(
vkcv::BufferType::INDEX, vkcv::BufferType::INDEX,
mesh.vertexGroups[0].indexBuffer.data.size(), mesh.vertexGroups[0].indexBuffer.data.size(),
...@@ -215,13 +223,15 @@ int main(int argc, const char** argv) { ...@@ -215,13 +223,15 @@ int main(int argc, const char** argv) {
const std::vector<vkcv::ImageHandle> renderTargets = { swapchainInput, depthBuffer }; const std::vector<vkcv::ImageHandle> renderTargets = { swapchainInput, depthBuffer };
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics); auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
core.recordDrawcallsToCmdStream( core.recordIndirectDrawcallsToCmdStream(
cmdStream, cmdStream,
firstMeshPass, firstMeshPass,
firstMeshPipeline, firstMeshPipeline,
pushConstants, pushConstants,
{ drawcall }, { drawcall },
renderTargets); renderTargets,
indirectBuffer,
indexedIndirectCommands.size());
core.prepareSwapchainImageForPresent(cmdStream); core.prepareSwapchainImageForPresent(cmdStream);
core.submitCommandStream(cmdStream); core.submitCommandStream(cmdStream);
core.endFrame(); core.endFrame();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment