void EndFrame()
{
auto swapchain = mGraphics.GetSwapchainForFBID( 0u );
+
+ // execute as secondary buffers
+ swapchain->GetPrimaryCommandBuffer()
+ ->ExecuteCommands( mSecondaryCommandBufferRefs );
+
swapchain->Present();
+ mSecondaryCommandBufferRefs.clear();
}
API::TextureFactory& GetTextureFactory() const
mBufferTransferRequests.clear();
}
- std::vector<Vulkan::RefCountedCommandBuffer> cmdBufRefs{};
-
// Prepare pipelines
for( auto&& command : commands )
{
drawCommand.firstInstance);
}
cmdbuf->End();
- cmdBufRefs.emplace_back( cmdbuf );
+ mSecondaryCommandBufferRefs.emplace_back( cmdbuf );
}
- // execute as secondary buffers
- mGraphics.GetSwapchainForFBID(0)->GetPrimaryCommandBuffer()
- ->ExecuteCommands( cmdBufRefs );
-
}
// resources
std::unique_ptr<VulkanAPI::UboManager> mUboManager;
+ // Accumulate all the secondary command buffers of the frame here to avoid them being overwritten
+ // This accumulator vector gets cleared at the end of the frame. The command buffers are returned to the pool
+ // and ready to be used for the next frame.
+ std::vector<Vulkan::RefCountedCommandBuffer> mSecondaryCommandBufferRefs;
+
};
// TODO: @todo temporarily ignore missing return type, will be fixed later
RefCountedSampler CreateSampler( const vk::SamplerCreateInfo& samplerCreateInfo );
public: // Actions
- vk::Result WaitForFence( RefCountedFence fence, uint32_t timeout = 0 );
+ vk::Result WaitForFence( RefCountedFence fence, uint32_t timeout = std::numeric_limits< uint32_t >::max() );
vk::Result WaitForFences( const std::vector< RefCountedFence >& fences,
bool waitAll = true,
.setFramebuffer(swapBuffer.framebuffer->GetVkHandle() )
.setRenderPass(swapBuffer.framebuffer->GetRenderPassVkHandle())
.setSubpass( 0 );
+
swapBuffer.masterCmdBuffer->Reset();
swapBuffer.masterCmdBuffer->Begin( vk::CommandBufferUsageFlagBits::eRenderPassContinue, &inheritanceInfo );
mGraphics.Submit( mQueue, { std::move(submissionData) } , swapBuffer.endOfFrameFence );
- mGraphics.WaitForFence(swapBuffer.endOfFrameFence);
+ mGraphics.WaitForFence( swapBuffer.endOfFrameFence );
// fixme: use semaphores to synchronize all previously submitted command buffers!
vk::PresentInfoKHR presentInfo{};
mGraphics.Present( mQueue, presentInfo );
- // just to speed things up :P
- mGraphics.QueueWaitIdle( mQueue );
-
mGraphics.CollectGarbage();
return true;