-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improves handling of window resizes on vulkan (avoids crashes) #2123
Improves handling of window resizes on vulkan (avoids crashes) #2123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be handled inside updateResolution
. This change would cause renderer to flicker.
Sorry for taking so long to reply. The vulkan spec dictates that on windows and linux/x11 the VkSurfaceCapabilitiesKHR::currentExtent (framebuffer), VkSurfaceCapabilitiesKHR::minImageExtent and VkSurfaceCapabilitiesKHR::maxImageExtent are always equal to the current size of the window. (On wayland, for example, minImageExtent and maxImageExtent are the true hardware capabilities and not the current window size) I'm going to try to give a specific example to explain this change. Whenever a new frame arrives at bgfx::RenderContextVK::submit(), updateResolution() tries to see if the resolution of the previous rendered frame is the same as the new one. If it is, it doesn't recreate the swapchain, and vkAcquireNextImage() is called. If between the call to vkAcquireNextImage() and vkQueuePresentKHR() the window changes size, the vkQueuePresentKHR() will fail with VK_ERROR_OUT_OF_DATE and the acquired swapchain image will not be returned. Once the next frame arrives, updateResolution() will once more check if the resolution of the previous frame matches the current frame. Now two things can happen: The code in this pull request just avoids making an invalid acquire. Basically, if the m_resolution of the arriving bgfx::Frame doesn't cause the swapchain to be recreated, which will only happen when it matches the window size (currentExtent), no new frame can be rendered. Would you prefer this piece of code to be inside updateResolution() which would return a bool and then return from submit() like in the renderer_d3d12.cpp? Line 5801 in 74aae90
|
Yes, change it to match D3D12. |
b3fd695
to
0a3fbe5
Compare
Rebased and added refresh swapchain check inside updateResolution(), similar to renderer_d3d12.cpp.
…dzic#2123) * Improves handling of window resizes on vulkan (avoids crashes) * Change to previous commit as requested. Rebased and added refresh swapchain check inside updateResolution(), similar to renderer_d3d12.cpp.
* master: (21 commits) Improves handling of window resizes on vulkan (avoids crashes) (bkaradzic#2123) Fix crash on window minimize on vulkan renderer (bkaradzic#2204) Fix X11 flicker when window is being resized (bkaradzic#2203) Updated spirv-cross. Updated spirv-tools. Updated glslang. Updated ImGui. Cleanup. Fixed docs. Fixed issue bkaradzic#2201. Updated version number. Cleanup. OpenGL: Disable scissor testing while blitting framebuffers when MSAA is enabled (bkaradzic#2200) Updating xcode config. (bkaradzic#2198) Updated glslang. shaderc: Disabled warnings. Updated spirv-cross. Updated spirv-tools. Updated spirv-headers. Updated vulkan headers. ...
No description provided.