andy-thomason / Vookoo

A set of utilities for taking the pain out of Vulkan in header only modern C++
MIT License
522 stars 52 forks source link

Resize #28

Closed FunMiles closed 4 years ago

FunMiles commented 4 years ago

I added code to handle the resizing of the window. Note that handling the static case requires the use of a std::function as member of to be able to rebuild the pipeline and associated command buffer whenever the window size has changed.

lhog commented 4 years ago

Testing on Triangle example. This branch crashes for me on resize the same way as master:

00000008 debugCallback: vkCreateSwapchainKHR: internal drawable creation failed

FunMiles commented 4 years ago

What's your configuration? I just re-checked that code and it works on my Mac OS system. However on Linux it used to work before I updated the drivers and now it works for a few resizes, then ends up throwing a vk::DeviceLostError exception from a call to device_.waitForFence in recreate(). This kind of error is hard to debug.... I am not sure I can do it. My Linux drivers are NVidia drivers. I upgraded from Ubuntu 18.04 where the resizing worked to 20.04 where Vulkan did not work until I upgraded the NVidia drivers.

lhog commented 4 years ago

I'm on Windows 10 & NVidia. The exception is thrown inside https://github.com/andy-thomason/Vookoo/pull/28/files#diff-efabd6c7c523e51c9cbe77dc7aac8245R559

FunMiles commented 4 years ago

I'm not sure how debug this. Both your crash and mine are within the recreate() method. I've research how to debug vk::DeviceLostError and it is frankly hard to see how it will help here. The code never crashes if there is no resize, so tracking the crash with the NVidia system seems a bit pointless since it only allows to find out what goes on in commands sent to the queue. Yet all the command go through normally if there's no resize. I am trying it anyways, but so far no success in even linking the code once I try to call NVidia's debug commands....

lhog commented 4 years ago

FYI: I've also checked a fork of Sascha's examples made in vulkan c++ API https://github.com/jherico/Vulkan/blob/cpp/examples/triangle/triangle.cpp#L84-L92 Resizing worked fine there.

FunMiles commented 4 years ago

I think I will go back to Sascha's example and work from there. By the way, the triangle one can be resized many times without crash but at some random point it does. So make sure you resize a lot before concluding it works. The teapot seems to crash more reliably....

lhog commented 4 years ago

vookoo's crash is happening in 100% of cases. I'll stress Sascha's example more during the week.

lhog commented 4 years ago

Checked https://github.com/jherico/Vulkan/blob/cpp/examples/triangle/triangle.cpp#L84-L92 again. Resized it like 50 times. No crash, no validation warnings.

lhog commented 4 years ago

I think crash is gone if I do the following:

//swapinfo.oldSwapchain = vk::SwapchainKHR{};
swapinfo.oldSwapchain = *swapchain_;

@FunMiles can you check if this change doesn't break anything on your side?