-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Vulkan: Fixing secondary viewport resize problems on linux #7513
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1731,7 +1731,12 @@ static void ImGui_ImplVulkan_RenderWindow(ImGuiViewport* viewport, void*) | |
{ | ||
{ | ||
err = vkAcquireNextImageKHR(v->Device, wd->Swapchain, UINT64_MAX, fsd->ImageAcquiredSemaphore, VK_NULL_HANDLE, &wd->FrameIndex); | ||
check_vk_result(err); | ||
if (err == VK_ERROR_OUT_OF_DATE_KHR) { | ||
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount); | ||
wd->CanPresent = false; | ||
return; | ||
} else | ||
check_vk_result(err); | ||
fd = &wd->Frames[wd->FrameIndex]; | ||
} | ||
for (;;) | ||
|
@@ -1858,6 +1863,11 @@ static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*) | |
ImGui_ImplVulkanH_Window* wd = &vd->Window; | ||
ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; | ||
|
||
if (!wd->CanPresent) { | ||
wd->CanPresent = true; | ||
return; | ||
} | ||
|
||
VkResult err; | ||
uint32_t present_index = wd->FrameIndex; | ||
|
||
|
@@ -1870,9 +1880,11 @@ static void ImGui_ImplVulkan_SwapBuffers(ImGuiViewport* viewport, void*) | |
info.pSwapchains = &wd->Swapchain; | ||
info.pImageIndices = &present_index; | ||
err = vkQueuePresentKHR(v->Queue, &info); | ||
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) | ||
if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) { | ||
ImGui_ImplVulkanH_CreateOrResizeWindow(v->Instance, v->PhysicalDevice, v->Device, &vd->Window, v->QueueFamily, v->Allocator, (int)viewport->Size.x, (int)viewport->Size.y, v->MinImageCount); | ||
else | ||
return; | ||
} | ||
else | ||
check_vk_result(err); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of returning here and not incrementing both indexes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also confirm that both paths calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. none of this is needed that's just how I handle it in my own backend. |
||
|
||
wd->FrameIndex = (wd->FrameIndex + 1) % wd->ImageCount; // This is for the next vkWaitForFences() | ||
|
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.
Can you also clarify how this is needed?
Our main.cpp example do a similar thing via setting
g_SwapChainRebuild = true
but it is primarily because the swap chain recreation is deferred to later.Can you confirm what happens if you attempt the
vkQueuePresentKHR()
? for my records. Thanks!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.
and yeah answers to this are in #3390