void ste_presentation_surface::present(std::uint32_t image_index, const vk::vk_queue<> &presentation_queue, const semaphore &wait_semaphore) { VkSwapchainKHR swapchain = *swap_chain; VkSemaphore semaphore_handle = wait_semaphore; VkPresentInfoKHR info = {}; info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; info.pNext = nullptr; info.waitSemaphoreCount = 1; info.pWaitSemaphores = &semaphore_handle; info.swapchainCount = 1; info.pSwapchains = &swapchain; info.pImageIndices = &image_index; info.pResults = nullptr; // Host wait for semaphore wait_semaphore.wait_host(); vk::vk_result res; { // std::unique_lock<std::mutex> l(shared_data.swap_chain_guard); res = vkQueuePresentKHR(presentation_queue, &info); } // Raise flag to recreate swap-chain if (res != VK_SUCCESS) shared_data.swap_chain_optimal_flag.clear(std::memory_order_release); if (res != VK_SUCCESS && res != VK_SUBOPTIMAL_KHR && res != VK_ERROR_OUT_OF_DATE_KHR) { throw vk::vk_exception(res); } }