Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.12k stars 513 forks source link

Window Resizing Results In Extent Out Of Bounds #186

Closed RussellHolgate closed 2 years ago

RussellHolgate commented 4 years ago

In Manjaro Linux using X11, in "16_swap_chain_recreation.cpp", resizing the window always results in a validation error:

Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 ] Object 0: handle = 0x5600db3ec300, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x7cd0911d | vkCreateSwapchainKHR() called with imageExtent = (746,547), which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (745,546), minImageExtent = (745,546), maxImageExtent = (745,546). The Vulkan spec states: imageExtent must be between minImageExtent and maxImageExtent, inclusive, where minImageExtent and maxImageExtent are members of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageExtent-01274)

My best guess is this is a thread issue. I've tried modifying the code to add a frame limit which resulted in receiving this error only half of the time instead of every time. I also tried replacing GLFW with SDL2 but results were the same.

Overv commented 4 years ago

I cannot reproduce this on Arch & X11 with the latest SDK version (1.2.140) and an NVIDIA GTX 1070.

RussellHolgate commented 4 years ago

The issue doesn't happen when maximizing or restoring the window, only when resizing by dragging the edges of the window.

I was able to fix the issue for myself by adding a delay to the beginning of the recreateSwapChain function.

void recreateSwapChain() { std::this_thread::sleep_for(800ms); //...

I've also been using the latest SDK with the XCB library and have a GTX 970.

Nonoreve commented 4 years ago

I got the exact same problem on Ubuntu Mint 18.04 with Intel HD Graphics on a dual monitor setup. An additional problem is when I resize the window on any axis to about the third of its initial size, the primary monitor get completely black. It does not came back when the application is closed and I have to switch tty to get the display back. I still get validation errors (maybe less) with the thread sleep and still get the display crash.

RussellHolgate commented 4 years ago

@Nonoreve Anything less than 800ms didn't work for me so perhaps you need a bigger delay. You could try 10s for testing purposes.