Skip to content

Commit 9134359

Browse files
i509VCBMarijnS95
authored andcommitted
Add Handle::is_null()
1 parent d783af0 commit 9134359

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Added `Handle::is_null()` to allow checking if a handle is a `NULL` value (#694)
1213
- Update Vulkan-Headers to 1.3.246 (#697, #723)
1314
- Added `VK_KHR_performance_query` device extension (#726)
1415
- Added `VK_EXT_shader_object` device extension (#732)

ash/src/vk.rs

+12
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,16 @@ pub trait Handle {
4949
const TYPE: ObjectType;
5050
fn as_raw(self) -> u64;
5151
fn from_raw(_: u64) -> Self;
52+
53+
/// Returns whether the handle is a `NULL` value.
54+
///
55+
/// # Example
56+
///
57+
/// ```
58+
/// # use ash::vk::{Handle, Instance};
59+
///
60+
/// let instance = Instance::null();
61+
/// assert!(instance.is_null());
62+
/// ```
63+
fn is_null(self) -> bool;
5264
}

ash/src/vk/macros.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ macro_rules! handle_nondispatchable {
9999
fn from_raw(x: u64) -> Self {
100100
Self(x)
101101
}
102+
fn is_null(self) -> bool {
103+
self.0 == 0
104+
}
102105
}
103106
impl $name {
104107
pub const fn null() -> Self {
@@ -140,6 +143,9 @@ macro_rules! define_handle {
140143
fn from_raw(x: u64) -> Self {
141144
Self(x as _)
142145
}
146+
fn is_null(self) -> bool {
147+
self.0.is_null()
148+
}
143149
}
144150
unsafe impl Send for $name {}
145151
unsafe impl Sync for $name {}

0 commit comments

Comments
 (0)