Skip to content

Commit f746a8a

Browse files
committed
extensions/amdx: Add VK_AMDX_shader_enqueue
1 parent f558761 commit f746a8a

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Added `VK_ANDROID_external_memory_android_hardware_buffer` device extension (#769)
1818
- Added `VK_AMD_buffer_marker` device extension (#772)
1919
- Added `VK_AMD_shader_info` device extension (#773)
20+
- Added `VK_AMDX_shader_enqueue` device extension (#776)
2021

2122
### Changed
2223

ash/src/extensions/amdx/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub use self::shader_enqueue::ShaderEnqueue;
2+
3+
mod shader_enqueue;
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
use crate::prelude::*;
2+
use crate::vk;
3+
use crate::RawPtr;
4+
use crate::{Device, Instance};
5+
use std::ffi::CStr;
6+
use std::mem;
7+
8+
/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_AMDX_shader_enqueue.html>
9+
#[derive(Clone)]
10+
pub struct ShaderEnqueue {
11+
handle: vk::Device,
12+
fp: vk::AmdxShaderEnqueueFn,
13+
}
14+
15+
impl ShaderEnqueue {
16+
pub fn new(instance: &Instance, device: &Device) -> Self {
17+
let handle = device.handle();
18+
let fp = vk::AmdxShaderEnqueueFn::load(|name| unsafe {
19+
mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr()))
20+
});
21+
Self { handle, fp }
22+
}
23+
24+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateExecutionGraphPipelinesAMDX.html>
25+
#[inline]
26+
pub unsafe fn create_execution_graph_pipelines(
27+
&self,
28+
pipeline_cache: vk::PipelineCache,
29+
create_infos: &[vk::ExecutionGraphPipelineCreateInfoAMDX],
30+
allocation_callbacks: Option<&vk::AllocationCallbacks>,
31+
) -> VkResult<Vec<vk::Pipeline>> {
32+
let mut pipelines = vec![mem::zeroed(); create_infos.len()];
33+
(self.fp.create_execution_graph_pipelines_amdx)(
34+
self.handle,
35+
pipeline_cache,
36+
create_infos.len() as u32,
37+
create_infos.as_ptr(),
38+
allocation_callbacks.as_raw_ptr(),
39+
pipelines.as_mut_ptr(),
40+
)
41+
.result_with_success(pipelines)
42+
}
43+
44+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetExecutionGraphPipelineScratchSizeAMDX.html>
45+
#[inline]
46+
pub unsafe fn get_execution_graph_pipeline_scratch_size(
47+
&self,
48+
execution_graph: vk::Pipeline,
49+
size_info: &mut vk::ExecutionGraphPipelineScratchSizeAMDX,
50+
) -> VkResult<()> {
51+
(self.fp.get_execution_graph_pipeline_scratch_size_amdx)(
52+
self.handle,
53+
execution_graph,
54+
size_info,
55+
)
56+
.result()
57+
}
58+
59+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetExecutionGraphPipelineNodeIndexAMDX.html>
60+
#[inline]
61+
pub unsafe fn get_execution_graph_pipeline_node_index(
62+
&self,
63+
execution_graph: vk::Pipeline,
64+
node_info: &vk::PipelineShaderStageNodeCreateInfoAMDX,
65+
) -> VkResult<u32> {
66+
let mut node_index = 0;
67+
(self.fp.get_execution_graph_pipeline_node_index_amdx)(
68+
self.handle,
69+
execution_graph,
70+
node_info,
71+
&mut node_index,
72+
)
73+
.result_with_success(node_index)
74+
}
75+
76+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdInitializeGraphScratchMemoryAMDX.html>
77+
#[inline]
78+
pub unsafe fn cmd_initialize_graph_scratch_memory(
79+
&self,
80+
command_buffer: vk::CommandBuffer,
81+
scratch: vk::DeviceAddress,
82+
) {
83+
(self.fp.cmd_initialize_graph_scratch_memory_amdx)(command_buffer, scratch)
84+
}
85+
86+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphAMDX.html>
87+
#[inline]
88+
pub unsafe fn cmd_dispatch_graph(
89+
&self,
90+
command_buffer: vk::CommandBuffer,
91+
scratch: vk::DeviceAddress,
92+
count_info: &vk::DispatchGraphCountInfoAMDX,
93+
) {
94+
(self.fp.cmd_dispatch_graph_amdx)(command_buffer, scratch, count_info)
95+
}
96+
97+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphIndirectAMDX.html>
98+
#[inline]
99+
pub unsafe fn cmd_dispatch_graph_indirect(
100+
&self,
101+
command_buffer: vk::CommandBuffer,
102+
scratch: vk::DeviceAddress,
103+
count_info: &vk::DispatchGraphCountInfoAMDX,
104+
) {
105+
(self.fp.cmd_dispatch_graph_indirect_amdx)(command_buffer, scratch, count_info)
106+
}
107+
108+
/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphIndirectCountAMDX.html>
109+
#[inline]
110+
pub unsafe fn cmd_dispatch_graph_indirect_count(
111+
&self,
112+
command_buffer: vk::CommandBuffer,
113+
scratch: vk::DeviceAddress,
114+
count_info: vk::DeviceAddress,
115+
) {
116+
(self.fp.cmd_dispatch_graph_indirect_count_amdx)(command_buffer, scratch, count_info)
117+
}
118+
119+
pub const NAME: &'static CStr = vk::AmdxShaderEnqueueFn::NAME;
120+
121+
#[inline]
122+
pub fn fp(&self) -> &vk::AmdxShaderEnqueueFn {
123+
&self.fp
124+
}
125+
126+
#[inline]
127+
pub fn device(&self) -> vk::Device {
128+
self.handle
129+
}
130+
}

ash/src/extensions/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod amd;
2+
pub mod amdx;
23
pub mod android;
34
pub mod ext;
45
pub mod google;

0 commit comments

Comments
 (0)