From 9df6aaddcfc045836ee95b658788385391bb6bb1 Mon Sep 17 00:00:00 2001 From: swinston Date: Thu, 20 Aug 2026 17:46:53 -0700 Subject: [PATCH 1/2] Fix messageSeverity/severity naming mismatch and add filtered debugCallback example --- .../00_Setup/02_Validation_layers.adoc | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc b/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc index cd1e8dde..458501f7 100644 --- a/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc @@ -285,11 +285,31 @@ 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 || + severity == vk::DebugUtilsMessageSeverityFlagBitsEXT::eError) { + std::cerr << "validation layer: type " << to_string(type) << " msg: " << pCallbackData->pMessage << std::endl; + } + + return vk::False; +} +---- + The `messageType` parameter can have the following values: * `vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral` : Some event has happened that is unrelated to the specification or performance From 3b86ca5ad85e4f00e729246b727b40239e9abe9e Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 1 Sep 2026 12:08:29 -0700 Subject: [PATCH 2/2] Explain FlagBits vs Flags for the debugCallback severity parameter --- .../00_Setup/02_Validation_layers.adoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc b/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc index 458501f7..65b950a6 100644 --- a/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc +++ b/en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc @@ -310,6 +310,15 @@ static VKAPI_ATTR vk::Bool32 VKAPI_CALL debugCallback(vk::DebugUtilsMessageSever } ---- +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