Skip to content

Commit

Permalink
✨ Add support for VK_NV_memory_decompression
Browse files Browse the repository at this point in the history
  • Loading branch information
BeastLe9enD committed Jun 18, 2023
1 parent eb17129 commit e8fee26
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `VK_NV_memory_decompression` device extension (#761)
- Added `Handle::is_null()` to allow checking if a handle is a `NULL` value (#694)
- Allow building `Entry`/`Instance`/`Device` from handle+fns (see their `from_parts_1_x()` associated functions) (#748)
- Update Vulkan-Headers to 1.3.254 (#760)
Expand Down
46 changes: 46 additions & 0 deletions ash/src/extensions/nv/memory_decompression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use crate::{vk, Device, Instance};
use std::mem;

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_memory_decompression.html>
#[derive(Clone)]
pub struct MemoryDecompression {
fp: vk::NvMemoryDecompressionFn,
}

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

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDecompressMemoryNV.html>
pub unsafe fn cmd_decompress_memory(
&self,
command_buffer: vk::CommandBuffer,
decompress_memory_regions: &[vk::DecompressMemoryRegionNV],
) {
(self.fp.cmd_decompress_memory_nv)(
command_buffer,
decompress_memory_regions.len() as u32,
decompress_memory_regions.as_ptr(),
)
}

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDecompressMemoryIndirectCountNV.html>
pub unsafe fn cmd_decompress_memory_indirect_count(
&self,
command_buffer: vk::CommandBuffer,
indirect_commands_address: vk::DeviceAddress,
indirect_commands_count_address: vk::DeviceAddress,
stride: u32,
) {
(self.fp.cmd_decompress_memory_indirect_count_nv)(
command_buffer,
indirect_commands_address,
indirect_commands_count_address,
stride,
)
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/nv/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pub use self::coverage_reduction_mode::CoverageReductionMode;
pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints;
pub use self::memory_decompression::MemoryDecompression;
pub use self::mesh_shader::MeshShader;
pub use self::ray_tracing::RayTracing;

mod coverage_reduction_mode;
mod device_diagnostic_checkpoints;
mod memory_decompression;
mod mesh_shader;
mod ray_tracing;

0 comments on commit e8fee26

Please sign in to comment.