diff --git a/Changelog.md b/Changelog.md index 387c5bd91..77e2891e8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added `VK_EXT_pipeline_properties` device extension (#622) +- 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) diff --git a/ash/src/vk.rs b/ash/src/vk.rs index 02a5e9c62..c145e7f74 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -45,8 +45,21 @@ pub(crate) unsafe fn ptr_chain_iter(ptr: &mut T) -> impl Iterator 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 { + self.as_raw() == 0 + } } diff --git a/ash/src/vk/macros.rs b/ash/src/vk/macros.rs index e986be312..16d182d29 100644 --- a/ash/src/vk/macros.rs +++ b/ash/src/vk/macros.rs @@ -140,6 +140,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 {}