From 89ca1d03f4b5a5fe6be98d7557a29658fe0205e1 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Sat, 29 Jan 2022 21:34:30 +0100 Subject: [PATCH] extensions/khr: Add VK_KHR_copy_commands2 (#571) --- Changelog.md | 1 + ash/src/extensions/khr/copy_commands2.rs | 80 ++++++++++++++++++++++++ ash/src/extensions/khr/mod.rs | 2 + 3 files changed, 83 insertions(+) create mode 100644 ash/src/extensions/khr/copy_commands2.rs diff --git a/Changelog.md b/Changelog.md index dc060ff..f4fc9ff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `VK_KHR_copy_commands2` device extension (#571) - Added `VK_EXT_private_data` device extension (#570) - Added conversions from `Extent2D` to `Extent3D` and `Rect2D` (#557) diff --git a/ash/src/extensions/khr/copy_commands2.rs b/ash/src/extensions/khr/copy_commands2.rs new file mode 100644 index 0000000..d5820ce --- /dev/null +++ b/ash/src/extensions/khr/copy_commands2.rs @@ -0,0 +1,80 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct CopyCommands2 { + fp: vk::KhrCopyCommands2Fn, +} + +impl CopyCommands2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrCopyCommands2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// + pub unsafe fn cmd_copy_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_info: &vk::CopyBufferInfo2KHR, + ) { + self.fp + .cmd_copy_buffer2_khr(command_buffer, copy_buffer_info) + } + /// + pub unsafe fn cmd_copy_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_info: &vk::CopyImageInfo2KHR, + ) { + self.fp.cmd_copy_image2_khr(command_buffer, copy_image_info) + } + /// + pub unsafe fn cmd_copy_buffer_to_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_to_image_info: &vk::CopyBufferToImageInfo2KHR, + ) { + self.fp + .cmd_copy_buffer_to_image2_khr(command_buffer, copy_buffer_to_image_info) + } + /// + pub unsafe fn cmd_copy_image_to_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_to_buffer_info: &vk::CopyImageToBufferInfo2KHR, + ) { + self.fp + .cmd_copy_image_to_buffer2_khr(command_buffer, copy_image_to_buffer_info) + } + /// + pub unsafe fn cmd_blit_image2( + &self, + command_buffer: vk::CommandBuffer, + blit_image_info: &vk::BlitImageInfo2KHR, + ) { + self.fp.cmd_blit_image2_khr(command_buffer, blit_image_info) + } + /// + pub unsafe fn cmd_resolve_image2( + &self, + command_buffer: vk::CommandBuffer, + resolve_image_info: &vk::ResolveImageInfo2KHR, + ) { + self.fp + .cmd_resolve_image2_khr(command_buffer, resolve_image_info) + } + + pub fn name() -> &'static CStr { + vk::KhrCopyCommands2Fn::name() + } + + pub fn fp(&self) -> &vk::KhrCopyCommands2Fn { + &self.fp + } +} diff --git a/ash/src/extensions/khr/mod.rs b/ash/src/extensions/khr/mod.rs index ca83e57..7405176 100644 --- a/ash/src/extensions/khr/mod.rs +++ b/ash/src/extensions/khr/mod.rs @@ -1,6 +1,7 @@ pub use self::acceleration_structure::AccelerationStructure; pub use self::android_surface::AndroidSurface; pub use self::buffer_device_address::BufferDeviceAddress; +pub use self::copy_commands2::CopyCommands2; pub use self::create_render_pass2::CreateRenderPass2; pub use self::deferred_host_operations::DeferredHostOperations; pub use self::display::Display; @@ -32,6 +33,7 @@ pub use self::xlib_surface::XlibSurface; mod acceleration_structure; mod android_surface; mod buffer_device_address; +mod copy_commands2; mod create_render_pass2; mod deferred_host_operations; mod display;