From afa4d53dfa31dfec18b64d0679486c4f70206c49 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Thu, 3 Aug 2023 01:35:31 -0400 Subject: [PATCH] Suppress validation error caused by OBS layer --- wgpu-hal/src/vulkan/instance.rs | 17 +++++++++++++++++ wgpu-hal/src/vulkan/mod.rs | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/wgpu-hal/src/vulkan/instance.rs b/wgpu-hal/src/vulkan/instance.rs index 81ecbaf3e3..931d4a2819 100644 --- a/wgpu-hal/src/vulkan/instance.rs +++ b/wgpu-hal/src/vulkan/instance.rs @@ -47,6 +47,19 @@ unsafe extern "system" fn debug_utils_messenger_callback( return vk::FALSE; } + // Silence Vulkan Validation error "VUID-VkRenderPassBeginInfo-framebuffer-04627" + // if the OBS layer is enabled. This is a bug in the OBS layer. As the OBS layer + // does not have a version number they increment, there is no way to qualify the + // supression of the error to a specific version of the OBS layer. + // + // See https://github.com/obsproject/obs-studio/issues/9353 + const VUID_VKRENDERPASSBEGININFO_FRAMEBUFFER_04627: i32 = 0x45125641; + if cd.message_id_number == VUID_VKRENDERPASSBEGININFO_FRAMEBUFFER_04627 + && user_data.has_obs_layer + { + return vk::FALSE; + } + let level = match message_severity { vk::DebugUtilsMessageSeverityFlagsEXT::VERBOSE => log::Level::Debug, vk::DebugUtilsMessageSeverityFlagsEXT::INFO => log::Level::Info, @@ -593,6 +606,9 @@ impl crate::Instance for super::Instance { let nv_optimus_layer = CStr::from_bytes_with_nul(b"VK_LAYER_NV_optimus\0").unwrap(); let has_nv_optimus = find_layer(&instance_layers, nv_optimus_layer).is_some(); + let obs_layer = CStr::from_bytes_with_nul(b"VK_LAYER_OBS_HOOK\0").unwrap(); + let has_obs_layer = find_layer(&instance_layers, obs_layer).is_some(); + let mut layers: Vec<&'static CStr> = Vec::new(); // Request validation layer if asked. @@ -609,6 +625,7 @@ impl crate::Instance for super::Instance { .unwrap() .to_owned(), validation_layer_spec_version: layer_properties.spec_version, + has_obs_layer, }); } else { log::warn!( diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 47cba21249..c2165e1dd8 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -96,6 +96,10 @@ pub struct DebugUtilsMessengerUserData { /// Validation layer specification version, from `vk::LayerProperties`. validation_layer_spec_version: u32, + + /// If the OBS layer is present. OBS never increments the version of their layer, + /// so there's no reason to have the version. + has_obs_layer: bool, } pub struct InstanceShared {