Skip to content

Conversation

@gpx1000
Copy link
Collaborator

@gpx1000 gpx1000 commented Oct 16, 2025

Description

Demonstrate and provide a tutorial for using VK_EXT_layer_settings

Fixes #

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

@SaschaWillems
Copy link
Collaborator

This does work, but it feels a bit too minimalist. Wouldn't it make more sense to actually trigger some best practices thing (e.g. using wrong buffer flags or doing non-optimal transitions) and have them show up in the application's UI instead? Otherwise one has to scroll to the very top of the terminal to see some validation infos. And that does only work on platforms where you actually have a terminal.

@gpx1000
Copy link
Collaborator Author

gpx1000 commented Oct 19, 2025

I had thought keeping it simple was going to make it easier to take and use elsewhere; but went ahead and made the changes recommended.

@gary-sweet
Copy link
Contributor

So this is just supposed to be a black screen with some UI messages (that get cropped at the right side of the screen)?

- Enables the instance extension `VK_EXT_layer_settings` (optionally).
- Adds settings for the Khronos validation layer before the Vulkan instance is created:
- Enables Best Practices checks.
- Enables `debugPrintfEXT` support (so shader `debugPrintf` messages are emitted via validation).
Copy link
Contributor

Choose a reason for hiding this comment

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

Those two bullet points are not rendered as sub-points.

if (strcmp(e.extensionName, VK_EXT_LAYER_SETTINGS_EXTENSION_NAME) == 0)
return true;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:
return std::ranges::find_if( exts, []( auto const & property ){ return strcmp( property.extensionName, VK_EXT_LAYER_SETTINGS_EXTENSION_NAME ) == 0; } ) != exts.end();

}
else
{
// Fallback for older SDKs: use VK_EXT_validation_features
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to check for VK_EXT_validation_features support?

{
VkInstance instance = get_instance().get_handle();
auto fpDestroy = reinterpret_cast<PFN_vkDestroyDebugUtilsMessengerEXT>(
vkGetInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you explicitly get the function pointer? As volk is initialized by the framework, just calling
vkDestroyDebugUtilsMessengerEXT(instance, debug_messenger_, nullptr); works as well


// Install a local DebugUtils messenger to collect validation messages into the UI.
// If it was already created during create_instance(), skip to avoid duplication.
if (debug_messenger_ == VK_NULL_HANDLE && get_instance().is_enabled(VK_EXT_DEBUG_UTILS_EXTENSION_NAME))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't get this.
Under what circumstances would the debug_messenger_ not be created during create_instance, which is called before this function?

Copy link
Contributor

Choose a reason for hiding this comment

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

On my configuration (Win10, NVIDIA GPU), this sample never gets to appending some line to the log_text_.

# Conflicts:
#	samples/extensions/README.adoc
…aching

Transforms layer_settings sample into an interactive demonstration with three toggleable validation scenarios (wrong buffer flags, suboptimal transitions, small allocations). Executes validation-triggering operations once during setup using one-time command buffers to work with message caching. Adds per-scenario warning/error counters, message caching, and resource cleanup. Updates UI with checkboxes, statistics display, and scrollable message viewer with improved styling.
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.

4 participants