From 9e14786b83f18719242f5ac019d54afd32d549d9 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Fri, 19 Nov 2021 10:39:06 +0100 Subject: [PATCH] extensions: Add VK_KHR_present_wait (#493) --- Changelog.md | 4 +++ ash/src/extensions/khr/mod.rs | 2 ++ ash/src/extensions/khr/present_wait.rs | 45 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 ash/src/extensions/khr/present_wait.rs diff --git a/Changelog.md b/Changelog.md index c69b5cf..a3ffe4a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Added + +- Add `VK_KHR_present_wait` extension (#493) + ## [0.33.3] - 2021-09-08 ### Added diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index 52b53f3..69cffe0 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -16,6 +16,7 @@ pub use self::maintenance1::Maintenance1; pub use self::maintenance3::Maintenance3; pub use self::maintenance4::Maintenance4; pub use self::pipeline_executable_properties::PipelineExecutableProperties; +pub use self::present_wait::PresentWait; pub use self::push_descriptor::PushDescriptor; pub use self::ray_tracing_pipeline::RayTracingPipeline; pub use self::surface::Surface; @@ -45,6 +46,7 @@ mod maintenance1; mod maintenance3; mod maintenance4; mod pipeline_executable_properties; +mod present_wait; mod push_descriptor; mod ray_tracing_pipeline; mod surface; diff --git a/ash/src/extensions/khr/present_wait.rs b/ash/src/extensions/khr/present_wait.rs new file mode 100644 index 0000000..bcdc70a --- /dev/null +++ b/ash/src/extensions/khr/present_wait.rs @@ -0,0 +1,45 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PresentWait { + handle: vk::Device, + fns: vk::KhrPresentWaitFn, +} + +impl PresentWait { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fns = vk::KhrPresentWaitFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fns } + } + + #[doc = ""] + pub unsafe fn wait_for_present( + &self, + swapchain: vk::SwapchainKHR, + present_id: u64, + timeout: u64, + ) -> VkResult<()> { + self.fns + .wait_for_present_khr(self.handle, swapchain, present_id, timeout) + .result() + } + + pub fn name() -> &'static CStr { + vk::KhrPresentWaitFn::name() + } + + pub fn fp(&self) -> &vk::KhrPresentWaitFn { + &self.fns + } + + pub fn device(&self) -> vk::Device { + self.handle + } +}