Skip to content

Commit

Permalink
Suppress validation error caused by OBS layer (#4002)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Sep 27, 2023
1 parent 8c89111 commit 8ea270c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -591,6 +604,9 @@ impl crate::Instance<super::Api> 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.
Expand All @@ -607,6 +623,7 @@ impl crate::Instance<super::Api> for super::Instance {
.unwrap()
.to_owned(),
validation_layer_spec_version: layer_properties.spec_version,
has_obs_layer,
});
} else {
log::warn!(
Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8ea270c

Please sign in to comment.