From e8018ca0803ada19ca1b7b47e7772d4dd5b74f1d Mon Sep 17 00:00:00 2001 From: Alexander Gauggel <agauggel@uni-koblenz.de> Date: Thu, 17 Jun 2021 11:49:48 +0200 Subject: [PATCH] [#70] Pulled drawcall preparation out of render loop --- projects/voxelization/src/main.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/projects/voxelization/src/main.cpp b/projects/voxelization/src/main.cpp index f832dd3d..55522f5f 100644 --- a/projects/voxelization/src/main.cpp +++ b/projects/voxelization/src/main.cpp @@ -409,6 +409,20 @@ int main(int argc, const char** argv) { } } + // prepare drawcalls + std::vector<vkcv::DrawcallInfo> drawcalls; + std::vector<vkcv::DrawcallInfo> shadowDrawcalls; + std::vector<vkcv::DrawcallInfo> voxelizationDrawcalls; + for (int i = 0; i < scene.vertexGroups.size(); i++) { + vkcv::Mesh mesh(vertexBufferBindings[i], indexBuffers[i].getVulkanHandle(), scene.vertexGroups[i].numIndices); + + vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSets[i]).vulkanHandle); + + drawcalls.push_back(vkcv::DrawcallInfo(mesh, { descriptorUsage })); + shadowDrawcalls.push_back(vkcv::DrawcallInfo(mesh, {})); + voxelizationDrawcalls.push_back(vkcv::DrawcallInfo(mesh, { voxelizationDescriptorUsage })); + } + auto start = std::chrono::system_clock::now(); const auto appStartTime = start; while (window.isWindowOpen()) { @@ -486,19 +500,6 @@ int main(int argc, const char** argv) { const glm::mat4 voxelizationView = glm::translate(glm::mat4(1.f), -voxelizationInfo.offset); const glm::mat4 voxelizationViewProjection = voxelizationProjection * voxelizationView; - std::vector<vkcv::DrawcallInfo> drawcalls; - std::vector<vkcv::DrawcallInfo> shadowDrawcalls; - std::vector<vkcv::DrawcallInfo> voxelizationDrawcalls; - for (int i = 0; i < scene.vertexGroups.size(); i++) { - vkcv::Mesh mesh(vertexBufferBindings[i], indexBuffers[i].getVulkanHandle(), scene.vertexGroups[i].numIndices); - - vkcv::DescriptorSetUsage descriptorUsage(0, core.getDescriptorSet(descriptorSets[i]).vulkanHandle); - - drawcalls.push_back(vkcv::DrawcallInfo(mesh, { descriptorUsage })); - shadowDrawcalls.push_back(vkcv::DrawcallInfo(mesh, {})); - voxelizationDrawcalls.push_back(vkcv::DrawcallInfo(mesh, { voxelizationDescriptorUsage })); - } - mainPassMatrices.clear(); mvpLight.clear(); voxelizationMatrices.clear(); -- GitLab