-
Notifications
You must be signed in to change notification settings - Fork 822
Use StructureChainBuilder to create the debug callbacks. #1526
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -458,27 +458,34 @@ bool ShaderDebugPrintf::prepare(const vkb::ApplicationOptions &options) | |
| return true; | ||
| } | ||
|
|
||
| VkDebugUtilsMessengerCreateInfoEXT ShaderDebugPrintf::get_debug_utils_messenger_create_info() const | ||
| { | ||
| return {.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, | ||
| .pNext = nullptr, | ||
| .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, | ||
| .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, | ||
| .pfnUserCallback = debug_utils_message_callback, | ||
| .pUserData = nullptr}; | ||
| } | ||
|
|
||
| void ShaderDebugPrintf::extend_instance_create_info(vkb::StructureChainBuilderC<VkInstanceCreateInfo> &scb) const | ||
| { | ||
| ApiVulkanSample::extend_instance_create_info(scb); | ||
|
|
||
| // Register a sample specific debug utils callback in addition to the one registered by the base class | ||
| VkDebugUtilsMessengerCreateInfoEXT debug_utils_messenger_create_info{.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, | ||
| .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, | ||
| .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, | ||
| .pfnUserCallback = debug_utils_message_callback}; | ||
| scb.add_struct(debug_utils_messenger_create_info); | ||
| scb.add_struct(get_debug_utils_messenger_create_info()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a fan of this. Samples like this are supposed to explicitly show how to set up things. Moving them to the framework and making things implicit makes it harder to follow and/or adopt such samples.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What exactly don't you like here? |
||
| } | ||
|
|
||
| VkDebugUtilsMessengerCreateInfoEXT const *ShaderDebugPrintf::get_debug_utils_messenger_create_info() const | ||
| void ShaderDebugPrintf::extend_debug_utils_messenger_create_info(vkb::StructureChainBuilderC<VkDebugUtilsMessengerCreateInfoEXT> &scb) const | ||
| { | ||
| ApiVulkanSample::extend_debug_utils_messenger_create_info(scb); | ||
|
|
||
| // Register a sample specific debug utils callback in addition to the one registered by the base class | ||
| static VkDebugUtilsMessengerCreateInfoEXT local_debug_utils_messenger_create_info{.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, | ||
| .pNext = ApiVulkanSample::get_debug_utils_messenger_create_info(), | ||
| .messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, | ||
| .messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, | ||
| .pfnUserCallback = debug_utils_message_callback}; | ||
| return &local_debug_utils_messenger_create_info; | ||
| // for some unknown reason, this VkDebugUtilsMessengerCreateInfoEXT needs to be the first one! | ||
| // That is, we need to replace the current anchor with this one, and add the current anchor as the second struct in the chain. | ||
| VkDebugUtilsMessengerCreateInfoEXT tmp = *scb.get_struct<VkDebugUtilsMessengerCreateInfoEXT>(); | ||
| scb.set_anchor_struct(get_debug_utils_messenger_create_info()); | ||
| scb.add_struct(tmp); | ||
| } | ||
|
|
||
| void ShaderDebugPrintf::render(float delta_time) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a good idea to hide these behind those defines. What about samples like debugprintf that are supposed to work without validation layers (to be used with e.g. RenderDoc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those two functions hidden by those defines are private helper functions of the
VulkanSampleclass. They are not virtual, and nobody out of this class actually need to know about them.In contrast to that,
extend_instance_create_infoandextend_debug_utils_messenger_create_infoare protected virtual functions inVulkanSample, not hidden by any defines. Theshader_debugprintfsample, for example, overrides them and calls it own local helper functionget_debug_utils_messenger_create_info, which is not hidden behind any defines.