diff --git a/ash/src/extensions/debug_marker.rs b/ash/src/extensions/debug_marker.rs new file mode 100644 index 0000000..19743e1 --- /dev/null +++ b/ash/src/extensions/debug_marker.rs @@ -0,0 +1,47 @@ +#![allow(dead_code)] +use prelude::*; +use std::mem; +use vk; +use std::ffi::CStr; +use version::{InstanceV1_0, DeviceV1_0}; + +#[derive(Clone)] +pub struct DebugMarker { + debug_marker_fn: vk::DebugMarkerFn, +} + +impl DebugMarker { + pub fn new( + instance: &I, + device: &D + ) -> Result> { + let debug_marker_fn = vk::DebugMarkerFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr( + device.handle(), + name.as_ptr(), + )) + })?; + Ok(DebugMarker { + debug_marker_fn: debug_marker_fn, + }) + } + + pub fn name() -> &'static CStr { + CStr::from_bytes_with_nul(b"VK_EXT_debug_marker\0").expect("Wrong extension string") + } + + pub unsafe fn debug_marker_set_object_name_ext( + &self, + device: vk::Device, + name_info: &vk::DebugMarkerObjectNameInfoEXT + ) -> VkResult<()> { + let err_code = self.debug_marker_fn.debug_marker_set_object_name_ext( + device, + name_info + ); + match err_code { + vk::Result::Success => Ok(()), + _ => Err(err_code) + } + } +} diff --git a/ash/src/extensions/mod.rs b/ash/src/extensions/mod.rs index b95213e..b5f2a14 100644 --- a/ash/src/extensions/mod.rs +++ b/ash/src/extensions/mod.rs @@ -2,6 +2,7 @@ pub use self::swapchain::Swapchain; pub use self::display_swapchain::DisplaySwapchain; pub use self::surface::Surface; pub use self::xlib_surface::XlibSurface; +pub use self::debug_marker::DebugMarker; pub use self::debug_report::DebugReport; pub use self::win32_surface::Win32Surface; pub use self::mir_surface::MirSurface; @@ -16,6 +17,7 @@ mod display_swapchain; mod surface; mod xlib_surface; mod win32_surface; +mod debug_marker; mod debug_report; mod mir_surface; mod android_surface; diff --git a/ash/src/vk.rs b/ash/src/vk.rs index fd8ecd4..1c2a45f 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -2529,6 +2529,15 @@ pub mod types { pub image_extent: Extent2D, } + #[repr(C)] + pub struct DebugMarkerObjectNameInfoEXT { + pub s_type: StructureType, + pub p_next: *const c_void, + pub object_type: DebugReportObjectTypeEXT, + pub object: uint64_t, + pub p_object_name: *const c_char, + } + #[repr(C)] pub struct DebugReportCallbackCreateInfoEXT { pub s_type: StructureType, @@ -2763,6 +2772,7 @@ pub mod types { DisplayPresentInfoKhr = 1000003000, DisplayModeCreateInfoKhr = 1000002000, DisplaySurfaceCreateInfoKhr = 1000002001, + DebugMarkerObjectNameInfoEXT = 1000022000, DebugReportCallbackCreateInfoExt = 1000011000, IOSSurfaceCreateInfoMvk = 1000122000, MacOSSurfaceCreateInfoMvk = 1000123000, @@ -4983,6 +4993,13 @@ pub mod cmds { dpy: *mut Display, visual_id: VisualID, ) -> Bool32; +} + vk_functions!{ + DebugMarkerFn, + "vkDebugMarkerSetObjectNameEXT", debug_marker_set_object_name_ext( + device: Device, + p_name_info: *const DebugMarkerObjectNameInfoEXT, + ) -> Result; } vk_functions!{ DebugReportFn,