From 269200999f2c9a22b2e4e4cb789f99fcfff3ee5a Mon Sep 17 00:00:00 2001 From: Chris Spencer Date: Mon, 14 Aug 2023 14:39:19 +0100 Subject: [PATCH] extensions/khr: Add VK_KHR_sampler_ycbcr_conversion --- Changelog.md | 1 + ash/src/extensions/khr/mod.rs | 2 + .../khr/sampler_ycbcr_conversion.rs | 66 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 ash/src/extensions/khr/sampler_ycbcr_conversion.rs diff --git a/Changelog.md b/Changelog.md index d8ac0961a..72a651315 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_ANDROID_external_memory_android_hardware_buffer` device extension (#769) - Added `VK_AMD_buffer_marker` device extension (#772) - Added `VK_AMD_shader_info` device extension (#773) +- Added `VK_KHR_sampler_ycbcr_conversion` device extension (#785) ### Changed diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index ff84d0dbf..66ef9667a 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -28,6 +28,7 @@ pub use self::present_wait::PresentWait; pub use self::push_descriptor::PushDescriptor; pub use self::ray_tracing_maintenance1::RayTracingMaintenance1; pub use self::ray_tracing_pipeline::RayTracingPipeline; +pub use self::sampler_ycbcr_conversion::SamplerYcbcrConversion; pub use self::surface::Surface; pub use self::swapchain::Swapchain; pub use self::synchronization2::Synchronization2; @@ -67,6 +68,7 @@ mod present_wait; mod push_descriptor; mod ray_tracing_maintenance1; mod ray_tracing_pipeline; +mod sampler_ycbcr_conversion; mod surface; mod swapchain; mod synchronization2; diff --git a/ash/src/extensions/khr/sampler_ycbcr_conversion.rs b/ash/src/extensions/khr/sampler_ycbcr_conversion.rs new file mode 100644 index 000000000..03b97067c --- /dev/null +++ b/ash/src/extensions/khr/sampler_ycbcr_conversion.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct SamplerYcbcrConversion { + handle: vk::Device, + fp: vk::KhrSamplerYcbcrConversionFn, +} + +impl SamplerYcbcrConversion { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrSamplerYcbcrConversionFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn create_sampler_ycbcr_conversion( + &self, + create_info: &vk::SamplerYcbcrConversionCreateInfo, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult { + let mut ycbcr_conversion = mem::zeroed(); + (self.fp.create_sampler_ycbcr_conversion_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut ycbcr_conversion, + ) + .result_with_success(ycbcr_conversion) + } + + /// + #[inline] + pub unsafe fn destroy_sampler_ycbcr_conversion( + &self, + ycbcr_conversion: vk::SamplerYcbcrConversion, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_sampler_ycbcr_conversion_khr)( + self.handle, + ycbcr_conversion, + allocation_callbacks.as_raw_ptr(), + ) + } + + pub const NAME: &'static CStr = vk::KhrSamplerYcbcrConversionFn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::KhrSamplerYcbcrConversionFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +}