extensions/nv: Add VK_NV_memory_decompression (#761)

This commit is contained in:
BeastLe9enD 2023-06-21 22:14:38 +02:00 committed by GitHub
parent eb1712944e
commit 75089f487f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 0 deletions

View file

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `Handle::is_null()` to allow checking if a handle is a `NULL` value (#694) - 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) - 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) - Update Vulkan-Headers to 1.3.254 (#760)
- Added `VK_NV_memory_decompression` device extension (#761)
### Changed ### Changed

View file

@ -0,0 +1,54 @@
use crate::{vk, Device, Instance};
use std::ffi::CStr;
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,
)
}
pub const NAME: &'static CStr = vk::NvMemoryDecompressionFn::NAME;
#[inline]
pub fn fp(&self) -> &vk::NvMemoryDecompressionFn {
&self.fp
}
}

View file

@ -1,9 +1,11 @@
pub use self::coverage_reduction_mode::CoverageReductionMode; pub use self::coverage_reduction_mode::CoverageReductionMode;
pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints; pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints;
pub use self::memory_decompression::MemoryDecompression;
pub use self::mesh_shader::MeshShader; pub use self::mesh_shader::MeshShader;
pub use self::ray_tracing::RayTracing; pub use self::ray_tracing::RayTracing;
mod coverage_reduction_mode; mod coverage_reduction_mode;
mod device_diagnostic_checkpoints; mod device_diagnostic_checkpoints;
mod memory_decompression;
mod mesh_shader; mod mesh_shader;
mod ray_tracing; mod ray_tracing;