Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ash/src/vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ pub mod native;
mod platform_types;
pub use platform_types::*;

pub trait DispatchableHandle: Handle {
// We choose to use a pointer type for the parameter to avoid possible integer-to-pointer cast,
// to keep the pointer provenance. See details at https://github.com/ash-rs/ash/issues/996.
fn from_raw_ptr(_: *mut u8) -> Self;
}

pub trait Handle: Sized {
const TYPE: ObjectType;
fn as_raw(self) -> u64;
Expand Down
5 changes: 5 additions & 0 deletions ash/src/vk/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ macro_rules! define_handle {
Self(x as _)
}
}
impl $crate::vk::DispatchableHandle for $name {
fn from_raw_ptr(x: *mut u8) -> Self {
Self(x)
}
}
unsafe impl Send for $name {}
unsafe impl Sync for $name {}
impl $name {
Expand Down