From 6857f7b4d3550209622ae1b8742d81e8a05aad40 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Tue, 9 Nov 2021 22:49:41 +0100 Subject: [PATCH] extensions/khr: Add VK_KHR_dynamic_rendering wrapper (#488) --- ash/src/extensions/khr/dynamic_rendering.rs | 43 +++++++++++++++++++++ ash/src/extensions/khr/mod.rs | 2 + 2 files changed, 45 insertions(+) create mode 100644 ash/src/extensions/khr/dynamic_rendering.rs diff --git a/ash/src/extensions/khr/dynamic_rendering.rs b/ash/src/extensions/khr/dynamic_rendering.rs new file mode 100644 index 0000000..57925f2 --- /dev/null +++ b/ash/src/extensions/khr/dynamic_rendering.rs @@ -0,0 +1,43 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DynamicRendering { + fns: vk::KhrDynamicRenderingFn, +} + +impl DynamicRendering { + pub fn new(instance: &Instance, device: &Device) -> Self { + let dynamic_rendering_fn = vk::KhrDynamicRenderingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + fns: dynamic_rendering_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDynamicRenderingFn::name() + } + + pub fn fp(&self) -> &vk::KhrDynamicRenderingFn { + &self.fns + } + + #[doc = ""] + pub unsafe fn cmd_begin_rendering( + &self, + command_buffer: vk::CommandBuffer, + rendering_info: &vk::RenderingInfoKHR, + ) { + self.fns + .cmd_begin_rendering_khr(command_buffer, rendering_info) + } + + #[doc = ""] + pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) { + self.fns.cmd_end_rendering_khr(command_buffer) + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index ef881ec..c7c99d4 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -6,6 +6,7 @@ pub use self::deferred_host_operations::DeferredHostOperations; pub use self::display::Display; pub use self::display_swapchain::DisplaySwapchain; pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::dynamic_rendering::DynamicRendering; pub use self::external_fence_fd::ExternalFenceFd; pub use self::external_memory_fd::ExternalMemoryFd; pub use self::external_semaphore_fd::ExternalSemaphoreFd; @@ -33,6 +34,7 @@ mod deferred_host_operations; mod display; mod display_swapchain; mod draw_indirect_count; +mod dynamic_rendering; mod external_fence_fd; mod external_memory_fd; mod external_semaphore_fd;