Skip to content

Conversation

@sylmroz
Copy link

@sylmroz sylmroz commented Jun 14, 2025

This PR fixes an issue where the attachment color format provided for dynamic rendering in ImGui_ImplVulkan_InitInfo does not match the surface format. A validation error occurs for viewports created outside the main window.

[{ Validation }]: Name: VUID-vkCmdDrawIndexed-dynamicRenderingUnusedAttachments-08910, Message: vkCmdDrawIndexed(): VkRenderingInfo::pColorAttachments[0].imageView format (VK_FORMAT_B8G8R8A8_UNORM) must match the corresponding format in VkPipelineRenderingCreateInfo::pColorAttachmentFormats[0] (VK_FORMAT_R16G16B16A16_SFLOAT).

Dynamic rendering does not require rendering directly to the swapchain. Instead, the rendering output can be directed to a separate image—potentially with a different format, resolution, etc.—and then blitted or copied to the swapchain image. This allows pipelines to render to images with formats that differ from the swapchain's format.
In the case of ImGui, the viewport uses a separate pipeline. Naturally, this pipeline should have its own VkPipelineRenderingCreateInfo, which allows specifying surface format formats which is taken from swapchain image which is a attached output for separate ImGui window. As a result, format mismatches are not an issue in this scenario.

To reproduce this issue.

  1. Create an image where the UI is rendered using a format different from the surface formatt e.g. auto desired_rendering_format = VK_FORMAT_R16G16B16A16_SFLOAT
  2. Provide same format to ImGui_ImplVulkan_InitInfo{ .PipelineRenderingCreateInfo = VkPipelineRenderingCreateInfo{ ... .pColorAttachmentFormats =&desired_rendering_format }
  3. Draw ImGui in your pipeline
  4. Move any ImGui window outside of the main window

…t should have its own rendering create info
ocornut added a commit that referenced this pull request Sep 26, 2025
…rameter to ImGui_ImplVulkanH_CreateOrResizeWindow(). (#8946, #8110, #8111, #8686)

Default to VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT.
ocornut added a commit that referenced this pull request Sep 26, 2025
…o: RenderPass, Subpass, MSAASamples, PipelineRenderingCreateInfo. (#8946, #8110, #8111, #8686)
ocornut added a commit that referenced this pull request Sep 26, 2025
@ocornut
Copy link
Owner

ocornut commented Sep 26, 2025

Hello,
Thank you for your PR.

I have pushed a couple of rework of the Vulkan backend which as a result of the final commit should solve this exactly.

  • 01686c6 Backends: Vulkan: added a way to specify custom vertex/fragment shaders.
  • 5fe9622 (Breaking) Backends: Vulkan: added VkImageUsageFlags image_usage parameter to ImGui_ImplVulkanH_CreateOrResizeWindow().
  • cc0a669 Backends: Vulkan: minor internal renames/tweaks to reduce further patches.
  • e312b99 (Breaking) Backends: Vulkan: renamed ImGui_ImplVulkan_MainPipelineCreateInfo to ImGui_ImplVulkan_PipelineInfo.
  • 3470e61 (Breaking) Backends: Vulkan: moved fields in ImGui_ImplVulkan_InitInfo: RenderPass, Subpass, MSAASamples, PipelineRenderingCreateInfo.
  • e4e3c2c Backends: Vulkan: amends for docking. Add PipelineInfoForViewports and SwapChainImageUsage.

Would you be able to confirm that things work as expected and as you need? If not I will reopen this and we can investigate together.

Thank you!

@ocornut ocornut closed this Sep 26, 2025
@sylmroz
Copy link
Author

sylmroz commented Sep 27, 2025

Hello,

Thank you for your commits and works.
It's nice and robust solution and everything works as expected.

Thank you so much!

ocornut added a commit that referenced this pull request Sep 29, 2025
ocornut added a commit that referenced this pull request Oct 23, 2025
…ACHMENT_BIT which is added automatically. (#8946, #8110, #8111, #8686)

Merge bad3c14 which was accidentally only pushed to docking. No important side effect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants