diff --git a/Changelog.md b/Changelog.md index d8ac096..9ac3f0b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `VK_ANDROID_external_memory_android_hardware_buffer` device extension (#769) - Added `VK_AMD_buffer_marker` device extension (#772) - Added `VK_AMD_shader_info` device extension (#773) +- Added `VK_AMDX_shader_enqueue` device extension (#776) ### Changed diff --git a/ash/src/extensions/amdx/mod.rs b/ash/src/extensions/amdx/mod.rs new file mode 100644 index 0000000..d8c85c6 --- /dev/null +++ b/ash/src/extensions/amdx/mod.rs @@ -0,0 +1,3 @@ +pub use self::shader_enqueue::ShaderEnqueue; + +mod shader_enqueue; diff --git a/ash/src/extensions/amdx/shader_enqueue.rs b/ash/src/extensions/amdx/shader_enqueue.rs new file mode 100644 index 0000000..d225fdc --- /dev/null +++ b/ash/src/extensions/amdx/shader_enqueue.rs @@ -0,0 +1,130 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// +#[derive(Clone)] +pub struct ShaderEnqueue { + handle: vk::Device, + fp: vk::AmdxShaderEnqueueFn, +} + +impl ShaderEnqueue { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::AmdxShaderEnqueueFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// + #[inline] + pub unsafe fn create_execution_graph_pipelines( + &self, + pipeline_cache: vk::PipelineCache, + create_infos: &[vk::ExecutionGraphPipelineCreateInfoAMDX], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult> { + let mut pipelines = vec![mem::zeroed(); create_infos.len()]; + (self.fp.create_execution_graph_pipelines_amdx)( + self.handle, + pipeline_cache, + create_infos.len() as u32, + create_infos.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ) + .result_with_success(pipelines) + } + + /// + #[inline] + pub unsafe fn get_execution_graph_pipeline_scratch_size( + &self, + execution_graph: vk::Pipeline, + size_info: &mut vk::ExecutionGraphPipelineScratchSizeAMDX, + ) -> VkResult<()> { + (self.fp.get_execution_graph_pipeline_scratch_size_amdx)( + self.handle, + execution_graph, + size_info, + ) + .result() + } + + /// + #[inline] + pub unsafe fn get_execution_graph_pipeline_node_index( + &self, + execution_graph: vk::Pipeline, + node_info: &vk::PipelineShaderStageNodeCreateInfoAMDX, + ) -> VkResult { + let mut node_index = 0; + (self.fp.get_execution_graph_pipeline_node_index_amdx)( + self.handle, + execution_graph, + node_info, + &mut node_index, + ) + .result_with_success(node_index) + } + + /// + #[inline] + pub unsafe fn cmd_initialize_graph_scratch_memory( + &self, + command_buffer: vk::CommandBuffer, + scratch: vk::DeviceAddress, + ) { + (self.fp.cmd_initialize_graph_scratch_memory_amdx)(command_buffer, scratch) + } + + /// + #[inline] + pub unsafe fn cmd_dispatch_graph( + &self, + command_buffer: vk::CommandBuffer, + scratch: vk::DeviceAddress, + count_info: &vk::DispatchGraphCountInfoAMDX, + ) { + (self.fp.cmd_dispatch_graph_amdx)(command_buffer, scratch, count_info) + } + + /// + #[inline] + pub unsafe fn cmd_dispatch_graph_indirect( + &self, + command_buffer: vk::CommandBuffer, + scratch: vk::DeviceAddress, + count_info: &vk::DispatchGraphCountInfoAMDX, + ) { + (self.fp.cmd_dispatch_graph_indirect_amdx)(command_buffer, scratch, count_info) + } + + /// + #[inline] + pub unsafe fn cmd_dispatch_graph_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + scratch: vk::DeviceAddress, + count_info: vk::DeviceAddress, + ) { + (self.fp.cmd_dispatch_graph_indirect_count_amdx)(command_buffer, scratch, count_info) + } + + pub const NAME: &'static CStr = vk::AmdxShaderEnqueueFn::NAME; + + #[inline] + pub fn fp(&self) -> &vk::AmdxShaderEnqueueFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/ash/src/extensions/mod.rs b/ash/src/extensions/mod.rs index 152d43f..9311c52 100644 --- a/ash/src/extensions/mod.rs +++ b/ash/src/extensions/mod.rs @@ -1,4 +1,5 @@ pub mod amd; +pub mod amdx; pub mod android; pub mod ext; pub mod google;