diff --git a/examples/src/lib.rs b/examples/src/lib.rs index da1460c..2cdf755 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -80,10 +80,10 @@ pub fn record_submit_commandbuffer, - entry: &Entry, - window: &winit::Window) - -> Result { +unsafe fn create_surface(entry: &E, + instance: &I, + window: &winit::Window) + -> Result { use winit::os::unix::WindowExt; let x11_display = window.get_xlib_display().unwrap(); let x11_window = window.get_xlib_window().unwrap(); @@ -94,16 +94,16 @@ unsafe fn create_surface(instance: &Instance, window: x11_window as vk::Window, dpy: x11_display as *mut vk::Display, }; - let xlib_surface_loader = XlibSurface::new(&entry, &instance) + let xlib_surface_loader = XlibSurface::new(entry, instance) .expect("Unable to load xlib surface"); xlib_surface_loader.create_xlib_surface_khr(&x11_create_info, None) } #[cfg(windows)] -unsafe fn create_surface(instance: &Instance, - entry: &Entry, - window: &winit::Window) - -> Result { +unsafe fn create_surface(entry: &E, + instance: &I, + window: &winit::Window) + -> Result { use winit::os::windows::WindowExt; let hwnd = window.get_hwnd() as *mut winapi::windef::HWND__; let hinstance = unsafe { user32::GetWindow(hwnd, 0) as *const () }; @@ -114,7 +114,7 @@ unsafe fn create_surface(instance: &Instance, hinstance: hinstance, hwnd: hwnd as *const (), }; - let win32_surface_loader = Win32Surface::new(&entry, &instance) + let win32_surface_loader = Win32Surface::new(entry, instance) .expect("Unable to load win32 surface"); win32_surface_loader.create_win32_surface_khr(&win32_create_info, None) } @@ -284,7 +284,7 @@ impl ExampleBase { let debug_call_back = debug_report_loader.create_debug_report_callback_ext(&debug_info, None) .unwrap(); - let surface = create_surface(&instance, &entry, &window).unwrap(); + let surface = create_surface(&entry, &instance, &window).unwrap(); let pdevices = instance.enumerate_physical_devices().expect("Physical device error"); let surface_loader = Surface::new(&entry, &instance) .expect("Unable to load the Surface extension"); diff --git a/src/device.rs b/src/device.rs index a53f05c..a6ccc59 100644 --- a/src/device.rs +++ b/src/device.rs @@ -3,13 +3,9 @@ use prelude::*; use std::mem; use vk; use ::RawPtr; +use version::{FunctionPointers, V1_0}; -use version::{FunctionPointers, V1_0, DeviceFpV1_0}; - -// unsafe impl Sync for Device {} -// unsafe impl Send for Device {} - - +#[allow(non_camel_case_types)] pub trait DeviceV1_0 { fn handle(&self) -> vk::Device; fn fp_v1_0(&self) -> &vk::DeviceFnV1_0; diff --git a/src/entry.rs b/src/entry.rs index 25886dc..8d06a27 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -7,7 +7,7 @@ use shared_library::dynamic_library::DynamicLibrary; use std::path::Path; use ::RawPtr; use std::marker::PhantomData; -use version::{FunctionPointers, V1_0, InstanceFpV1_0, InstanceLoader, EntryLoader}; +use version::{FunctionPointers, V1_0, InstanceLoader, EntryLoader}; #[cfg(windows)] fn get_path() -> &'static Path { @@ -47,6 +47,8 @@ pub enum InstanceError { LoadError(Vec<&'static str>), VkError(vk::Result), } + +#[allow(non_camel_case_types)] pub trait EntryV1_0 { type Fp: FunctionPointers; fn fp_v1_0(&self) -> &vk::EntryFnV1_0; @@ -135,7 +137,9 @@ impl Entry { } Err(ref err) => Err(LoadingError::LibraryLoadError(err.clone())), }?; - let entry_fn = unsafe { V::EntryFp::load(&static_fn).map_err(|err| LoadingError::EntryLoadError(err))? }; + let entry_fn = unsafe { + V::EntryFp::load(&static_fn).map_err(|err| LoadingError::EntryLoadError(err))? + }; Ok(Entry { static_fn: static_fn, entry_fn: entry_fn, diff --git a/src/extensions/surface.rs b/src/extensions/surface.rs index e4a6193..01380c7 100644 --- a/src/extensions/surface.rs +++ b/src/extensions/surface.rs @@ -2,12 +2,10 @@ use prelude::*; use std::ptr; use std::mem; -use instance::Instance; -use entry::Entry; use vk; use std::ffi::CStr; use ::RawPtr; -use version::{V1_0, EntryV1_0}; +use version::{EntryV1_0, InstanceV1_0}; #[derive(Clone)] pub struct Surface { @@ -16,9 +14,9 @@ pub struct Surface { } impl Surface { - pub fn new(entry: &Entry, - instance: &Instance) - -> Result> { + pub fn new(entry: &E, + instance: &I) + -> Result> { let surface_fn = vk::SurfaceFn::load(|name| { unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) diff --git a/src/extensions/swapchain.rs b/src/extensions/swapchain.rs index cfc3c84..e9e69f4 100644 --- a/src/extensions/swapchain.rs +++ b/src/extensions/swapchain.rs @@ -1,13 +1,10 @@ use prelude::*; use std::ptr; use std::mem; -use instance::Instance; -use device::Device; use vk; use std::ffi::CStr; use ::RawPtr; -use instance::InstanceV1_0; -use version::{V1_0}; +use version::{InstanceV1_0, DeviceV1_0}; #[derive(Clone)] pub struct Swapchain { @@ -16,7 +13,9 @@ pub struct Swapchain { } impl Swapchain { - pub fn new(instance: &Instance, device: &Device) -> Result> { + pub fn new(instance: &I, + device: &D) + -> Result> { let swapchain_fn = vk::SwapchainFn::load(|name| { unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) } })?; diff --git a/src/extensions/win32_surface.rs b/src/extensions/win32_surface.rs index a7b3a5c..9cd0e71 100644 --- a/src/extensions/win32_surface.rs +++ b/src/extensions/win32_surface.rs @@ -1,13 +1,10 @@ #![allow(dead_code)] use prelude::*; use std::mem; -use instance::Instance; -use entry::Entry; use vk; use std::ffi::CStr; use ::RawPtr; -use instance::InstanceV1_0; -use version::{V1_0, EntryV1_0}; +use version::{EntryV1_0, InstanceV1_0}; #[derive(Clone)] pub struct Win32Surface { @@ -16,9 +13,9 @@ pub struct Win32Surface { } impl Win32Surface { - pub fn new(entry: &Entry, - instance: &Instance) - -> Result> { + pub fn new(entry: &E, + instance: &I) + -> Result> { let surface_fn = vk::Win32SurfaceFn::load(|name| { unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) diff --git a/src/extensions/xlib_surface.rs b/src/extensions/xlib_surface.rs index c5d9779..45477e6 100644 --- a/src/extensions/xlib_surface.rs +++ b/src/extensions/xlib_surface.rs @@ -1,13 +1,10 @@ #![allow(dead_code)] use prelude::*; use std::mem; -use instance::Instance; -use entry::Entry; use vk; use std::ffi::CStr; use ::RawPtr; -use instance::InstanceV1_0; -use version::{V1_0, EntryV1_0}; +use version::{EntryV1_0, InstanceV1_0}; #[derive(Clone)] pub struct XlibSurface { @@ -16,9 +13,9 @@ pub struct XlibSurface { } impl XlibSurface { - pub fn new(entry: &Entry, - instance: &Instance) - -> Result> { + pub fn new(entry: &E, + instance: &I) + -> Result> { let surface_fn = vk::XlibSurfaceFn::load(|name| { unsafe { mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) diff --git a/src/instance.rs b/src/instance.rs index a73dc54..b5c5fb0 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -5,8 +5,8 @@ use std::mem; use vk; use device::Device; use ::RawPtr; -use version::{FunctionPointers, V1_0, InstanceFpV1_0, DeviceFpV1_0}; -use version::{InstanceLoader, DeviceLoader}; +use version::{FunctionPointers, V1_0}; +use version::DeviceLoader; #[derive(Debug)] pub enum DeviceError { @@ -43,7 +43,7 @@ impl Instance { } } -#[warn(non_camel_case_types)] +#[allow(non_camel_case_types)] pub trait InstanceV1_0 { type Fp: FunctionPointers; fn handle(&self) -> vk::Instance;