diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:46:11 +1100 |
---|---|---|
committer | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:46:11 +1100 |
commit | 693dfe8ed12d39d70c74223da370622feb3c0c78 (patch) | |
tree | 014566305a1134ae036e25c9d0e7c67d32967e62 /src | |
parent | d912f9ee62341538a2d351763c17d66301d48150 (diff) |
src/main.cpp: Implement queue semaphore syncronization
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index dbacb24..b62fd6c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,6 +50,9 @@ private: VDeleter<VkCommandPool> commandPool{device, vkDestroyCommandPool}; std::vector<VkCommandBuffer> commandBuffers; + VDeleter<VkSemaphore> imageAvailableSemaphore{device, vkDestroySemaphore}; + VDeleter<VkSemaphore> renderFinishedSemaphore{device, vkDestroySemaphore}; + struct QueueFamilyIndices { int graphicsFamily = -1; int presentFamily = -1; @@ -99,6 +102,16 @@ private: createFramebuffers(); createCommandPool(); createCommandBuffers(); + createSemaphores(); + } + + void createSemaphores() { + VkSemaphoreCreateInfo semaphoreInfo = {}; + semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; + + if (vkCreateSemaphore(device, &semaphoreInfo, nullptr, imageAvailableSemaphore.replace()) != VK_SUCCESS || + vkCreateSemaphore(device, &semaphoreInfo, nullptr, renderFinishedSemaphore.replace()) != VK_SUCCESS) + throw std::runtime_error("failed to create semaphores!"); } void createCommandPool() { @@ -593,6 +606,8 @@ private: drawFrame(); } + vkDeviceWaitIdle(device); + glfwDestroyWindow(window); } |