Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions/khr: Add VK_KHR_dynamic_rendering wrapper #488

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions ash/src/extensions/khr/dynamic_rendering.rs
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down