extensions/khr: Add VK_KHR_dynamic_rendering wrapper (#488)

This commit is contained in:
Marijn Suijten 2021-11-09 22:49:41 +01:00 committed by GitHub
parent 3947675aaa
commit 6857f7b4d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View file

@ -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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginRenderingKHR.html>"]
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 = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndRenderingKHR.html>"]
pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) {
self.fns.cmd_end_rendering_khr(command_buffer)
}
}

View file

@ -6,6 +6,7 @@ pub use self::deferred_host_operations::DeferredHostOperations;
pub use self::display::Display; pub use self::display::Display;
pub use self::display_swapchain::DisplaySwapchain; pub use self::display_swapchain::DisplaySwapchain;
pub use self::draw_indirect_count::DrawIndirectCount; pub use self::draw_indirect_count::DrawIndirectCount;
pub use self::dynamic_rendering::DynamicRendering;
pub use self::external_fence_fd::ExternalFenceFd; pub use self::external_fence_fd::ExternalFenceFd;
pub use self::external_memory_fd::ExternalMemoryFd; pub use self::external_memory_fd::ExternalMemoryFd;
pub use self::external_semaphore_fd::ExternalSemaphoreFd; pub use self::external_semaphore_fd::ExternalSemaphoreFd;
@ -33,6 +34,7 @@ mod deferred_host_operations;
mod display; mod display;
mod display_swapchain; mod display_swapchain;
mod draw_indirect_count; mod draw_indirect_count;
mod dynamic_rendering;
mod external_fence_fd; mod external_fence_fd;
mod external_memory_fd; mod external_memory_fd;
mod external_semaphore_fd; mod external_semaphore_fd;