Entry LIB_PATH

This commit is contained in:
Dzmitry Malyshau 2018-02-16 11:33:40 -05:00
parent 485ba8b9d5
commit 522445d079

View file

@ -4,34 +4,26 @@ use std::ptr;
use vk; use vk;
use instance::Instance; use instance::Instance;
use shared_library::dynamic_library::DynamicLibrary; use shared_library::dynamic_library::DynamicLibrary;
use std::path::Path;
use std::error::Error; use std::error::Error;
use std::fmt; use std::fmt;
use std::path::Path;
use RawPtr; use RawPtr;
use version::{EntryLoader, FunctionPointers, InstanceLoader, V1_0}; use version::{EntryLoader, FunctionPointers, InstanceLoader, V1_0};
#[cfg(windows)] #[cfg(windows)]
fn get_path() -> &'static Path { const LIB_PATH: &'static str = "vulkan-1.dll";
Path::new("vulkan-1.dll")
}
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "android"))))] #[cfg(all(unix, not(any(target_os = "macos", target_os = "ios", target_os = "android"))))]
fn get_path() -> &'static Path { const LIB_PATH: &'static str = "libvulkan.so.1";
Path::new("libvulkan.so.1")
}
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
fn get_path() -> &'static Path { const LIB_PATH: &'static str = "libvulkan.so";
Path::new("libvulkan.so")
}
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(any(target_os = "macos", target_os = "ios"))]
fn get_path() -> &'static Path { const LIB_PATH: &'static str = "libMoltenVK.dylib";
Path::new("libMoltenVK.dylib")
}
lazy_static!{ lazy_static!{
static ref VK_LIB: Result<DynamicLibrary, String> = DynamicLibrary::open(Some(get_path())); static ref VK_LIB: Result<DynamicLibrary, String> = DynamicLibrary::open(Some(&Path::new(LIB_PATH)));
} }
#[derive(Clone)] #[derive(Clone)]
@ -165,7 +157,7 @@ impl<V: FunctionPointers> Entry<V> {
.map_err(|err| LoadingError::LibraryLoadError(err.clone()))?; .map_err(|err| LoadingError::LibraryLoadError(err.clone()))?;
let static_fn = vk::StaticFn::load(|name| unsafe { let static_fn = vk::StaticFn::load(|name| unsafe {
lib.symbol(name.to_str().unwrap()) lib.symbol(&*name.to_string_lossy())
.unwrap_or(ptr::null_mut()) .unwrap_or(ptr::null_mut())
}).map_err(LoadingError::StaticLoadError)?; }).map_err(LoadingError::StaticLoadError)?;