Skip to content

Comments

Adding GUI Support for Dynamic Rendering#1483

Merged
marty-johnson59 merged 1 commit intoKhronosGroup:mainfrom
ellioman:fix-dynamic-rendering-gui
Feb 19, 2026
Merged

Adding GUI Support for Dynamic Rendering#1483
marty-johnson59 merged 1 commit intoKhronosGroup:mainfrom
ellioman:fix-dynamic-rendering-gui

Conversation

@ellioman
Copy link
Contributor

@ellioman ellioman commented Feb 11, 2026

Description

Adds framework support for rendering the GUI overlay when samples use dynamic rendering instead of render passes, and introduces a cleaner get_gui_subpass() pattern for samples that render the GUI in a non-zero subpass.

Changes

Gui class (gui.h):

  • Added prepare() overload that accepts color/depth formats instead of a render pass, creating the GUI pipeline with VkPipelineRenderingCreateInfoKHR
  • Added draw() overload that manages its own rendering pass internally for dynamic rendering
  • Added subpass parameter to the render pass prepare() overload (default 0), replacing the old set_subpass() method
  • Removed set_subpass() method and subpass member variable — subpass is now passed directly at prepare time

ApiVulkanSample / HppApiVulkanSample (api_vulkan_sample.h/cpp, hpp_api_vulkan_sample.h):

  • Added uses_dynamic_rendering() helper that checks if render_pass == VK_NULL_HANDLE
  • Updated prepare_gui() to automatically detect dynamic rendering and call the appropriate Gui::prepare() overload
  • prepare_gui() now passes get_gui_subpass() to Gui::prepare() for the render pass path
  • Added virtual uint32_t get_gui_subpass() const (returns 0) — samples override this to render the GUI in a later subpass
  • Added draw_ui(cmd, swapchain_index) overload for dynamic rendering
  • Updated destructor to use the uses_dynamic_rendering() check

dynamic_rendering sample:

  • Removed prepare_gui() override — the base class now handles both dynamic rendering and render pass GUI paths
  • Added setup_render_pass() and setup_framebuffer() overrides that skip creation when using dynamic rendering, ensuring uses_dynamic_rendering() returns the correct value
  • Added draw_ui(cmd) call in the render pass command buffer path (was previously missing)
  • Fixed clearValueCount to use clear_values.size() instead of a hardcoded 3

dynamic_rendering_local_read sample:

  • Replaced prepare_gui() override with get_gui_subpass() override returning 2
  • Uses the new draw_ui(cmd, swapchain_index) overload for the dynamic rendering path

color_write_enable sample:

  • Replaced prepare_gui() override with get_gui_subpass() override returning 1

Usage

For samples using dynamic rendering, call draw_ui() after ending your main rendering pass:

vkCmdEndRenderingKHR(cmd);
draw_ui(cmd, swapchain_image_index);

Unlike render passes which support subpasses with different attachment configurations, dynamic rendering has a fixed attachment configuration per vkCmdBeginRenderingKHR block. Since the GUI renders to a single color attachment but samples may use multiple attachments (e.g., G-buffer), the GUI must render in its own separate rendering pass - requiring the main pass to be ended first. Otherwise you'll get validation errors, like in the dynamic_rendering_local_read sample.

For samples using render passes, the existing draw_ui(cmd) call remains unchanged. If the GUI needs to render in a non-zero subpass, override get_gui_subpass() instead of prepare_gui().

Screenshots

Below is a screenshot from the dynamic_rendering sample.
dynamic_rendering

Below are two screenshots, from the dynamic_rendering_local_read sample, first one using renderpasses and the other dynamic rendering.

image image

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@ellioman ellioman force-pushed the fix-dynamic-rendering-gui branch from 21f86cc to e882761 Compare February 11, 2026 20:24
@asuessenbach
Copy link
Contributor

With this change, I still get the same error as mentioned in #1462.

@JoseEmilio-ARM JoseEmilio-ARM requested a review from a team February 16, 2026 10:54
@ellioman
Copy link
Contributor Author

With this change, I still get the same error as mentioned in #1462.

Good to know. That issue though seems to be unrelated to the work done in this PR.

I'm working on a new sample, using dynamic rendering, and I need the GUI to work with that so I created this PR to add that support. I used the dynamic_rendering_local_read sample to test with, on Android + Windows, and didn't see any errors so I enabled it.

@SaschaWillems
Copy link
Collaborator

Thank you very much for this!

LTGM, but can you also add the UI to the dynamic_rendering sample? That way both dynamic rendering samples do display a user interface.

Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of mix-ups with C- and C++-binding types. I tried to clarify them in the comments below.
Besides that, could you please adjust the same stuff you're changing in ApiVulkanSample in HPPApiVulkanSample?

@ellioman ellioman force-pushed the fix-dynamic-rendering-gui branch 4 times, most recently from c5239a5 to 5f7f761 Compare February 18, 2026 12:54
@ellioman
Copy link
Contributor Author

@SaschaWillems

LTGM, but can you also add the UI to the dynamic_rendering sample? That way both dynamic rendering samples do display a user interface.

Done, I've added the UI to that sample and I also added a screenshot to the description for this PR.

@ellioman
Copy link
Contributor Author

@asuessenbach

There are a couple of mix-ups with C- and C++-binding types. I tried to clarify them in the comments below. Besides that, could you please adjust the same stuff you're changing in ApiVulkanSample in HPPApiVulkanSample?

Thank you for the review.
First time making a PR for these samples and clearly many things that I wasn't aware of.

I've hopefully addressed the issues you found, including adding the changes to HPPApiVulkanSample, so when you have a moment, please take another look.

@ellioman ellioman force-pushed the fix-dynamic-rendering-gui branch 2 times, most recently from d88a60d to ebec500 Compare February 18, 2026 22:48
gpx1000
gpx1000 previously approved these changes Feb 19, 2026
Copy link
Collaborator

@gpx1000 gpx1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in Lnux. Looks good to me.

@ellioman ellioman force-pushed the fix-dynamic-rendering-gui branch from 754e5ce to d3107d1 Compare February 19, 2026 10:06
@ellioman
Copy link
Contributor Author

@gpx1000 Thanks for reviewing the PR.
I had to do some minor changes as part of other PR review comments.
When you have a moment, please take another look :)

Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great. Thank you very much for this 👍🏻

@marty-johnson59
Copy link
Contributor

3 approvals - merging

@marty-johnson59 marty-johnson59 merged commit 46668f2 into KhronosGroup:main Feb 19, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants