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/amdx: Add VK_AMDX_shader_enqueue #776

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 @@ -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

Expand Down
3 changes: 3 additions & 0 deletions ash/src/extensions/amdx/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use self::shader_enqueue::ShaderEnqueue;

mod shader_enqueue;
130 changes: 130 additions & 0 deletions ash/src/extensions/amdx/shader_enqueue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
use crate::prelude::*;
use crate::vk;
use crate::RawPtr;
use crate::{Device, Instance};
use std::ffi::CStr;
use std::mem;

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

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateExecutionGraphPipelinesAMDX.html>
#[inline]
pub unsafe fn create_execution_graph_pipelines(
&self,
pipeline_cache: vk::PipelineCache,
create_infos: &[vk::ExecutionGraphPipelineCreateInfoAMDX],
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<Vec<vk::Pipeline>> {
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)
}

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

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetExecutionGraphPipelineNodeIndexAMDX.html>
#[inline]
pub unsafe fn get_execution_graph_pipeline_node_index(
&self,
execution_graph: vk::Pipeline,
node_info: &vk::PipelineShaderStageNodeCreateInfoAMDX,
) -> VkResult<u32> {
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)
}

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

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

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

/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphIndirectCountAMDX.html>
#[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
}
}
1 change: 1 addition & 0 deletions ash/src/extensions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod amd;
pub mod amdx;
pub mod android;
pub mod ext;
pub mod google;
Expand Down
Loading