mirror of
https://github.com/italicsjenga/ash-molten.git
synced 2024-12-23 13:21:30 +11:00
parent
6d8a0e6e79
commit
823fbb851a
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
32
src/lib.rs
32
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
|
||||
}
|
||||
pub fn load() -> Entry {
|
||||
let static_fn = vk::StaticFn {
|
||||
get_instance_proc_addr: vkGetInstanceProcAddr,
|
||||
};
|
||||
unsafe { Entry::from_static_fn(static_fn) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue