diff --git a/src/entry.rs b/src/entry.rs index 98dd471..0ff9cdf 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -116,4 +116,11 @@ impl Entry { } } } + + pub fn get_instance_proc_addr(&self, + instance: vk::Instance, + p_name: *const vk::c_char) + -> vk::PFN_vkVoidFunction { + unsafe { self.static_fn.get_instance_proc_addr(instance, p_name) } + } } diff --git a/src/extensions/debug_report.rs b/src/extensions/debug_report.rs index 32cc1ba..56a9929 100644 --- a/src/extensions/debug_report.rs +++ b/src/extensions/debug_report.rs @@ -25,7 +25,7 @@ impl DebugReport { }) } - pub fn destroy_debug_report_callback_ext(&self, debug: vk::DebugReportCallbackEXT) { + pub unsafe fn destroy_debug_report_callback_ext(&self, debug: vk::DebugReportCallbackEXT) { unsafe { self.debug_report_fn.destroy_debug_report_callback_ext(self.handle, debug, ptr::null()); } diff --git a/src/extensions/surface.rs b/src/extensions/surface.rs index 006257d..7d94062 100644 --- a/src/extensions/surface.rs +++ b/src/extensions/surface.rs @@ -13,10 +13,7 @@ pub struct Surface { impl Surface { pub fn new(entry: &Entry, instance: &Instance) -> Result { let surface_fn = vk::SurfaceFn::load(|name| { - unsafe { - mem::transmute(entry.static_fn - .get_instance_proc_addr(instance.handle, name.as_ptr())) - } + unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle, name.as_ptr())) } })?; Ok(Surface { handle: instance.handle, @@ -104,7 +101,7 @@ impl Surface { } } - pub fn destroy_surface_khr(&self, surface: vk::SurfaceKHR) { + pub unsafe fn destroy_surface_khr(&self, surface: vk::SurfaceKHR) { unsafe { self.surface_fn.destroy_surface_khr(self.handle, surface, ptr::null()); } diff --git a/src/extensions/swapchain.rs b/src/extensions/swapchain.rs index d157471..93a2ea7 100644 --- a/src/extensions/swapchain.rs +++ b/src/extensions/swapchain.rs @@ -14,8 +14,7 @@ impl Swapchain { pub fn new(instance: &Instance, device: &Device) -> Result { let swapchain_fn = vk::SwapchainFn::load(|name| { unsafe { - mem::transmute(instance.instance_fn - .get_device_proc_addr(device.handle, name.as_ptr())) + mem::transmute(instance.get_device_proc_addr(device.handle, name.as_ptr())) } })?; Ok(Swapchain { diff --git a/src/instance.rs b/src/instance.rs index 18cca2a..9faacf6 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -45,6 +45,13 @@ impl Instance { } } + pub fn get_device_proc_addr(&self, + device: vk::Device, + p_name: *const vk::c_char) + -> vk::PFN_vkVoidFunction { + unsafe { self.instance_fn.get_device_proc_addr(device, p_name) } + } + pub unsafe fn destroy_instance(&self) { unsafe { self.instance_fn.destroy_instance(self.handle, ptr::null()); diff --git a/src/vk.rs b/src/vk.rs index 13145f0..d92173a 100644 --- a/src/vk.rs +++ b/src/vk.rs @@ -3693,16 +3693,16 @@ macro_rules! vk_functions { impl ::std::fmt::Debug for $struct_name { #[inline] fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::result::Result<(), ::std::fmt::Error> { - writeln!(fmt, stringify!($struct_name)).unwrap(); + writeln!(fmt, stringify!($struct_name))?; $( if !(self.$name as *const c_void).is_null() { - write!(fmt," Is loaded => " ).unwrap(); + write!(fmt," Is loaded => " )?; } else{ - write!(fmt," Is not loaded => " ).unwrap(); + write!(fmt," Is not loaded => " )?; } - write!(fmt, $raw_name).unwrap(); - writeln!(fmt, ", ").unwrap(); + write!(fmt, $raw_name)?; + writeln!(fmt, ", ")?; )+ write!(fmt, "") }