From a6f8450edf4721536bc37a056838c54b36905a41 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 26 Oct 2023 09:05:14 +0200 Subject: [PATCH] extensions/ext: Add VK_EXT_hdr_metadata extension (#804) --- Changelog.md | 1 + ash/src/extensions/ext/hdr_metadata.rs | 49 ++++++++++++++++++++++++++ ash/src/extensions/ext/mesh_shader.rs | 6 ++-- ash/src/extensions/ext/mod.rs | 2 ++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 ash/src/extensions/ext/hdr_metadata.rs diff --git a/Changelog.md b/Changelog.md index d98a3f2..fac6f5f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_KHR_sampler_ycbcr_conversion` device extension (#785) - Added `VK_EXT_swapchain_maintenance1` device extension (#786) - Added `VK_NV_low_latency2` device extension (#802) +- Added `VK_EXT_hdr_metadata` device extension (#804) ### Changed diff --git a/ash/src/extensions/ext/hdr_metadata.rs b/ash/src/extensions/ext/hdr_metadata.rs new file mode 100644 index 0000000..156b85a --- /dev/null +++ b/ash/src/extensions/ext/hdr_metadata.rs @@ -0,0 +1,49 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct HdrMetadata { + handle: vk::Device, + fp: vk::ExtHdrMetadataFn, +} + +impl HdrMetadata { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtHdrMetadataFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn set_hdr_metadata( + &self, + swapchains: &[vk::SwapchainKHR], + metadata: &[vk::HdrMetadataEXT<'_>], + ) { + assert_eq!(swapchains.len(), metadata.len()); + (self.fp.set_hdr_metadata_ext)( + self.handle, + swapchains.len() as u32, + swapchains.as_ptr(), + metadata.as_ptr(), + ) + } + + pub const NAME: &'static CStr = vk::ExtHdrMetadataFn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::ExtHdrMetadataFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/ext/mesh_shader.rs b/ash/src/extensions/ext/mesh_shader.rs index 3371d43..df830d2 100644 --- a/ash/src/extensions/ext/mesh_shader.rs +++ b/ash/src/extensions/ext/mesh_shader.rs @@ -31,7 +31,7 @@ impl MeshShader { group_count_x, group_count_y, group_count_z, - ); + ) } /// @@ -52,7 +52,7 @@ impl MeshShader { offset, draw_count, stride, - ); + ) } /// @@ -79,7 +79,7 @@ impl MeshShader { count_buffer_offset, max_draw_count, stride, - ); + ) } pub const NAME: &'static CStr = vk::ExtMeshShaderFn::NAME; diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 680a997..9f01c98 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -11,6 +11,7 @@ pub use self::extended_dynamic_state::ExtendedDynamicState; pub use self::extended_dynamic_state2::ExtendedDynamicState2; pub use self::extended_dynamic_state3::ExtendedDynamicState3; pub use self::full_screen_exclusive::FullScreenExclusive; +pub use self::hdr_metadata::HdrMetadata; pub use self::headless_surface::HeadlessSurface; pub use self::host_image_copy::HostImageCopy; pub use self::image_compression_control::ImageCompressionControl; @@ -38,6 +39,7 @@ mod extended_dynamic_state; mod extended_dynamic_state2; mod extended_dynamic_state3; mod full_screen_exclusive; +mod hdr_metadata; mod headless_surface; mod host_image_copy; mod image_compression_control;