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/nv: Add VK_NV_device_generated_commands_compute #781

Merged
merged 1 commit into from
Aug 14, 2023
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 @@ -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

Expand Down
71 changes: 71 additions & 0 deletions ash/src/extensions/nv/device_generated_commands_compute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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_NV_device_generated_commands_compute.html>
#[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 }
}

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

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

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPipelineIndirectDeviceAddressNV.html>
#[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
}
}
2 changes: 2 additions & 0 deletions ash/src/extensions/nv/mod.rs
Original file line number Diff line number Diff line change
@@ -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;