Skip to content

Commit

Permalink
extensions/ext: Add VK_EXT_hdr_metadata extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Oct 25, 2023
1 parent 2d2aeac commit 8f81f7d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
49 changes: 49 additions & 0 deletions ash/src/extensions/ext/hdr_metadata.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
6 changes: 3 additions & 3 deletions ash/src/extensions/ext/mesh_shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -52,7 +52,7 @@ impl MeshShader {
offset,
draw_count,
stride,
);
)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectCountEXT.html>
Expand All @@ -79,7 +79,7 @@ impl MeshShader {
count_buffer_offset,
max_draw_count,
stride,
);
)
}

pub const NAME: &'static CStr = vk::ExtMeshShaderFn::NAME;
Expand Down
2 changes: 2 additions & 0 deletions ash/src/extensions/ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8f81f7d

Please sign in to comment.