Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions/ext: Add VK_EXT_hdr_metadata extension #804

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentional: I used this mod as a base and noticed that ; was hampering our ability to ensure that the return types are identical.

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
Loading