Skip to content
Snippets Groups Projects
Commit e0be4db1 authored by Patric Schmitz's avatar Patric Schmitz
Browse files

transition from volk to vulkan-hpp dynamic dispatcher

parent 218938cd
No related branches found
No related tags found
No related merge requests found
......@@ -141,15 +141,25 @@ DisplayWindow::Frame DisplayWindow::startFrame() {
assert(mChain && "You need to provide a handler for swapchain creation.");
while (true) {
auto res = vkAcquireNextImageKHR(mDevice->handle(), mChain, 1e9,
mImageReady, {}, &mPresentIndex);
if (res == VK_TIMEOUT) {
lava::error()
<< "GlfwWindow::startFrame(): acquireNextImage timed out (>1s)";
// TODO: count retries, risk of infinite loop!
// TODO: consolidate into abstract window base class? -> GlfwWindow
try {
auto result = mDevice->handle().acquireNextImageKHR(mChain, 1e9, mImageReady, {});
if(result.result == vk::Result::eTimeout ||
result.result == vk::Result::eNotReady) {
lava::error() << "GlfwWindow::startFrame(): acquireNextImage timed out (>1s)";
continue;
}
if(result.result == vk::Result::eSuboptimalKHR) {
mDevice->handle().waitIdle();
buildSwapchain();
continue;
}
if (res == VK_ERROR_OUT_OF_DATE_KHR || res == VK_SUBOPTIMAL_KHR) {
mPresentIndex = result.value;
}
catch(vk::OutOfDateKHRError) {
mDevice->handle().waitIdle();
buildSwapchain();
continue;
......@@ -174,19 +184,12 @@ DisplayWindow::Frame::~Frame() {
info.pWaitSemaphores = &window->mRenderingComplete;
info.waitSemaphoreCount = 1;
auto result = vkQueuePresentKHR(window->mQueue->handle(), (VkPresentInfoKHR*)&info);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
auto result = window->mQueue->handle().presentKHR(info);
if (result == vk::Result::eErrorOutOfDateKHR) {
std::cout << "DisplayWindow: Rebuilding swapchain" << std::endl;
window->mDevice->handle().waitIdle();
window->buildSwapchain();
}
//try {
// window->mQueue->handle().presentKHR(info);
//} catch (vk::OutOfDateKHRError const &) {
// window->mDevice->handle().waitIdle();
// window->buildSwapchain();
//}
}
DisplayWindow::Frame::Frame(DisplayWindow *parent) : window(parent) {}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment