From 0d4f2ba23ac87e3e4a77f3a51a5cf6f6939bb85c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sun, 3 Jul 2022 22:09:06 +0200 Subject: [PATCH] extensions/ext: Add VK_EXT_image_compression_control device extension (#621) --- Changelog.md | 1 + .../ext/image_compression_control.rs | 47 +++++++++++++++++++ ash/src/extensions/ext/mod.rs | 2 + 3 files changed, 50 insertions(+) create mode 100644 ash/src/extensions/ext/image_compression_control.rs diff --git a/Changelog.md b/Changelog.md index 2f10b54..09775e3 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_EXT_sample_locations` device extension (#616) - Added `VK_NV_coverage_reduction_mode` device extension (#617) - Added `VK_KHR_ray_tracing_maintenance1` device extension (#620) +- Added `VK_EXT_image_compression_control` device extension (#621) - Added new functions to `VK_KHR_swapchain`, available since Vulkan 1.1 (#629) - Added `VK_KHR_device_group_creation` instance extension (#630) - Added `VK_KHR_device_group` device extension (#631) diff --git a/ash/src/extensions/ext/image_compression_control.rs b/ash/src/extensions/ext/image_compression_control.rs new file mode 100644 index 0000000..a326116 --- /dev/null +++ b/ash/src/extensions/ext/image_compression_control.rs @@ -0,0 +1,47 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct ImageCompressionControl { + handle: vk::Device, + fp: vk::ExtImageCompressionControlFn, +} + +impl ImageCompressionControl { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtImageCompressionControlFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn get_image_subresource_layout2( + &self, + image: vk::Image, + subresource: &vk::ImageSubresource2EXT, + layout: &mut vk::SubresourceLayout2EXT, + ) { + (self.fp.get_image_subresource_layout2_ext)(self.handle, image, subresource, layout) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtImageCompressionControlFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtImageCompressionControlFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index 2de7c80..477eb81 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -9,6 +9,7 @@ pub use self::extended_dynamic_state::ExtendedDynamicState; pub use self::extended_dynamic_state2::ExtendedDynamicState2; pub use self::full_screen_exclusive::FullScreenExclusive; pub use self::headless_surface::HeadlessSurface; +pub use self::image_compression_control::ImageCompressionControl; pub use self::image_drm_format_modifier::ImageDrmFormatModifier; pub use self::metal_surface::MetalSurface; pub use self::physical_device_drm::PhysicalDeviceDrm; @@ -27,6 +28,7 @@ mod extended_dynamic_state; mod extended_dynamic_state2; mod full_screen_exclusive; mod headless_surface; +mod image_compression_control; mod image_drm_format_modifier; mod metal_surface; mod physical_device_drm;