diff options
author | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:47:00 +1100 |
---|---|---|
committer | Edward O'Callaghan <funfunctor@folklore1984.net> | 2017-02-08 01:47:17 +1100 |
commit | c14249b2bcb0ef901e5e9d7ea98816e8555048ce (patch) | |
tree | cea856d8ac8bbc43892ee8477093d1ce55fd0a01 /src | |
parent | 693dfe8ed12d39d70c74223da370622feb3c0c78 (diff) |
The freaking Triangle works now !!!
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index b62fd6c..1166cfd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -612,7 +612,43 @@ private: } void drawFrame() { - // XXX workout syncronization + uint32_t imageIndex; + vkAcquireNextImageKHR(device, swapChain, std::numeric_limits<uint64_t>::max(), + imageAvailableSemaphore, VK_NULL_HANDLE, &imageIndex); + + VkSubmitInfo submitInfo = {}; + submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + + VkSemaphore waitSemaphores[] = {imageAvailableSemaphore}; + VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT}; + + submitInfo.waitSemaphoreCount = 1; + submitInfo.pWaitSemaphores = waitSemaphores; + submitInfo.pWaitDstStageMask = waitStages; + + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &commandBuffers[imageIndex]; + + VkSemaphore signalSemaphores[] = {renderFinishedSemaphore}; + submitInfo.signalSemaphoreCount = 1; + submitInfo.pSignalSemaphores = signalSemaphores; + + if (vkQueueSubmit(graphicsQueue, 1, &submitInfo, VK_NULL_HANDLE) != VK_SUCCESS) + throw std::runtime_error("failed to submit draw command buffer!"); + + VkPresentInfoKHR presentInfo = {}; + presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; + + presentInfo.waitSemaphoreCount = 1; + presentInfo.pWaitSemaphores = signalSemaphores; + + VkSwapchainKHR swapChains[] = {swapChain}; + presentInfo.swapchainCount =1; + presentInfo.pSwapchains = swapChains; + + presentInfo.pImageIndices = &imageIndex; + + vkQueuePresentKHR(presentQueue, &presentInfo); } void createInstance() { |