Skip to content
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

Multi-viewports Vulkan Bug "RenderPasses incompatible" #3522

Closed
MoritzR200 opened this issue Oct 11, 2020 · 1 comment
Closed

Multi-viewports Vulkan Bug "RenderPasses incompatible" #3522

MoritzR200 opened this issue Oct 11, 2020 · 1 comment

Comments

@MoritzR200
Copy link

Build used

Short: Docking GLFW Vulkan, This bug can occur on any Platform.
Version tested:

Dear ImGui 1.79 WIP (17803)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1916
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw
io.BackendRendererName: imgui_impl_vulkan
io.ConfigFlags: 0x00000441
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigWindowsMemoryCompactTimer = 60.0f
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1024.00,1024.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

What is the issue?

This issue is about ImGui causing vulkan validation errors if an VkRenderPass that uses a different valid format for attachment 0, than ImGui would select by default, is passed to ImGui_ImplVulkan_Init. The issue only ocures if at least one UI-Box is dragged out of the main window -> when ImGui has to create its own windows.

What causes the issue?

As ImGui creates separate VkRenderPass objects for each window and then selects its default format for attachment 0, the main and the custom window can have different color formats for attachment 0, if the user selects an other valid format.
This leads to the VkRenderPass objects being incompatible (https://vulkan.lunarg.com/doc/view/1.2.154.1/windows/vkspec.html#renderpass-compatibility).
This wouldn't be a problem if ImGui would use two different VkPipeline objects (each created with the corresponding VkRenderPass) for rendering,
but as it doesn't an issue is caused by the call to ImGui_ImplVulkan_RenderWindow performed by ImGui::RenderPlatformWindowsDefault() when calling ImGui_ImplVulkan_SetupRenderState through calling ImGui_ImplVulkan_RenderDrawData,
because ImGui_ImplVulkan_SetupRenderState binds the global Pipeline g_Pipeline, wich is incompatible with the current renderpass (The renderpass created by ImGui), as it was created with a different format for attachment 0,
because ImGui selected the format used by this window's renderPass(The currently bound renderpass) and the Main window's renderpass (The one used to create g_Pipeline) uses an user selected format for attachment 0 and they don't have to match.

How can it be fixed?

This issue can be fixed in multiple ways, but the best solution I have come up with is to create separate pipelines for the other windows' renderpasses. This would mean that g_Pipeline would be unused and that each ImGui_ImplVulkanH_Window would have its own VkPipeline object.

Standalone, minimal, complete and verifiable example:

Go into eyample_glfw_vulkan/main.cpp
Change line 214 from:
" const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };"
to " const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM };"
On a platform that supports both VK_FORMAT_B8G8R8A8_UNORM and VK_FORMAT_R8G8B8A8_UNORM
Then run the programm and drag one window like the DEMO window out of the main window.

The actual error produced:

[vulkan] Debug report from ObjectType: 0
Message: Validation Error: [ VUID-vkCmdDrawIndexed-renderPass-02684 ] Object 0: handle = 0x92d209000000002c, type = VK_OBJECT_TYPE_UNKNOWN; Object 1: handle = 0xbd54020000000007, type = VK_OBJECT_TYPE_UNKNOWN; | MessageID = 0x8cb637c2 | vkCmdDrawIndexed(): RenderPasses incompatible between active render pass w/ VkNonDispatchableHandle 0x92d209000000002c[] and pipeline state object w/ VkNonDispatchableHandle 0xbd54020000000007[] Attachment 0 is not compatible with 0: They have different formats.. The Vulkan spec states: The current render pass must be compatible with the renderPass member of the VkGraphicsPipelineCreateInfo structure specified when creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS (https://vulkan.lunarg.com/doc/view/1.2.154.0/windows/1.2-extensions/vkspec.html#VUID-vkCmdDrawIndexed-renderPass-02684)

Final words

I would be happy if this issue would be resolved, because it took me a lot of time and effort to find it an I don't want others to have to struggle to, like this poor guy(https://stackoverflow.com/questions/61231840/imgui-vulkan-validation-layer-error-when-undocking).

Sincerely MoritzR200

@ocornut ocornut changed the title Docking Vulkan Bug "RenderPasses incompatible" Multi-viewports Vulkan Bug "RenderPasses incompatible" Oct 11, 2020
@MoritzR200
Copy link
Author

The issue has been resolved by this change:
41e2aa2#diff-7cc1c1bef2b0a533bc7379b3ee752903277d262a642ae1a0373a42db6dc08cd8

Thank you for your good work on this great repository!

lolrobbe2 pushed a commit to lolrobbe2/luna that referenced this issue Oct 13, 2022
Ribosome2 added a commit to Ribosome2/rasengan that referenced this issue Oct 14, 2022
ocornut added a commit that referenced this issue Apr 30, 2024
…indow::Pipeline (#6325, #6305, #7398, #3459, #3253, #3522)

As this is currently unused and misleading. Next commit will add a separate pipeline for secondary viewport.
ocornut pushed a commit that referenced this issue Apr 30, 2024
…6325, #6305, #7398, #3459, #3253, #3522)

Edited from original commit: moved ImGui_ImplVulkan_CreatePipeline() call from ImGui_ImplVulkanH_CreateOrResizeWindow() to ImGui_ImplVulkan_CreateWindow().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants