Use DebugUtils instead of DebugReport in example.
This commit is contained in:
parent
3eeb78f214
commit
93238e093b
|
@ -23,7 +23,7 @@ use std::mem;
|
||||||
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
||||||
use ash::extensions::khr::XlibSurface;
|
use ash::extensions::khr::XlibSurface;
|
||||||
use ash::extensions::{
|
use ash::extensions::{
|
||||||
ext::DebugReport,
|
ext::DebugUtils,
|
||||||
khr::{Surface, Swapchain},
|
khr::{Surface, Swapchain},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,11 +33,12 @@ use ash::extensions::khr::Win32Surface;
|
||||||
use ash::extensions::mvk::MacOSSurface;
|
use ash::extensions::mvk::MacOSSurface;
|
||||||
pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};
|
||||||
use ash::{vk, Device, Entry, Instance};
|
use ash::{vk, Device, Entry, Instance};
|
||||||
|
use std::borrow::Cow;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
use std::os::raw::{c_char, c_void};
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
// Simple offset_of macro akin to C++ offsetof
|
// Simple offset_of macro akin to C++ offsetof
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -181,7 +182,7 @@ fn extension_names() -> Vec<*const i8> {
|
||||||
vec![
|
vec![
|
||||||
Surface::name().as_ptr(),
|
Surface::name().as_ptr(),
|
||||||
XlibSurface::name().as_ptr(),
|
XlibSurface::name().as_ptr(),
|
||||||
DebugReport::name().as_ptr(),
|
DebugUtils::name().as_ptr(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ fn extension_names() -> Vec<*const i8> {
|
||||||
vec![
|
vec![
|
||||||
Surface::name().as_ptr(),
|
Surface::name().as_ptr(),
|
||||||
MacOSSurface::name().as_ptr(),
|
MacOSSurface::name().as_ptr(),
|
||||||
DebugReport::name().as_ptr(),
|
DebugUtils::name().as_ptr(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,21 +200,40 @@ fn extension_names() -> Vec<*const i8> {
|
||||||
vec![
|
vec![
|
||||||
Surface::name().as_ptr(),
|
Surface::name().as_ptr(),
|
||||||
Win32Surface::name().as_ptr(),
|
Win32Surface::name().as_ptr(),
|
||||||
DebugReport::name().as_ptr(),
|
DebugUtils::name().as_ptr(),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "system" fn vulkan_debug_callback(
|
unsafe extern "system" fn vulkan_debug_callback(
|
||||||
_: vk::DebugReportFlagsEXT,
|
message_severity: vk::DebugUtilsMessageSeverityFlagsEXT,
|
||||||
_: vk::DebugReportObjectTypeEXT,
|
message_type: vk::DebugUtilsMessageTypeFlagsEXT,
|
||||||
_: u64,
|
p_callback_data: *const vk::DebugUtilsMessengerCallbackDataEXT,
|
||||||
_: usize,
|
_user_data: *mut std::os::raw::c_void,
|
||||||
_: i32,
|
) -> vk::Bool32 {
|
||||||
_: *const c_char,
|
let callback_data = *p_callback_data;
|
||||||
p_message: *const c_char,
|
let message_id_number: i32 = callback_data.message_id_number as i32;
|
||||||
_: *mut c_void,
|
|
||||||
) -> u32 {
|
let message_id_name = if callback_data.p_message_id_name.is_null() {
|
||||||
println!("{:?}", CStr::from_ptr(p_message));
|
Cow::from("")
|
||||||
|
} else {
|
||||||
|
CStr::from_ptr(callback_data.p_message_id_name).to_string_lossy()
|
||||||
|
};
|
||||||
|
|
||||||
|
let message = if callback_data.p_message.is_null() {
|
||||||
|
Cow::from("")
|
||||||
|
} else {
|
||||||
|
CStr::from_ptr(callback_data.p_message).to_string_lossy()
|
||||||
|
};
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"{:?}:\n{:?} [{} ({})] : {}\n",
|
||||||
|
message_severity,
|
||||||
|
message_type,
|
||||||
|
message_id_name,
|
||||||
|
&message_id_number.to_string(),
|
||||||
|
message,
|
||||||
|
);
|
||||||
|
|
||||||
vk::FALSE
|
vk::FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,10 +278,10 @@ pub struct ExampleBase {
|
||||||
pub device: Device,
|
pub device: Device,
|
||||||
pub surface_loader: Surface,
|
pub surface_loader: Surface,
|
||||||
pub swapchain_loader: Swapchain,
|
pub swapchain_loader: Swapchain,
|
||||||
pub debug_report_loader: DebugReport,
|
pub debug_utils_loader: DebugUtils,
|
||||||
pub window: winit::Window,
|
pub window: winit::Window,
|
||||||
pub events_loop: RefCell<winit::EventsLoop>,
|
pub events_loop: RefCell<winit::EventsLoop>,
|
||||||
pub debug_call_back: vk::DebugReportCallbackEXT,
|
pub debug_call_back: vk::DebugUtilsMessengerEXT,
|
||||||
|
|
||||||
pub pdevice: vk::PhysicalDevice,
|
pub pdevice: vk::PhysicalDevice,
|
||||||
pub device_memory_properties: vk::PhysicalDeviceMemoryProperties,
|
pub device_memory_properties: vk::PhysicalDeviceMemoryProperties,
|
||||||
|
@ -348,17 +368,18 @@ impl ExampleBase {
|
||||||
.create_instance(&create_info, None)
|
.create_instance(&create_info, None)
|
||||||
.expect("Instance creation error");
|
.expect("Instance creation error");
|
||||||
|
|
||||||
let debug_info = vk::DebugReportCallbackCreateInfoEXT::builder()
|
let debug_info = vk::DebugUtilsMessengerCreateInfoEXT::builder()
|
||||||
.flags(
|
.message_severity(
|
||||||
vk::DebugReportFlagsEXT::ERROR
|
vk::DebugUtilsMessageSeverityFlagsEXT::ERROR
|
||||||
| vk::DebugReportFlagsEXT::WARNING
|
| vk::DebugUtilsMessageSeverityFlagsEXT::WARNING
|
||||||
| vk::DebugReportFlagsEXT::PERFORMANCE_WARNING,
|
| vk::DebugUtilsMessageSeverityFlagsEXT::INFO,
|
||||||
)
|
)
|
||||||
.pfn_callback(Some(vulkan_debug_callback));
|
.message_type(vk::DebugUtilsMessageTypeFlagsEXT::all())
|
||||||
|
.pfn_user_callback(Some(vulkan_debug_callback));
|
||||||
|
|
||||||
let debug_report_loader = DebugReport::new(&entry, &instance);
|
let debug_utils_loader = DebugUtils::new(&entry, &instance);
|
||||||
let debug_call_back = debug_report_loader
|
let debug_call_back = debug_utils_loader
|
||||||
.create_debug_report_callback(&debug_info, None)
|
.create_debug_utils_messenger(&debug_info, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let surface = create_surface(&entry, &instance, &window).unwrap();
|
let surface = create_surface(&entry, &instance, &window).unwrap();
|
||||||
let pdevices = instance
|
let pdevices = instance
|
||||||
|
@ -647,7 +668,7 @@ impl ExampleBase {
|
||||||
rendering_complete_semaphore,
|
rendering_complete_semaphore,
|
||||||
surface,
|
surface,
|
||||||
debug_call_back,
|
debug_call_back,
|
||||||
debug_report_loader,
|
debug_utils_loader,
|
||||||
depth_image_memory,
|
depth_image_memory,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,8 +694,8 @@ impl Drop for ExampleBase {
|
||||||
.destroy_swapchain(self.swapchain, None);
|
.destroy_swapchain(self.swapchain, None);
|
||||||
self.device.destroy_device(None);
|
self.device.destroy_device(None);
|
||||||
self.surface_loader.destroy_surface(self.surface, None);
|
self.surface_loader.destroy_surface(self.surface, None);
|
||||||
self.debug_report_loader
|
self.debug_utils_loader
|
||||||
.destroy_debug_report_callback(self.debug_call_back, None);
|
.destroy_debug_utils_messenger(self.debug_call_back, None);
|
||||||
self.instance.destroy_instance(None);
|
self.instance.destroy_instance(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue