-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions/amdx: Add VK_AMDX_shader_enqueue
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub use self::shader_enqueue::ShaderEnqueue; | ||
|
||
mod shader_enqueue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
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 } | ||
} | ||
|
||
#[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) | ||
} | ||
|
||
#[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<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) | ||
} | ||
|
||
#[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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ pub mod khr; | |
pub mod mvk; | ||
pub mod nn; | ||
pub mod nv; | ||
pub mod amdx; |