Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,40 @@ some level of severity, for example:

[,c++]
----
if (messageSeverity >= vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning) {
if (severity >= vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning) {
// Message is important enough to show
}
----

Applying that to our `debugCallback`, we can filter out anything less severe
than a warning so that verbose and informational messages don't clutter the
output:

[,c++]
----
static VKAPI_ATTR vk::Bool32 VKAPI_CALL debugCallback(vk::DebugUtilsMessageSeverityFlagBitsEXT severity,
vk::DebugUtilsMessageTypeFlagsEXT type,
const vk::DebugUtilsMessengerCallbackDataEXT * pCallbackData,
void * pUserData)
{
if (severity == vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning ||
Comment thread
SaschaWillems marked this conversation as resolved.
severity == vk::DebugUtilsMessageSeverityFlagBitsEXT::eError) {
std::cerr << "validation layer: type " << to_string(type) << " msg: " << pCallbackData->pMessage << std::endl;
}

return vk::False;
}
----

Note that `severity` is comparable with `==` here rather than needing a
bitwise `&`. It's typed as `vk::DebugUtilsMessageSeverityFlagBitsEXT`, not
`vk::DebugUtilsMessageSeverityFlagsEXT`: the `FlagBits` suffix marks it as an
enum whose values are individual bits, and Vulkan invokes the callback once
per severity bit, so `severity` always holds exactly one of those bits on any
given call. A `Flags` value, by contrast, is a plain integer that can hold
several `FlagBits` combined together, which is when you'd need `&` to test
whether one of them is set.

The `messageType` parameter can have the following values:

* `vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral` : Some event has happened that is unrelated to the specification or performance
Expand Down
Loading