Skip to content

Commit

Permalink
Examples: SDL+Vulkan: handle swap chain resize even without Vulkan re…
Browse files Browse the repository at this point in the history
…turning VK_SUBOPTIMAL_KHR (#7671)
  • Loading branch information
ocornut committed Jun 10, 2024
1 parent a47bfb1 commit 7538ca6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 3 additions & 2 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ Breaking 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]
- Examples: GLFW+Vulkan, SDL+Vulkan: handle swap chain resize even without Vulkan
returning VK_SUBOPTIMAL_KHR, which doesn't seem to happen on Wayland. (#7671)
[@AndreiNego, @ocornut]


-----------------------------------------------------------------------
Expand Down
17 changes: 7 additions & 10 deletions examples/example_sdl2_vulkan/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,14 @@ int main(int, char**)
}

// Resize swap chain?
if (g_SwapChainRebuild)
int fb_width, fb_height;
SDL_GetWindowSize(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;
SDL_GetWindowSize(window, &width, &height);
if (width > 0 && height > 0)
{
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;
}
ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount);
ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, fb_width, fb_height, g_MinImageCount);
g_MainWindowData.FrameIndex = 0;
g_SwapChainRebuild = false;
}

// Start the Dear ImGui frame
Expand Down

0 comments on commit 7538ca6

Please sign in to comment.