Skip to content

Commit

Permalink
Add Handle::is_null()
Browse files Browse the repository at this point in the history
  • Loading branch information
i509VCB authored and MarijnS95 committed May 6, 2023
1 parent d783af0 commit 9134359
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `Handle::is_null()` to allow checking if a handle is a `NULL` value (#694)
- Update Vulkan-Headers to 1.3.246 (#697, #723)
- Added `VK_KHR_performance_query` device extension (#726)
- Added `VK_EXT_shader_object` device extension (#732)
Expand Down
12 changes: 12 additions & 0 deletions ash/src/vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ pub trait Handle {
const TYPE: ObjectType;
fn as_raw(self) -> u64;
fn from_raw(_: u64) -> Self;

/// Returns whether the handle is a `NULL` value.
///
/// # Example
///
/// ```
/// # use ash::vk::{Handle, Instance};
///
/// let instance = Instance::null();
/// assert!(instance.is_null());
/// ```
fn is_null(self) -> bool;
}
6 changes: 6 additions & 0 deletions ash/src/vk/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ macro_rules! handle_nondispatchable {
fn from_raw(x: u64) -> Self {
Self(x)
}
fn is_null(self) -> bool {
self.0 == 0
}
}
impl $name {
pub const fn null() -> Self {
Expand Down Expand Up @@ -140,6 +143,9 @@ macro_rules! define_handle {
fn from_raw(x: u64) -> Self {
Self(x as _)
}
fn is_null(self) -> bool {
self.0.is_null()
}
}
unsafe impl Send for $name {}
unsafe impl Sync for $name {}
Expand Down

0 comments on commit 9134359

Please sign in to comment.