Missing unsafe fn for the extension loaders

This commit is contained in:
maik klein 2016-12-24 05:07:21 +01:00
parent 8c7a459b90
commit f1b310a529
6 changed files with 23 additions and 13 deletions

View file

@ -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) }
}
}

View file

@ -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());
}

View file

@ -13,10 +13,7 @@ pub struct Surface {
impl Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<Surface, String> {
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());
}

View file

@ -14,8 +14,7 @@ impl Swapchain {
pub fn new(instance: &Instance, device: &Device) -> Result<Swapchain, String> {
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 {

View file

@ -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());

View file

@ -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, "")
}