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_copy_commands2 #571

Merged
merged 1 commit into from
Jan 29, 2022
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
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
80 changes: 80 additions & 0 deletions ash/src/extensions/khr/copy_commands2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use crate::vk;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_copy_commands2.html>
#[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 }
}

/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBuffer2KHR.html>
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)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImage2KHR.html>
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)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage2KHR.html>
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)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImageToBuffer2KHR.html>
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)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBlitImage2KHR.html>
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)
}
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdResolveImage2KHR.html>
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
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/khr/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down