1 use crate::prelude::*; 2 use crate::vk; 3 use crate::RawPtr; 4 use crate::{EntryCustom, Instance}; 5 use std::ffi::CStr; 6 use std::mem; 7 8 #[derive(Clone)] 9 pub struct DebugReport { 10 handle: vk::Instance, 11 debug_report_fn: vk::ExtDebugReportFn, 12 } 13 14 impl DebugReport { new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self15 pub fn new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self { 16 let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe { 17 mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) 18 }); 19 Self { 20 handle: instance.handle(), 21 debug_report_fn, 22 } 23 } 24 name() -> &'static CStr25 pub fn name() -> &'static CStr { 26 vk::ExtDebugReportFn::name() 27 } 28 29 #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"] destroy_debug_report_callback( &self, debug: vk::DebugReportCallbackEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>, )30 pub unsafe fn destroy_debug_report_callback( 31 &self, 32 debug: vk::DebugReportCallbackEXT, 33 allocation_callbacks: Option<&vk::AllocationCallbacks>, 34 ) { 35 self.debug_report_fn.destroy_debug_report_callback_ext( 36 self.handle, 37 debug, 38 allocation_callbacks.as_raw_ptr(), 39 ); 40 } 41 42 #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugReportCallbackEXT.html>"] create_debug_report_callback( &self, create_info: &vk::DebugReportCallbackCreateInfoEXT, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult<vk::DebugReportCallbackEXT>43 pub unsafe fn create_debug_report_callback( 44 &self, 45 create_info: &vk::DebugReportCallbackCreateInfoEXT, 46 allocation_callbacks: Option<&vk::AllocationCallbacks>, 47 ) -> VkResult<vk::DebugReportCallbackEXT> { 48 let mut debug_cb = mem::zeroed(); 49 self.debug_report_fn 50 .create_debug_report_callback_ext( 51 self.handle, 52 create_info, 53 allocation_callbacks.as_raw_ptr(), 54 &mut debug_cb, 55 ) 56 .result_with_success(debug_cb) 57 } 58 fp(&self) -> &vk::ExtDebugReportFn59 pub fn fp(&self) -> &vk::ExtDebugReportFn { 60 &self.debug_report_fn 61 } 62 instance(&self) -> vk::Instance63 pub fn instance(&self) -> vk::Instance { 64 self.handle 65 } 66 } 67