diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/rust/ash/src/extensions | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/ash/src/extensions')
72 files changed, 6834 insertions, 0 deletions
diff --git a/third_party/rust/ash/src/extensions/experimental/amd.rs b/third_party/rust/ash/src/extensions/experimental/amd.rs new file mode 100644 index 0000000000..35b4289f16 --- /dev/null +++ b/third_party/rust/ash/src/extensions/experimental/amd.rs @@ -0,0 +1,722 @@ +#![allow(clippy::unreadable_literal)] + +/* + *********************************************************************************************************************** + * + * Copyright (c) 2014-2019 Advanced Micro Devices, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + **********************************************************************************************************************/ + +#[cfg(feature = "debug")] +use crate::prelude::debug_flags; +use crate::vk::*; + +use std::fmt; +use std::os::raw::*; + +// Extension: `VK_AMD_gpa_interface` + +#[repr(transparent)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct GpaSqShaderStageFlags(pub(crate) Flags); +vk_bitflags_wrapped!(GpaSqShaderStageFlags, Flags); +#[cfg(feature = "debug")] +impl fmt::Debug for GpaSqShaderStageFlags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + const KNOWN: &[(Flags, &str)] = &[ + (GpaSqShaderStageFlags::PS.0, "PS"), + (GpaSqShaderStageFlags::VS.0, "VS"), + (GpaSqShaderStageFlags::GS.0, "GS"), + (GpaSqShaderStageFlags::ES.0, "ES"), + (GpaSqShaderStageFlags::HS.0, "HS"), + (GpaSqShaderStageFlags::LS.0, "LS"), + (GpaSqShaderStageFlags::CS.0, "CS"), + ]; + debug_flags(f, KNOWN, self.0) + } +} +impl GpaSqShaderStageFlags { + pub const PS: Self = Self(0b1); + pub const VS: Self = Self(0b10); + pub const GS: Self = Self(0b100); + pub const ES: Self = Self(0b1000); + pub const HS: Self = Self(0b10000); + pub const LS: Self = Self(0b100000); + pub const CS: Self = Self(0b1000000); +} + +impl StructureType { + pub const PHYSICAL_DEVICE_GPA_FEATURES_AMD: Self = Self(1000133000); + pub const PHYSICAL_DEVICE_GPA_PROPERTIES_AMD: Self = Self(1000133001); + pub const GPA_SAMPLE_BEGIN_INFO_AMD: Self = Self(1000133002); + pub const GPA_SESSION_CREATE_INFO_AMD: Self = Self(1000133003); + pub const GPA_DEVICE_CLOCK_MODE_INFO_AMD: Self = Self(1000133004); +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[cfg_attr(feature = "debug", derive(Debug))] +#[repr(transparent)] +pub struct GpaDeviceClockModeAmd(pub(crate) i32); +impl GpaDeviceClockModeAmd { + pub fn from_raw(x: i32) -> Self { + Self(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaDeviceClockModeAmd { + pub const DEFAULT: Self = Self(0); + pub const QUERY: Self = Self(1); + pub const PROFILING: Self = Self(2); + pub const MIN_MEMORY: Self = Self(3); + pub const MIN_ENGINE: Self = Self(4); + pub const PEAK: Self = Self(5); +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[cfg_attr(feature = "debug", derive(Debug))] +#[repr(transparent)] +pub struct GpaPerfBlockAmd(pub(crate) i32); +impl GpaPerfBlockAmd { + pub fn from_raw(x: i32) -> Self { + Self(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaPerfBlockAmd { + pub const CPF: Self = Self(0); + pub const IA: Self = Self(1); + pub const VGT: Self = Self(2); + pub const PA: Self = Self(3); + pub const SC: Self = Self(4); + pub const SPI: Self = Self(5); + pub const SQ: Self = Self(6); + pub const SX: Self = Self(7); + pub const TA: Self = Self(8); + pub const TD: Self = Self(9); + pub const TCP: Self = Self(10); + pub const TCC: Self = Self(11); + pub const TCA: Self = Self(12); + pub const DB: Self = Self(13); + pub const CB: Self = Self(14); + pub const GDS: Self = Self(15); + pub const SRBM: Self = Self(16); + pub const GRBM: Self = Self(17); + pub const GRBM_SE: Self = Self(18); + pub const RLC: Self = Self(19); + pub const DMA: Self = Self(20); + pub const MC: Self = Self(21); + pub const CPG: Self = Self(22); + pub const CPC: Self = Self(23); + pub const WD: Self = Self(24); + pub const TCS: Self = Self(25); + pub const ATC: Self = Self(26); + pub const ATC_L2: Self = Self(27); + pub const MC_VM_L2: Self = Self(28); + pub const EA: Self = Self(29); + pub const RPB: Self = Self(30); + pub const RMI: Self = Self(31); +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[cfg_attr(feature = "debug", derive(Debug))] +#[repr(transparent)] +pub struct GpaSampleTypeAmd(pub(crate) i32); +impl GpaSampleTypeAmd { + pub fn from_raw(x: i32) -> Self { + Self(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaSampleTypeAmd { + pub const CUMULATIVE: Self = Self(0); + pub const TRACE: Self = Self(1); + pub const TIMING: Self = Self(2); +} + +handle_nondispatchable!(GpaSessionAmd, UNKNOWN); + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct GpaSessionCreateInfoAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub secondary_copy_source: GpaSessionAmd, +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct GpaPerfBlockPropertiesAmd { + pub block_type: GpaPerfBlockAmd, + pub flags: Flags, + pub instance_count: u32, + pub max_event_id: u32, + pub max_global_only_counters: u32, + pub max_global_shared_counters: u32, + pub max_streaming_counters: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct PhysicalDeviceGpaFeaturesAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub perf_counters: Bool32, + pub streaming_perf_counters: Bool32, + pub sq_thread_tracing: Bool32, + pub clock_modes: Bool32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct PhysicalDeviceGpaPropertiesAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub flags: Flags, + pub max_sqtt_se_buffer_size: DeviceSize, + pub shader_engine_count: u32, + pub perf_block_count: u32, + pub p_perf_block_properties: *mut GpaPerfBlockPropertiesAmd, +} + +impl ::std::default::Default for PhysicalDeviceGpaPropertiesAmd { + fn default() -> Self { + Self { + s_type: StructureType::PHYSICAL_DEVICE_GPA_PROPERTIES_AMD, + p_next: ::std::ptr::null_mut(), + flags: Flags::default(), + max_sqtt_se_buffer_size: DeviceSize::default(), + shader_engine_count: u32::default(), + perf_block_count: u32::default(), + p_perf_block_properties: ::std::ptr::null_mut(), + } + } +} +impl PhysicalDeviceGpaPropertiesAmd { + pub fn builder<'a>() -> PhysicalDeviceGpaPropertiesAmdBuilder<'a> { + PhysicalDeviceGpaPropertiesAmdBuilder { + inner: Self::default(), + marker: ::std::marker::PhantomData, + } + } +} +pub struct PhysicalDeviceGpaPropertiesAmdBuilder<'a> { + inner: PhysicalDeviceGpaPropertiesAmd, + marker: ::std::marker::PhantomData<&'a ()>, +} +pub unsafe trait ExtendsPhysicalDeviceGpaPropertiesAmd {} +unsafe impl ExtendsPhysicalDeviceProperties2 for PhysicalDeviceGpaPropertiesAmd {} +impl<'a> ::std::ops::Deref for PhysicalDeviceGpaPropertiesAmdBuilder<'a> { + type Target = PhysicalDeviceGpaPropertiesAmd; + fn deref(&self) -> &Self::Target { + &self.inner + } +} +impl<'a> PhysicalDeviceGpaPropertiesAmdBuilder<'a> { + pub fn push_next<T>(mut self, next: &'a mut T) -> PhysicalDeviceGpaPropertiesAmdBuilder<'a> + where + T: ExtendsPhysicalDeviceGpaPropertiesAmd, + { + unsafe { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.inner.p_next as _; + self.inner.p_next = next_ptr; + } + self + } + pub fn build(self) -> PhysicalDeviceGpaPropertiesAmd { + self.inner + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct GpaPerfCounterAmd { + pub block_type: GpaPerfBlockAmd, + pub block_instance: u32, + pub event_id: u32, +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct GpaSampleBeginInfoAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub sample_type: GpaSampleTypeAmd, + pub sample_internal_operations: Bool32, + pub cache_flush_on_counter_collection: Bool32, + pub sq_shader_mask_enable: Bool32, + pub sq_shader_mask: GpaSqShaderStageFlags, + pub perf_counter_count: u32, + pub p_perf_counters: *const GpaPerfCounterAmd, + pub streaming_perf_trace_sample_interval: u32, + pub perf_counter_device_memory_limit: DeviceSize, + pub sq_thread_trace_enable: Bool32, + pub sq_thread_trace_suppress_instruction_tokens: Bool32, + pub sq_thread_trace_device_memory_limit: DeviceSize, + pub timing_pre_sample: PipelineStageFlags, + pub timing_post_sample: PipelineStageFlags, +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct GpaDeviceClockModeInfoAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub clock_mode: GpaDeviceClockModeAmd, + pub memory_clock_ratio_to_peak: f32, + pub engine_clock_ratio_to_peak: f32, +} + +#[allow(non_camel_case_types)] +pub type PFN_vkCreateGpaSessionAMD = extern "system" fn( + device: Device, + p_create_info: *const GpaSessionCreateInfoAmd, + p_allocator: *const AllocationCallbacks, + p_gpa_session: *mut GpaSessionAmd, +) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkDestroyGpaSessionAMD = extern "system" fn( + device: Device, + gpa_session: GpaSessionAmd, + p_allocator: *const AllocationCallbacks, +) -> c_void; + +#[allow(non_camel_case_types)] +pub type PFN_vkSetGpaDeviceClockModeAMD = + extern "system" fn(device: Device, p_info: *mut GpaDeviceClockModeInfoAmd) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkCmdBeginGpaSessionAMD = + extern "system" fn(commandBuffer: CommandBuffer, gpa_session: GpaSessionAmd) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkCmdEndGpaSessionAMD = + extern "system" fn(commandBuffer: CommandBuffer, gpa_session: GpaSessionAmd) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkCmdBeginGpaSampleAMD = extern "system" fn( + commandBuffer: CommandBuffer, + gpa_session: GpaSessionAmd, + p_gpa_sample_begin_info: *const GpaSampleBeginInfoAmd, + p_sample_id: *mut u32, +) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkCmdEndGpaSampleAMD = extern "system" fn( + commandBuffer: CommandBuffer, + gpa_session: GpaSessionAmd, + sample_id: u32, +) -> c_void; + +#[allow(non_camel_case_types)] +pub type PFN_vkGetGpaSessionStatusAMD = + extern "system" fn(device: Device, gpaSession: GpaSessionAmd) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkGetGpaSessionResultsAMD = extern "system" fn( + device: Device, + gpaSession: GpaSessionAmd, + sample_id: u32, + p_size_in_bytes: *mut usize, + p_data: *mut c_void, +) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkResetGpaSessionAMD = + extern "system" fn(device: Device, gpaSession: GpaSessionAmd) -> Result; + +#[allow(non_camel_case_types)] +pub type PFN_vkCmdCopyGpaSessionResultsAMD = + extern "system" fn(commandBuffer: CommandBuffer, gpaSession: GpaSessionAmd) -> c_void; + +pub struct AmdGpaInterfaceFn { + pub create_gpa_session: PFN_vkCreateGpaSessionAMD, + pub destroy_gpa_session: PFN_vkDestroyGpaSessionAMD, + pub set_gpa_device_clock_mode: PFN_vkSetGpaDeviceClockModeAMD, + pub cmd_begin_gpa_session: PFN_vkCmdBeginGpaSessionAMD, + pub cmd_end_gpa_session: PFN_vkCmdEndGpaSessionAMD, + pub cmd_begin_gpa_sample: PFN_vkCmdBeginGpaSampleAMD, + pub cmd_end_gpa_sample: PFN_vkCmdEndGpaSampleAMD, + pub get_gpa_session_status: PFN_vkGetGpaSessionStatusAMD, + pub get_gpa_session_results: PFN_vkGetGpaSessionResultsAMD, + pub reset_gpa_session: PFN_vkResetGpaSessionAMD, + pub cmd_copy_gpa_session_results: PFN_vkCmdCopyGpaSessionResultsAMD, +} +unsafe impl Send for AmdGpaInterfaceFn {} +unsafe impl Sync for AmdGpaInterfaceFn {} + +impl ::std::clone::Clone for AmdGpaInterfaceFn { + fn clone(&self) -> Self { + Self { + create_gpa_session: self.create_gpa_session, + destroy_gpa_session: self.destroy_gpa_session, + set_gpa_device_clock_mode: self.set_gpa_device_clock_mode, + cmd_begin_gpa_session: self.cmd_begin_gpa_session, + cmd_end_gpa_session: self.cmd_end_gpa_session, + cmd_begin_gpa_sample: self.cmd_begin_gpa_sample, + cmd_end_gpa_sample: self.cmd_end_gpa_sample, + get_gpa_session_status: self.get_gpa_session_status, + get_gpa_session_results: self.get_gpa_session_results, + reset_gpa_session: self.reset_gpa_session, + cmd_copy_gpa_session_results: self.cmd_copy_gpa_session_results, + } + } +} + +impl AmdGpaInterfaceFn { + pub fn load<F>(mut _f: F) -> Self + where + F: FnMut(&::std::ffi::CStr) -> *const c_void, + { + Self { + create_gpa_session: unsafe { + extern "system" fn create_gpa_session_amd( + _device: Device, + _p_create_info: *const GpaSessionCreateInfoAmd, + _p_allocator: *const AllocationCallbacks, + _p_gpa_session: *mut GpaSessionAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(create_gpa_session_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCreateGpaSessionAMD\0"); + let val = _f(cname); + if val.is_null() { + create_gpa_session_amd + } else { + ::std::mem::transmute(val) + } + }, + destroy_gpa_session: unsafe { + extern "system" fn destroy_gpa_session_amd( + _device: Device, + _gpa_session: GpaSessionAmd, + _p_allocator: *const AllocationCallbacks, + ) -> c_void { + panic!(concat!( + "Unable to load ", + stringify!(destroy_gpa_session_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkDestroyGpaSessionAMD\0"); + let val = _f(cname); + if val.is_null() { + destroy_gpa_session_amd + } else { + ::std::mem::transmute(val) + } + }, + set_gpa_device_clock_mode: unsafe { + extern "system" fn set_gpa_device_clock_mode_amd( + _device: Device, + _p_info: *mut GpaDeviceClockModeInfoAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(set_gpa_device_clock_mode_amd) + )) + } + let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked( + b"vkSetGpaDeviceClockModeAMD\0", + ); + let val = _f(cname); + if val.is_null() { + set_gpa_device_clock_mode_amd + } else { + ::std::mem::transmute(val) + } + }, + cmd_begin_gpa_session: unsafe { + extern "system" fn cmd_begin_gpa_session_amd( + _command_buffer: CommandBuffer, + _gpa_session: GpaSessionAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(cmd_begin_gpa_session_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSessionAMD\0"); + let val = _f(cname); + if val.is_null() { + cmd_begin_gpa_session_amd + } else { + ::std::mem::transmute(val) + } + }, + cmd_end_gpa_session: unsafe { + extern "system" fn cmd_end_gpa_session_amd( + _command_buffer: CommandBuffer, + _gpa_session: GpaSessionAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(cmd_end_gpa_session_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSessionAMD\0"); + let val = _f(cname); + if val.is_null() { + cmd_end_gpa_session_amd + } else { + ::std::mem::transmute(val) + } + }, + cmd_begin_gpa_sample: unsafe { + extern "system" fn cmd_begin_gpa_sample_amd( + _command_buffer: CommandBuffer, + _gpa_session: GpaSessionAmd, + _p_gpa_sample_begin_info: *const GpaSampleBeginInfoAmd, + _p_sample_id: *mut u32, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(cmd_begin_gpa_sample_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdBeginGpaSampleAMD\0"); + let val = _f(cname); + if val.is_null() { + cmd_begin_gpa_sample_amd + } else { + ::std::mem::transmute(val) + } + }, + cmd_end_gpa_sample: unsafe { + extern "system" fn cmd_end_gpa_sample_amd( + _command_buffer: CommandBuffer, + _gpa_session: GpaSessionAmd, + _sample_id: u32, + ) -> c_void { + panic!(concat!( + "Unable to load ", + stringify!(cmd_end_gpa_sample_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0"); + let val = _f(cname); + if val.is_null() { + cmd_end_gpa_sample_amd + } else { + ::std::mem::transmute(val) + } + }, + get_gpa_session_status: unsafe { + extern "system" fn get_gpa_session_status_amd( + _device: Device, + _gpa_session: GpaSessionAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(get_gpa_session_status_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionStatusAMD\0"); + let val = _f(cname); + if val.is_null() { + get_gpa_session_status_amd + } else { + ::std::mem::transmute(val) + } + }, + get_gpa_session_results: unsafe { + extern "system" fn get_gpa_session_results_amd( + _device: Device, + _gpa_session: GpaSessionAmd, + _sample_id: u32, + _p_size_in_bytes: *mut usize, + _p_data: *mut c_void, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(get_gpa_session_results_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkGetGpaSessionResultsAMD\0"); + let val = _f(cname); + if val.is_null() { + get_gpa_session_results_amd + } else { + ::std::mem::transmute(val) + } + }, + reset_gpa_session: unsafe { + extern "system" fn reset_gpa_session_amd( + _device: Device, + _gpa_session: GpaSessionAmd, + ) -> Result { + panic!(concat!( + "Unable to load ", + stringify!(reset_gpa_session_amd) + )) + } + let cname = + ::std::ffi::CStr::from_bytes_with_nul_unchecked(b"vkCmdEndGpaSampleAMD\0"); + let val = _f(cname); + if val.is_null() { + reset_gpa_session_amd + } else { + ::std::mem::transmute(val) + } + }, + cmd_copy_gpa_session_results: unsafe { + extern "system" fn cmd_copy_gpa_session_results_amd( + _command_buffer: CommandBuffer, + _gpa_session: GpaSessionAmd, + ) -> c_void { + panic!(concat!( + "Unable to load ", + stringify!(cmd_copy_gpa_session_results_amd) + )) + } + let cname = ::std::ffi::CStr::from_bytes_with_nul_unchecked( + b"vkCmdCopyGpaSessionResultsAMD\0", + ); + let val = _f(cname); + if val.is_null() { + cmd_copy_gpa_session_results_amd + } else { + ::std::mem::transmute(val) + } + }, + } + } + pub unsafe fn create_gpa_session( + &self, + device: Device, + create_info: *const GpaSessionCreateInfoAmd, + allocator: *const AllocationCallbacks, + gpa_session: *mut GpaSessionAmd, + ) -> Result { + (self.create_gpa_session)(device, create_info, allocator, gpa_session) + } + pub unsafe fn destroy_gpa_session( + &self, + device: Device, + gpa_session: GpaSessionAmd, + allocator: *const AllocationCallbacks, + ) -> c_void { + (self.destroy_gpa_session)(device, gpa_session, allocator) + } +} + +// Extension: `VK_AMD_wave_limits` + +impl StructureType { + pub const WAVE_LIMIT_AMD: Self = Self(1000045000); + pub const PHYSICAL_DEVICE_WAVE_LIMIT_PROPERTIES_AMD: Self = Self(1000045001); +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct PhysicalDeviceWaveLimitPropertiesAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub cu_count: u32, + pub max_waves_per_cu: u32, +} + +impl ::std::default::Default for PhysicalDeviceWaveLimitPropertiesAmd { + fn default() -> Self { + Self { + s_type: StructureType::PHYSICAL_DEVICE_WAVE_LIMIT_PROPERTIES_AMD, + p_next: ::std::ptr::null_mut(), + cu_count: u32::default(), + max_waves_per_cu: u32::default(), + } + } +} +impl PhysicalDeviceWaveLimitPropertiesAmd { + pub fn builder<'a>() -> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> { + PhysicalDeviceWaveLimitPropertiesAmdBuilder { + inner: Self::default(), + marker: ::std::marker::PhantomData, + } + } +} +pub struct PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> { + inner: PhysicalDeviceWaveLimitPropertiesAmd, + marker: ::std::marker::PhantomData<&'a ()>, +} +pub unsafe trait ExtendsPhysicalDeviceWaveLimitPropertiesAmd {} +unsafe impl ExtendsPhysicalDeviceProperties2 for PhysicalDeviceWaveLimitPropertiesAmd {} +impl<'a> ::std::ops::Deref for PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> { + type Target = PhysicalDeviceWaveLimitPropertiesAmd; + fn deref(&self) -> &Self::Target { + &self.inner + } +} +impl<'a> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> { + pub fn push_next<T>( + mut self, + next: &'a mut T, + ) -> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> + where + T: ExtendsPhysicalDeviceWaveLimitPropertiesAmd, + { + unsafe { + let next_ptr = <*const T>::cast(next); + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.inner.p_next as _; + self.inner.p_next = next_ptr; + } + self + } + pub fn build(self) -> PhysicalDeviceWaveLimitPropertiesAmd { + self.inner + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg_attr(feature = "debug", derive(Debug))] +pub struct PipelineShaderStageCreateInfoWaveLimitAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub waves_per_cu: f32, + pub cu_enable_mask: *mut u32, +} diff --git a/third_party/rust/ash/src/extensions/experimental/mod.rs b/third_party/rust/ash/src/extensions/experimental/mod.rs new file mode 100644 index 0000000000..49e51f80c3 --- /dev/null +++ b/third_party/rust/ash/src/extensions/experimental/mod.rs @@ -0,0 +1 @@ +pub mod amd; diff --git a/third_party/rust/ash/src/extensions/ext/acquire_drm_display.rs b/third_party/rust/ash/src/extensions/ext/acquire_drm_display.rs new file mode 100644 index 0000000000..8c80e506e0 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/acquire_drm_display.rs @@ -0,0 +1,55 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_acquire_drm_display.html> +#[derive(Clone)] +pub struct AcquireDrmDisplay { + fp: vk::ExtAcquireDrmDisplayFn, +} + +impl AcquireDrmDisplay { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtAcquireDrmDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireDrmDisplayEXT.html> + #[inline] + pub unsafe fn acquire_drm_display( + &self, + physical_device: vk::PhysicalDevice, + drm_fd: i32, + display: vk::DisplayKHR, + ) -> VkResult<()> { + (self.fp.acquire_drm_display_ext)(physical_device, drm_fd, display).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDrmDisplayEXT.html> + #[inline] + pub unsafe fn get_drm_display( + &self, + physical_device: vk::PhysicalDevice, + drm_fd: i32, + connector_id: u32, + ) -> VkResult<vk::DisplayKHR> { + let mut display = mem::MaybeUninit::uninit(); + (self.fp.get_drm_display_ext)(physical_device, drm_fd, connector_id, display.as_mut_ptr()) + .assume_init_on_success(display) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtAcquireDrmDisplayFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtAcquireDrmDisplayFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/buffer_device_address.rs b/third_party/rust/ash/src/extensions/ext/buffer_device_address.rs new file mode 100644 index 0000000000..a1d304e639 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/buffer_device_address.rs @@ -0,0 +1,44 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct BufferDeviceAddress { + handle: vk::Device, + fp: vk::ExtBufferDeviceAddressFn, +} + +impl BufferDeviceAddress { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtBufferDeviceAddressFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferDeviceAddressEXT.html> + #[inline] + pub unsafe fn get_buffer_device_address( + &self, + info: &vk::BufferDeviceAddressInfoEXT, + ) -> vk::DeviceAddress { + (self.fp.get_buffer_device_address_ext)(self.handle, info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtBufferDeviceAddressFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtBufferDeviceAddressFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/calibrated_timestamps.rs b/third_party/rust/ash/src/extensions/ext/calibrated_timestamps.rs new file mode 100644 index 0000000000..e102fca15c --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/calibrated_timestamps.rs @@ -0,0 +1,72 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct CalibratedTimestamps { + handle: vk::Instance, + fp: vk::ExtCalibratedTimestampsFn, +} + +impl CalibratedTimestamps { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtCalibratedTimestampsFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceCalibrateableTimeDomainsEXT.html> + #[inline] + pub unsafe fn get_physical_device_calibrateable_time_domains( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::TimeDomainEXT>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_calibrateable_time_domains_ext)( + physical_device, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetCalibratedTimestampsEXT.html> + /// + /// Returns a tuple containing `(timestamps, max_deviation)` + #[inline] + pub unsafe fn get_calibrated_timestamps( + &self, + device: vk::Device, + info: &[vk::CalibratedTimestampInfoEXT], + ) -> VkResult<(Vec<u64>, Vec<u64>)> { + let mut timestamps = vec![0u64; info.len()]; + let mut max_deviation = vec![0u64; info.len()]; + (self.fp.get_calibrated_timestamps_ext)( + device, + info.len() as u32, + info.as_ptr(), + timestamps.as_mut_ptr(), + max_deviation.as_mut_ptr(), + ) + .result_with_success((timestamps, max_deviation)) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtCalibratedTimestampsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtCalibratedTimestampsFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/debug_marker.rs b/third_party/rust/ash/src/extensions/ext/debug_marker.rs new file mode 100755 index 0000000000..1c21a47fd9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_marker.rs @@ -0,0 +1,71 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugMarker { + handle: vk::Device, + fp: vk::ExtDebugMarkerFn, +} + +impl DebugMarker { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtDebugMarkerFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html> + #[inline] + pub unsafe fn debug_marker_set_object_name( + &self, + name_info: &vk::DebugMarkerObjectNameInfoEXT, + ) -> VkResult<()> { + (self.fp.debug_marker_set_object_name_ext)(self.handle, name_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDebugMarkerBeginEXT.html> + #[inline] + pub unsafe fn cmd_debug_marker_begin( + &self, + command_buffer: vk::CommandBuffer, + marker_info: &vk::DebugMarkerMarkerInfoEXT, + ) { + (self.fp.cmd_debug_marker_begin_ext)(command_buffer, marker_info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDebugMarkerEndEXT.html> + #[inline] + pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) { + (self.fp.cmd_debug_marker_end_ext)(command_buffer); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDebugMarkerInsertEXT.html> + #[inline] + pub unsafe fn cmd_debug_marker_insert( + &self, + command_buffer: vk::CommandBuffer, + marker_info: &vk::DebugMarkerMarkerInfoEXT, + ) { + (self.fp.cmd_debug_marker_insert_ext)(command_buffer, marker_info); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtDebugMarkerFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtDebugMarkerFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/debug_report.rs b/third_party/rust/ash/src/extensions/ext/debug_report.rs new file mode 100755 index 0000000000..625ebf479e --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_report.rs @@ -0,0 +1,68 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugReport { + handle: vk::Instance, + fp: vk::ExtDebugReportFn, +} + +impl DebugReport { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtDebugReportFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyDebugReportCallbackEXT.html> + #[inline] + pub unsafe fn destroy_debug_report_callback( + &self, + debug: vk::DebugReportCallbackEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_debug_report_callback_ext)( + self.handle, + debug, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDebugReportCallbackEXT.html> + #[inline] + pub unsafe fn create_debug_report_callback( + &self, + create_info: &vk::DebugReportCallbackCreateInfoEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DebugReportCallbackEXT> { + let mut debug_cb = mem::zeroed(); + (self.fp.create_debug_report_callback_ext)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut debug_cb, + ) + .result_with_success(debug_cb) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtDebugReportFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtDebugReportFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/debug_utils.rs b/third_party/rust/ash/src/extensions/ext/debug_utils.rs new file mode 100755 index 0000000000..46d91769ad --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_utils.rs @@ -0,0 +1,173 @@ +use crate::prelude::*; +use crate::{vk, RawPtr}; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugUtils { + handle: vk::Instance, + fp: vk::ExtDebugUtilsFn, +} + +impl DebugUtils { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtDebugUtilsFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html> + #[deprecated = "Backwards-compatible alias containing a typo, use `set_debug_utils_object_name()` instead"] + #[inline] + pub unsafe fn debug_utils_set_object_name( + &self, + device: vk::Device, + name_info: &vk::DebugUtilsObjectNameInfoEXT, + ) -> VkResult<()> { + self.set_debug_utils_object_name(device, name_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html> + #[inline] + pub unsafe fn set_debug_utils_object_name( + &self, + device: vk::Device, + name_info: &vk::DebugUtilsObjectNameInfoEXT, + ) -> VkResult<()> { + (self.fp.set_debug_utils_object_name_ext)(device, name_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html> + #[deprecated = "Backwards-compatible alias containing a typo, use `set_debug_utils_object_tag()` instead"] + #[inline] + pub unsafe fn debug_utils_set_object_tag( + &self, + device: vk::Device, + tag_info: &vk::DebugUtilsObjectTagInfoEXT, + ) -> VkResult<()> { + self.set_debug_utils_object_tag(device, tag_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html> + #[inline] + pub unsafe fn set_debug_utils_object_tag( + &self, + device: vk::Device, + tag_info: &vk::DebugUtilsObjectTagInfoEXT, + ) -> VkResult<()> { + (self.fp.set_debug_utils_object_tag_ext)(device, tag_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn cmd_begin_debug_utils_label( + &self, + command_buffer: vk::CommandBuffer, + label: &vk::DebugUtilsLabelEXT, + ) { + (self.fp.cmd_begin_debug_utils_label_ext)(command_buffer, label); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) { + (self.fp.cmd_end_debug_utils_label_ext)(command_buffer); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn cmd_insert_debug_utils_label( + &self, + command_buffer: vk::CommandBuffer, + label: &vk::DebugUtilsLabelEXT, + ) { + (self.fp.cmd_insert_debug_utils_label_ext)(command_buffer, label); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueueBeginDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn queue_begin_debug_utils_label( + &self, + queue: vk::Queue, + label: &vk::DebugUtilsLabelEXT, + ) { + (self.fp.queue_begin_debug_utils_label_ext)(queue, label); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) { + (self.fp.queue_end_debug_utils_label_ext)(queue); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html> + #[inline] + pub unsafe fn queue_insert_debug_utils_label( + &self, + queue: vk::Queue, + label: &vk::DebugUtilsLabelEXT, + ) { + (self.fp.queue_insert_debug_utils_label_ext)(queue, label); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html> + #[inline] + pub unsafe fn create_debug_utils_messenger( + &self, + create_info: &vk::DebugUtilsMessengerCreateInfoEXT, + allocator: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DebugUtilsMessengerEXT> { + let mut messenger = mem::zeroed(); + (self.fp.create_debug_utils_messenger_ext)( + self.handle, + create_info, + allocator.as_raw_ptr(), + &mut messenger, + ) + .result_with_success(messenger) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html> + #[inline] + pub unsafe fn destroy_debug_utils_messenger( + &self, + messenger: vk::DebugUtilsMessengerEXT, + allocator: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_debug_utils_messenger_ext)(self.handle, messenger, allocator.as_raw_ptr()); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html> + #[inline] + pub unsafe fn submit_debug_utils_message( + &self, + message_severity: vk::DebugUtilsMessageSeverityFlagsEXT, + message_types: vk::DebugUtilsMessageTypeFlagsEXT, + callback_data: &vk::DebugUtilsMessengerCallbackDataEXT, + ) { + (self.fp.submit_debug_utils_message_ext)( + self.handle, + message_severity, + message_types, + callback_data, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtDebugUtilsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtDebugUtilsFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/descriptor_buffer.rs b/third_party/rust/ash/src/extensions/ext/descriptor_buffer.rs new file mode 100644 index 0000000000..4503f5bdab --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/descriptor_buffer.rs @@ -0,0 +1,211 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_descriptor_buffer.html> +#[derive(Clone)] +pub struct DescriptorBuffer { + handle: vk::Device, + fp: vk::ExtDescriptorBufferFn, +} + +impl DescriptorBuffer { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtDescriptorBufferFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutSizeEXT.html> + #[inline] + pub unsafe fn get_descriptor_set_layout_size( + &self, + layout: vk::DescriptorSetLayout, + ) -> vk::DeviceSize { + let mut count = 0; + (self.fp.get_descriptor_set_layout_size_ext)(self.handle, layout, &mut count); + count + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutBindingOffsetEXT.html> + #[inline] + pub unsafe fn get_descriptor_set_layout_binding_offset( + &self, + layout: vk::DescriptorSetLayout, + binding: u32, + ) -> vk::DeviceSize { + let mut offset = 0; + (self.fp.get_descriptor_set_layout_binding_offset_ext)( + self.handle, + layout, + binding, + &mut offset, + ); + offset + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorEXT.html> + #[inline] + pub unsafe fn get_descriptor( + &self, + descriptor_info: &vk::DescriptorGetInfoEXT, + descriptor: &mut [u8], + ) { + (self.fp.get_descriptor_ext)( + self.handle, + descriptor_info, + descriptor.len(), + descriptor.as_mut_ptr().cast(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBindDescriptorBuffersEXT.html> + #[inline] + pub unsafe fn cmd_bind_descriptor_buffers( + &self, + command_buffer: vk::CommandBuffer, + binding_info: &[vk::DescriptorBufferBindingInfoEXT], + ) { + (self.fp.cmd_bind_descriptor_buffers_ext)( + command_buffer, + binding_info.len() as u32, + binding_info.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDescriptorBufferOffsetsEXT.html> + #[inline] + pub unsafe fn cmd_set_descriptor_buffer_offsets( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + layout: vk::PipelineLayout, + first_set: u32, + buffer_indices: &[u32], + offsets: &[vk::DeviceSize], + ) { + assert_eq!(buffer_indices.len(), offsets.len()); + (self.fp.cmd_set_descriptor_buffer_offsets_ext)( + command_buffer, + pipeline_bind_point, + layout, + first_set, + buffer_indices.len() as u32, + buffer_indices.as_ptr(), + offsets.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBindDescriptorBufferEmbeddedSamplersEXT.html> + #[inline] + pub unsafe fn cmd_bind_descriptor_buffer_embedded_samplers( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + layout: vk::PipelineLayout, + set: u32, + ) { + (self.fp.cmd_bind_descriptor_buffer_embedded_samplers_ext)( + command_buffer, + pipeline_bind_point, + layout, + set, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferOpaqueCaptureDescriptorDataEXT.html> + #[inline] + pub unsafe fn get_buffer_opaque_capture_descriptor_data( + &self, + info: &vk::BufferCaptureDescriptorDataInfoEXT, + data: &mut [u8], + ) -> VkResult<()> { + (self.fp.get_buffer_opaque_capture_descriptor_data_ext)( + self.handle, + info, + data.as_mut_ptr().cast(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageOpaqueCaptureDescriptorDataEXT.html> + #[inline] + pub unsafe fn get_image_opaque_capture_descriptor_data( + &self, + info: &vk::ImageCaptureDescriptorDataInfoEXT, + data: &mut [u8], + ) -> VkResult<()> { + (self.fp.get_image_opaque_capture_descriptor_data_ext)( + self.handle, + info, + data.as_mut_ptr().cast(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageViewOpaqueCaptureDescriptorDataEXT.html> + #[inline] + pub unsafe fn get_image_view_opaque_capture_descriptor_data( + &self, + info: &vk::ImageViewCaptureDescriptorDataInfoEXT, + data: &mut [u8], + ) -> VkResult<()> { + (self.fp.get_image_view_opaque_capture_descriptor_data_ext)( + self.handle, + info, + data.as_mut_ptr().cast(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSamplerOpaqueCaptureDescriptorDataEXT.html> + #[inline] + pub unsafe fn get_sampler_opaque_capture_descriptor_data( + &self, + info: &vk::SamplerCaptureDescriptorDataInfoEXT, + data: &mut [u8], + ) -> VkResult<()> { + (self.fp.get_sampler_opaque_capture_descriptor_data_ext)( + self.handle, + info, + data.as_mut_ptr().cast(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT.html> + #[inline] + pub unsafe fn get_acceleration_structure_opaque_capture_descriptor_data( + &self, + info: &vk::AccelerationStructureCaptureDescriptorDataInfoEXT, + data: &mut [u8], + ) -> VkResult<()> { + (self + .fp + .get_acceleration_structure_opaque_capture_descriptor_data_ext)( + self.handle, + info, + data.as_mut_ptr().cast(), + ) + .result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtDescriptorBufferFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtDescriptorBufferFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/extended_dynamic_state.rs b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state.rs new file mode 100644 index 0000000000..2e6b3eeca3 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state.rs @@ -0,0 +1,196 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct ExtendedDynamicState { + fp: vk::ExtExtendedDynamicStateFn, +} + +impl ExtendedDynamicState { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::ExtExtendedDynamicStateFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCullModeEXT.html> + #[inline] + pub unsafe fn cmd_set_cull_mode( + &self, + command_buffer: vk::CommandBuffer, + cull_mode: vk::CullModeFlags, + ) { + (self.fp.cmd_set_cull_mode_ext)(command_buffer, cull_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetFrontFaceEXT.html> + #[inline] + pub unsafe fn cmd_set_front_face( + &self, + command_buffer: vk::CommandBuffer, + front_face: vk::FrontFace, + ) { + (self.fp.cmd_set_front_face_ext)(command_buffer, front_face) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPrimitiveTopologyEXT.html> + #[inline] + pub unsafe fn cmd_set_primitive_topology( + &self, + command_buffer: vk::CommandBuffer, + primitive_topology: vk::PrimitiveTopology, + ) { + (self.fp.cmd_set_primitive_topology_ext)(command_buffer, primitive_topology) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportWithCountEXT.html> + #[inline] + pub unsafe fn cmd_set_viewport_with_count( + &self, + command_buffer: vk::CommandBuffer, + viewports: &[vk::Viewport], + ) { + (self.fp.cmd_set_viewport_with_count_ext)( + command_buffer, + viewports.len() as u32, + viewports.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetScissorWithCountEXT.html> + #[inline] + pub unsafe fn cmd_set_scissor_with_count( + &self, + command_buffer: vk::CommandBuffer, + scissors: &[vk::Rect2D], + ) { + (self.fp.cmd_set_scissor_with_count_ext)( + command_buffer, + scissors.len() as u32, + scissors.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBindVertexBuffers2EXT.html> + #[inline] + pub unsafe fn cmd_bind_vertex_buffers2( + &self, + command_buffer: vk::CommandBuffer, + first_binding: u32, + buffers: &[vk::Buffer], + offsets: &[vk::DeviceSize], + sizes: Option<&[vk::DeviceSize]>, + strides: Option<&[vk::DeviceSize]>, + ) { + assert_eq!(offsets.len(), buffers.len()); + let p_sizes = if let Some(sizes) = sizes { + assert_eq!(sizes.len(), buffers.len()); + sizes.as_ptr() + } else { + ptr::null() + }; + let p_strides = if let Some(strides) = strides { + assert_eq!(strides.len(), buffers.len()); + strides.as_ptr() + } else { + ptr::null() + }; + (self.fp.cmd_bind_vertex_buffers2_ext)( + command_buffer, + first_binding, + buffers.len() as u32, + buffers.as_ptr(), + offsets.as_ptr(), + p_sizes, + p_strides, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthTestEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_test_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_test_enable: bool, + ) { + (self.fp.cmd_set_depth_test_enable_ext)(command_buffer, depth_test_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthWriteEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_write_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_write_enable: bool, + ) { + (self.fp.cmd_set_depth_write_enable_ext)(command_buffer, depth_write_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthCompareOpEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_compare_op( + &self, + command_buffer: vk::CommandBuffer, + depth_compare_op: vk::CompareOp, + ) { + (self.fp.cmd_set_depth_compare_op_ext)(command_buffer, depth_compare_op) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthBoundsTestEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_bounds_test_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_bounds_test_enable: bool, + ) { + (self.fp.cmd_set_depth_bounds_test_enable_ext)( + command_buffer, + depth_bounds_test_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetStencilTestEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_stencil_test_enable( + &self, + command_buffer: vk::CommandBuffer, + stencil_test_enable: bool, + ) { + (self.fp.cmd_set_stencil_test_enable_ext)(command_buffer, stencil_test_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetStencilOpEXT.html> + #[inline] + pub unsafe fn cmd_set_stencil_op( + &self, + command_buffer: vk::CommandBuffer, + face_mask: vk::StencilFaceFlags, + fail_op: vk::StencilOp, + pass_op: vk::StencilOp, + depth_fail_op: vk::StencilOp, + compare_op: vk::CompareOp, + ) { + (self.fp.cmd_set_stencil_op_ext)( + command_buffer, + face_mask, + fail_op, + pass_op, + depth_fail_op, + compare_op, + ) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtExtendedDynamicStateFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtExtendedDynamicStateFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/extended_dynamic_state2.rs b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state2.rs new file mode 100644 index 0000000000..b515385930 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state2.rs @@ -0,0 +1,85 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_extended_dynamic_state2.html> +#[derive(Clone)] +pub struct ExtendedDynamicState2 { + fp: vk::ExtExtendedDynamicState2Fn, +} + +impl ExtendedDynamicState2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::ExtExtendedDynamicState2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPatchControlPointsEXT.html> + #[inline] + pub unsafe fn cmd_set_patch_control_points( + &self, + command_buffer: vk::CommandBuffer, + patch_control_points: u32, + ) { + (self.fp.cmd_set_patch_control_points_ext)(command_buffer, patch_control_points) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizerDiscardEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_rasterizer_discard_enable( + &self, + command_buffer: vk::CommandBuffer, + rasterizer_discard_enable: bool, + ) { + (self.fp.cmd_set_rasterizer_discard_enable_ext)( + command_buffer, + rasterizer_discard_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthBiasEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_bias_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_bias_enable: bool, + ) { + (self.fp.cmd_set_depth_bias_enable_ext)(command_buffer, depth_bias_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLogicOpEXT.html> + #[inline] + pub unsafe fn cmd_set_logic_op( + &self, + command_buffer: vk::CommandBuffer, + logic_op: vk::LogicOp, + ) { + (self.fp.cmd_set_logic_op_ext)(command_buffer, logic_op) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPrimitiveRestartEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_primitive_restart_enable( + &self, + command_buffer: vk::CommandBuffer, + primitive_restart_enable: bool, + ) { + (self.fp.cmd_set_primitive_restart_enable_ext)( + command_buffer, + primitive_restart_enable.into(), + ) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtExtendedDynamicState2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtExtendedDynamicState2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/extended_dynamic_state3.rs b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state3.rs new file mode 100644 index 0000000000..bb68f75f3e --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/extended_dynamic_state3.rs @@ -0,0 +1,409 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_extended_dynamic_state3.html> +#[derive(Clone)] +pub struct ExtendedDynamicState3 { + fp: vk::ExtExtendedDynamicState3Fn, +} + +impl ExtendedDynamicState3 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::ExtExtendedDynamicState3Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetTessellationDomainOriginEXT.html> + #[inline] + pub unsafe fn cmd_set_tessellation_domain_origin( + &self, + command_buffer: vk::CommandBuffer, + domain_origin: vk::TessellationDomainOrigin, + ) { + (self.fp.cmd_set_tessellation_domain_origin_ext)(command_buffer, domain_origin) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClampEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_clamp_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_clamp_enable: bool, + ) { + (self.fp.cmd_set_depth_clamp_enable_ext)(command_buffer, depth_clamp_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetPolygonModeEXT.html> + #[inline] + pub unsafe fn cmd_set_polygon_mode( + &self, + command_buffer: vk::CommandBuffer, + polygon_mode: vk::PolygonMode, + ) { + (self.fp.cmd_set_polygon_mode_ext)(command_buffer, polygon_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizationSamplesEXT.html> + #[inline] + pub unsafe fn cmd_set_rasterization_samples( + &self, + command_buffer: vk::CommandBuffer, + rasterization_samples: vk::SampleCountFlags, + ) { + (self.fp.cmd_set_rasterization_samples_ext)(command_buffer, rasterization_samples) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleMaskEXT.html> + #[inline] + pub unsafe fn cmd_set_sample_mask( + &self, + command_buffer: vk::CommandBuffer, + samples: vk::SampleCountFlags, + sample_mask: &[vk::SampleMask], + ) { + assert!( + samples.as_raw().is_power_of_two(), + "Only one SampleCount bit must be set" + ); + assert_eq!(samples.as_raw() as usize / 32, sample_mask.len()); + (self.fp.cmd_set_sample_mask_ext)(command_buffer, samples, sample_mask.as_ptr()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetAlphaToCoverageEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_alpha_to_coverage_enable( + &self, + command_buffer: vk::CommandBuffer, + alpha_to_coverage_enable: bool, + ) { + (self.fp.cmd_set_alpha_to_coverage_enable_ext)( + command_buffer, + alpha_to_coverage_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetAlphaToOneEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_alpha_to_one_enable( + &self, + command_buffer: vk::CommandBuffer, + alpha_to_one_enable: bool, + ) { + (self.fp.cmd_set_alpha_to_one_enable_ext)(command_buffer, alpha_to_one_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLogicOpEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_logic_op_enable( + &self, + command_buffer: vk::CommandBuffer, + logic_op_enable: bool, + ) { + (self.fp.cmd_set_logic_op_enable_ext)(command_buffer, logic_op_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_color_blend_enable( + &self, + command_buffer: vk::CommandBuffer, + first_attachment: u32, + color_blend_enables: &[vk::Bool32], + ) { + (self.fp.cmd_set_color_blend_enable_ext)( + command_buffer, + first_attachment, + color_blend_enables.len() as u32, + color_blend_enables.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendEquationEXT.html> + #[inline] + pub unsafe fn cmd_set_color_blend_equation( + &self, + command_buffer: vk::CommandBuffer, + first_attachment: u32, + color_blend_equations: &[vk::ColorBlendEquationEXT], + ) { + (self.fp.cmd_set_color_blend_equation_ext)( + command_buffer, + first_attachment, + color_blend_equations.len() as u32, + color_blend_equations.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorWriteMaskEXT.html> + #[inline] + pub unsafe fn cmd_set_color_write_mask( + &self, + command_buffer: vk::CommandBuffer, + first_attachment: u32, + color_write_masks: &[vk::ColorComponentFlags], + ) { + (self.fp.cmd_set_color_write_mask_ext)( + command_buffer, + first_attachment, + color_write_masks.len() as u32, + color_write_masks.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRasterizationStreamEXT.html> + #[inline] + pub unsafe fn cmd_set_rasterization_stream( + &self, + command_buffer: vk::CommandBuffer, + rasterization_stream: u32, + ) { + (self.fp.cmd_set_rasterization_stream_ext)(command_buffer, rasterization_stream) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetConservativeRasterizationModeEXT.html> + #[inline] + pub unsafe fn cmd_set_conservative_rasterization_mode( + &self, + command_buffer: vk::CommandBuffer, + conservative_rasterization_mode: vk::ConservativeRasterizationModeEXT, + ) { + (self.fp.cmd_set_conservative_rasterization_mode_ext)( + command_buffer, + conservative_rasterization_mode, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetExtraPrimitiveOverestimationSizeEXT.html> + #[inline] + pub unsafe fn cmd_set_extra_primitive_overestimation_size( + &self, + command_buffer: vk::CommandBuffer, + extra_primitive_overestimation_size: f32, + ) { + (self.fp.cmd_set_extra_primitive_overestimation_size_ext)( + command_buffer, + extra_primitive_overestimation_size, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClipEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_clip_enable( + &self, + command_buffer: vk::CommandBuffer, + depth_clip_enable: bool, + ) { + (self.fp.cmd_set_depth_clip_enable_ext)(command_buffer, depth_clip_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleLocationsEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_sample_locations_enable( + &self, + command_buffer: vk::CommandBuffer, + sample_locations_enable: bool, + ) { + (self.fp.cmd_set_sample_locations_enable_ext)( + command_buffer, + sample_locations_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetColorBlendAdvancedEXT.html> + #[inline] + pub unsafe fn cmd_set_color_blend_advanced( + &self, + command_buffer: vk::CommandBuffer, + first_attachment: u32, + color_blend_advanced: &[vk::ColorBlendAdvancedEXT], + ) { + (self.fp.cmd_set_color_blend_advanced_ext)( + command_buffer, + first_attachment, + color_blend_advanced.len() as u32, + color_blend_advanced.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetProvokingVertexModeEXT.html> + #[inline] + pub unsafe fn cmd_set_provoking_vertex_mode( + &self, + command_buffer: vk::CommandBuffer, + provoking_vertex_mode: vk::ProvokingVertexModeEXT, + ) { + (self.fp.cmd_set_provoking_vertex_mode_ext)(command_buffer, provoking_vertex_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineRasterizationModeEXT.html> + #[inline] + pub unsafe fn cmd_set_line_rasterization_mode( + &self, + command_buffer: vk::CommandBuffer, + line_rasterization_mode: vk::LineRasterizationModeEXT, + ) { + (self.fp.cmd_set_line_rasterization_mode_ext)(command_buffer, line_rasterization_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetLineStippleEnableEXT.html> + #[inline] + pub unsafe fn cmd_set_line_stipple_enable( + &self, + command_buffer: vk::CommandBuffer, + stippled_line_enable: bool, + ) { + (self.fp.cmd_set_line_stipple_enable_ext)(command_buffer, stippled_line_enable.into()) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDepthClipNegativeOneToOneEXT.html> + #[inline] + pub unsafe fn cmd_set_depth_clip_negative_one_to_one( + &self, + command_buffer: vk::CommandBuffer, + negative_one_to_one: bool, + ) { + (self.fp.cmd_set_depth_clip_negative_one_to_one_ext)( + command_buffer, + negative_one_to_one.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportWScalingEnableNV.html> + #[inline] + pub unsafe fn cmd_set_viewport_w_scaling_enable_nv( + &self, + command_buffer: vk::CommandBuffer, + viewport_w_scaling_enable: bool, + ) { + (self.fp.cmd_set_viewport_w_scaling_enable_nv)( + command_buffer, + viewport_w_scaling_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetViewportSwizzleNV.html> + #[inline] + pub unsafe fn cmd_set_viewport_swizzle_nv( + &self, + command_buffer: vk::CommandBuffer, + first_attachment: u32, + viewport_swizzles: &[vk::ViewportSwizzleNV], + ) { + (self.fp.cmd_set_viewport_swizzle_nv)( + command_buffer, + first_attachment, + viewport_swizzles.len() as u32, + viewport_swizzles.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageToColorEnableNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_to_color_enable_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_to_color_enable: bool, + ) { + (self.fp.cmd_set_coverage_to_color_enable_nv)( + command_buffer, + coverage_to_color_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageToColorLocationNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_to_color_location_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_to_color_location: u32, + ) { + (self.fp.cmd_set_coverage_to_color_location_nv)(command_buffer, coverage_to_color_location) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationModeNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_modulation_mode_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_modulation_mode: vk::CoverageModulationModeNV, + ) { + (self.fp.cmd_set_coverage_modulation_mode_nv)(command_buffer, coverage_modulation_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationTableEnableNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_modulation_table_enable_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_modulation_table_enable: bool, + ) { + (self.fp.cmd_set_coverage_modulation_table_enable_nv)( + command_buffer, + coverage_modulation_table_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageModulationTableNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_modulation_table_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_modulation_table: &[f32], + ) { + (self.fp.cmd_set_coverage_modulation_table_nv)( + command_buffer, + coverage_modulation_table.len() as u32, + coverage_modulation_table.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetShadingRateImageEnableNV.html> + #[inline] + pub unsafe fn cmd_set_shading_rate_image_enable_nv( + &self, + command_buffer: vk::CommandBuffer, + shading_rate_image_enable: bool, + ) { + (self.fp.cmd_set_shading_rate_image_enable_nv)( + command_buffer, + shading_rate_image_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRepresentativeFragmentTestEnableNV.html> + #[inline] + pub unsafe fn cmd_set_representative_fragment_test_enable_nv( + &self, + command_buffer: vk::CommandBuffer, + representative_fragment_test_enable: bool, + ) { + (self.fp.cmd_set_representative_fragment_test_enable_nv)( + command_buffer, + representative_fragment_test_enable.into(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCoverageReductionModeNV.html> + #[inline] + pub unsafe fn cmd_set_coverage_reduction_mode_nv( + &self, + command_buffer: vk::CommandBuffer, + coverage_reduction_mode: vk::CoverageReductionModeNV, + ) { + (self.fp.cmd_set_coverage_reduction_mode_nv)(command_buffer, coverage_reduction_mode) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtExtendedDynamicState3Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtExtendedDynamicState3Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/full_screen_exclusive.rs b/third_party/rust/ash/src/extensions/ext/full_screen_exclusive.rs new file mode 100644 index 0000000000..3cb73cdaeb --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/full_screen_exclusive.rs @@ -0,0 +1,86 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct FullScreenExclusive { + handle: vk::Device, + fp: vk::ExtFullScreenExclusiveFn, +} + +impl FullScreenExclusive { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtFullScreenExclusiveFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireFullScreenExclusiveModeEXT.html> + #[inline] + pub unsafe fn acquire_full_screen_exclusive_mode( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<()> { + (self.fp.acquire_full_screen_exclusive_mode_ext)(self.handle, swapchain).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModes2EXT.html> + #[inline] + pub unsafe fn get_physical_device_surface_present_modes2( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<Vec<vk::PresentModeKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_surface_present_modes2_ext)( + physical_device, + surface_info, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkReleaseFullScreenExclusiveModeEXT.html> + #[inline] + pub unsafe fn release_full_screen_exclusive_mode( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<()> { + (self.fp.release_full_screen_exclusive_mode_ext)(self.handle, swapchain).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModes2EXT.html> + #[inline] + pub unsafe fn get_device_group_surface_present_modes2( + &self, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { + let mut present_modes = mem::zeroed(); + (self.fp.get_device_group_surface_present_modes2_ext)( + self.handle, + surface_info, + &mut present_modes, + ) + .result_with_success(present_modes) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtFullScreenExclusiveFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtFullScreenExclusiveFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/headless_surface.rs b/third_party/rust/ash/src/extensions/ext/headless_surface.rs new file mode 100644 index 0000000000..fe04236aaf --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/headless_surface.rs @@ -0,0 +1,55 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_headless_surface.html> +#[derive(Clone)] +pub struct HeadlessSurface { + handle: vk::Instance, + fp: vk::ExtHeadlessSurfaceFn, +} + +impl HeadlessSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtHeadlessSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateHeadlessSurfaceEXT.html> + #[inline] + pub unsafe fn create_headless_surface( + &self, + create_info: &vk::HeadlessSurfaceCreateInfoEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_headless_surface_ext)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtHeadlessSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtHeadlessSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/image_compression_control.rs b/third_party/rust/ash/src/extensions/ext/image_compression_control.rs new file mode 100644 index 0000000000..a326116973 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/image_compression_control.rs @@ -0,0 +1,47 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_compression_control.html> +#[derive(Clone)] +pub struct ImageCompressionControl { + handle: vk::Device, + fp: vk::ExtImageCompressionControlFn, +} + +impl ImageCompressionControl { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtImageCompressionControlFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageSubresourceLayout2EXT.html> + #[inline] + pub unsafe fn get_image_subresource_layout2( + &self, + image: vk::Image, + subresource: &vk::ImageSubresource2EXT, + layout: &mut vk::SubresourceLayout2EXT, + ) { + (self.fp.get_image_subresource_layout2_ext)(self.handle, image, subresource, layout) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtImageCompressionControlFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtImageCompressionControlFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/image_drm_format_modifier.rs b/third_party/rust/ash/src/extensions/ext/image_drm_format_modifier.rs new file mode 100644 index 0000000000..ccdce2eb5e --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/image_drm_format_modifier.rs @@ -0,0 +1,48 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_image_drm_format_modifier.html> +#[derive(Clone)] +pub struct ImageDrmFormatModifier { + handle: vk::Device, + fp: vk::ExtImageDrmFormatModifierFn, +} + +impl ImageDrmFormatModifier { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtImageDrmFormatModifierFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageDrmFormatModifierPropertiesEXT.html> + #[inline] + pub unsafe fn get_image_drm_format_modifier_properties( + &self, + image: vk::Image, + properties: &mut vk::ImageDrmFormatModifierPropertiesEXT, + ) -> VkResult<()> { + (self.fp.get_image_drm_format_modifier_properties_ext)(self.handle, image, properties) + .result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtImageDrmFormatModifierFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtImageDrmFormatModifierFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/mesh_shader.rs b/third_party/rust/ash/src/extensions/ext/mesh_shader.rs new file mode 100644 index 0000000000..7d58f0c135 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/mesh_shader.rs @@ -0,0 +1,94 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_mesh_shader.html> +#[derive(Clone)] +pub struct MeshShader { + fp: vk::ExtMeshShaderFn, +} + +impl MeshShader { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::ExtMeshShaderFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksEXT.html> + #[inline] + pub unsafe fn cmd_draw_mesh_tasks( + &self, + command_buffer: vk::CommandBuffer, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_ext)( + command_buffer, + group_count_x, + group_count_y, + group_count_z, + ); + } + + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectEXT.html> + /// + /// `buffer` contains `draw_count` [`vk::DrawMeshTasksIndirectCommandEXT`] structures starting at `offset` in bytes, holding the draw parameters. + #[inline] + pub unsafe fn cmd_draw_mesh_tasks_indirect( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_indirect_ext)( + command_buffer, + buffer, + offset, + draw_count, + stride, + ); + } + + /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectCountEXT.html> + /// + /// `buffer` contains a maximum of `max_draw_count` [`vk::DrawMeshTasksIndirectCommandEXT`] structures starting at `offset` in bytes, holding the draw parameters. + /// `count_buffer` is the buffer containing the draw count, starting at `count_buffer_offset` in bytes. + /// The actual number of executed draw calls is the minimum of the count specified in `count_buffer` and `max_draw_count`. + #[inline] + pub unsafe fn cmd_draw_mesh_tasks_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_indirect_count_ext)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtMeshShaderFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtMeshShaderFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/metal_surface.rs b/third_party/rust/ash/src/extensions/ext/metal_surface.rs new file mode 100644 index 0000000000..9627d2f510 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/metal_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MetalSurface { + handle: vk::Instance, + fp: vk::ExtMetalSurfaceFn, +} + +impl MetalSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::ExtMetalSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateMetalSurfaceEXT.html> + #[inline] + pub unsafe fn create_metal_surface( + &self, + create_info: &vk::MetalSurfaceCreateInfoEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_metal_surface_ext)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtMetalSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtMetalSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/mod.rs b/third_party/rust/ash/src/extensions/ext/mod.rs new file mode 100644 index 0000000000..26a78f77d6 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/mod.rs @@ -0,0 +1,45 @@ +pub use self::acquire_drm_display::AcquireDrmDisplay; +pub use self::buffer_device_address::BufferDeviceAddress; +pub use self::calibrated_timestamps::CalibratedTimestamps; +#[allow(deprecated)] +pub use self::debug_marker::DebugMarker; +#[allow(deprecated)] +pub use self::debug_report::DebugReport; +pub use self::debug_utils::DebugUtils; +pub use self::descriptor_buffer::DescriptorBuffer; +pub use self::extended_dynamic_state::ExtendedDynamicState; +pub use self::extended_dynamic_state2::ExtendedDynamicState2; +pub use self::extended_dynamic_state3::ExtendedDynamicState3; +pub use self::full_screen_exclusive::FullScreenExclusive; +pub use self::headless_surface::HeadlessSurface; +pub use self::image_compression_control::ImageCompressionControl; +pub use self::image_drm_format_modifier::ImageDrmFormatModifier; +pub use self::mesh_shader::MeshShader; +pub use self::metal_surface::MetalSurface; +pub use self::physical_device_drm::PhysicalDeviceDrm; +pub use self::private_data::PrivateData; +pub use self::sample_locations::SampleLocations; +pub use self::tooling_info::ToolingInfo; + +mod acquire_drm_display; +mod buffer_device_address; +mod calibrated_timestamps; +#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")] +mod debug_marker; +#[deprecated(note = "Please use the [DebugUtils](struct.DebugUtils.html) extension instead.")] +mod debug_report; +mod debug_utils; +mod descriptor_buffer; +mod extended_dynamic_state; +mod extended_dynamic_state2; +mod extended_dynamic_state3; +mod full_screen_exclusive; +mod headless_surface; +mod image_compression_control; +mod image_drm_format_modifier; +mod mesh_shader; +mod metal_surface; +mod physical_device_drm; +mod private_data; +mod sample_locations; +mod tooling_info; diff --git a/third_party/rust/ash/src/extensions/ext/physical_device_drm.rs b/third_party/rust/ash/src/extensions/ext/physical_device_drm.rs new file mode 100644 index 0000000000..29b6cd7b32 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/physical_device_drm.rs @@ -0,0 +1,26 @@ +use crate::vk; +use crate::Instance; +use std::ffi::CStr; + +#[derive(Clone)] +pub struct PhysicalDeviceDrm; + +impl PhysicalDeviceDrm { + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceDrmPropertiesEXT { + let mut props_drm = vk::PhysicalDeviceDrmPropertiesEXT::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_drm); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_drm + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtPhysicalDeviceDrmFn::name() + } +} diff --git a/third_party/rust/ash/src/extensions/ext/private_data.rs b/third_party/rust/ash/src/extensions/ext/private_data.rs new file mode 100644 index 0000000000..c6cc6aefb1 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/private_data.rs @@ -0,0 +1,105 @@ +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_EXT_private_data.html> +#[derive(Clone)] +pub struct PrivateData { + handle: vk::Device, + fp: vk::ExtPrivateDataFn, +} + +impl PrivateData { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::ExtPrivateDataFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreatePrivateDataSlotEXT.html> + #[inline] + pub unsafe fn create_private_data_slot( + &self, + create_info: &vk::PrivateDataSlotCreateInfoEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::PrivateDataSlotEXT> { + let mut private_data_slot = mem::zeroed(); + (self.fp.create_private_data_slot_ext)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut private_data_slot, + ) + .result_with_success(private_data_slot) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyPrivateDataSlotEXT.html> + #[inline] + pub unsafe fn destroy_private_data_slot( + &self, + private_data_slot: vk::PrivateDataSlotEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_private_data_slot_ext)( + self.handle, + private_data_slot, + allocation_callbacks.as_raw_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSetPrivateDataEXT.html> + #[inline] + pub unsafe fn set_private_data<T: vk::Handle>( + &self, + object: T, + private_data_slot: vk::PrivateDataSlotEXT, + data: u64, + ) -> VkResult<()> { + (self.fp.set_private_data_ext)( + self.handle, + T::TYPE, + object.as_raw(), + private_data_slot, + data, + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPrivateDataEXT.html> + #[inline] + pub unsafe fn get_private_data<T: vk::Handle>( + &self, + object: T, + private_data_slot: vk::PrivateDataSlotEXT, + ) -> u64 { + let mut data = mem::zeroed(); + (self.fp.get_private_data_ext)( + self.handle, + T::TYPE, + object.as_raw(), + private_data_slot, + &mut data, + ); + data + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtPrivateDataFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtPrivateDataFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/ext/sample_locations.rs b/third_party/rust/ash/src/extensions/ext/sample_locations.rs new file mode 100644 index 0000000000..360b83a681 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/sample_locations.rs @@ -0,0 +1,54 @@ +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_EXT_sample_locations.html> +#[derive(Clone)] +pub struct SampleLocations { + fp: vk::ExtSampleLocationsFn, +} + +impl SampleLocations { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::ExtSampleLocationsFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMultisamplePropertiesEXT.html> + #[inline] + pub unsafe fn get_physical_device_multisample_properties( + &self, + physical_device: vk::PhysicalDevice, + samples: vk::SampleCountFlags, + multisample_properties: &mut vk::MultisamplePropertiesEXT, + ) { + (self.fp.get_physical_device_multisample_properties_ext)( + physical_device, + samples, + multisample_properties, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetSampleLocationsEXT.html> + #[inline] + pub unsafe fn cmd_set_sample_locations( + &self, + command_buffer: vk::CommandBuffer, + sample_locations_info: &vk::SampleLocationsInfoEXT, + ) { + (self.fp.cmd_set_sample_locations_ext)(command_buffer, sample_locations_info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtSampleLocationsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtSampleLocationsFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/ext/tooling_info.rs b/third_party/rust/ash/src/extensions/ext/tooling_info.rs new file mode 100644 index 0000000000..fd4bf994e7 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/tooling_info.rs @@ -0,0 +1,40 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ToolingInfo { + fp: vk::ExtToolingInfoFn, +} + +impl ToolingInfo { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::ExtToolingInfoFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceToolPropertiesEXT.html> + #[inline] + pub unsafe fn get_physical_device_tool_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::PhysicalDeviceToolPropertiesEXT>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_physical_device_tool_properties_ext)(physical_device, count, data) + }) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::ExtToolingInfoFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::ExtToolingInfoFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs b/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs new file mode 100644 index 0000000000..9772e9baf4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs @@ -0,0 +1,322 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AccelerationStructure { + handle: vk::Device, + fp: vk::KhrAccelerationStructureFn, +} + +impl AccelerationStructure { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrAccelerationStructureFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR { + let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateAccelerationStructureKHR.html> + #[inline] + pub unsafe fn create_acceleration_structure( + &self, + create_info: &vk::AccelerationStructureCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::AccelerationStructureKHR> { + let mut accel_struct = mem::zeroed(); + (self.fp.create_acceleration_structure_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ) + .result_with_success(accel_struct) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_acceleration_structure_khr)( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBuildAccelerationStructuresKHR.html> + #[inline] + pub unsafe fn cmd_build_acceleration_structures( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], + ) { + assert_eq!(infos.len(), build_range_infos.len()); + + let build_range_infos = build_range_infos + .iter() + .zip(infos.iter()) + .map(|(range_info, info)| { + assert_eq!(range_info.len(), info.geometry_count as usize); + range_info.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.cmd_build_acceleration_structures_khr)( + command_buffer, + infos.len() as _, + infos.as_ptr(), + build_range_infos.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBuildAccelerationStructuresIndirectKHR.html> + #[inline] + pub unsafe fn cmd_build_acceleration_structures_indirect( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + indirect_device_addresses: &[vk::DeviceAddress], + indirect_strides: &[u32], + max_primitive_counts: &[&[u32]], + ) { + assert_eq!(infos.len(), indirect_device_addresses.len()); + assert_eq!(infos.len(), indirect_strides.len()); + assert_eq!(infos.len(), max_primitive_counts.len()); + + let max_primitive_counts = max_primitive_counts + .iter() + .zip(infos.iter()) + .map(|(cnt, info)| { + assert_eq!(cnt.len(), info.geometry_count as usize); + cnt.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.cmd_build_acceleration_structures_indirect_khr)( + command_buffer, + infos.len() as _, + infos.as_ptr(), + indirect_device_addresses.as_ptr(), + indirect_strides.as_ptr(), + max_primitive_counts.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkBuildAccelerationStructuresKHR.html> + #[inline] + pub unsafe fn build_acceleration_structures( + &self, + deferred_operation: vk::DeferredOperationKHR, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], + ) -> VkResult<()> { + assert_eq!(infos.len(), build_range_infos.len()); + + let build_range_infos = build_range_infos + .iter() + .zip(infos.iter()) + .map(|(range_info, info)| { + assert_eq!(range_info.len(), info.geometry_count as usize); + range_info.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.build_acceleration_structures_khr)( + self.handle, + deferred_operation, + infos.len() as _, + infos.as_ptr(), + build_range_infos.as_ptr(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn copy_acceleration_structure( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyAccelerationStructureInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_acceleration_structure_khr)(self.handle, deferred_operation, info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyAccelerationStructureToMemoryKHR.html> + #[inline] + pub unsafe fn copy_acceleration_structure_to_memory( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_acceleration_structure_to_memory_khr)(self.handle, deferred_operation, info) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyMemoryToAccelerationStructureKHR.html> + #[inline] + pub unsafe fn copy_memory_to_acceleration_structure( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_memory_to_acceleration_structure_khr)(self.handle, deferred_operation, info) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWriteAccelerationStructuresPropertiesKHR.html> + #[inline] + pub unsafe fn write_acceleration_structures_properties( + &self, + acceleration_structures: &[vk::AccelerationStructureKHR], + query_type: vk::QueryType, + data: &mut [u8], + stride: usize, + ) -> VkResult<()> { + (self.fp.write_acceleration_structures_properties_khr)( + self.handle, + acceleration_structures.len() as _, + acceleration_structures.as_ptr(), + query_type, + data.len(), + data.as_mut_ptr().cast(), + stride, + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureInfoKHR, + ) { + (self.fp.cmd_copy_acceleration_structure_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyAccelerationStructureToMemoryKHR.html> + #[inline] + pub unsafe fn cmd_copy_acceleration_structure_to_memory( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) { + (self.fp.cmd_copy_acceleration_structure_to_memory_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyMemoryToAccelerationStructureKHR.html> + #[inline] + pub unsafe fn cmd_copy_memory_to_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) { + (self.fp.cmd_copy_memory_to_acceleration_structure_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureHandleKHR.html> + #[inline] + pub unsafe fn get_acceleration_structure_device_address( + &self, + info: &vk::AccelerationStructureDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + (self.fp.get_acceleration_structure_device_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html> + #[inline] + pub unsafe fn cmd_write_acceleration_structures_properties( + &self, + command_buffer: vk::CommandBuffer, + structures: &[vk::AccelerationStructureKHR], + query_type: vk::QueryType, + query_pool: vk::QueryPool, + first_query: u32, + ) { + (self.fp.cmd_write_acceleration_structures_properties_khr)( + command_buffer, + structures.len() as _, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceAccelerationStructureCompatibilityKHR.html> + #[inline] + pub unsafe fn get_device_acceleration_structure_compatibility( + &self, + version: &vk::AccelerationStructureVersionInfoKHR, + ) -> vk::AccelerationStructureCompatibilityKHR { + let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default(); + + (self.fp.get_device_acceleration_structure_compatibility_khr)( + self.handle, + version, + &mut compatibility, + ); + + compatibility + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureBuildSizesKHR.html> + #[inline] + pub unsafe fn get_acceleration_structure_build_sizes( + &self, + build_type: vk::AccelerationStructureBuildTypeKHR, + build_info: &vk::AccelerationStructureBuildGeometryInfoKHR, + max_primitive_counts: &[u32], + ) -> vk::AccelerationStructureBuildSizesInfoKHR { + assert_eq!(max_primitive_counts.len(), build_info.geometry_count as _); + + let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default(); + + (self.fp.get_acceleration_structure_build_sizes_khr)( + self.handle, + build_type, + build_info, + max_primitive_counts.as_ptr(), + &mut size_info, + ); + + size_info + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrAccelerationStructureFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrAccelerationStructureFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/android_surface.rs b/third_party/rust/ash/src/extensions/khr/android_surface.rs new file mode 100755 index 0000000000..071d367510 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/android_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AndroidSurface { + handle: vk::Instance, + fp: vk::KhrAndroidSurfaceFn, +} + +impl AndroidSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrAndroidSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateAndroidSurfaceKHR.html> + #[inline] + pub unsafe fn create_android_surface( + &self, + create_info: &vk::AndroidSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_android_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrAndroidSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs b/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs new file mode 100644 index 0000000000..65eae69681 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs @@ -0,0 +1,62 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct BufferDeviceAddress { + handle: vk::Device, + fp: vk::KhrBufferDeviceAddressFn, +} + +impl BufferDeviceAddress { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrBufferDeviceAddressFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferDeviceAddressKHR.html> + #[inline] + pub unsafe fn get_buffer_device_address( + &self, + info: &vk::BufferDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + (self.fp.get_buffer_device_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html> + #[inline] + pub unsafe fn get_buffer_opaque_capture_address( + &self, + info: &vk::BufferDeviceAddressInfoKHR, + ) -> u64 { + (self.fp.get_buffer_opaque_capture_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceMemoryOpaqueCaptureAddressKHR.html> + #[inline] + pub unsafe fn get_device_memory_opaque_capture_address( + &self, + info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR, + ) -> u64 { + (self.fp.get_device_memory_opaque_capture_address_khr)(self.handle, info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrBufferDeviceAddressFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/copy_commands2.rs b/third_party/rust/ash/src/extensions/khr/copy_commands2.rs new file mode 100644 index 0000000000..b46593093a --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/copy_commands2.rs @@ -0,0 +1,84 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_copy_commands2.html> +#[derive(Clone)] +pub struct CopyCommands2 { + fp: vk::KhrCopyCommands2Fn, +} + +impl CopyCommands2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrCopyCommands2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBuffer2KHR.html> + #[inline] + pub unsafe fn cmd_copy_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_info: &vk::CopyBufferInfo2KHR, + ) { + (self.fp.cmd_copy_buffer2_khr)(command_buffer, copy_buffer_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImage2KHR.html> + #[inline] + pub unsafe fn cmd_copy_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_info: &vk::CopyImageInfo2KHR, + ) { + (self.fp.cmd_copy_image2_khr)(command_buffer, copy_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage2KHR.html> + #[inline] + pub unsafe fn cmd_copy_buffer_to_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_to_image_info: &vk::CopyBufferToImageInfo2KHR, + ) { + (self.fp.cmd_copy_buffer_to_image2_khr)(command_buffer, copy_buffer_to_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImageToBuffer2KHR.html> + #[inline] + pub unsafe fn cmd_copy_image_to_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_to_buffer_info: &vk::CopyImageToBufferInfo2KHR, + ) { + (self.fp.cmd_copy_image_to_buffer2_khr)(command_buffer, copy_image_to_buffer_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBlitImage2KHR.html> + #[inline] + pub unsafe fn cmd_blit_image2( + &self, + command_buffer: vk::CommandBuffer, + blit_image_info: &vk::BlitImageInfo2KHR, + ) { + (self.fp.cmd_blit_image2_khr)(command_buffer, blit_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdResolveImage2KHR.html> + #[inline] + pub unsafe fn cmd_resolve_image2( + &self, + command_buffer: vk::CommandBuffer, + resolve_image_info: &vk::ResolveImageInfo2KHR, + ) { + (self.fp.cmd_resolve_image2_khr)(command_buffer, resolve_image_info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrCopyCommands2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrCopyCommands2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs b/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs new file mode 100644 index 0000000000..bf78bc5f54 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs @@ -0,0 +1,90 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct CreateRenderPass2 { + handle: vk::Device, + fp: vk::KhrCreateRenderpass2Fn, +} + +impl CreateRenderPass2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrCreateRenderpass2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateRenderPass2.html> + #[inline] + pub unsafe fn create_render_pass2( + &self, + create_info: &vk::RenderPassCreateInfo2, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::RenderPass> { + let mut renderpass = mem::zeroed(); + (self.fp.create_render_pass2_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut renderpass, + ) + .result_with_success(renderpass) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBeginRenderPass2.html> + #[inline] + pub unsafe fn cmd_begin_render_pass2( + &self, + command_buffer: vk::CommandBuffer, + render_pass_begin_info: &vk::RenderPassBeginInfo, + subpass_begin_info: &vk::SubpassBeginInfo, + ) { + (self.fp.cmd_begin_render_pass2_khr)( + command_buffer, + render_pass_begin_info, + subpass_begin_info, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdNextSubpass2.html> + #[inline] + pub unsafe fn cmd_next_subpass2( + &self, + command_buffer: vk::CommandBuffer, + subpass_begin_info: &vk::SubpassBeginInfo, + subpass_end_info: &vk::SubpassEndInfo, + ) { + (self.fp.cmd_next_subpass2_khr)(command_buffer, subpass_begin_info, subpass_end_info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdEndRenderPass2.html> + #[inline] + pub unsafe fn cmd_end_render_pass2( + &self, + command_buffer: vk::CommandBuffer, + subpass_end_info: &vk::SubpassEndInfo, + ) { + (self.fp.cmd_end_render_pass2_khr)(command_buffer, subpass_end_info); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrCreateRenderpass2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs b/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs new file mode 100644 index 0000000000..51aeaad8bb --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs @@ -0,0 +1,93 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DeferredHostOperations { + handle: vk::Device, + fp: vk::KhrDeferredHostOperationsFn, +} + +impl DeferredHostOperations { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDeferredOperationKHR.html> + #[inline] + pub unsafe fn create_deferred_operation( + &self, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DeferredOperationKHR> { + let mut operation = mem::zeroed(); + (self.fp.create_deferred_operation_khr)( + self.handle, + allocation_callbacks.as_raw_ptr(), + &mut operation, + ) + .result_with_success(operation) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDeferredOperationJoinKHR.html> + #[inline] + pub unsafe fn deferred_operation_join( + &self, + operation: vk::DeferredOperationKHR, + ) -> VkResult<()> { + (self.fp.deferred_operation_join_khr)(self.handle, operation).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyDeferredOperationKHR.html> + #[inline] + pub unsafe fn destroy_deferred_operation( + &self, + operation: vk::DeferredOperationKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_deferred_operation_khr)( + self.handle, + operation, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeferredOperationMaxConcurrencyKHR.html> + #[inline] + pub unsafe fn get_deferred_operation_max_concurrency( + &self, + operation: vk::DeferredOperationKHR, + ) -> u32 { + (self.fp.get_deferred_operation_max_concurrency_khr)(self.handle, operation) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeferredOperationResultKHR.html> + #[inline] + pub unsafe fn get_deferred_operation_result( + &self, + operation: vk::DeferredOperationKHR, + ) -> VkResult<()> { + (self.fp.get_deferred_operation_result_khr)(self.handle, operation).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeferredHostOperationsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/device_group.rs b/third_party/rust/ash/src/extensions/khr/device_group.rs new file mode 100644 index 0000000000..356db71e4d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/device_group.rs @@ -0,0 +1,169 @@ +#[cfg(doc)] +use super::Swapchain; +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group.html> +#[derive(Clone)] +pub struct DeviceGroup { + handle: vk::Device, + fp: vk::KhrDeviceGroupFn, +} + +impl DeviceGroup { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDeviceGroupFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPeerMemoryFeaturesKHR.html> + #[inline] + pub unsafe fn get_device_group_peer_memory_features( + &self, + heap_index: u32, + local_device_index: u32, + remote_device_index: u32, + ) -> vk::PeerMemoryFeatureFlags { + let mut peer_memory_features = mem::zeroed(); + (self.fp.get_device_group_peer_memory_features_khr)( + self.handle, + heap_index, + local_device_index, + remote_device_index, + &mut peer_memory_features, + ); + peer_memory_features + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDeviceMaskKHR.html> + #[inline] + pub unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) { + (self.fp.cmd_set_device_mask_khr)(command_buffer, device_mask) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchBaseKHR.html> + #[inline] + pub unsafe fn cmd_dispatch_base( + &self, + command_buffer: vk::CommandBuffer, + base_group: (u32, u32, u32), + group_count: (u32, u32, u32), + ) { + (self.fp.cmd_dispatch_base_khr)( + command_buffer, + base_group.0, + base_group.1, + base_group.2, + group_count.0, + group_count.1, + group_count.2, + ) + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_device_group_present_capabilities()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPresentCapabilitiesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_present_capabilities( + &self, + device_group_present_capabilities: &mut vk::DeviceGroupPresentCapabilitiesKHR, + ) -> VkResult<()> { + (self.fp.get_device_group_present_capabilities_khr)( + self.handle, + device_group_present_capabilities, + ) + .result() + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_device_group_surface_present_modes()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_surface_present_modes( + &self, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { + let mut modes = mem::zeroed(); + (self.fp.get_device_group_surface_present_modes_khr)(self.handle, surface, &mut modes) + .result_with_success(modes) + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_physical_device_present_rectangles()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDevicePresentRectanglesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_physical_device_present_rectangles( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::Rect2D>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_present_rectangles_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// Requires [`VK_KHR_swapchain`] to be enabled. + /// + /// Also available as [`Swapchain::acquire_next_image2()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImage2KHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_swapchain`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html + #[inline] + pub unsafe fn acquire_next_image2( + &self, + acquire_info: &vk::AcquireNextImageInfoKHR, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image2_khr)(self.handle, acquire_info, &mut index); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeviceGroupFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeviceGroupFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/device_group_creation.rs b/third_party/rust/ash/src/extensions/khr/device_group_creation.rs new file mode 100644 index 0000000000..9a21a714c9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/device_group_creation.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group_creation.html> +#[derive(Clone)] +pub struct DeviceGroupCreation { + handle: vk::Instance, + fp: vk::KhrDeviceGroupCreationFn, +} + +impl DeviceGroupCreation { + pub fn new(entry: Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrDeviceGroupCreationFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// Retrieve the number of elements to pass to [`enumerate_physical_device_groups()`][Self::enumerate_physical_device_groups()] + #[inline] + pub unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult<usize> { + let mut group_count = 0; + (self.fp.enumerate_physical_device_groups_khr)( + self.handle, + &mut group_count, + ptr::null_mut(), + ) + .result_with_success(group_count as usize) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumeratePhysicalDeviceGroupsKHR.html> + /// + /// Call [`enumerate_physical_device_groups_len()`][Self::enumerate_physical_device_groups_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn enumerate_physical_device_groups( + &self, + out: &mut [vk::PhysicalDeviceGroupProperties], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self.fp.enumerate_physical_device_groups_khr)(self.handle, &mut count, out.as_mut_ptr()) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeviceGroupCreationFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeviceGroupCreationFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display.rs b/third_party/rust/ash/src/extensions/khr/display.rs new file mode 100755 index 0000000000..b71c9c11e1 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display.rs @@ -0,0 +1,143 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Display { + handle: vk::Instance, + fp: vk::KhrDisplayFn, +} + +impl Display { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_display_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_display_properties_khr)(physical_device, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_display_plane_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_display_plane_properties_khr)(physical_device, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html> + #[inline] + pub unsafe fn get_display_plane_supported_displays( + &self, + physical_device: vk::PhysicalDevice, + plane_index: u32, + ) -> VkResult<Vec<vk::DisplayKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_display_plane_supported_displays_khr)( + physical_device, + plane_index, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayModePropertiesKHR.html> + #[inline] + pub unsafe fn get_display_mode_properties( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_display_mode_properties_khr)(physical_device, display, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDisplayModeKHR.html> + #[inline] + pub unsafe fn create_display_mode( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + create_info: &vk::DisplayModeCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DisplayModeKHR> { + let mut display_mode = mem::MaybeUninit::zeroed(); + (self.fp.create_display_mode_khr)( + physical_device, + display, + create_info, + allocation_callbacks.as_raw_ptr(), + display_mode.as_mut_ptr(), + ) + .assume_init_on_success(display_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html> + #[inline] + pub unsafe fn get_display_plane_capabilities( + &self, + physical_device: vk::PhysicalDevice, + mode: vk::DisplayModeKHR, + plane_index: u32, + ) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> { + let mut display_plane_capabilities = mem::MaybeUninit::zeroed(); + (self.fp.get_display_plane_capabilities_khr)( + physical_device, + mode, + plane_index, + display_plane_capabilities.as_mut_ptr(), + ) + .assume_init_on_success(display_plane_capabilities) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html> + #[inline] + pub unsafe fn create_display_plane_surface( + &self, + create_info: &vk::DisplaySurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::MaybeUninit::zeroed(); + (self.fp.create_display_plane_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + surface.as_mut_ptr(), + ) + .assume_init_on_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDisplayFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDisplayFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display_swapchain.rs b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs new file mode 100755 index 0000000000..e4a33b2bdb --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs @@ -0,0 +1,57 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DisplaySwapchain { + handle: vk::Device, + fp: vk::KhrDisplaySwapchainFn, +} + +impl DisplaySwapchain { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDisplaySwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSharedSwapchainsKHR.html> + #[inline] + pub unsafe fn create_shared_swapchains( + &self, + create_infos: &[vk::SwapchainCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::SwapchainKHR>> { + let mut swapchains = Vec::with_capacity(create_infos.len()); + (self.fp.create_shared_swapchains_khr)( + self.handle, + create_infos.len() as u32, + create_infos.as_ptr(), + allocation_callbacks.as_raw_ptr(), + swapchains.as_mut_ptr(), + ) + .result()?; + swapchains.set_len(create_infos.len()); + Ok(swapchains) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDisplaySwapchainFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs new file mode 100644 index 0000000000..f35ecbe9e3 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs @@ -0,0 +1,74 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DrawIndirectCount { + fp: vk::KhrDrawIndirectCountFn, +} + +impl DrawIndirectCount { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrDrawIndirectCountFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html> + #[inline] + pub unsafe fn cmd_draw_indexed_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_indexed_indirect_count_khr)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawIndirectCountKHR.html> + #[inline] + pub unsafe fn cmd_draw_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_indirect_count_khr)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDrawIndirectCountFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDrawIndirectCountFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs b/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs new file mode 100644 index 0000000000..ea6149a816 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs @@ -0,0 +1,44 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DynamicRendering { + fp: vk::KhrDynamicRenderingFn, +} + +impl DynamicRendering { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrDynamicRenderingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBeginRenderingKHR.html> + #[inline] + pub unsafe fn cmd_begin_rendering( + &self, + command_buffer: vk::CommandBuffer, + rendering_info: &vk::RenderingInfoKHR, + ) { + (self.fp.cmd_begin_rendering_khr)(command_buffer, rendering_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdEndRenderingKHR.html> + #[inline] + pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) { + (self.fp.cmd_end_rendering_khr)(command_buffer) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDynamicRenderingFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDynamicRenderingFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs b/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs new file mode 100644 index 0000000000..6a3ec559d4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs @@ -0,0 +1,49 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalFenceFd { + handle: vk::Device, + fp: vk::KhrExternalFenceFdFn, +} + +impl ExternalFenceFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalFenceFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportFenceFdKHR.html> + #[inline] + pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> { + (self.fp.import_fence_fd_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceFdKHR.html> + #[inline] + pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_fence_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalFenceFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalFenceFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs b/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs new file mode 100644 index 0000000000..627bd1cca9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_fence_win32.html> +#[derive(Clone)] +pub struct ExternalFenceWin32 { + handle: vk::Device, + fp: vk::KhrExternalFenceWin32Fn, +} + +impl ExternalFenceWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalFenceWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportFenceWin32HandleKHR.html> + #[inline] + pub unsafe fn import_fence_win32_handle( + &self, + import_info: &vk::ImportFenceWin32HandleInfoKHR, + ) -> VkResult<()> { + (self.fp.import_fence_win32_handle_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceWin32HandleKHR.html> + #[inline] + pub unsafe fn get_fence_win32_handle( + &self, + get_info: &vk::FenceGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_fence_win32_handle_khr)(self.handle, get_info, &mut handle) + .result_with_success(handle) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalFenceWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalFenceWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs new file mode 100644 index 0000000000..902349802f --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs @@ -0,0 +1,60 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalMemoryFd { + handle: vk::Device, + fp: vk::KhrExternalMemoryFdFn, +} + +impl ExternalMemoryFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalMemoryFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdKHR.html> + #[inline] + pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_memory_fd_khr)(self.handle, create_info, &mut fd).result_with_success(fd) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdPropertiesKHR.html> + #[inline] + pub unsafe fn get_memory_fd_properties( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + fd: i32, + ) -> VkResult<vk::MemoryFdPropertiesKHR> { + let mut memory_fd_properties = Default::default(); + (self.fp.get_memory_fd_properties_khr)( + self.handle, + handle_type, + fd, + &mut memory_fd_properties, + ) + .result_with_success(memory_fd_properties) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalMemoryFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs b/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs new file mode 100644 index 0000000000..8e43a26d48 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_memory_win32.html> +#[derive(Clone)] +pub struct ExternalMemoryWin32 { + handle: vk::Device, + fp: vk::KhrExternalMemoryWin32Fn, +} + +impl ExternalMemoryWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalMemoryWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryWin32HandleKHR.html> + #[inline] + pub unsafe fn get_memory_win32_handle( + &self, + create_info: &vk::MemoryGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_memory_win32_handle_khr)(self.handle, create_info, &mut handle) + .result_with_success(handle) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryWin32HandlePropertiesKHR.html> + #[inline] + pub unsafe fn get_memory_win32_handle_properties( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + handle: vk::HANDLE, + ) -> VkResult<vk::MemoryWin32HandlePropertiesKHR> { + let mut memory_win32_handle_properties = Default::default(); + (self.fp.get_memory_win32_handle_properties_khr)( + self.handle, + handle_type, + handle, + &mut memory_win32_handle_properties, + ) + .result_with_success(memory_win32_handle_properties) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalMemoryWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalMemoryWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs b/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs new file mode 100644 index 0000000000..eadebef40d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs @@ -0,0 +1,52 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalSemaphoreFd { + handle: vk::Device, + fp: vk::KhrExternalSemaphoreFdFn, +} + +impl ExternalSemaphoreFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportSemaphoreFdKHR.html> + #[inline] + pub unsafe fn import_semaphore_fd( + &self, + import_info: &vk::ImportSemaphoreFdInfoKHR, + ) -> VkResult<()> { + (self.fp.import_semaphore_fd_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreFdKHR.html> + #[inline] + pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_semaphore_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalSemaphoreFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs b/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs new file mode 100644 index 0000000000..102da8c1ee --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_semaphore_win32.html> +#[derive(Clone)] +pub struct ExternalSemaphoreWin32 { + handle: vk::Device, + fp: vk::KhrExternalSemaphoreWin32Fn, +} + +impl ExternalSemaphoreWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalSemaphoreWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportSemaphoreWin32HandleKHR.html> + #[inline] + pub unsafe fn import_semaphore_win32_handle( + &self, + import_info: &vk::ImportSemaphoreWin32HandleInfoKHR, + ) -> VkResult<()> { + (self.fp.import_semaphore_win32_handle_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreWin32HandleKHR.html> + #[inline] + pub unsafe fn get_semaphore_win32_handle( + &self, + get_info: &vk::SemaphoreGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_semaphore_win32_handle_khr)(self.handle, get_info, &mut handle) + .result_with_success(handle) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalSemaphoreWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalSemaphoreWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs b/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs new file mode 100644 index 0000000000..13e5a1bf61 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs @@ -0,0 +1,92 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct GetMemoryRequirements2 { + handle: vk::Device, + fp: vk::KhrGetMemoryRequirements2Fn, +} + +impl GetMemoryRequirements2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html> + #[inline] + pub unsafe fn get_buffer_memory_requirements2( + &self, + info: &vk::BufferMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + (self.fp.get_buffer_memory_requirements2_khr)(self.handle, info, memory_requirements); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageMemoryRequirements2KHR.html> + #[inline] + pub unsafe fn get_image_memory_requirements2( + &self, + info: &vk::ImageMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + (self.fp.get_image_memory_requirements2_khr)(self.handle, info, memory_requirements); + } + + /// Retrieve the number of elements to pass to [`get_image_sparse_memory_requirements2()`][Self::get_image_sparse_memory_requirements2()] + #[inline] + pub unsafe fn get_image_sparse_memory_requirements2_len( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + ) -> usize { + let mut count = 0; + (self.fp.get_image_sparse_memory_requirements2_khr)( + self.handle, + info, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageSparseMemoryRequirements2KHR.html> + /// + /// Call [`get_image_sparse_memory_requirements2_len()`][Self::get_image_sparse_memory_requirements2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_image_sparse_memory_requirements2( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + out: &mut [vk::SparseImageMemoryRequirements2KHR], + ) { + let mut count = out.len() as u32; + (self.fp.get_image_sparse_memory_requirements2_khr)( + self.handle, + info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetMemoryRequirements2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs b/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs new file mode 100644 index 0000000000..9e610b4831 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs @@ -0,0 +1,167 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct GetPhysicalDeviceProperties2 { + fp: vk::KhrGetPhysicalDeviceProperties2Fn, +} + +impl GetPhysicalDeviceProperties2 { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html> + #[inline] + pub unsafe fn get_physical_device_features2( + &self, + physical_device: vk::PhysicalDevice, + features: &mut vk::PhysicalDeviceFeatures2KHR, + ) { + (self.fp.get_physical_device_features2_khr)(physical_device, features); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFormatProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + format: vk::Format, + format_properties: &mut vk::FormatProperties2KHR, + ) { + (self.fp.get_physical_device_format_properties2_khr)( + physical_device, + format, + format_properties, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_image_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR, + image_format_properties: &mut vk::ImageFormatProperties2KHR, + ) -> VkResult<()> { + (self.fp.get_physical_device_image_format_properties2_khr)( + physical_device, + image_format_info, + image_format_properties, + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_memory_properties2( + &self, + physical_device: vk::PhysicalDevice, + memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR, + ) { + (self.fp.get_physical_device_memory_properties2_khr)(physical_device, memory_properties); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_properties2( + &self, + physical_device: vk::PhysicalDevice, + properties: &mut vk::PhysicalDeviceProperties2KHR, + ) { + (self.fp.get_physical_device_properties2_khr)(physical_device, properties); + } + + /// Retrieve the number of elements to pass to [`get_physical_device_queue_family_properties2()`][Self::get_physical_device_queue_family_properties2()] + #[inline] + pub unsafe fn get_physical_device_queue_family_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + ) -> usize { + let mut count = 0; + (self.fp.get_physical_device_queue_family_properties2_khr)( + physical_device, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2KHR.html> + /// + /// Call [`get_physical_device_queue_family_properties2_len()`][Self::get_physical_device_queue_family_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_queue_family_properties2( + &self, + physical_device: vk::PhysicalDevice, + out: &mut [vk::QueueFamilyProperties2KHR], + ) { + let mut count = out.len() as u32; + (self.fp.get_physical_device_queue_family_properties2_khr)( + physical_device, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + /// Retrieve the number of elements to pass to [`get_physical_device_sparse_image_format_properties2()`][Self::get_physical_device_sparse_image_format_properties2()] + #[inline] + pub unsafe fn get_physical_device_sparse_image_format_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, + ) -> usize { + let mut count = 0; + (self + .fp + .get_physical_device_sparse_image_format_properties2_khr)( + physical_device, + format_info, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2KHR.html> + /// + /// Call [`get_physical_device_sparse_image_format_properties2_len()`][Self::get_physical_device_sparse_image_format_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_sparse_image_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, + out: &mut [vk::SparseImageFormatProperties2KHR], + ) { + let mut count = out.len() as u32; + (self + .fp + .get_physical_device_sparse_image_format_properties2_khr)( + physical_device, + format_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetPhysicalDeviceProperties2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs b/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs new file mode 100644 index 0000000000..0208b7b4a5 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs @@ -0,0 +1,84 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct GetSurfaceCapabilities2 { + fp: vk::KhrGetSurfaceCapabilities2Fn, +} + +impl GetSurfaceCapabilities2 { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::KhrGetSurfaceCapabilities2Fn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilities2KHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_capabilities2( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<vk::SurfaceCapabilities2KHR> { + let mut surface_capabilities = Default::default(); + (self.fp.get_physical_device_surface_capabilities2_khr)( + physical_device, + surface_info, + &mut surface_capabilities, + ) + .result_with_success(surface_capabilities) + } + + /// Retrieve the number of elements to pass to [`get_physical_device_surface_formats2()`][Self::get_physical_device_surface_formats2()] + #[inline] + pub unsafe fn get_physical_device_surface_formats2_len( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<usize> { + let mut count = 0; + let err_code = (self.fp.get_physical_device_surface_formats2_khr)( + physical_device, + surface_info, + &mut count, + std::ptr::null_mut(), + ); + err_code.result_with_success(count as usize) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormats2KHR.html> + /// + /// Call [`get_physical_device_surface_formats2_len()`][Self::get_physical_device_surface_formats2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_surface_formats2( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + out: &mut [vk::SurfaceFormat2KHR], + ) -> VkResult<()> { + let mut count = out.len() as u32; + let err_code = (self.fp.get_physical_device_surface_formats2_khr)( + physical_device, + surface_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + err_code.result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetSurfaceCapabilities2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetSurfaceCapabilities2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance1.rs b/third_party/rust/ash/src/extensions/khr/maintenance1.rs new file mode 100644 index 0000000000..1226d31cd5 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance1.rs @@ -0,0 +1,45 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance1 { + handle: vk::Device, + fp: vk::KhrMaintenance1Fn, +} + +impl Maintenance1 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance1Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkTrimCommandPoolKHR.html> + #[inline] + pub unsafe fn trim_command_pool( + &self, + command_pool: vk::CommandPool, + flags: vk::CommandPoolTrimFlagsKHR, + ) { + (self.fp.trim_command_pool_khr)(self.handle, command_pool, flags); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance1Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance1Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance3.rs b/third_party/rust/ash/src/extensions/khr/maintenance3.rs new file mode 100644 index 0000000000..3b22959332 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance3.rs @@ -0,0 +1,45 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance3 { + handle: vk::Device, + fp: vk::KhrMaintenance3Fn, +} + +impl Maintenance3 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance3Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutSupportKHR.html> + #[inline] + pub unsafe fn get_descriptor_set_layout_support( + &self, + create_info: &vk::DescriptorSetLayoutCreateInfo, + out: &mut vk::DescriptorSetLayoutSupportKHR, + ) { + (self.fp.get_descriptor_set_layout_support_khr)(self.handle, create_info, out); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance3Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance3Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance4.rs b/third_party/rust/ash/src/extensions/khr/maintenance4.rs new file mode 100644 index 0000000000..003e1a9cf2 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance4.rs @@ -0,0 +1,91 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance4 { + handle: vk::Device, + fp: vk::KhrMaintenance4Fn, +} + +impl Maintenance4 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance4Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceBufferMemoryRequirementsKHR.html> + #[inline] + pub unsafe fn get_device_buffer_memory_requirements( + &self, + create_info: &vk::DeviceBufferMemoryRequirementsKHR, + out: &mut vk::MemoryRequirements2, + ) { + (self.fp.get_device_buffer_memory_requirements_khr)(self.handle, create_info, out) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageMemoryRequirementsKHR.html> + #[inline] + pub unsafe fn get_device_image_memory_requirements( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + out: &mut vk::MemoryRequirements2, + ) { + (self.fp.get_device_image_memory_requirements_khr)(self.handle, create_info, out) + } + + /// Retrieve the number of elements to pass to [`get_device_image_sparse_memory_requirements()`][Self::get_device_image_sparse_memory_requirements()] + #[inline] + pub unsafe fn get_device_image_sparse_memory_requirements_len( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + ) -> usize { + let mut count = 0; + (self.fp.get_device_image_sparse_memory_requirements_khr)( + self.handle, + create_info, + &mut count, + std::ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageSparseMemoryRequirementsKHR.html> + /// + /// Call [`get_device_image_sparse_memory_requirements_len()`][Self::get_device_image_sparse_memory_requirements_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_device_image_sparse_memory_requirements( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + out: &mut [vk::SparseImageMemoryRequirements2], + ) { + let mut count = out.len() as u32; + (self.fp.get_device_image_sparse_memory_requirements_khr)( + self.handle, + create_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance4Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance4Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/mod.rs b/third_party/rust/ash/src/extensions/khr/mod.rs new file mode 100644 index 0000000000..ea809b43da --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/mod.rs @@ -0,0 +1,75 @@ +pub use self::acceleration_structure::AccelerationStructure; +pub use self::android_surface::AndroidSurface; +pub use self::buffer_device_address::BufferDeviceAddress; +pub use self::copy_commands2::CopyCommands2; +pub use self::create_render_pass2::CreateRenderPass2; +pub use self::deferred_host_operations::DeferredHostOperations; +pub use self::device_group::DeviceGroup; +pub use self::device_group_creation::DeviceGroupCreation; +pub use self::display::Display; +pub use self::display_swapchain::DisplaySwapchain; +pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::dynamic_rendering::DynamicRendering; +pub use self::external_fence_fd::ExternalFenceFd; +pub use self::external_fence_win32::ExternalFenceWin32; +pub use self::external_memory_fd::ExternalMemoryFd; +pub use self::external_memory_win32::ExternalMemoryWin32; +pub use self::external_semaphore_fd::ExternalSemaphoreFd; +pub use self::external_semaphore_win32::ExternalSemaphoreWin32; +pub use self::get_memory_requirements2::GetMemoryRequirements2; +pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2; +pub use self::get_surface_capabilities2::GetSurfaceCapabilities2; +pub use self::maintenance1::Maintenance1; +pub use self::maintenance3::Maintenance3; +pub use self::maintenance4::Maintenance4; +pub use self::pipeline_executable_properties::PipelineExecutableProperties; +pub use self::present_wait::PresentWait; +pub use self::push_descriptor::PushDescriptor; +pub use self::ray_tracing_maintenance1::RayTracingMaintenance1; +pub use self::ray_tracing_pipeline::RayTracingPipeline; +pub use self::surface::Surface; +pub use self::swapchain::Swapchain; +pub use self::synchronization2::Synchronization2; +pub use self::timeline_semaphore::TimelineSemaphore; +pub use self::wayland_surface::WaylandSurface; +pub use self::win32_surface::Win32Surface; +pub use self::xcb_surface::XcbSurface; +pub use self::xlib_surface::XlibSurface; + +mod acceleration_structure; +mod android_surface; +mod buffer_device_address; +mod copy_commands2; +mod create_render_pass2; +mod deferred_host_operations; +mod device_group; +mod device_group_creation; +mod display; +mod display_swapchain; +mod draw_indirect_count; +mod dynamic_rendering; +mod external_fence_fd; +mod external_fence_win32; +mod external_memory_fd; +mod external_memory_win32; +mod external_semaphore_fd; +mod external_semaphore_win32; +mod get_memory_requirements2; +mod get_physical_device_properties2; +mod get_surface_capabilities2; +mod maintenance1; +mod maintenance3; +mod maintenance4; +mod pipeline_executable_properties; +mod present_wait; +mod push_descriptor; +mod ray_tracing_maintenance1; +mod ray_tracing_pipeline; +mod surface; +mod swapchain; +mod synchronization2; +mod timeline_semaphore; +mod wayland_surface; +mod win32_surface; +mod xcb_surface; +mod xlib_surface; diff --git a/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs b/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs new file mode 100644 index 0000000000..68e43b4a81 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs @@ -0,0 +1,84 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PipelineExecutableProperties { + handle: vk::Device, + fp: vk::KhrPipelineExecutablePropertiesFn, +} + +impl PipelineExecutableProperties { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_internal_representations( + &self, + executable_info: &vk::PipelineExecutableInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_internal_representations_khr)( + self.handle, + executable_info, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_properties( + &self, + pipeline_info: &vk::PipelineInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_properties_khr)( + self.handle, + pipeline_info, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_statistics( + &self, + executable_info: &vk::PipelineExecutableInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_statistics_khr)( + self.handle, + executable_info, + count, + data, + ) + }) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPipelineExecutablePropertiesFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/present_wait.rs b/third_party/rust/ash/src/extensions/khr/present_wait.rs new file mode 100644 index 0000000000..4d8effe48d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/present_wait.rs @@ -0,0 +1,47 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PresentWait { + handle: vk::Device, + fp: vk::KhrPresentWaitFn, +} + +impl PresentWait { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrPresentWaitFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWaitForPresentKHR.html> + #[inline] + pub unsafe fn wait_for_present( + &self, + swapchain: vk::SwapchainKHR, + present_id: u64, + timeout: u64, + ) -> VkResult<()> { + (self.fp.wait_for_present_khr)(self.handle, swapchain, present_id, timeout).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPresentWaitFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPresentWaitFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/push_descriptor.rs b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs new file mode 100644 index 0000000000..22d1572883 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs @@ -0,0 +1,68 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::c_void; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PushDescriptor { + fp: vk::KhrPushDescriptorFn, +} + +impl PushDescriptor { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrPushDescriptorFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetKHR.html> + #[inline] + pub unsafe fn cmd_push_descriptor_set( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + layout: vk::PipelineLayout, + set: u32, + descriptor_writes: &[vk::WriteDescriptorSet], + ) { + (self.fp.cmd_push_descriptor_set_khr)( + command_buffer, + pipeline_bind_point, + layout, + set, + descriptor_writes.len() as u32, + descriptor_writes.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetWithTemplateKHR.html> + #[inline] + pub unsafe fn cmd_push_descriptor_set_with_template( + &self, + command_buffer: vk::CommandBuffer, + descriptor_update_template: vk::DescriptorUpdateTemplate, + layout: vk::PipelineLayout, + set: u32, + p_data: *const c_void, + ) { + (self.fp.cmd_push_descriptor_set_with_template_khr)( + command_buffer, + descriptor_update_template, + layout, + set, + p_data, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPushDescriptorFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPushDescriptorFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs new file mode 100644 index 0000000000..a5159ad395 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs @@ -0,0 +1,42 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_ray_tracing_maintenance1.html> +#[derive(Clone)] +pub struct RayTracingMaintenance1 { + fp: vk::KhrRayTracingMaintenance1Fn, +} + +impl RayTracingMaintenance1 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrRayTracingMaintenance1Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirect2KHR.html> + /// + /// `indirect_device_address` is a buffer device address which is a pointer to a [`vk::TraceRaysIndirectCommand2KHR`] structure containing the trace ray parameters. + #[inline] + pub unsafe fn cmd_trace_rays_indirect2( + &self, + command_buffer: vk::CommandBuffer, + indirect_device_address: vk::DeviceAddress, + ) { + (self.fp.cmd_trace_rays_indirect2_khr)(command_buffer, indirect_device_address); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrRayTracingMaintenance1Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrRayTracingMaintenance1Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs new file mode 100644 index 0000000000..af733430d1 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs @@ -0,0 +1,194 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracingPipeline { + handle: vk::Device, + fp: vk::KhrRayTracingPipelineFn, +} + +impl RayTracingPipeline { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrRayTracingPipelineFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceRayTracingPipelinePropertiesKHR { + let mut props_rt = vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysKHR.html> + #[inline] + pub unsafe fn cmd_trace_rays( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + miss_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + hit_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + callable_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + width: u32, + height: u32, + depth: u32, + ) { + (self.fp.cmd_trace_rays_khr)( + command_buffer, + raygen_shader_binding_tables, + miss_shader_binding_tables, + hit_shader_binding_tables, + callable_shader_binding_tables, + width, + height, + depth, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateRayTracingPipelinesKHR.html> + #[inline] + pub unsafe fn create_ray_tracing_pipelines( + &self, + deferred_operation: vk::DeferredOperationKHR, + pipeline_cache: vk::PipelineCache, + create_info: &[vk::RayTracingPipelineCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::Pipeline>> { + let mut pipelines = vec![mem::zeroed(); create_info.len()]; + (self.fp.create_ray_tracing_pipelines_khr)( + self.handle, + deferred_operation, + pipeline_cache, + create_info.len() as u32, + create_info.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ) + .result_with_success(pipelines) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data = Vec::<u8>::with_capacity(data_size); + (self.fp.get_ray_tracing_shader_group_handles_khr)( + self.handle, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr().cast(), + ) + .result()?; + data.set_len(data_size); + Ok(data) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingCaptureReplayShaderGroupHandlesKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_capture_replay_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data = Vec::<u8>::with_capacity(data_size); + (self + .fp + .get_ray_tracing_capture_replay_shader_group_handles_khr)( + self.handle, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr().cast(), + ) + .result()?; + data.set_len(data_size); + Ok(data) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html> + /// + /// `indirect_device_address` is a buffer device address which is a pointer to a [`vk::TraceRaysIndirectCommandKHR`] structure containing the trace ray parameters. + #[inline] + pub unsafe fn cmd_trace_rays_indirect( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + miss_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + hit_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + callable_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + indirect_device_address: vk::DeviceAddress, + ) { + (self.fp.cmd_trace_rays_indirect_khr)( + command_buffer, + raygen_shader_binding_table.as_ptr(), + miss_shader_binding_table.as_ptr(), + hit_shader_binding_table.as_ptr(), + callable_shader_binding_table.as_ptr(), + indirect_device_address, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingShaderGroupStackSizeKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_shader_group_stack_size( + &self, + pipeline: vk::Pipeline, + group: u32, + group_shader: vk::ShaderGroupShaderKHR, + ) -> vk::DeviceSize { + (self.fp.get_ray_tracing_shader_group_stack_size_khr)( + self.handle, + pipeline, + group, + group_shader, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRayTracingPipelineStackSizeKHR.html> + #[inline] + pub unsafe fn cmd_set_ray_tracing_pipeline_stack_size( + &self, + command_buffer: vk::CommandBuffer, + pipeline_stack_size: u32, + ) { + (self.fp.cmd_set_ray_tracing_pipeline_stack_size_khr)(command_buffer, pipeline_stack_size); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrRayTracingPipelineFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/surface.rs b/third_party/rust/ash/src/extensions/khr/surface.rs new file mode 100755 index 0000000000..11508bdcc9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/surface.rs @@ -0,0 +1,110 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Surface { + handle: vk::Instance, + fp: vk::KhrSurfaceFn, +} + +impl Surface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + surface: vk::SurfaceKHR, + ) -> VkResult<bool> { + let mut b = 0; + (self.fp.get_physical_device_surface_support_khr)( + physical_device, + queue_family_index, + surface, + &mut b, + ) + .result_with_success(b > 0) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_present_modes( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::PresentModeKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_surface_present_modes_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_capabilities( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::SurfaceCapabilitiesKHR> { + let mut surface_capabilities = mem::zeroed(); + (self.fp.get_physical_device_surface_capabilities_khr)( + physical_device, + surface, + &mut surface_capabilities, + ) + .result_with_success(surface_capabilities) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_formats( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::SurfaceFormatKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_surface_formats_khr)(physical_device, surface, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroySurfaceKHR.html> + #[inline] + pub unsafe fn destroy_surface( + &self, + surface: vk::SurfaceKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_surface_khr)(self.handle, surface, allocation_callbacks.as_raw_ptr()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/swapchain.rs b/third_party/rust/ash/src/extensions/khr/swapchain.rs new file mode 100755 index 0000000000..8f57729de7 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/swapchain.rs @@ -0,0 +1,211 @@ +#[cfg(doc)] +use super::DeviceGroup; +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Swapchain { + handle: vk::Device, + fp: vk::KhrSwapchainFn, +} + +impl Swapchain { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrSwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html> + #[inline] + pub unsafe fn create_swapchain( + &self, + create_info: &vk::SwapchainCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SwapchainKHR> { + let mut swapchain = mem::zeroed(); + (self.fp.create_swapchain_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut swapchain, + ) + .result_with_success(swapchain) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroySwapchainKHR.html> + #[inline] + pub unsafe fn destroy_swapchain( + &self, + swapchain: vk::SwapchainKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_swapchain_khr)(self.handle, swapchain, allocation_callbacks.as_raw_ptr()); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSwapchainImagesKHR.html> + #[inline] + pub unsafe fn get_swapchain_images( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<Vec<vk::Image>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_swapchain_images_khr)(self.handle, swapchain, count, data) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImageKHR.html> + #[inline] + pub unsafe fn acquire_next_image( + &self, + swapchain: vk::SwapchainKHR, + timeout: u64, + semaphore: vk::Semaphore, + fence: vk::Fence, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image_khr)( + self.handle, + swapchain, + timeout, + semaphore, + fence, + &mut index, + ); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + /// On success, returns whether the swapchain is suboptimal for the surface. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html> + #[inline] + pub unsafe fn queue_present( + &self, + queue: vk::Queue, + present_info: &vk::PresentInfoKHR, + ) -> VkResult<bool> { + let err_code = (self.fp.queue_present_khr)(queue, present_info); + match err_code { + vk::Result::SUCCESS => Ok(false), + vk::Result::SUBOPTIMAL_KHR => Ok(true), + _ => Err(err_code), + } + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_device_group_present_capabilities()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPresentCapabilitiesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_present_capabilities( + &self, + device_group_present_capabilities: &mut vk::DeviceGroupPresentCapabilitiesKHR, + ) -> VkResult<()> { + (self.fp.get_device_group_present_capabilities_khr)( + self.handle, + device_group_present_capabilities, + ) + .result() + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_device_group_surface_present_modes()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_surface_present_modes( + &self, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { + let mut modes = mem::zeroed(); + (self.fp.get_device_group_surface_present_modes_khr)(self.handle, surface, &mut modes) + .result_with_success(modes) + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_physical_device_present_rectangles()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDevicePresentRectanglesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_physical_device_present_rectangles( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::Rect2D>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_present_rectangles_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::acquire_next_image2()`] + /// when [`VK_KHR_swapchain`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImage2KHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_swapchain`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html + #[inline] + pub unsafe fn acquire_next_image2( + &self, + acquire_info: &vk::AcquireNextImageInfoKHR, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image2_khr)(self.handle, acquire_info, &mut index); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSwapchainFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSwapchainFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/synchronization2.rs b/third_party/rust/ash/src/extensions/khr/synchronization2.rs new file mode 100644 index 0000000000..d8baefd602 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/synchronization2.rs @@ -0,0 +1,101 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Synchronization2 { + fp: vk::KhrSynchronization2Fn, +} + +impl Synchronization2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrSynchronization2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPipelineBarrier2KHR.html> + #[inline] + pub unsafe fn cmd_pipeline_barrier2( + &self, + command_buffer: vk::CommandBuffer, + dependency_info: &vk::DependencyInfoKHR, + ) { + (self.fp.cmd_pipeline_barrier2_khr)(command_buffer, dependency_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdResetEvent2KHR.html> + #[inline] + pub unsafe fn cmd_reset_event2( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + stage_mask: vk::PipelineStageFlags2KHR, + ) { + (self.fp.cmd_reset_event2_khr)(command_buffer, event, stage_mask) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetEvent2KHR.html> + #[inline] + pub unsafe fn cmd_set_event2( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + dependency_info: &vk::DependencyInfoKHR, + ) { + (self.fp.cmd_set_event2_khr)(command_buffer, event, dependency_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWaitEvents2KHR.html> + #[inline] + pub unsafe fn cmd_wait_events2( + &self, + command_buffer: vk::CommandBuffer, + events: &[vk::Event], + dependency_infos: &[vk::DependencyInfoKHR], + ) { + assert_eq!(events.len(), dependency_infos.len()); + (self.fp.cmd_wait_events2_khr)( + command_buffer, + events.len() as u32, + events.as_ptr(), + dependency_infos.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWriteTimestamp2KHR.html> + #[inline] + pub unsafe fn cmd_write_timestamp2( + &self, + command_buffer: vk::CommandBuffer, + stage: vk::PipelineStageFlags2KHR, + query_pool: vk::QueryPool, + query: u32, + ) { + (self.fp.cmd_write_timestamp2_khr)(command_buffer, stage, query_pool, query) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueueSubmit2KHR.html> + #[inline] + pub unsafe fn queue_submit2( + &self, + queue: vk::Queue, + submits: &[vk::SubmitInfo2KHR], + fence: vk::Fence, + ) -> VkResult<()> { + (self.fp.queue_submit2_khr)(queue, submits.len() as u32, submits.as_ptr(), fence).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSynchronization2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSynchronization2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs new file mode 100644 index 0000000000..de9a492506 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs @@ -0,0 +1,60 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct TimelineSemaphore { + handle: vk::Device, + fp: vk::KhrTimelineSemaphoreFn, +} + +impl TimelineSemaphore { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreCounterValue.html> + #[inline] + pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> { + let mut value = 0; + (self.fp.get_semaphore_counter_value_khr)(self.handle, semaphore, &mut value) + .result_with_success(value) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWaitSemaphores.html> + #[inline] + pub unsafe fn wait_semaphores( + &self, + wait_info: &vk::SemaphoreWaitInfo, + timeout: u64, + ) -> VkResult<()> { + (self.fp.wait_semaphores_khr)(self.handle, wait_info, timeout).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSignalSemaphore.html> + #[inline] + pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { + (self.fp.signal_semaphore_khr)(self.handle, signal_info).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrTimelineSemaphoreFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/wayland_surface.rs b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs new file mode 100755 index 0000000000..d51fcb9914 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs @@ -0,0 +1,71 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct WaylandSurface { + handle: vk::Instance, + fp: vk::KhrWaylandSurfaceFn, +} + +impl WaylandSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrWaylandSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateWaylandSurfaceKHR.html> + #[inline] + pub unsafe fn create_wayland_surface( + &self, + create_info: &vk::WaylandSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_wayland_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_wayland_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + wl_display: &mut vk::wl_display, + ) -> bool { + let b = (self.fp.get_physical_device_wayland_presentation_support_khr)( + physical_device, + queue_family_index, + wl_display, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrWaylandSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/win32_surface.rs b/third_party/rust/ash/src/extensions/khr/win32_surface.rs new file mode 100755 index 0000000000..be56a02e2e --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/win32_surface.rs @@ -0,0 +1,69 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Win32Surface { + handle: vk::Instance, + fp: vk::KhrWin32SurfaceFn, +} + +impl Win32Surface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrWin32SurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateWin32SurfaceKHR.html> + #[inline] + pub unsafe fn create_win32_surface( + &self, + create_info: &vk::Win32SurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_win32_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_win32_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + ) -> bool { + let b = (self.fp.get_physical_device_win32_presentation_support_khr)( + physical_device, + queue_family_index, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrWin32SurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xcb_surface.rs b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs new file mode 100755 index 0000000000..967376e7c6 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs @@ -0,0 +1,73 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XcbSurface { + handle: vk::Instance, + fp: vk::KhrXcbSurfaceFn, +} + +impl XcbSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrXcbSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateXcbSurfaceKHR.html> + #[inline] + pub unsafe fn create_xcb_surface( + &self, + create_info: &vk::XcbSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_xcb_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_xcb_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + connection: &mut vk::xcb_connection_t, + visual_id: vk::xcb_visualid_t, + ) -> bool { + let b = (self.fp.get_physical_device_xcb_presentation_support_khr)( + physical_device, + queue_family_index, + connection, + visual_id, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrXcbSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xlib_surface.rs b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs new file mode 100755 index 0000000000..59ad416e47 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs @@ -0,0 +1,73 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XlibSurface { + handle: vk::Instance, + fp: vk::KhrXlibSurfaceFn, +} + +impl XlibSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrXlibSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateXlibSurfaceKHR.html> + #[inline] + pub unsafe fn create_xlib_surface( + &self, + create_info: &vk::XlibSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_xlib_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_xlib_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + display: &mut vk::Display, + visual_id: vk::VisualID, + ) -> bool { + let b = (self.fp.get_physical_device_xlib_presentation_support_khr)( + physical_device, + queue_family_index, + display, + visual_id, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrXlibSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/mod.rs b/third_party/rust/ash/src/extensions/mod.rs new file mode 100644 index 0000000000..fefba9b688 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mod.rs @@ -0,0 +1,6 @@ +pub mod experimental; +pub mod ext; +pub mod khr; +pub mod mvk; +pub mod nn; +pub mod nv; diff --git a/third_party/rust/ash/src/extensions/mvk/ios_surface.rs b/third_party/rust/ash/src/extensions/mvk/ios_surface.rs new file mode 100755 index 0000000000..8ae83e98d2 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mvk/ios_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct IOSSurface { + handle: vk::Instance, + fp: vk::MvkIosSurfaceFn, +} + +impl IOSSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::MvkIosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateIOSSurfaceMVK.html> + #[inline] + pub unsafe fn create_ios_surface( + &self, + create_info: &vk::IOSSurfaceCreateInfoMVK, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_ios_surface_mvk)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::MvkIosSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::MvkIosSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/mvk/macos_surface.rs b/third_party/rust/ash/src/extensions/mvk/macos_surface.rs new file mode 100755 index 0000000000..878829e452 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mvk/macos_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MacOSSurface { + handle: vk::Instance, + fp: vk::MvkMacosSurfaceFn, +} + +impl MacOSSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::MvkMacosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateMacOSSurfaceMVK.html> + #[inline] + pub unsafe fn create_mac_os_surface( + &self, + create_info: &vk::MacOSSurfaceCreateInfoMVK, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_mac_os_surface_mvk)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::MvkMacosSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::MvkMacosSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/mvk/mod.rs b/third_party/rust/ash/src/extensions/mvk/mod.rs new file mode 100644 index 0000000000..e475d53563 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mvk/mod.rs @@ -0,0 +1,5 @@ +pub use self::ios_surface::IOSSurface; +pub use self::macos_surface::MacOSSurface; + +mod ios_surface; +mod macos_surface; diff --git a/third_party/rust/ash/src/extensions/nn/mod.rs b/third_party/rust/ash/src/extensions/nn/mod.rs new file mode 100644 index 0000000000..e429050a6c --- /dev/null +++ b/third_party/rust/ash/src/extensions/nn/mod.rs @@ -0,0 +1,3 @@ +pub use self::vi_surface::ViSurface; + +mod vi_surface; diff --git a/third_party/rust/ash/src/extensions/nn/vi_surface.rs b/third_party/rust/ash/src/extensions/nn/vi_surface.rs new file mode 100644 index 0000000000..0aa188ac27 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nn/vi_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ViSurface { + handle: vk::Instance, + fp: vk::NnViSurfaceFn, +} + +impl ViSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::NnViSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateViSurfaceNN.html> + #[inline] + pub unsafe fn create_vi_surface( + &self, + create_info: &vk::ViSurfaceCreateInfoNN, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_vi_surface_nn)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::NnViSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::NnViSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/nv/coverage_reduction_mode.rs b/third_party/rust/ash/src/extensions/nv/coverage_reduction_mode.rs new file mode 100644 index 0000000000..b4304772e3 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/coverage_reduction_mode.rs @@ -0,0 +1,70 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_NV_coverage_reduction_mode.html> +#[derive(Clone)] +pub struct CoverageReductionMode { + fp: vk::NvCoverageReductionModeFn, +} + +impl CoverageReductionMode { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::NvCoverageReductionModeFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// Retrieve the number of elements to pass to [`get_physical_device_supported_framebuffer_mixed_samples_combinations()`][Self::get_physical_device_supported_framebuffer_mixed_samples_combinations()] + #[inline] + pub unsafe fn get_physical_device_supported_framebuffer_mixed_samples_combinations_len( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<usize> { + let mut count = 0; + (self + .fp + .get_physical_device_supported_framebuffer_mixed_samples_combinations_nv)( + physical_device, + &mut count, + std::ptr::null_mut(), + ) + .result_with_success(count as usize) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV.html> + /// + /// Call [`get_physical_device_supported_framebuffer_mixed_samples_combinations_len()`][Self::get_physical_device_supported_framebuffer_mixed_samples_combinations_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_supported_framebuffer_mixed_samples_combinations( + &self, + physical_device: vk::PhysicalDevice, + out: &mut [vk::FramebufferMixedSamplesCombinationNV], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self + .fp + .get_physical_device_supported_framebuffer_mixed_samples_combinations_nv)( + physical_device, + &mut count, + out.as_mut_ptr(), + ) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::NvCoverageReductionModeFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::NvCoverageReductionModeFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/nv/device_diagnostic_checkpoints.rs b/third_party/rust/ash/src/extensions/nv/device_diagnostic_checkpoints.rs new file mode 100644 index 0000000000..ce43d046e6 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/device_diagnostic_checkpoints.rs @@ -0,0 +1,63 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::os::raw::c_void; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_NV_device_diagnostic_checkpoints.html> +#[derive(Clone)] +pub struct DeviceDiagnosticCheckpoints { + fp: vk::NvDeviceDiagnosticCheckpointsFn, +} + +impl DeviceDiagnosticCheckpoints { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::NvDeviceDiagnosticCheckpointsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetCheckpointNV.html> + #[inline] + pub unsafe fn cmd_set_checkpoint( + &self, + command_buffer: vk::CommandBuffer, + p_checkpoint_marker: *const c_void, + ) { + (self.fp.cmd_set_checkpoint_nv)(command_buffer, p_checkpoint_marker); + } + + /// Retrieve the number of elements to pass to [`get_queue_checkpoint_data()`][Self::get_queue_checkpoint_data()] + #[inline] + pub unsafe fn get_queue_checkpoint_data_len(&self, queue: vk::Queue) -> usize { + let mut count = 0; + (self.fp.get_queue_checkpoint_data_nv)(queue, &mut count, std::ptr::null_mut()); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetQueueCheckpointDataNV.html> + /// + /// Call [`get_queue_checkpoint_data_len()`][Self::get_queue_checkpoint_data_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_queue_checkpoint_data( + &self, + queue: vk::Queue, + out: &mut [vk::CheckpointDataNV], + ) { + let mut count = out.len() as u32; + (self.fp.get_queue_checkpoint_data_nv)(queue, &mut count, out.as_mut_ptr()); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::NvDeviceDiagnosticCheckpointsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::NvDeviceDiagnosticCheckpointsFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/nv/mesh_shader.rs b/third_party/rust/ash/src/extensions/nv/mesh_shader.rs new file mode 100755 index 0000000000..14ef8d44ac --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/mesh_shader.rs @@ -0,0 +1,81 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MeshShader { + fp: vk::NvMeshShaderFn, +} + +impl MeshShader { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::NvMeshShaderFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksNV.html> + #[inline] + pub unsafe fn cmd_draw_mesh_tasks( + &self, + command_buffer: vk::CommandBuffer, + task_count: u32, + first_task: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_nv)(command_buffer, task_count, first_task); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectNV.html> + #[inline] + pub unsafe fn cmd_draw_mesh_tasks_indirect( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_indirect_nv)( + command_buffer, + buffer, + offset, + draw_count, + stride, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html> + #[inline] + pub unsafe fn cmd_draw_mesh_tasks_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_mesh_tasks_indirect_count_nv)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::NvMeshShaderFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::NvMeshShaderFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/nv/mod.rs b/third_party/rust/ash/src/extensions/nv/mod.rs new file mode 100644 index 0000000000..bfde37a55c --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/mod.rs @@ -0,0 +1,9 @@ +pub use self::coverage_reduction_mode::CoverageReductionMode; +pub use self::device_diagnostic_checkpoints::DeviceDiagnosticCheckpoints; +pub use self::mesh_shader::MeshShader; +pub use self::ray_tracing::RayTracing; + +mod coverage_reduction_mode; +mod device_diagnostic_checkpoints; +mod mesh_shader; +mod ray_tracing; diff --git a/third_party/rust/ash/src/extensions/nv/ray_tracing.rs b/third_party/rust/ash/src/extensions/nv/ray_tracing.rs new file mode 100755 index 0000000000..d97ec85dfe --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/ray_tracing.rs @@ -0,0 +1,271 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracing { + handle: vk::Device, + fp: vk::NvRayTracingFn, +} + +impl RayTracing { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::NvRayTracingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceRayTracingPropertiesNV { + let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesNV::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateAccelerationStructureNV.html> + #[inline] + pub unsafe fn create_acceleration_structure( + &self, + create_info: &vk::AccelerationStructureCreateInfoNV, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::AccelerationStructureNV> { + let mut accel_struct = mem::zeroed(); + (self.fp.create_acceleration_structure_nv)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ) + .result_with_success(accel_struct) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyAccelerationStructureNV.html> + #[inline] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureNV, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_acceleration_structure_nv)( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsNV.html> + #[inline] + pub unsafe fn get_acceleration_structure_memory_requirements( + &self, + info: &vk::AccelerationStructureMemoryRequirementsInfoNV, + ) -> vk::MemoryRequirements2KHR { + let mut requirements = mem::zeroed(); + (self.fp.get_acceleration_structure_memory_requirements_nv)( + self.handle, + info, + &mut requirements, + ); + requirements + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkBindAccelerationStructureMemoryNV.html> + #[inline] + pub unsafe fn bind_acceleration_structure_memory( + &self, + bind_info: &[vk::BindAccelerationStructureMemoryInfoNV], + ) -> VkResult<()> { + (self.fp.bind_acceleration_structure_memory_nv)( + self.handle, + bind_info.len() as u32, + bind_info.as_ptr(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBuildAccelerationStructureNV.html> + #[inline] + pub unsafe fn cmd_build_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::AccelerationStructureInfoNV, + instance_data: vk::Buffer, + instance_offset: vk::DeviceSize, + update: bool, + dst: vk::AccelerationStructureNV, + src: vk::AccelerationStructureNV, + scratch: vk::Buffer, + scratch_offset: vk::DeviceSize, + ) { + (self.fp.cmd_build_acceleration_structure_nv)( + command_buffer, + info, + instance_data, + instance_offset, + if update { vk::TRUE } else { vk::FALSE }, + dst, + src, + scratch, + scratch_offset, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyAccelerationStructureNV.html> + #[inline] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + dst: vk::AccelerationStructureNV, + src: vk::AccelerationStructureNV, + mode: vk::CopyAccelerationStructureModeNV, + ) { + (self.fp.cmd_copy_acceleration_structure_nv)(command_buffer, dst, src, mode); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysNV.html> + #[inline] + pub unsafe fn cmd_trace_rays( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_table_buffer: vk::Buffer, + raygen_shader_binding_offset: vk::DeviceSize, + miss_shader_binding_table_buffer: vk::Buffer, + miss_shader_binding_offset: vk::DeviceSize, + miss_shader_binding_stride: vk::DeviceSize, + hit_shader_binding_table_buffer: vk::Buffer, + hit_shader_binding_offset: vk::DeviceSize, + hit_shader_binding_stride: vk::DeviceSize, + callable_shader_binding_table_buffer: vk::Buffer, + callable_shader_binding_offset: vk::DeviceSize, + callable_shader_binding_stride: vk::DeviceSize, + width: u32, + height: u32, + depth: u32, + ) { + (self.fp.cmd_trace_rays_nv)( + command_buffer, + raygen_shader_binding_table_buffer, + raygen_shader_binding_offset, + miss_shader_binding_table_buffer, + miss_shader_binding_offset, + miss_shader_binding_stride, + hit_shader_binding_table_buffer, + hit_shader_binding_offset, + hit_shader_binding_stride, + callable_shader_binding_table_buffer, + callable_shader_binding_offset, + callable_shader_binding_stride, + width, + height, + depth, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateRayTracingPipelinesNV.html> + #[inline] + pub unsafe fn create_ray_tracing_pipelines( + &self, + pipeline_cache: vk::PipelineCache, + create_info: &[vk::RayTracingPipelineCreateInfoNV], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::Pipeline>> { + let mut pipelines = vec![mem::zeroed(); create_info.len()]; + (self.fp.create_ray_tracing_pipelines_nv)( + self.handle, + pipeline_cache, + create_info.len() as u32, + create_info.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ) + .result_with_success(pipelines) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html> + #[inline] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data: &mut [u8], + ) -> VkResult<()> { + (self.fp.get_ray_tracing_shader_group_handles_nv)( + self.handle, + pipeline, + first_group, + group_count, + data.len(), + data.as_mut_ptr().cast(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureHandleNV.html> + #[inline] + pub unsafe fn get_acceleration_structure_handle( + &self, + accel_struct: vk::AccelerationStructureNV, + ) -> VkResult<u64> { + let mut handle: u64 = 0; + let handle_ptr: *mut u64 = &mut handle; + (self.fp.get_acceleration_structure_handle_nv)( + self.handle, + accel_struct, + std::mem::size_of::<u64>(), + handle_ptr.cast(), + ) + .result_with_success(handle) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html> + #[inline] + pub unsafe fn cmd_write_acceleration_structures_properties( + &self, + command_buffer: vk::CommandBuffer, + structures: &[vk::AccelerationStructureNV], + query_type: vk::QueryType, + query_pool: vk::QueryPool, + first_query: u32, + ) { + (self.fp.cmd_write_acceleration_structures_properties_nv)( + command_buffer, + structures.len() as u32, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCompileDeferredNV.html> + #[inline] + pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> { + (self.fp.compile_deferred_nv)(self.handle, pipeline, shader).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::NvRayTracingFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::NvRayTracingFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} |