Base class wait fences

This commit is contained in:
saschawillems 2018-06-03 09:38:14 +02:00
parent a911f0e785
commit 19afba3f71
2 changed files with 17 additions and 0 deletions

View file

@ -188,6 +188,7 @@ void VulkanExampleBase::prepare()
createCommandPool();
setupSwapChain();
createCommandBuffers();
createSynchronizationPrimitives();
setupDepthStencil();
setupRenderPass();
createPipelineCache();
@ -798,6 +799,9 @@ VulkanExampleBase::~VulkanExampleBase()
vkDestroySemaphore(device, semaphores.presentComplete, nullptr);
vkDestroySemaphore(device, semaphores.renderComplete, nullptr);
vkDestroySemaphore(device, semaphores.overlayComplete, nullptr);
for (auto& fence : waitFences) {
vkDestroyFence(device, fence, nullptr);
}
if (UIOverlay) {
delete UIOverlay;
@ -1956,6 +1960,16 @@ void VulkanExampleBase::mouseMoved(double x, double y, bool & handled) {}
void VulkanExampleBase::buildCommandBuffers() {}
void VulkanExampleBase::createSynchronizationPrimitives()
{
// Wait fences to sync command buffer access
VkFenceCreateInfo fenceCreateInfo = vks::initializers::fenceCreateInfo(VK_FENCE_CREATE_SIGNALED_BIT);
waitFences.resize(drawCmdBuffers.size());
for (auto& fence : waitFences) {
VK_CHECK_RESULT(vkCreateFence(device, &fenceCreateInfo, nullptr, &fence));
}
}
void VulkanExampleBase::createCommandPool()
{
VkCommandPoolCreateInfo cmdPoolInfo = {};