extensions/amdx: Add VK_AMDX_shader_enqueue (#776)

This commit is contained in:
Marijn Suijten 2023-08-14 15:51:20 +02:00 committed by GitHub
parent f558761997
commit c3f322f65e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 135 additions and 0 deletions

View file

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

View file

@ -0,0 +1,3 @@
pub use self::shader_enqueue::ShaderEnqueue;
mod shader_enqueue;

View file

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

View file

@ -1,4 +1,5 @@
pub mod amd;
pub mod amdx;
pub mod android;
pub mod ext;
pub mod google;