Update ash to 0.35 (#63)

* Update ash to 0.34

* Update ash to 0.35
This commit is contained in:
Ashley Hauck 2021-12-28 14:04:00 +01:00 committed by GitHub
parent 6d8a0e6e79
commit 823fbb851a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 29 deletions

View file

@ -14,7 +14,7 @@ documentation = "https://docs.rs/ash-molten"
build = "build/build.rs" build = "build/build.rs"
[dependencies] [dependencies]
ash = { version = "0.33", default-features = false } ash = { version = "0.35", default-features = false }
[build-dependencies] [build-dependencies]
anyhow = "1.0" anyhow = "1.0"

View file

@ -74,7 +74,7 @@ use ash::vk;
use std::ffi::CString; use std::ffi::CString;
fn main() { fn main() {
unsafe { unsafe {
let entry = ash_molten::MoltenEntry::load(); let entry = ash_molten::load();
let app_name = CString::new("Hello Static Molten").unwrap(); let app_name = CString::new("Hello Static Molten").unwrap();
let appinfo = vk::ApplicationInfo::builder() let appinfo = vk::ApplicationInfo::builder()

View file

@ -70,9 +70,7 @@
// crate-specific exceptions: // crate-specific exceptions:
#![allow(unsafe_code)] #![allow(unsafe_code)]
use std::ops::Deref; use ash::{vk, Entry};
use ash::{vk, EntryCustom};
extern "system" { extern "system" {
fn vkGetInstanceProcAddr( fn vkGetInstanceProcAddr(
@ -81,28 +79,10 @@ extern "system" {
) -> vk::PFN_vkVoidFunction; ) -> vk::PFN_vkVoidFunction;
} }
/// The entry point for the statically linked molten library /// Fetches the function pointer to `vkGetInstanceProcAddr` which is statically linked.
pub struct MoltenEntry(EntryCustom<()>); pub fn load() -> Entry {
let static_fn = vk::StaticFn {
impl MoltenEntry { get_instance_proc_addr: vkGetInstanceProcAddr,
/// Fetches the function pointer to `vkGetInstanceProcAddr` which is statically linked. };
pub fn load() -> Self { unsafe { Entry::from_static_fn(static_fn) }
Self(
EntryCustom::new_custom((), |(), name| {
assert_eq!(name.to_bytes_with_nul(), b"vkGetInstanceProcAddr\0");
vkGetInstanceProcAddr as _
})
// This can never fail because we always return the address of
// `vkGetInstanceProcAddr` from the closure:
.unwrap(),
)
}
}
impl Deref for MoltenEntry {
type Target = EntryCustom<()>;
fn deref(&self) -> &Self::Target {
&self.0
}
} }