mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-29 10:14:29 +00:00
Add fallback library names (#2230)
This commit is contained in:
parent
638f72279b
commit
3fdf75a727
@ -60,25 +60,38 @@ impl VulkanLibrary {
|
|||||||
#[cfg(not(target_os = "ios"))]
|
#[cfg(not(target_os = "ios"))]
|
||||||
fn def_loader_impl() -> Result<Box<dyn Loader>, LoadingError> {
|
fn def_loader_impl() -> Result<Box<dyn Loader>, LoadingError> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_path() -> &'static Path {
|
fn get_paths() -> [&'static Path; 1] {
|
||||||
Path::new("vulkan-1.dll")
|
[Path::new("vulkan-1.dll")]
|
||||||
}
|
}
|
||||||
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
#[cfg(all(unix, not(target_os = "android"), not(target_os = "macos")))]
|
||||||
fn get_path() -> &'static Path {
|
fn get_paths() -> [&'static Path; 1] {
|
||||||
Path::new("libvulkan.so.1")
|
[Path::new("libvulkan.so.1")]
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
fn get_path() -> &'static Path {
|
fn get_paths() -> [&'static Path; 3] {
|
||||||
Path::new("libvulkan.1.dylib")
|
[
|
||||||
|
Path::new("libvulkan.dylib"),
|
||||||
|
Path::new("libvulkan.1.dylib"),
|
||||||
|
Path::new("libMoltenVK.dylib"),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
fn get_path() -> &'static Path {
|
fn get_paths() -> [&'static Path; 2] {
|
||||||
Path::new("libvulkan.so")
|
[Path::new("libvulkan.so.1"), Path::new("libvulkan.so")]
|
||||||
}
|
}
|
||||||
|
|
||||||
let loader = unsafe { DynamicLibraryLoader::new(get_path())? };
|
let paths = get_paths();
|
||||||
|
|
||||||
Ok(Box::new(loader))
|
let mut err: Option<LoadingError> = None;
|
||||||
|
|
||||||
|
for path in paths {
|
||||||
|
match unsafe { DynamicLibraryLoader::new(path) } {
|
||||||
|
Ok(library) => return Ok(Box::new(library)),
|
||||||
|
Err(e) => err = Some(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(err.unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
def_loader_impl().and_then(VulkanLibrary::with_loader)
|
def_loader_impl().and_then(VulkanLibrary::with_loader)
|
||||||
|
Loading…
Reference in New Issue
Block a user