Skip to content

Commit

Permalink
extensions/nv: Add VK_NV_copy_memory_indirect extension
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Mar 25, 2024
1 parent 9900d1a commit 5e8bbc8
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `VK_KHR_line_rasterization` device extension (#889)
- Added `VK_KHR_calibrated_timestamps` device extension (#890)
- Added `VK_KHR_maintenance6` device extension (#891)
- Added `VK_NV_copy_memory_indirect` device extension (#892)

### Changed

Expand Down
72 changes: 72 additions & 0 deletions ash/src/extensions/nv/copy_memory_indirect.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_copy_memory_indirect.html>
use crate::vk;
use core::mem;
pub use vk::nv::copy_memory_indirect::NAME;

#[derive(Clone)]
pub struct Device {
fp: vk::nv::copy_memory_indirect::DeviceFn,
}

impl Device {
pub fn new(instance: &crate::Instance, device: &crate::Device) -> Self {
let handle = device.handle();
let fp = vk::nv::copy_memory_indirect::DeviceFn::load(|name| unsafe {
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
});
Self { fp }
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCopyMemoryIndirectNV.html>
///
/// `copy_buffer_address` is a buffer device address which is a pointer to an array of
/// `copy_count` number of [`vk::CopyMemoryIndirectCommandNV`] structures containing the copy
/// parameters, each `stride` bytes apart.
#[inline]
pub unsafe fn cmd_copy_memory_indirect(
&self,
command_buffer: vk::CommandBuffer,
copy_buffer_address: vk::DeviceAddress,
copy_count: u32,
stride: u32,
) {
(self.fp.cmd_copy_memory_indirect_nv)(
command_buffer,
copy_buffer_address,
copy_count,
stride,
)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCopyMemoryToImageIndirectNV.html>
///
/// `copy_buffer_address` is a buffer device address which is a pointer to an array of
/// `image_subresources.len()` number of [`vk::CopyMemoryToImageIndirectCommandNV`] structures
/// containing the copy parameters, each `stride` bytes apart.
#[inline]
pub unsafe fn cmd_copy_memory_to_image_indirect(
&self,
command_buffer: vk::CommandBuffer,
copy_buffer_address: vk::DeviceAddress,
stride: u32,
dst_image: vk::Image,
dst_image_layout: vk::ImageLayout,
image_subresources: &[vk::ImageSubresourceLayers],
) {
(self.fp.cmd_copy_memory_to_image_indirect_nv)(
command_buffer,
copy_buffer_address,
image_subresources.len() as u32,
stride,
dst_image,
dst_image_layout,
image_subresources.as_ptr(),
)
}

#[inline]
pub fn fp(&self) -> &vk::nv::copy_memory_indirect::DeviceFn {
&self.fp
}
}
1 change: 1 addition & 0 deletions ash/src/extensions/nv/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod copy_memory_indirect;
pub mod coverage_reduction_mode;
pub mod cuda_kernel_launch;
pub mod device_diagnostic_checkpoints;
Expand Down

0 comments on commit 5e8bbc8

Please sign in to comment.