diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 131ed456..fc3da95b 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -485,6 +485,8 @@ VulkanExampleBase::~VulkanExampleBase() vkDestroyCommandPool(device, cmdPool, nullptr); + vkDestroySemaphore(device, presentCompleteSemaphore, nullptr); + vkDestroyDevice(device, nullptr); if (enableValidation) @@ -570,6 +572,11 @@ void VulkanExampleBase::initVulkan(bool enableValidation) assert(validDepthFormat); swapChain.connect(instance, physicalDevice, device); + + // Create a semaphore used to synchronize image presentation + VkSemaphoreCreateInfo presentCompleteSemaphoreCreateInfo = vkTools::initializers::semaphoreCreateInfo(); + err = vkCreateSemaphore(device, &presentCompleteSemaphoreCreateInfo, nullptr, &presentCompleteSemaphore); + assert(!err); } #ifdef _WIN32 diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 2707868f..80fa4ab0 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -88,6 +88,8 @@ protected: VkPipelineCache pipelineCache; // Wraps the swap chain to present images (framebuffers) to the windowing system VulkanSwapChain swapChain; + // Semaphore to synchronize image presentation + VkSemaphore presentCompleteSemaphore; // Simple texture loader vkTools::VulkanTextureLoader *textureLoader = nullptr; public: