Skip to content

Commit

Permalink
Only request debug layers when they're available (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzywilczek authored Oct 14, 2024
1 parent 1148959 commit 61a8322
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions vk-video/src/vulkan_decoder/vulkan_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,28 @@ impl VulkanCtx {
..Default::default()
};

let layers = if cfg!(debug_assertions) {
vec![c"VK_LAYER_KHRONOS_validation".as_ptr()]
let requested_layers = if cfg!(debug_assertions) {
vec![c"VK_LAYER_KHRONOS_validation"]
} else {
Vec::new()
};

let instance_layer_properties = unsafe { entry.enumerate_instance_layer_properties()? };
let instance_layer_names = instance_layer_properties
.iter()
.map(|layer| layer.layer_name_as_c_str())
.collect::<Result<Vec<_>, _>>()?;

let layers = requested_layers
.into_iter()
.filter(|requested_layer_name| {
instance_layer_names
.iter()
.any(|instance_layer_name| instance_layer_name == requested_layer_name)
})
.map(|layer| layer.as_ptr())
.collect::<Vec<_>>();

let extensions = if cfg!(debug_assertions) {
vec![vk::EXT_DEBUG_UTILS_NAME]
} else {
Expand Down

0 comments on commit 61a8322

Please sign in to comment.