librashader/librashader-runtime-vk/tests/hello_triangle/debug.rs

54 lines
1.6 KiB
Rust
Raw Normal View History

use ash::extensions::ext::DebugUtils;
use ash::prelude::VkResult;
use ash::vk;
use ash::vk::{DebugUtilsMessengerEXT, PFN_vkDebugUtilsMessengerCallbackEXT};
pub struct VulkanDebug {
pub loader: DebugUtils,
2023-01-10 14:54:54 +11:00
messenger: DebugUtilsMessengerEXT,
}
2023-02-10 13:03:55 +11:00
#[allow(dead_code)]
impl VulkanDebug {
2023-01-10 14:54:54 +11:00
pub fn new(
entry: &ash::Entry,
instance: &ash::Instance,
callback: PFN_vkDebugUtilsMessengerCallbackEXT,
) -> VkResult<VulkanDebug> {
let debug_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
.message_severity(
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
| vk::DebugUtilsMessageSeverityFlagsEXT::INFO,
)
.message_type(
vk::DebugUtilsMessageTypeFlagsEXT::GENERAL
| vk::DebugUtilsMessageTypeFlagsEXT::VALIDATION
| vk::DebugUtilsMessageTypeFlagsEXT::PERFORMANCE,
)
.pfn_user_callback(callback);
let debug_utils_loader = DebugUtils::new(entry, instance);
dbg!("got to dbg");
unsafe {
2023-01-10 14:54:54 +11:00
let debug_call_back =
debug_utils_loader.create_debug_utils_messenger(&debug_info, None)?;
Ok(VulkanDebug {
loader: debug_utils_loader,
2023-01-10 14:54:54 +11:00
messenger: debug_call_back,
})
}
}
}
impl Drop for VulkanDebug {
fn drop(&mut self) {
unsafe {
2023-01-10 14:54:54 +11:00
self.loader
.destroy_debug_utils_messenger(self.messenger, None);
}
}
2023-01-10 14:54:54 +11:00
}