From 2022b4f6038058dff8446a9899dbad90b4f9c29f Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 10 May 2022 15:18:13 +0200 Subject: [PATCH] extensions/ext: Add VK_EXT_pipeline_properties device extension --- Changelog.md | 1 + ash/src/extensions/ext/mod.rs | 2 + ash/src/extensions/ext/pipeline_properties.rs | 47 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 ash/src/extensions/ext/pipeline_properties.rs diff --git a/Changelog.md b/Changelog.md index dcfcaee54..ea78b8478 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Update Vulkan-Headers to 1.3.244 (#697) +- Added `VK_EXT_pipeline_properties` device extension (#622) ### Changed diff --git a/ash/src/extensions/ext/mod.rs b/ash/src/extensions/ext/mod.rs index f30ee32b5..ca247b65f 100644 --- a/ash/src/extensions/ext/mod.rs +++ b/ash/src/extensions/ext/mod.rs @@ -16,6 +16,7 @@ pub use self::image_compression_control::ImageCompressionControl; pub use self::image_drm_format_modifier::ImageDrmFormatModifier; pub use self::mesh_shader::MeshShader; pub use self::metal_surface::MetalSurface; +pub use self::pipeline_properties::PipelineProperties; pub use self::private_data::PrivateData; pub use self::sample_locations::SampleLocations; pub use self::tooling_info::ToolingInfo; @@ -38,6 +39,7 @@ mod image_compression_control; mod image_drm_format_modifier; mod mesh_shader; mod metal_surface; +mod pipeline_properties; mod private_data; mod sample_locations; mod tooling_info; diff --git a/ash/src/extensions/ext/pipeline_properties.rs b/ash/src/extensions/ext/pipeline_properties.rs new file mode 100644 index 000000000..0abaeebe4 --- /dev/null +++ b/ash/src/extensions/ext/pipeline_properties.rs @@ -0,0 +1,47 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct PipelineProperties { + handle: vk::Device, + fp: vk::ExtPipelinePropertiesFn, +} + +impl PipelineProperties { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtPipelinePropertiesFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + /// + /// Currently only accepts [`vk::PipelinePropertiesIdentifierEXT`]. + #[inline] + pub unsafe fn get_pipeline_properties( + &self, + pipeline_info: &vk::PipelineInfoEXT, + pipeline_properties: *mut vk::BaseOutStructure, + ) -> VkResult<()> { + (self.fp.get_pipeline_properties_ext)(self.handle, pipeline_info, pipeline_properties) + .result() + } + + pub const NAME: &'static CStr = vk::ExtPipelinePropertiesFn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::ExtPipelinePropertiesFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +}