Skip to main content

jay_ash/extensions/amdx/
shader_enqueue.rs

1//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_AMDX_shader_enqueue.html>
2
3use crate::RawPtr;
4use crate::prelude::*;
5use crate::vk;
6use alloc::vec::Vec;
7use core::mem;
8
9impl crate::amdx::shader_enqueue::Device {
10    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateExecutionGraphPipelinesAMDX.html>
11    ///
12    /// Pipelines are created and returned as described for [Multiple Pipeline Creation].
13    ///
14    /// [Multiple Pipeline Creation]: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#pipelines-multiple
15    #[inline]
16    pub unsafe fn create_execution_graph_pipelines(
17        &self,
18        pipeline_cache: vk::PipelineCache,
19        create_infos: &[vk::ExecutionGraphPipelineCreateInfoAMDX<'_>],
20        allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
21    ) -> Result<Vec<vk::Pipeline>, (Vec<vk::Pipeline>, vk::Result)> {
22        unsafe {
23            let mut pipelines = Vec::with_capacity(create_infos.len());
24            let err_code = (self.fp.create_execution_graph_pipelines_amdx)(
25                self.handle,
26                pipeline_cache,
27                create_infos.len() as u32,
28                create_infos.as_ptr(),
29                allocation_callbacks.as_raw_ptr(),
30                pipelines.as_mut_ptr(),
31            );
32            pipelines.set_len(create_infos.len());
33            match err_code {
34                vk::Result::SUCCESS => Ok(pipelines),
35                _ => Err((pipelines, err_code)),
36            }
37        }
38    }
39
40    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetExecutionGraphPipelineScratchSizeAMDX.html>
41    #[inline]
42    pub unsafe fn get_execution_graph_pipeline_scratch_size(
43        &self,
44        execution_graph: vk::Pipeline,
45        size_info: &mut vk::ExecutionGraphPipelineScratchSizeAMDX<'_>,
46    ) -> VkResult<()> {
47        unsafe {
48            (self.fp.get_execution_graph_pipeline_scratch_size_amdx)(
49                self.handle,
50                execution_graph,
51                size_info,
52            )
53            .result()
54        }
55    }
56
57    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetExecutionGraphPipelineNodeIndexAMDX.html>
58    #[inline]
59    pub unsafe fn get_execution_graph_pipeline_node_index(
60        &self,
61        execution_graph: vk::Pipeline,
62        node_info: &vk::PipelineShaderStageNodeCreateInfoAMDX<'_>,
63    ) -> VkResult<u32> {
64        unsafe {
65            let mut node_index = mem::MaybeUninit::uninit();
66            (self.fp.get_execution_graph_pipeline_node_index_amdx)(
67                self.handle,
68                execution_graph,
69                node_info,
70                node_index.as_mut_ptr(),
71            )
72            .assume_init_on_success(node_index)
73        }
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        execution_graph: vk::Pipeline,
82        scratch: vk::DeviceAddress,
83        scratch_size: vk::DeviceSize,
84    ) {
85        unsafe {
86            (self.fp.cmd_initialize_graph_scratch_memory_amdx)(
87                command_buffer,
88                execution_graph,
89                scratch,
90                scratch_size,
91            );
92        }
93    }
94
95    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphAMDX.html>
96    #[inline]
97    pub unsafe fn cmd_dispatch_graph(
98        &self,
99        command_buffer: vk::CommandBuffer,
100        scratch: vk::DeviceAddress,
101        scratch_size: vk::DeviceSize,
102        count_info: &vk::DispatchGraphCountInfoAMDX,
103    ) {
104        unsafe {
105            (self.fp.cmd_dispatch_graph_amdx)(command_buffer, scratch, scratch_size, count_info)
106        }
107    }
108
109    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphIndirectAMDX.html>
110    #[inline]
111    pub unsafe fn cmd_dispatch_graph_indirect(
112        &self,
113        command_buffer: vk::CommandBuffer,
114        scratch: vk::DeviceAddress,
115        scratch_size: vk::DeviceSize,
116        count_info: &vk::DispatchGraphCountInfoAMDX,
117    ) {
118        unsafe {
119            (self.fp.cmd_dispatch_graph_indirect_amdx)(
120                command_buffer,
121                scratch,
122                scratch_size,
123                count_info,
124            )
125        }
126    }
127
128    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchGraphIndirectCountAMDX.html>
129    #[inline]
130    pub unsafe fn cmd_dispatch_graph_indirect_count(
131        &self,
132        command_buffer: vk::CommandBuffer,
133        scratch: vk::DeviceAddress,
134        scratch_size: vk::DeviceSize,
135        count_info: vk::DeviceAddress,
136    ) {
137        unsafe {
138            (self.fp.cmd_dispatch_graph_indirect_count_amdx)(
139                command_buffer,
140                scratch,
141                scratch_size,
142                count_info,
143            )
144        }
145    }
146}