Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning VK_SUBOPTIMAL_KHR (#7671)

This commit is contained in:
ocornut 2024-06-10 15:02:43 +02:00
parent d46a0aa069
commit a47bfb1b5b
2 changed files with 10 additions and 10 deletions

View File

@ -43,6 +43,9 @@ Breaking changes:
Other changes: Other changes:
- Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning
VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671) [@AndreiNego]
----------------------------------------------------------------------- -----------------------------------------------------------------------
VERSION 1.90.8 (Released 2024-06-06) VERSION 1.90.8 (Released 2024-06-06)

View File

@ -485,17 +485,14 @@ int main(int, char**)
glfwPollEvents(); glfwPollEvents();
// Resize swap chain? // Resize swap chain?
if (g_SwapChainRebuild) int fb_width, fb_height;
glfwGetFramebufferSize(window, &fb_width, &fb_height);
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
{ {
int width, height; ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
glfwGetFramebufferSize(window, &width, &height); ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
if (width > 0 && height > 0) g_MainWindowData.FrameIndex = 0;
{ g_SwapChainRebuild = false;
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
g_MainWindowData.FrameIndex = 0;
g_SwapChainRebuild = false;
}
} }
// Start the Dear ImGui frame // Start the Dear ImGui frame