Remove all Into wrapper

This commit is contained in:
maik klein 2016-12-09 01:55:29 +01:00
parent 5ed62ba2a4
commit f10e00eea2
5 changed files with 189 additions and 181 deletions

View file

@ -126,7 +126,7 @@ impl<'r> Device<'r> {
pub fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { pub fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> {
unsafe { unsafe {
let err_code = self.device_fn let err_code = self.device_fn
.reset_fences(self.handle, fences.len() as u32, fences.as_ptr()); .reset_fences(self.handle, fences.len() as vk::uint32_t, fences.as_ptr());
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code), _ => Err(err_code),
@ -155,7 +155,10 @@ impl<'r> Device<'r> {
pub fn cmd_set_scissor(&self, command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D]) { pub fn cmd_set_scissor(&self, command_buffer: vk::CommandBuffer, scissors: &[vk::Rect2D]) {
unsafe { unsafe {
self.device_fn self.device_fn
.cmd_set_scissor(command_buffer, 0, scissors.len() as u32, scissors.as_ptr()); .cmd_set_scissor(command_buffer,
0,
scissors.len() as vk::uint32_t,
scissors.as_ptr());
} }
} }
@ -166,7 +169,7 @@ impl<'r> Device<'r> {
unsafe { unsafe {
self.device_fn.cmd_bind_vertex_buffers(command_buffer, self.device_fn.cmd_bind_vertex_buffers(command_buffer,
0, 0,
buffers.len() as u32, buffers.len() as vk::uint32_t,
buffers.as_ptr(), buffers.as_ptr(),
offsets); offsets);
} }
@ -179,10 +182,10 @@ impl<'r> Device<'r> {
} }
pub fn cmd_draw(&self, pub fn cmd_draw(&self,
command_buffer: vk::CommandBuffer, command_buffer: vk::CommandBuffer,
vertex_count: u32, vertex_count: vk::uint32_t,
instance_count: u32, instance_count: vk::uint32_t,
first_vertex: u32, first_vertex: vk::uint32_t,
first_instance: u32) { first_instance: vk::uint32_t) {
unsafe { unsafe {
self.device_fn.cmd_draw(command_buffer, self.device_fn.cmd_draw(command_buffer,
vertex_count, vertex_count,
@ -196,16 +199,16 @@ impl<'r> Device<'r> {
unsafe { unsafe {
self.device_fn.cmd_set_viewport(command_buffer, self.device_fn.cmd_set_viewport(command_buffer,
0, 0,
viewports.len() as u32, viewports.len() as vk::uint32_t,
viewports.as_ptr()); viewports.as_ptr());
} }
} }
pub fn acquire_next_image_khr(&self, pub fn acquire_next_image_khr(&self,
swapchain: vk::SwapchainKHR, swapchain: vk::SwapchainKHR,
timeout: u64, timeout: vk::uint64_t,
semaphore: vk::Semaphore, semaphore: vk::Semaphore,
fence: vk::Fence) fence: vk::Fence)
-> VkResult<u32> { -> VkResult<vk::uint32_t> {
unsafe { unsafe {
let mut index = mem::uninitialized(); let mut index = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
@ -244,7 +247,7 @@ impl<'r> Device<'r> {
let err_code = self.device_fn let err_code = self.device_fn
.create_graphics_pipelines(self.handle, .create_graphics_pipelines(self.handle,
pipeline_cache, pipeline_cache,
create_infos.len() as u32, create_infos.len() as vk::uint32_t,
create_infos.as_ptr(), create_infos.as_ptr(),
ptr::null(), ptr::null(),
pipelines.as_mut_ptr()); pipelines.as_mut_ptr());
@ -297,7 +300,8 @@ impl<'r> Device<'r> {
let x: *mut T = data as *mut T; let x: *mut T = data as *mut T;
match err_code { match err_code {
vk::Result::Success => { vk::Result::Success => {
Ok(::std::slice::from_raw_parts_mut(x, size as usize / mem::size_of::<T>())) Ok(::std::slice::from_raw_parts_mut(x,
size as vk::size_t / mem::size_of::<T>()))
} }
_ => Err(err_code), _ => Err(err_code),
} }
@ -324,7 +328,10 @@ impl<'r> Device<'r> {
} }
} }
pub fn get_device_queue(&self, queue_family_index: u32, queue_index: u32) -> vk::Queue { pub fn get_device_queue(&self,
queue_family_index: vk::uint32_t,
queue_index: vk::uint32_t)
-> vk::Queue {
unsafe { unsafe {
let mut queue = mem::uninitialized(); let mut queue = mem::uninitialized();
self.device_fn self.device_fn
@ -346,11 +353,11 @@ impl<'r> Device<'r> {
src_stage_mask, src_stage_mask,
dst_stage_mask, dst_stage_mask,
dependency_flags, dependency_flags,
memory_barriers.len() as u32, memory_barriers.len() as vk::uint32_t,
memory_barriers.as_ptr(), memory_barriers.as_ptr(),
buffer_memory_barriers.len() as u32, buffer_memory_barriers.len() as vk::uint32_t,
buffer_memory_barriers.as_ptr(), buffer_memory_barriers.as_ptr(),
image_memory_barriers.len() as u32, image_memory_barriers.len() as vk::uint32_t,
image_memory_barriers.as_ptr()); image_memory_barriers.as_ptr());
} }
} }
@ -397,14 +404,14 @@ impl<'r> Device<'r> {
pub fn wait_for_fences(&self, pub fn wait_for_fences(&self,
fences: &[vk::Fence], fences: &[vk::Fence],
wait_all: bool, wait_all: bool,
timeout: u64) timeout: vk::uint64_t)
-> VkResult<()> { -> VkResult<()> {
unsafe { unsafe {
let err_code = self.device_fn let err_code = self.device_fn
.wait_for_fences(self.handle, .wait_for_fences(self.handle,
fences.len() as u32, fences.len() as vk::uint32_t,
fences.as_ptr(), fences.as_ptr(),
wait_all as u32, wait_all as vk::uint32_t,
timeout); timeout);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
@ -443,7 +450,10 @@ impl<'r> Device<'r> {
-> VkResult<()> { -> VkResult<()> {
unsafe { unsafe {
let err_code = self.device_fn let err_code = self.device_fn
.queue_submit(queue, submits.len() as u32, submits.as_ptr(), fence); .queue_submit(queue,
submits.len() as vk::uint32_t,
submits.as_ptr(),
fence);
match err_code { match err_code {
vk::Result::Success => Ok(()), vk::Result::Success => Ok(()),
_ => Err(err_code), _ => Err(err_code),
@ -472,10 +482,10 @@ impl<'r> Device<'r> {
self.device_fn self.device_fn
.get_swapchain_images_khr(self.handle, swapchain, &mut count, ptr::null_mut()); .get_swapchain_images_khr(self.handle, swapchain, &mut count, ptr::null_mut());
let mut v = Vec::with_capacity(count as usize); let mut v = Vec::with_capacity(count as vk::size_t);
let err_code = self.device_fn let err_code = self.device_fn
.get_swapchain_images_khr(self.handle, swapchain, &mut count, v.as_mut_ptr()); .get_swapchain_images_khr(self.handle, swapchain, &mut count, v.as_mut_ptr());
v.set_len(count as usize); v.set_len(count as vk::size_t);
match err_code { match err_code {
vk::Result::Success => Ok(v), vk::Result::Success => Ok(v),
_ => Err(err_code), _ => Err(err_code),
@ -483,45 +493,40 @@ impl<'r> Device<'r> {
} }
} }
pub fn allocate_command_buffers<I: Into<vk::CommandBufferAllocateInfo>> pub fn allocate_command_buffers(&self,
(&self, create_info: &vk::CommandBufferAllocateInfo)
i: I) -> VkResult<Vec<vk::CommandBuffer>> {
-> VkResult<Vec<vk::CommandBuffer>> {
let create_info = i.into();
unsafe { unsafe {
let mut buffers = Vec::with_capacity(create_info.command_buffer_count as usize); let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t);
let err_code = self.device_fn let err_code = self.device_fn
.allocate_command_buffers(self.handle, &create_info, buffers.as_mut_ptr()); .allocate_command_buffers(self.handle, create_info, buffers.as_mut_ptr());
buffers.set_len(create_info.command_buffer_count as usize); buffers.set_len(create_info.command_buffer_count as vk::size_t);
match err_code { match err_code {
vk::Result::Success => Ok(buffers), vk::Result::Success => Ok(buffers),
_ => Err(err_code), _ => Err(err_code),
} }
} }
} }
pub fn create_command_pool<I: Into<vk::CommandPoolCreateInfo>>(&self, pub fn create_command_pool(&self,
i: I) create_info: &vk::CommandPoolCreateInfo)
-> VkResult<vk::CommandPool> { -> VkResult<vk::CommandPool> {
let create_info = i.into();
unsafe { unsafe {
let mut pool = mem::uninitialized(); let mut pool = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_command_pool(self.handle, &create_info, ptr::null(), &mut pool); .create_command_pool(self.handle, create_info, ptr::null(), &mut pool);
match err_code { match err_code {
vk::Result::Success => Ok(pool), vk::Result::Success => Ok(pool),
_ => Err(err_code), _ => Err(err_code),
} }
} }
} }
pub fn create_swapchain_khr<I: Into<vk::SwapchainCreateInfoKHR>> pub fn create_swapchain_khr(&self,
(&self, create_info: &vk::SwapchainCreateInfoKHR)
i: I) -> VkResult<vk::SwapchainKHR> {
-> VkResult<vk::SwapchainKHR> {
let create_info = i.into();
unsafe { unsafe {
let mut swapchain = mem::uninitialized(); let mut swapchain = mem::uninitialized();
let err_code = self.device_fn let err_code = self.device_fn
.create_swapchain_khr(self.handle, &create_info, ptr::null(), &mut swapchain); .create_swapchain_khr(self.handle, create_info, ptr::null(), &mut swapchain);
match err_code { match err_code {
vk::Result::Success => Ok(swapchain), vk::Result::Success => Ok(swapchain),
_ => Err(err_code), _ => Err(err_code),

116
ash/src/entry.rs Normal file
View file

@ -0,0 +1,116 @@
use std::mem;
use std::ptr;
use vk_loader2 as vk;
use instance::Instance;
use shared_library::dynamic_library::DynamicLibrary;
use std::path::Path;
type VkResult<T> = Result<T, vk::Result>;
#[cfg(windows)]
fn get_path() -> &'static Path {
Path::new("vulkan-1.dll")
}
#[cfg(all(unix, not(target_os = "android")))]
fn get_path() -> &'static Path {
Path::new("libvulkan.so.1")
}
#[cfg(target_os = "android")]
fn get_path() -> &'static Path {
Path::new("libvulkan.so")
}
pub struct Entry {
lib: DynamicLibrary,
static_fn: vk::Static,
entry_fn: vk::EntryFn,
}
#[derive(Debug)]
pub enum LoadingError {
LibraryLoadFailure(String),
StaticLoadError(String),
EntryLoadError(String),
}
impl Entry {
pub fn load_vulkan_path(path: &Path) -> Result<Entry, LoadingError> {
let lib = try!(DynamicLibrary::open(Some(path))
.map_err(|err| LoadingError::LibraryLoadFailure(err)));
let static_fn = try!(vk::Static::load(|name| unsafe {
let name = name.to_str().unwrap();
let f = match lib.symbol(name) {
Ok(s) => s,
Err(_) => ptr::null(),
};
f
})
.map_err(|err| LoadingError::StaticLoadError(err)));
let entry_fn = try!(vk::EntryFn::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(ptr::null_mut(), name.as_ptr()))
})
.map_err(|err| LoadingError::EntryLoadError(err)));
Ok(Entry {
lib: lib,
static_fn: static_fn,
entry_fn: entry_fn,
})
}
pub fn load_vulkan() -> Result<Entry, LoadingError> {
Entry::load_vulkan_path(get_path())
}
pub fn create_instance(&self,
create_info: &vk::InstanceCreateInfo)
-> Result<Instance, vk::Result> {
unsafe {
let mut instance: vk::Instance = mem::uninitialized();
let err_code = self.entry_fn.create_instance(create_info, ptr::null(), &mut instance);
if err_code != vk::Result::Success {
return Err(err_code);
}
let instance_fn = vk::InstanceFn::load(|name| unsafe {
mem::transmute(self.static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})
.unwrap();
Ok(Instance::from_raw(instance, instance_fn))
}
}
pub fn enumerate_instance_layer_properties(&self)
-> Result<Vec<vk::LayerProperties>, vk::Result> {
unsafe {
let mut num = 0;
self.entry_fn.enumerate_instance_layer_properties(&mut num, ptr::null_mut());
let mut v = Vec::with_capacity(num as usize);
let err_code = self.entry_fn
.enumerate_instance_layer_properties(&mut num, v.as_mut_ptr());
v.set_len(num as usize);
match err_code {
vk::Result::Success => Ok(v),
_ => Err(err_code),
}
}
}
pub fn enumerate_instance_extension_properties
(&self)
-> Result<Vec<vk::ExtensionProperties>, vk::Result> {
unsafe {
let mut num = 0;
self.entry_fn
.enumerate_instance_extension_properties(ptr::null(), &mut num, ptr::null_mut());
let mut data = Vec::with_capacity(num as usize);
let err_code = self.entry_fn
.enumerate_instance_extension_properties(ptr::null(), &mut num, data.as_mut_ptr());
data.set_len(num as usize);
match err_code {
vk::Result::Success => Ok(data),
_ => Err(err_code),
}
}
}
}

View file

@ -9,120 +9,6 @@ use shared_library::dynamic_library::DynamicLibrary;
type VkResult<T> = Result<T, vk::Result>; type VkResult<T> = Result<T, vk::Result>;
#[cfg(windows)]
fn get_path() -> &'static Path {
Path::new("vulkan-1.dll")
}
#[cfg(all(unix, not(target_os = "android")))]
fn get_path() -> &'static Path {
Path::new("libvulkan.so.1")
}
#[cfg(target_os = "android")]
fn get_path() -> &'static Path {
Path::new("libvulkan.so")
}
pub struct Entry {
lib: DynamicLibrary,
static_fn: vk::Static,
entry_fn: vk::EntryFn,
}
#[derive(Debug)]
pub enum LoadingError {
LibraryLoadFailure(String),
StaticLoadError(String),
EntryLoadError(String),
}
impl Entry {
pub fn load_vulkan_path(path: &Path) -> Result<Entry, LoadingError> {
let lib = try!(DynamicLibrary::open(Some(path))
.map_err(|err| LoadingError::LibraryLoadFailure(err)));
let static_fn = try!(vk::Static::load(|name| unsafe {
let name = name.to_str().unwrap();
let f = match lib.symbol(name) {
Ok(s) => s,
Err(_) => ptr::null(),
};
f
})
.map_err(|err| LoadingError::StaticLoadError(err)));
let entry_fn = try!(vk::EntryFn::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(ptr::null_mut(), name.as_ptr()))
})
.map_err(|err| LoadingError::EntryLoadError(err)));
Ok(Entry {
lib: lib,
static_fn: static_fn,
entry_fn: entry_fn,
})
}
pub fn load_vulkan() -> Result<Entry, LoadingError> {
Entry::load_vulkan_path(get_path())
}
pub fn create_instance<I: Into<vk::InstanceCreateInfo>>(&self,
i: I)
-> Result<Instance, vk::Result> {
let create_info = i.into();
unsafe {
let mut instance: vk::Instance = mem::uninitialized();
let err_code = self.entry_fn.create_instance(&create_info, ptr::null(), &mut instance);
if err_code != vk::Result::Success {
return Err(err_code);
}
let instance_fn = vk::InstanceFn::load(|name| unsafe {
mem::transmute(self.static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})
.unwrap();
Ok(Instance {
handle: instance,
instance_fn: instance_fn,
_lifetime: ::std::marker::PhantomData,
})
}
}
pub fn enumerate_instance_layer_properties(&self)
-> Result<Vec<vk::LayerProperties>, vk::Result> {
unsafe {
let mut num = 0;
self.entry_fn.enumerate_instance_layer_properties(&mut num, ptr::null_mut());
let mut v = Vec::with_capacity(num as usize);
let err_code = self.entry_fn
.enumerate_instance_layer_properties(&mut num, v.as_mut_ptr());
v.set_len(num as usize);
match err_code {
vk::Result::Success => Ok(v),
_ => Err(err_code),
}
}
}
pub fn enumerate_instance_extension_properties
(&self)
-> Result<Vec<vk::ExtensionProperties>, vk::Result> {
unsafe {
let mut num = 0;
self.entry_fn
.enumerate_instance_extension_properties(ptr::null(), &mut num, ptr::null_mut());
let mut data = Vec::with_capacity(num as usize);
let err_code = self.entry_fn
.enumerate_instance_extension_properties(ptr::null(), &mut num, data.as_mut_ptr());
data.set_len(num as usize);
match err_code {
vk::Result::Success => Ok(data),
_ => Err(err_code),
}
}
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct Instance<'r> { pub struct Instance<'r> {
@ -131,6 +17,13 @@ pub struct Instance<'r> {
_lifetime: ::std::marker::PhantomData<&'r ()>, _lifetime: ::std::marker::PhantomData<&'r ()>,
} }
impl<'r> Instance<'r> { impl<'r> Instance<'r> {
pub unsafe fn from_raw(handle: vk::Instance, instance_fn: vk::InstanceFn) -> Self {
Instance {
handle: handle,
instance_fn: instance_fn,
_lifetime: ::std::marker::PhantomData,
}
}
pub fn destroy_instance(&self) { pub fn destroy_instance(&self) {
unsafe { unsafe {
self.instance_fn.destroy_instance(self.handle, ptr::null()); self.instance_fn.destroy_instance(self.handle, ptr::null());
@ -238,15 +131,13 @@ impl<'r> Instance<'r> {
self.instance_fn.destroy_surface_khr(self.handle, surface, ptr::null()); self.instance_fn.destroy_surface_khr(self.handle, surface, ptr::null());
} }
} }
pub fn create_xlib_surface_khr<I: Into<vk::XlibSurfaceCreateInfoKHR>> pub fn create_xlib_surface_khr(&self,
(&self, create_info: &vk::XlibSurfaceCreateInfoKHR)
i: I) -> VkResult<vk::SurfaceKHR> {
-> VkResult<vk::SurfaceKHR> {
let create_info = i.into();
unsafe { unsafe {
let mut surface = mem::uninitialized(); let mut surface = mem::uninitialized();
let err_code = self.instance_fn let err_code = self.instance_fn
.create_xlib_surface_khr(self.handle, &create_info, ptr::null(), &mut surface); .create_xlib_surface_khr(self.handle, create_info, ptr::null(), &mut surface);
match err_code { match err_code {
vk::Result::Success => Ok(surface), vk::Result::Success => Ok(surface),
_ => Err(err_code), _ => Err(err_code),
@ -256,7 +147,7 @@ impl<'r> Instance<'r> {
} }
pub fn get_physical_device_surface_support_khr(&self, pub fn get_physical_device_surface_support_khr(&self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
queue_index: u32, queue_index: vk::uint32_t,
surface: vk::SurfaceKHR) surface: vk::SurfaceKHR)
-> bool { -> bool {
unsafe { unsafe {
@ -289,15 +180,14 @@ impl<'r> Instance<'r> {
} }
} }
pub fn create_device<I: Into<vk::DeviceCreateInfo>>(&self, pub fn create_device(&self,
physical_device: vk::PhysicalDevice, physical_device: vk::PhysicalDevice,
i: I) create_info: &vk::DeviceCreateInfo)
-> VkResult<Device> { -> VkResult<Device> {
let create_info = i.into();
unsafe { unsafe {
let mut device = mem::uninitialized(); let mut device = mem::uninitialized();
let err_code = self.instance_fn let err_code = self.instance_fn
.create_device(physical_device, &create_info, ptr::null(), &mut device); .create_device(physical_device, create_info, ptr::null(), &mut device);
if err_code != vk::Result::Success { if err_code != vk::Result::Success {
return Err(err_code); return Err(err_code);
} }

View file

@ -11,6 +11,7 @@ extern crate glfw;
pub mod instance; pub mod instance;
//pub mod feature; //pub mod feature;
pub mod device; pub mod device;
pub mod entry;
//pub mod commandpool; //pub mod commandpool;
//pub mod fence; //pub mod fence;
//pub mod buffer; //pub mod buffer;

View file

@ -9,7 +9,8 @@ extern crate time;
use std::default::Default; use std::default::Default;
use glfw::*; use glfw::*;
use ash::instance::{Entry, Instance}; use ash::entry::Entry;
use ash::instance::Instance;
use ash::device::Device; use ash::device::Device;
use std::ptr; use std::ptr;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
@ -17,7 +18,6 @@ use std::mem;
use std::path::Path; use std::path::Path;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
use std::os::raw::c_void;
unsafe extern "system" fn vulkan_debug_callback(flags: vk::DebugReportFlagsEXT, unsafe extern "system" fn vulkan_debug_callback(flags: vk::DebugReportFlagsEXT,
obj_type: vk::DebugReportObjectTypeEXT, obj_type: vk::DebugReportObjectTypeEXT,
@ -28,8 +28,7 @@ unsafe extern "system" fn vulkan_debug_callback(flags: vk::DebugReportFlagsEXT,
p_message: *const i8, p_message: *const i8,
data: *mut ()) data: *mut ())
-> u32 { -> u32 {
let s = CStr::from_ptr(p_message); println!("{:?}", CStr::from_ptr(p_message));
println!("{:?}", s);
1 1
} }
fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) { fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
@ -107,7 +106,7 @@ fn main() {
pp_enabled_extension_names: extension_names_raw.as_ptr(), pp_enabled_extension_names: extension_names_raw.as_ptr(),
enabled_extension_count: extension_names_raw.len() as u32, enabled_extension_count: extension_names_raw.len() as u32,
}; };
let instance: Instance = entry.create_instance(create_info).expect("Instance creation error"); let instance: Instance = entry.create_instance(&create_info).expect("Instance creation error");
let debug_info = vk::DebugReportCallbackCreateInfoEXT { let debug_info = vk::DebugReportCallbackCreateInfoEXT {
s_type: vk::StructureType::DebugReportCallbackCreateInfoExt, s_type: vk::StructureType::DebugReportCallbackCreateInfoExt,
p_next: ptr::null(), p_next: ptr::null(),
@ -126,7 +125,7 @@ fn main() {
window: x11_window as vk::Window, window: x11_window as vk::Window,
dpy: x11_display as *mut vk::Display, dpy: x11_display as *mut vk::Display,
}; };
let surface = instance.create_xlib_surface_khr(x11_create_info).unwrap(); let surface = instance.create_xlib_surface_khr(&x11_create_info).unwrap();
let pdevices = instance.enumerate_physical_devices().expect("Physical device error"); let pdevices = instance.enumerate_physical_devices().expect("Physical device error");
let (pdevice, queue_family_index) = pdevices.iter() let (pdevice, queue_family_index) = pdevices.iter()
.map(|pdevice| { .map(|pdevice| {
@ -176,7 +175,7 @@ fn main() {
pp_enabled_extension_names: device_extension_names_raw.as_ptr(), pp_enabled_extension_names: device_extension_names_raw.as_ptr(),
p_enabled_features: &features, p_enabled_features: &features,
}; };
let device: Device = instance.create_device(pdevice, device_create_info) let device: Device = instance.create_device(pdevice, &device_create_info)
.unwrap(); .unwrap();
let present_queue = device.get_device_queue(queue_family_index as u32, 0); let present_queue = device.get_device_queue(queue_family_index as u32, 0);
@ -245,15 +244,14 @@ fn main() {
p_queue_family_indices: ptr::null(), p_queue_family_indices: ptr::null(),
queue_family_index_count: 0, queue_family_index_count: 0,
}; };
let swapchain = device.create_swapchain_khr(swapchain_create_info).unwrap(); let swapchain = device.create_swapchain_khr(&swapchain_create_info).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(),
flags: vk::COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, flags: vk::COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
queue_family_index: queue_family_index, queue_family_index: queue_family_index,
}; };
let pool = device.create_command_pool(pool_create_info).unwrap(); let pool = device.create_command_pool(&pool_create_info).unwrap();
let command_buffer_allocate_info = vk::CommandBufferAllocateInfo { let command_buffer_allocate_info = vk::CommandBufferAllocateInfo {
s_type: vk::StructureType::CommandBufferAllocateInfo, s_type: vk::StructureType::CommandBufferAllocateInfo,
p_next: ptr::null(), p_next: ptr::null(),
@ -261,9 +259,7 @@ fn main() {
command_pool: pool, command_pool: pool,
level: vk::CommandBufferLevel::Primary, level: vk::CommandBufferLevel::Primary,
}; };
// let draw_command_buffers = device.allocate_command_buffers(command_buffer_allocate_info).unwrap(); let command_buffers = device.allocate_command_buffers(&command_buffer_allocate_info).unwrap();
let command_buffers = device.allocate_command_buffers(command_buffer_allocate_info).unwrap();
let setup_command_buffer = command_buffers[0]; let setup_command_buffer = command_buffers[0];
let draw_command_buffer = command_buffers[1]; let draw_command_buffer = command_buffers[1];