ash/extensions/ext/
debug_report.rs1use crate::prelude::*;
2use crate::vk;
3use crate::RawPtr;
4use crate::{Entry, Instance};
5use std::ffi::CStr;
6use std::mem;
7
8#[derive(Clone)]
9pub struct DebugReport {
10 handle: vk::Instance,
11 fp: vk::ExtDebugReportFn,
12}
13
14impl DebugReport {
15 pub fn new(entry: &Entry, instance: &Instance) -> Self {
16 let handle = instance.handle();
17 let fp = vk::ExtDebugReportFn::load(|name| unsafe {
18 mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
19 });
20 Self { handle, fp }
21 }
22
23 #[inline]
25 pub unsafe fn destroy_debug_report_callback(
26 &self,
27 debug: vk::DebugReportCallbackEXT,
28 allocation_callbacks: Option<&vk::AllocationCallbacks>,
29 ) {
30 (self.fp.destroy_debug_report_callback_ext)(
31 self.handle,
32 debug,
33 allocation_callbacks.as_raw_ptr(),
34 );
35 }
36
37 #[inline]
39 pub unsafe fn create_debug_report_callback(
40 &self,
41 create_info: &vk::DebugReportCallbackCreateInfoEXT,
42 allocation_callbacks: Option<&vk::AllocationCallbacks>,
43 ) -> VkResult<vk::DebugReportCallbackEXT> {
44 let mut debug_cb = mem::zeroed();
45 (self.fp.create_debug_report_callback_ext)(
46 self.handle,
47 create_info,
48 allocation_callbacks.as_raw_ptr(),
49 &mut debug_cb,
50 )
51 .result_with_success(debug_cb)
52 }
53
54 #[inline]
55 pub const fn name() -> &'static CStr {
56 vk::ExtDebugReportFn::name()
57 }
58
59 #[inline]
60 pub fn fp(&self) -> &vk::ExtDebugReportFn {
61 &self.fp
62 }
63
64 #[inline]
65 pub fn instance(&self) -> vk::Instance {
66 self.handle
67 }
68}