Adds missing allocators for the extensions

This commit is contained in:
maik klein 2016-12-28 11:04:50 +01:00
parent e6415a91df
commit f01eb2d9d5
4 changed files with 24 additions and 19 deletions

View file

@ -79,7 +79,7 @@ pub fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(device
} }
#[cfg(all(unix, not(target_os = "android")))] #[cfg(all(unix, not(target_os = "android")))]
fn create_surface(instance: &Instance, unsafe fn create_surface(instance: &Instance,
entry: &Entry, entry: &Entry,
window: &winit::Window) window: &winit::Window)
-> Result<vk::SurfaceKHR, vk::Result> { -> Result<vk::SurfaceKHR, vk::Result> {
@ -95,11 +95,11 @@ fn create_surface(instance: &Instance,
}; };
let xlib_surface_loader = XlibSurface::new(&entry, &instance) let xlib_surface_loader = XlibSurface::new(&entry, &instance)
.expect("Unable to load xlib surface"); .expect("Unable to load xlib surface");
xlib_surface_loader.create_xlib_surface_khr(&x11_create_info) xlib_surface_loader.create_xlib_surface_khr(&x11_create_info, None)
} }
#[cfg(windows)] #[cfg(windows)]
fn create_surface(instance: &Instance, unsafe fn create_surface(instance: &Instance,
entry: &Entry, entry: &Entry,
window: &winit::Window) window: &winit::Window)
-> Result<vk::SurfaceKHR, vk::Result> { -> Result<vk::SurfaceKHR, vk::Result> {
@ -254,7 +254,7 @@ impl ExampleBase {
}; };
let debug_report_loader = DebugReport::new(&entry, &instance) let debug_report_loader = DebugReport::new(&entry, &instance)
.expect("Unable to load debug report"); .expect("Unable to load debug report");
let debug_call_back = debug_report_loader.create_debug_report_callback_ext(&debug_info) let debug_call_back = debug_report_loader.create_debug_report_callback_ext(&debug_info, None)
.unwrap(); .unwrap();
let surface = create_surface(&instance, &entry, &window).unwrap(); let surface = create_surface(&instance, &entry, &window).unwrap();
let pdevices = instance.enumerate_physical_devices().expect("Physical device error"); let pdevices = instance.enumerate_physical_devices().expect("Physical device error");
@ -379,7 +379,7 @@ impl ExampleBase {
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
queue_family_index_count: 0, queue_family_index_count: 0,
}; };
let swapchain = swapchain_loader.create_swapchain_khr(&swapchain_create_info).unwrap(); let swapchain = swapchain_loader.create_swapchain_khr(&swapchain_create_info, None).unwrap();
let pool_create_info = vk::CommandPoolCreateInfo { let pool_create_info = vk::CommandPoolCreateInfo {
s_type: vk::StructureType::CommandPoolCreateInfo, s_type: vk::StructureType::CommandPoolCreateInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -596,11 +596,11 @@ impl Drop for ExampleBase {
self.device.destroy_image_view(image_view, None); self.device.destroy_image_view(image_view, None);
} }
self.device.destroy_command_pool(self.pool, None); self.device.destroy_command_pool(self.pool, None);
self.swapchain_loader.destroy_swapchain_khr(self.swapchain); self.swapchain_loader.destroy_swapchain_khr(self.swapchain, None);
self.device.destroy_device(None); self.device.destroy_device(None);
self.surface_loader.destroy_surface_khr(self.surface); self.surface_loader.destroy_surface_khr(self.surface, None);
self.debug_report_loader.destroy_debug_report_callback_ext(self.debug_call_back); self.debug_report_loader.destroy_debug_report_callback_ext(self.debug_call_back, None);
self.instance.destroy_instance(); self.instance.destroy_instance(None);
} }
} }
} }

View file

@ -5,6 +5,7 @@ use instance::Instance;
use entry::Entry; use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr;
pub struct Surface { pub struct Surface {
pub handle: vk::Instance, pub handle: vk::Instance,
@ -108,7 +109,7 @@ impl Surface {
} }
} }
pub unsafe fn destroy_surface_khr(&self, surface: vk::SurfaceKHR) { pub unsafe fn destroy_surface_khr(&self, surface: vk::SurfaceKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.surface_fn.destroy_surface_khr(self.handle, surface, ptr::null()); self.surface_fn.destroy_surface_khr(self.handle, surface, allocation_callbacks.as_raw_ptr());
} }
} }

View file

@ -38,7 +38,10 @@ impl Instance {
unsafe { unsafe {
let mut device: vk::Device = mem::uninitialized(); let mut device: vk::Device = mem::uninitialized();
let err_code = self.instance_fn let err_code = self.instance_fn
.create_device(physical_device, create_info, allocation_callbacks.as_raw_ptr(), &mut device); .create_device(physical_device,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut device);
if err_code != vk::Result::Success { if err_code != vk::Result::Success {
return Err(DeviceError::VkError(err_code)); return Err(DeviceError::VkError(err_code));
} }
@ -56,8 +59,8 @@ impl Instance {
unsafe { self.instance_fn.get_device_proc_addr(device, p_name) } unsafe { self.instance_fn.get_device_proc_addr(device, p_name) }
} }
pub unsafe fn destroy_instance(&self) { pub unsafe fn destroy_instance(&self, allocation_callbacks: Option<&vk::AllocationCallbacks>) {
self.instance_fn.destroy_instance(self.handle, ptr::null()); self.instance_fn.destroy_instance(self.handle, allocation_callbacks.as_raw_ptr());
} }
pub fn get_physical_device_format_properties(&self, pub fn get_physical_device_format_properties(&self,

View file

@ -3708,6 +3708,7 @@ pub mod cmds {
use super::*; use super::*;
#[allow(unused_imports)] #[allow(unused_imports)]
use super::libc_reexports::*; use super::libc_reexports::*;
vk_functions!{ vk_functions!{
StaticFn, StaticFn,
"vkGetInstanceProcAddr", get_instance_proc_addr( "vkGetInstanceProcAddr", get_instance_proc_addr(