From 61a6a15ef5e78ba1ae7f8fddcb6876e2ea0e4a2a Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 31 Jul 2023 22:04:58 +0200 Subject: [PATCH] extensions/khr: Add VK_KHR_maintenance5 --- Changelog.md | 1 + ash/src/extensions/ext/host_image_copy.rs | 6 +- .../ext/image_compression_control.rs | 6 +- ash/src/extensions/khr/maintenance1.rs | 1 + ash/src/extensions/khr/maintenance3.rs | 1 + ash/src/extensions/khr/maintenance4.rs | 1 + ash/src/extensions/khr/maintenance5.rs | 93 +++++++++++++++++++ ash/src/extensions/khr/mod.rs | 2 + 8 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 ash/src/extensions/khr/maintenance5.rs diff --git a/Changelog.md b/Changelog.md index ae1de9e92..ea53dd7e8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_AMD_shader_info` device extension (#773) - Added `VK_AMDX_shader_enqueue` device extension (#776) - Added `VK_EXT_host_image_copy` device extension (#779) +- Added `VK_KHR_maintenance5` device extension (#780) ### Changed diff --git a/ash/src/extensions/ext/host_image_copy.rs b/ash/src/extensions/ext/host_image_copy.rs index 10494117e..70f3b4d5f 100644 --- a/ash/src/extensions/ext/host_image_copy.rs +++ b/ash/src/extensions/ext/host_image_copy.rs @@ -1,5 +1,5 @@ #[cfg(doc)] -use super::ImageCompressionControl; +use super::{super::khr::Maintenance5, ImageCompressionControl}; use crate::prelude::*; use crate::vk; use crate::{Device, Instance}; @@ -65,9 +65,13 @@ impl HostImageCopy { /// /// + /// Also available as [`Maintenance5::get_image_subresource_layout2()`] + /// when [`VK_KHR_maintenance5`] is enabled. + /// /// Also available as [`ImageCompressionControl::get_image_subresource_layout2()`] /// when [`VK_EXT_image_compression_control`] is enabled. /// + /// [`VK_KHR_maintenance5`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance5.html /// [`VK_EXT_image_compression_control`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_compression_control.html #[inline] pub unsafe fn get_image_subresource_layout2( diff --git a/ash/src/extensions/ext/image_compression_control.rs b/ash/src/extensions/ext/image_compression_control.rs index 59315ee60..513be0f16 100644 --- a/ash/src/extensions/ext/image_compression_control.rs +++ b/ash/src/extensions/ext/image_compression_control.rs @@ -1,5 +1,5 @@ #[cfg(doc)] -use super::HostImageCopy; +use super::{super::khr::Maintenance5, HostImageCopy}; use crate::vk; use crate::{Device, Instance}; use std::ffi::CStr; @@ -23,9 +23,13 @@ impl ImageCompressionControl { /// /// + /// Also available as [`Maintenance5::get_image_subresource_layout2()`] + /// when [`VK_KHR_maintenance5`] is enabled. + /// /// Also available as [`HostImageCopy::get_image_subresource_layout2()`] /// when [`VK_EXT_host_image_copy`] is enabled. /// + /// [`VK_KHR_maintenance5`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_maintenance5.html /// [`VK_EXT_host_image_copy`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html #[inline] pub unsafe fn get_image_subresource_layout2( diff --git a/ash/src/extensions/khr/maintenance1.rs b/ash/src/extensions/khr/maintenance1.rs index 8bd43eb86..2df63b72d 100644 --- a/ash/src/extensions/khr/maintenance1.rs +++ b/ash/src/extensions/khr/maintenance1.rs @@ -3,6 +3,7 @@ use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; +/// #[derive(Clone)] pub struct Maintenance1 { handle: vk::Device, diff --git a/ash/src/extensions/khr/maintenance3.rs b/ash/src/extensions/khr/maintenance3.rs index 67723811e..2d6a0f70e 100644 --- a/ash/src/extensions/khr/maintenance3.rs +++ b/ash/src/extensions/khr/maintenance3.rs @@ -3,6 +3,7 @@ use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; +/// #[derive(Clone)] pub struct Maintenance3 { handle: vk::Device, diff --git a/ash/src/extensions/khr/maintenance4.rs b/ash/src/extensions/khr/maintenance4.rs index fa7555eb0..0b1e24464 100644 --- a/ash/src/extensions/khr/maintenance4.rs +++ b/ash/src/extensions/khr/maintenance4.rs @@ -3,6 +3,7 @@ use crate::{Device, Instance}; use std::ffi::CStr; use std::mem; +/// #[derive(Clone)] pub struct Maintenance4 { handle: vk::Device, diff --git a/ash/src/extensions/khr/maintenance5.rs b/ash/src/extensions/khr/maintenance5.rs new file mode 100644 index 000000000..80b2fc6fa --- /dev/null +++ b/ash/src/extensions/khr/maintenance5.rs @@ -0,0 +1,93 @@ +#[cfg(doc)] +use super::super::ext::{HostImageCopy, ImageCompressionControl}; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct Maintenance5 { + handle: vk::Device, + fp: vk::KhrMaintenance5Fn, +} + +impl Maintenance5 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance5Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn cmd_bind_index_buffer2( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + size: vk::DeviceSize, + index_type: vk::IndexType, + ) { + (self.fp.cmd_bind_index_buffer2_khr)(command_buffer, buffer, offset, size, index_type) + } + + /// + #[inline] + pub unsafe fn get_rendering_area_granularity( + &self, + rendering_area_info: &vk::RenderingAreaInfoKHR, + ) -> vk::Extent2D { + let mut granularity = mem::zeroed(); + (self.fp.get_rendering_area_granularity_khr)( + self.handle, + rendering_area_info, + &mut granularity, + ); + granularity + } + + /// + #[inline] + pub unsafe fn get_device_image_subresource_layout( + &self, + info: &vk::DeviceImageSubresourceInfoKHR, + layout: &mut vk::SubresourceLayout2KHR, + ) { + (self.fp.get_device_image_subresource_layout_khr)(self.handle, info, layout) + } + + /// + /// + /// Also available as [`HostImageCopy::get_image_subresource_layout2()`] + /// when [`VK_EXT_host_image_copy`] is enabled. + /// + /// Also available as [`ImageCompressionControl::get_image_subresource_layout2()`] + /// when [`VK_EXT_image_compression_control`] is enabled. + /// + /// [`VK_EXT_host_image_copy`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_host_image_copy.html + /// [`VK_EXT_image_compression_control`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_compression_control.html + #[inline] + pub unsafe fn get_image_subresource_layout2( + &self, + image: vk::Image, + subresource: &vk::ImageSubresource2KHR, + layout: &mut vk::SubresourceLayout2KHR, + ) { + (self.fp.get_image_subresource_layout2_khr)(self.handle, image, subresource, layout) + } + + pub const NAME: &'static CStr = vk::KhrMaintenance5Fn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance5Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index ff84d0dbf..fdd41f4c2 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -22,6 +22,7 @@ pub use self::get_surface_capabilities2::GetSurfaceCapabilities2; pub use self::maintenance1::Maintenance1; pub use self::maintenance3::Maintenance3; pub use self::maintenance4::Maintenance4; +pub use self::maintenance5::Maintenance5; pub use self::performance_query::PerformanceQuery; pub use self::pipeline_executable_properties::PipelineExecutableProperties; pub use self::present_wait::PresentWait; @@ -61,6 +62,7 @@ mod get_surface_capabilities2; mod maintenance1; mod maintenance3; mod maintenance4; +mod maintenance5; mod performance_query; mod pipeline_executable_properties; mod present_wait;