extensions/ext: Add VK_EXT_hdr_metadata extension (#804)

This commit is contained in:
Marijn Suijten 2023-10-26 09:05:14 +02:00 committed by GitHub
parent ff54d22a15
commit a6f8450edf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 3 deletions

View file

@ -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

View file

@ -0,0 +1,49 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_hdr_metadata.html>
#[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 }
}
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkSetHdrMetadataEXT.html>
#[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
}
}

View file

@ -31,7 +31,7 @@ impl MeshShader {
group_count_x,
group_count_y,
group_count_z,
);
)
}
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectEXT.html>
@ -52,7 +52,7 @@ impl MeshShader {
offset,
draw_count,
stride,
);
)
}
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectCountEXT.html>
@ -79,7 +79,7 @@ impl MeshShader {
count_buffer_offset,
max_draw_count,
stride,
);
)
}
pub const NAME: &'static CStr = vk::ExtMeshShaderFn::NAME;

View file

@ -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;