2024-08-01 15:23:18 +10:00
|
|
|
use ash::ext::debug_utils::Instance;
|
2023-01-03 16:55:35 +11:00
|
|
|
use ash::prelude::VkResult;
|
|
|
|
use ash::vk;
|
|
|
|
use ash::vk::{DebugUtilsMessengerEXT, PFN_vkDebugUtilsMessengerCallbackEXT};
|
|
|
|
|
|
|
|
pub struct VulkanDebug {
|
2024-08-01 15:23:18 +10:00
|
|
|
pub loader: Instance,
|
2023-01-10 14:54:54 +11:00
|
|
|
messenger: DebugUtilsMessengerEXT,
|
2023-01-03 16:55:35 +11:00
|
|
|
}
|
|
|
|
|
2023-02-10 13:03:55 +11:00
|
|
|
#[allow(dead_code)]
|
2023-01-03 16:55:35 +11:00
|
|
|
impl VulkanDebug {
|
2023-01-10 14:54:54 +11:00
|
|
|
pub fn new(
|
|
|
|
entry: &ash::Entry,
|
|
|
|
instance: &ash::Instance,
|
|
|
|
callback: PFN_vkDebugUtilsMessengerCallbackEXT,
|
|
|
|
) -> VkResult<VulkanDebug> {
|
2024-08-01 15:23:18 +10:00
|
|
|
let debug_info = vk::DebugUtilsMessengerCreateInfoEXT::default()
|
2023-01-03 16:55:35 +11:00
|
|
|
.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);
|
|
|
|
|
2024-08-01 15:23:18 +10:00
|
|
|
let debug_utils_loader = Instance::new(entry, instance);
|
2023-01-03 16:55:35 +11:00
|
|
|
|
2023-01-13 16:07:03 +11:00
|
|
|
dbg!("got to dbg");
|
2023-01-03 16:55:35 +11:00
|
|
|
unsafe {
|
2023-01-10 14:54:54 +11:00
|
|
|
let debug_call_back =
|
|
|
|
debug_utils_loader.create_debug_utils_messenger(&debug_info, None)?;
|
2023-01-03 16:55:35 +11:00
|
|
|
|
|
|
|
Ok(VulkanDebug {
|
|
|
|
loader: debug_utils_loader,
|
2023-01-10 14:54:54 +11:00
|
|
|
messenger: debug_call_back,
|
2023-01-03 16:55:35 +11:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03 16:55:35 +11:00
|
|
|
}
|
|
|
|
}
|
2023-01-10 14:54:54 +11:00
|
|
|
}
|