Skip to content

Commit a47bfb1

Browse files
committed
Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning VK_SUBOPTIMAL_KHR (#7671)
1 parent d46a0aa commit a47bfb1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Breaking changes:
4343

4444
Other changes:
4545

46+
- Examples: GLFW+Vulkan: handle swap chain resize even without Vulkan returning
47+
VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671) [@AndreiNego]
48+
4649

4750
-----------------------------------------------------------------------
4851
VERSION 1.90.8 (Released 2024-06-06)

examples/example_glfw_vulkan/main.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,14 @@ int main(int, char**)
485485
glfwPollEvents();
486486

487487
// Resize swap chain?
488-
if (g_SwapChainRebuild)
488+
int fb_width, fb_height;
489+
glfwGetFramebufferSize(window, &fb_width, &fb_height);
490+
if (fb_width > 0 && fb_height > 0 && (g_SwapChainRebuild || g_MainWindowData.Width != fb_width || g_MainWindowData.Height != fb_height))
489491
{
490-
int width, height;
491-
glfwGetFramebufferSize(window, &width, &height);
492-
if (width > 0 && height > 0)
493-
{
494-
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
495-
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount);
496-
g_MainWindowData.FrameIndex = 0;
497-
g_SwapChainRebuild = false;
498-
}
492+
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
493+
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
494+
g_MainWindowData.FrameIndex = 0;
495+
g_SwapChainRebuild = false;
499496
}
500497

501498
// Start the Dear ImGui frame

0 commit comments

Comments
 (0)