From 88ac91f638ea195dbef06828f25a55f557568e01 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sat, 27 May 2023 16:07:31 -0700 Subject: [PATCH] Don't report violations of VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912. As described in [Vulkan-ValidationLayers#5671], the validation layers don't understand debug ranges paired across different command buffers on the same queue, even though the Vulkan spec says: > An application may open a debug label region in one command buffer and close it in another, or otherwise split debug label regions across multiple command buffers or multiple queue submissions. When viewed from the linear series of submissions to a single queue, the calls to vkCmdBeginDebugUtilsLabelEXT and vkCmdEndDebugUtilsLabelEXT must be matched and balanced. Until this is fixed, wgpu should ignore this validation error to reduce noise in test runs. Fixes #3733. [Vulkan-ValidationLayers#5671]: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671, --- wgpu-hal/src/vulkan/instance.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 101f303c16a..08617aac62e 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -16,13 +16,30 @@ unsafe extern "system" fn debug_utils_messenger_callback( callback_data_ptr: *const vk::DebugUtilsMessengerCallbackDataEXT, _user_data: *mut c_void, ) -> vk::Bool32 { - const VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274: i32 = 0x7cd0911d; use std::borrow::Cow; if thread::panicking() { return vk::FALSE; } + let cd = unsafe { &*callback_data_ptr }; + + const VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274: i32 = 0x7cd0911d; + const VUID_VKCMDENDDEBUGUTILSLABELEXT_COMMANDBUFFER_01912: i32 = 0x56146426; + + // Silence Vulkan Validation error " VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912" + // This is a bug in the validation layer: + // https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671 + if cd.message_id_number == VUID_VKCMDENDDEBUGUTILSLABELEXT_COMMANDBUFFER_01912 { + return vk::FALSE; + } + + // Silence Vulkan Validation error "VUID-VkSwapchainCreateInfoKHR-imageExtent-01274" + // - it's a false positive due to the inherent racy-ness of surface resizing + if cd.message_id_number == VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274 { + return vk::FALSE; + } + let level = match message_severity { vk::DebugUtilsMessageSeverityFlagsEXT::VERBOSE => log::Level::Debug, vk::DebugUtilsMessageSeverityFlagsEXT::INFO => log::Level::Info, @@ -31,8 +48,6 @@ unsafe extern "system" fn debug_utils_messenger_callback( _ => log::Level::Warn, }; - let cd = unsafe { &*callback_data_ptr }; - let message_id_name = if cd.p_message_id_name.is_null() { Cow::from("") } else { @@ -44,12 +59,6 @@ unsafe extern "system" fn debug_utils_messenger_callback( unsafe { CStr::from_ptr(cd.p_message) }.to_string_lossy() }; - // Silence Vulkan Validation error "VUID-VkSwapchainCreateInfoKHR-imageExtent-01274" - // - it's a false positive due to the inherent racy-ness of surface resizing - if cd.message_id_number == VUID_VKSWAPCHAINCREATEINFOKHR_IMAGEEXTENT_01274 { - return vk::FALSE; - } - let _ = std::panic::catch_unwind(|| { log::log!( level,