Remove EntryExt

This commit is contained in:
maik klein 2017-01-01 08:50:52 +01:00
parent 1fb4e2ae42
commit 2fdec50947
4 changed files with 2 additions and 31 deletions

View file

@ -17,7 +17,6 @@ use ash::extensions::{Swapchain, XlibSurface, Surface, DebugReport, Win32Surface
use std::ptr; use std::ptr;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::ops::Drop; use std::ops::Drop;
use ash::entry::EntryExt;
// Simple offset_of macro akin to C++ offsetof // Simple offset_of macro akin to C++ offsetof
#[macro_export] #[macro_export]

View file

@ -47,34 +47,7 @@ pub enum InstanceError {
LoadError(Vec<&'static str>), LoadError(Vec<&'static str>),
VkError(vk::Result), VkError(vk::Result),
} }
pub trait EntryExt {
fn load_vulkan<V: FunctionPointers>() -> Result<Entry<V>, LoadingError> {
let static_fn = match *VK_LIB {
Ok(ref lib) => {
let static_fn = vk::StaticFn::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))?;
Ok(static_fn)
}
Err(ref err) => Err(LoadingError::LibraryLoadError(err.clone())),
}?;
let entry_fn = vk::EntryFn::load(|name| unsafe {
mem::transmute(static_fn.get_instance_proc_addr(vk::Instance::null(), name.as_ptr()))
}).map_err(|err| LoadingError::EntryLoadError(err))?;
Ok(Entry {
static_fn: static_fn,
entry_fn: entry_fn,
_v: PhantomData,
})
}
}
impl<V: FunctionPointers> EntryExt for Entry<V> {}
impl Entry<V1_0> {}
impl<V: FunctionPointers> Entry<V> { impl<V: FunctionPointers> Entry<V> {
pub fn create_instance(&self, pub fn create_instance(&self,
create_info: &vk::InstanceCreateInfo, create_info: &vk::InstanceCreateInfo,

View file

@ -7,7 +7,7 @@ pub use entry::Entry;
mod instance; mod instance;
mod device; mod device;
pub mod entry; mod entry;
pub mod prelude; pub mod prelude;
pub mod vk; pub mod vk;
pub mod allocator; pub mod allocator;

View file

@ -1,7 +1,6 @@
use vk; use vk;
pub use instance::InstanceV1_0; pub use instance::InstanceV1_0;
pub use device::DeviceV1_0; pub use device::DeviceV1_0;
use entry::EntryExt;
use std::mem; use std::mem;
pub trait FunctionPointers { pub trait FunctionPointers {
type InstanceFp: InstanceLoader; type InstanceFp: InstanceLoader;