Skip to content

examples/vulkan: add optional dynamic rendering support#9357

Open
qiyuewuyi2333 wants to merge 1 commit intoocornut:dockingfrom
qiyuewuyi2333:fix/example_vulkan_dynamic_rendering
Open

examples/vulkan: add optional dynamic rendering support#9357
qiyuewuyi2333 wants to merge 1 commit intoocornut:dockingfrom
qiyuewuyi2333:fix/example_vulkan_dynamic_rendering

Conversation

@qiyuewuyi2333
Copy link
Copy Markdown

Related issue: #9340

Add opt-in dynamic rendering support to all four Vulkan examples
(glfw, sdl2, sdl3, win32) via a commented-out macro at the top of
each main.cpp:

//#define APP_USE_DYNAMIC_RENDERING

When enabled:

  • Requests VK_KHR_dynamic_rendering (and its dependencies) at device
    creation and enables the VkPhysicalDeviceDynamicRenderingFeaturesKHR
    feature.
  • Loads vkCmdBeginRendering/vkCmdEndRendering at runtime via
    vkGetDeviceProcAddr (falls back to the KHR suffixed variants for
    pre-1.3 drivers).
  • Sets wd->UseDynamicRendering = true before
    ImGui_ImplVulkanH_CreateOrResizeWindow so the helper skips
    RenderPass/Framebuffer creation.
  • Configures ImGui_ImplVulkan_InitInfo with UseDynamicRendering=true
    and PipelineRenderingCreateInfo (using the actual surface format)
    for both main and viewport pipelines.
  • Replaces vkCmdBeginRenderPass/vkCmdEndRenderPass in FrameRender
    with vkCmdBeginRendering/vkCmdEndRendering plus the required
    image layout transitions (PRESENT_SRC_KHR <-> COLOR_ATTACHMENT_OPTIMAL).

When the macro is not defined the examples behave exactly as before.

@qiyuewuyi2333
Copy link
Copy Markdown
Author

Actually, it's more better if the backend support handle with dynamic rendering for main window like muti-window does.
But that will be a much more impact. So I think just adjusting it in example is acceptable.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Apr 9, 2026

Note that both #5446 and #8600 had code to enable dynamic rendering in examples. I've attached the latest patch version for both for references. You can probably compare your code to them. They seem simpler?

…MIC_RENDERING)

Add opt-in dynamic rendering support to all four Vulkan examples
(glfw, sdl2, sdl3, win32) via a commented-out macro at the top of
each main.cpp:
  //#define APP_USE_DYNAMIC_RENDERING
@qiyuewuyi2333 qiyuewuyi2333 force-pushed the fix/example_vulkan_dynamic_rendering branch from 8226e97 to e6750fc Compare April 10, 2026 01:58
@qiyuewuyi2333
Copy link
Copy Markdown
Author

Note that both #5446 and #8600 had code to enable dynamic rendering in examples. I've attached the latest patch version for both for references. You can probably compare your code to them. They seem simpler?

Thx for your references. I have compared my code to both patches and simplified accordingly as below:

I also applied the same changes to all four Vulkan examples (glfw, sdl2, sdl3, win32) for consistency.

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.

3 participants