Closed Farouk123456 closed 4 months ago
The error also only triggers when resizing the window of the window is left alone the errors stop
The problem got solved by not passing the oldSwapChain parameter wich is not documented anywhere in the spec
Also assigning @versalinyaa whom I think? is currently chairing the SI TSG.
While I haven't read the entire code, I can see a bug with oldSwapchain
right away. But first, a high level comment:
And since window resizing is so glitchy on xorg I tried VkSwapchainPresentScalingCreateInfoEXT, and it worked wonderfully until I decided that I also want to recreate the swap chain when the Window becomes too big/small and the scaling makes the image to pixelated — basically if the window size is bigger than 50 + original window size recreate the swap chain.
I strongly suggest not doing that. Scaling by even just one pixel will visibly affect the quality of the output (making it blurry). If you intend to recreate the swapchain, my suggestion is to do it on every window size change instead of mixing it with scaling.
And since window resizing is so glitchy on xorg
It's not glitchy at all if you get it right. I wrote this sample + doc to explain how one can deal with swapchain recreation with and without VK_EXT_swapchain_maintenance1, which would hopefully help you understand why this extension helps and also shed light on what you still need to take care of: https://github.com/KhronosGroup/Vulkan-Samples/tree/main/samples/api/swapchain_recreation
(If you run that samples, you can verify that window resizing can be buttery smooth!)
In particular, you need to pay attention to the fact that the lifetime of the objects are managed by the application, which means it is an error to destroy objects while they are still in use by the GPU or the present engine. The bug I mentioned is this:
if (vkCreateSwapchainKHR(device, &createInfo, nullptr, &retSwap) != VK_SUCCESS)
{
LOG_FATAL("failed to create swap chain!");
}
if (oldSwapchain != VK_NULL_HANDLE)
vkDestroySwapchainKHR(device, oldSwapchain, nullptr);
The application is not waiting for the present engine to be done with the old swapchain before destroying it.
I'm going to close this bug as there is nothing to fix in the spec about this. If you believe there is a validation bug, please file an issue with https://github.com/KhronosGroup/Vulkan-ValidationLayers. My suggestion is to closely study the Vulkan sample I linked to as dealing with the window system is quite tricky :)
@ShabbyX hi thanks for the info i implemented some of it (old swapchain issue) and it helped somewhat. im pretty sure it must be on SDL# or xorg becaus in wayland resizing is always smooth but in xorg resizing is only smooth when using window decorations when usin borderless mode its not smooth at all even though its running at around 15k fps
Could you also tell me what the validation error means i dont quite understand it
Could you also tell me what the validation error means i dont quite understand it
Sorry, what validation error?
This one:
Failed to initialize scaled swapchain images (-2)
I don't know why that says "validation: ..." is that your app's log? The error itself (VK_ERROR_OUT_OF_DEVICE_MEMORY == -2) is a driver error, nothing about validation layers here.
Your best option is to enable VVL (Vulkan Validation Layers) and make sure your program is error free before pursuing driver-returned failures. If the application is error-free (according to VVL), you could consider filing an issue with your vendor (mesa or nvidia for example).
[VK_EXT_swapchain_maintenance1] @syoussefi
Hello, I'm starting to learn Vulkan API as of a few months now. And since window resizing is so glitchy on xorg I tried VkSwapchainPresentScalingCreateInfoEXT, and it worked wonderfully until I decided that I also want to recreate the swap chain when the Window becomes too big/small and the scaling makes the image to pixelated — basically if the window size is bigger than 50 + original window size recreate the swap chain.
When I do this, I get the error :
validation: Failed to initialize scaled swapchain images (-2)
It's also of Note that the error only occurs after a few swap chain recreations, making the issue more frustrating Im Vaguely following this guide https://docs.vulkan.org/tutorial/latest/00_Introduction.html although i used SDL2
Also if the pNext of VkSwapchainPresentScalingCreateInfoEXT isnt nullptr or something else it will segfault
Here's my function for recreating the swap chain:
Any Help would be appreciated