From 823fbb851a3e4c87df3d03a06505931ea837dbda Mon Sep 17 00:00:00 2001 From: Ashley Hauck <953151+khyperia@users.noreply.github.com> Date: Tue, 28 Dec 2021 14:04:00 +0100 Subject: [PATCH] Update ash to 0.35 (#63) * Update ash to 0.34 * Update ash to 0.35 --- Cargo.toml | 2 +- src/bin/main.rs | 2 +- src/lib.rs | 34 +++++++--------------------------- 3 files changed, 9 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 35dbcd6..1df8dc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ documentation = "https://docs.rs/ash-molten" build = "build/build.rs" [dependencies] -ash = { version = "0.33", default-features = false } +ash = { version = "0.35", default-features = false } [build-dependencies] anyhow = "1.0" diff --git a/src/bin/main.rs b/src/bin/main.rs index 1462396..def6e89 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -74,7 +74,7 @@ use ash::vk; use std::ffi::CString; fn main() { unsafe { - let entry = ash_molten::MoltenEntry::load(); + let entry = ash_molten::load(); let app_name = CString::new("Hello Static Molten").unwrap(); let appinfo = vk::ApplicationInfo::builder() diff --git a/src/lib.rs b/src/lib.rs index 08d81d7..51e115b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,9 +70,7 @@ // crate-specific exceptions: #![allow(unsafe_code)] -use std::ops::Deref; - -use ash::{vk, EntryCustom}; +use ash::{vk, Entry}; extern "system" { fn vkGetInstanceProcAddr( @@ -81,28 +79,10 @@ extern "system" { ) -> vk::PFN_vkVoidFunction; } -/// The entry point for the statically linked molten library -pub struct MoltenEntry(EntryCustom<()>); - -impl MoltenEntry { - /// Fetches the function pointer to `vkGetInstanceProcAddr` which is statically linked. - pub fn load() -> Self { - 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 - } +/// Fetches the function pointer to `vkGetInstanceProcAddr` which is statically linked. +pub fn load() -> Entry { + let static_fn = vk::StaticFn { + get_instance_proc_addr: vkGetInstanceProcAddr, + }; + unsafe { Entry::from_static_fn(static_fn) } }