From 3fa908c70a1f1e5e3704a0b9421fbf01c2706320 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 14 Aug 2023 16:42:57 +0200 Subject: [PATCH] extensions/nv: Add VK_NV_device_generated_commands_compute (#781) --- Changelog.md | 1 + .../nv/device_generated_commands_compute.rs | 71 +++++++++++++++++++ ash/src/extensions/nv/mod.rs | 2 + 3 files changed, 74 insertions(+) create mode 100644 ash/src/extensions/nv/device_generated_commands_compute.rs diff --git a/Changelog.md b/Changelog.md index ea53dd7..bfd1706 100644 --- a/Changelog.md +++ b/Changelog.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_AMDX_shader_enqueue` device extension (#776) - Added `VK_EXT_host_image_copy` device extension (#779) - Added `VK_KHR_maintenance5` device extension (#780) +- Added `VK_NV_device_generated_commands_compute` device extension (#781) ### Changed diff --git a/ash/src/extensions/nv/device_generated_commands_compute.rs b/ash/src/extensions/nv/device_generated_commands_compute.rs new file mode 100644 index 0000000..8dadc44 --- /dev/null +++ b/ash/src/extensions/nv/device_generated_commands_compute.rs @@ -0,0 +1,71 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct DeviceGeneratedCommandsCompute { + handle: vk::Device, + fp: vk::NvDeviceGeneratedCommandsComputeFn, +} + +impl DeviceGeneratedCommandsCompute { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::NvDeviceGeneratedCommandsComputeFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn get_pipeline_indirect_memory_requirements( + &self, + create_info: &vk::ComputePipelineCreateInfo, + memory_requirements: &mut vk::MemoryRequirements2, + ) { + (self.fp.get_pipeline_indirect_memory_requirements_nv)( + self.handle, + create_info, + memory_requirements, + ) + } + + /// + #[inline] + pub unsafe fn cmd_update_pipeline_indirect_buffer( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + pipeline: vk::Pipeline, + ) { + (self.fp.cmd_update_pipeline_indirect_buffer_nv)( + command_buffer, + pipeline_bind_point, + pipeline, + ) + } + + /// + #[inline] + pub unsafe fn get_pipeline_indirect_device_address( + &self, + info: &vk::PipelineIndirectDeviceAddressInfoNV, + ) -> vk::DeviceAddress { + (self.fp.get_pipeline_indirect_device_address_nv)(self.handle, info) + } + + pub const NAME: &'static CStr = vk::NvDeviceGeneratedCommandsComputeFn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::NvDeviceGeneratedCommandsComputeFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/nv/mod.rs b/ash/src/extensions/nv/mod.rs index 4f6c3fa..0065426 100644 --- a/ash/src/extensions/nv/mod.rs +++ b/ash/src/extensions/nv/mod.rs @@ -1,11 +1,13 @@ pub use self::coverage_reduction_mode::CoverageReductionMode; pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints; +pub use self::device_generated_commands_compute::DeviceGeneratedCommandsCompute; 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 device_generated_commands_compute; mod memory_decompression; mod mesh_shader; mod ray_tracing;