diff --git a/CHANGELOG_VULKANO.md b/CHANGELOG_VULKANO.md index 26891511..7482b5d4 100644 --- a/CHANGELOG_VULKANO.md +++ b/CHANGELOG_VULKANO.md @@ -1,5 +1,6 @@ # Unreleased +- **Breaking** `Message::layer_prefix` turned to Option to prevent segfaults when Vulkan message didn't provide `pMessageIdName` value - **Breaking** On `AutoCommandBufferBuilder`, methods that bind a descriptor set now take a `dynamic_offsets` parameter - **Breaking** On `AutoCommandBufferBuilder` and `SyncCommandBufferBuilder`, the `update_buffer` method now takes `data` by reference - **Breaking** Made `PipelineLayoutDescTweaks` public, for use with compute pipelines diff --git a/examples/src/bin/debug.rs b/examples/src/bin/debug.rs index 20e52b32..45c952d5 100644 --- a/examples/src/bin/debug.rs +++ b/examples/src/bin/debug.rs @@ -99,7 +99,10 @@ fn main() { println!( "{} {} {}: {}", - msg.layer_prefix, ty, severity, msg.description + msg.layer_prefix.unwrap_or("unknown"), + ty, + severity, + msg.description ); }) .ok(); diff --git a/vulkano/src/instance/debug.rs b/vulkano/src/instance/debug.rs index 054df1e1..d7ab40cc 100644 --- a/vulkano/src/instance/debug.rs +++ b/vulkano/src/instance/debug.rs @@ -96,9 +96,12 @@ impl DebugCallback { let user_callback = user_data as *mut Box as *const _; let user_callback: &Box = &*user_callback; - let layer_prefix = CStr::from_ptr((*callback_data).pMessageIdName) - .to_str() - .expect("debug callback message not utf-8"); + let layer_prefix = (*callback_data).pMessageIdName.as_ref().map(|msg_id_name| { + CStr::from_ptr(msg_id_name) + .to_str() + .expect("debug callback message not utf-8") + }); + let description = CStr::from_ptr((*callback_data).pMessage) .to_str() .expect("debug callback message not utf-8"); @@ -231,8 +234,8 @@ pub struct Message<'a> { pub severity: MessageSeverity, /// Type of message, pub ty: MessageType, - /// Prefix of the layer that reported this message. - pub layer_prefix: &'a str, + /// Prefix of the layer that reported this message or `None` if unknown. + pub layer_prefix: Option<&'a str>, /// Description of the message. pub description: &'a str, }