diff options
Diffstat (limited to 'third_party/rust/ash/src/extensions')
29 files changed, 3156 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..b01ef48d30 --- /dev/null +++ b/third_party/rust/ash/src/extensions/experimental/amd.rs @@ -0,0 +1,703 @@ +#![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. + * + **********************************************************************************************************************/ + +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, + 0b1111111111111111111111111111111, + Flags +); +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 = GpaSqShaderStageFlags(0b1); + pub const VS: Self = GpaSqShaderStageFlags(0b10); + pub const GS: Self = GpaSqShaderStageFlags(0b100); + pub const ES: Self = GpaSqShaderStageFlags(0b1000); + pub const HS: Self = GpaSqShaderStageFlags(0b10000); + pub const LS: Self = GpaSqShaderStageFlags(0b100000); + pub const CS: Self = GpaSqShaderStageFlags(0b1000000); +} + +impl StructureType { + pub const PHYSICAL_DEVICE_GPA_FEATURES_AMD: Self = StructureType(1000133000); + pub const PHYSICAL_DEVICE_GPA_PROPERTIES_AMD: Self = StructureType(1000133001); + pub const GPA_SAMPLE_BEGIN_INFO_AMD: Self = StructureType(1000133002); + pub const GPA_SESSION_CREATE_INFO_AMD: Self = StructureType(1000133003); + pub const GPA_DEVICE_CLOCK_MODE_INFO_AMD: Self = StructureType(1000133004); +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct GpaDeviceClockModeAmd(pub(crate) i32); +impl GpaDeviceClockModeAmd { + pub fn from_raw(x: i32) -> Self { + GpaDeviceClockModeAmd(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaDeviceClockModeAmd { + pub const DEFAULT: Self = GpaDeviceClockModeAmd(0); + pub const QUERY: Self = GpaDeviceClockModeAmd(1); + pub const PROFILING: Self = GpaDeviceClockModeAmd(2); + pub const MIN_MEMORY: Self = GpaDeviceClockModeAmd(3); + pub const MIN_ENGINE: Self = GpaDeviceClockModeAmd(4); + pub const PEAK: Self = GpaDeviceClockModeAmd(5); +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct GpaPerfBlockAmd(pub(crate) i32); +impl GpaPerfBlockAmd { + pub fn from_raw(x: i32) -> Self { + GpaPerfBlockAmd(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaPerfBlockAmd { + pub const CPF: Self = GpaPerfBlockAmd(0); + pub const IA: Self = GpaPerfBlockAmd(1); + pub const VGT: Self = GpaPerfBlockAmd(2); + pub const PA: Self = GpaPerfBlockAmd(3); + pub const SC: Self = GpaPerfBlockAmd(4); + pub const SPI: Self = GpaPerfBlockAmd(5); + pub const SQ: Self = GpaPerfBlockAmd(6); + pub const SX: Self = GpaPerfBlockAmd(7); + pub const TA: Self = GpaPerfBlockAmd(8); + pub const TD: Self = GpaPerfBlockAmd(9); + pub const TCP: Self = GpaPerfBlockAmd(10); + pub const TCC: Self = GpaPerfBlockAmd(11); + pub const TCA: Self = GpaPerfBlockAmd(12); + pub const DB: Self = GpaPerfBlockAmd(13); + pub const CB: Self = GpaPerfBlockAmd(14); + pub const GDS: Self = GpaPerfBlockAmd(15); + pub const SRBM: Self = GpaPerfBlockAmd(16); + pub const GRBM: Self = GpaPerfBlockAmd(17); + pub const GRBM_SE: Self = GpaPerfBlockAmd(18); + pub const RLC: Self = GpaPerfBlockAmd(19); + pub const DMA: Self = GpaPerfBlockAmd(20); + pub const MC: Self = GpaPerfBlockAmd(21); + pub const CPG: Self = GpaPerfBlockAmd(22); + pub const CPC: Self = GpaPerfBlockAmd(23); + pub const WD: Self = GpaPerfBlockAmd(24); + pub const TCS: Self = GpaPerfBlockAmd(25); + pub const ATC: Self = GpaPerfBlockAmd(26); + pub const ATC_L2: Self = GpaPerfBlockAmd(27); + pub const MC_VM_L2: Self = GpaPerfBlockAmd(28); + pub const EA: Self = GpaPerfBlockAmd(29); + pub const RPB: Self = GpaPerfBlockAmd(30); + pub const RMI: Self = GpaPerfBlockAmd(31); +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] +#[repr(transparent)] +pub struct GpaSampleTypeAmd(pub(crate) i32); +impl GpaSampleTypeAmd { + pub fn from_raw(x: i32) -> Self { + GpaSampleTypeAmd(x) + } + pub fn as_raw(self) -> i32 { + self.0 + } +} +impl GpaSampleTypeAmd { + pub const CUMULATIVE: Self = GpaSampleTypeAmd(0); + pub const TRACE: Self = GpaSampleTypeAmd(1); + pub const TIMING: Self = GpaSampleTypeAmd(2); +} + +handle_nondispatchable!(GpaSessionAmd, UNKNOWN); + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct GpaSessionCreateInfoAmd { + pub s_type: StructureType, + pub p_next: *const c_void, + pub secondary_copy_source: GpaSessionAmd, +} + +#[repr(C)] +#[derive(Copy, Clone, 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, 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, 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() -> PhysicalDeviceGpaPropertiesAmd { + PhysicalDeviceGpaPropertiesAmd { + 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: PhysicalDeviceGpaPropertiesAmd::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 next<T>(mut self, next: &'a mut T) -> PhysicalDeviceGpaPropertiesAmdBuilder<'a> + where + T: ExtendsPhysicalDeviceGpaPropertiesAmd, + { + self.inner.p_next = next as *mut T as *mut c_void; + self + } + pub fn build(self) -> PhysicalDeviceGpaPropertiesAmd { + self.inner + } +} + +#[repr(C)] +#[derive(Copy, Clone, Debug)] +pub struct GpaPerfCounterAmd { + pub block_type: GpaPerfBlockAmd, + pub block_instance: u32, + pub event_id: u32, +} + +#[repr(C)] +#[derive(Copy, Clone, 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, 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 { + AmdGpaInterfaceFn { + 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, + { + AmdGpaInterfaceFn { + 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 raw_name = stringify!(vkCreateGpaSessionAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkDestroyGpaSessionAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkSetGpaDeviceClockModeAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdBeginGpaSessionAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdEndGpaSessionAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdBeginGpaSampleAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdEndGpaSampleAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkGetGpaSessionStatusAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkGetGpaSessionResultsAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdEndGpaSampleAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 raw_name = stringify!(vkCmdCopyGpaSessionResultsAMD); + let cname = ::std::ffi::CString::new(raw_name).unwrap(); + 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 = StructureType(1000045000); + pub const PHYSICAL_DEVICE_WAVE_LIMIT_PROPERTIES_AMD: Self = StructureType(1000045001); +} + +#[repr(C)] +#[derive(Copy, Clone, 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() -> PhysicalDeviceWaveLimitPropertiesAmd { + PhysicalDeviceWaveLimitPropertiesAmd { + 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: PhysicalDeviceWaveLimitPropertiesAmd::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 = next as *mut T as *mut BaseOutStructure; + let last_next = ptr_chain_iter(next).last().unwrap(); + (*last_next).p_next = self.inner.p_next as _; + self.inner.p_next = next_ptr as _; + } + self + } + pub fn build(self) -> PhysicalDeviceWaveLimitPropertiesAmd { + self.inner + } +} + +#[repr(C)] +#[derive(Copy, Clone, 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/debug_marker.rs b/third_party/rust/ash/src/extensions/ext/debug_marker.rs new file mode 100755 index 0000000000..626f23ab50 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_marker.rs @@ -0,0 +1,69 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugMarker { + debug_marker_fn: vk::ExtDebugMarkerFn, +} + +impl DebugMarker { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DebugMarker { + let debug_marker_fn = vk::ExtDebugMarkerFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + DebugMarker { debug_marker_fn } + } + + pub fn name() -> &'static CStr { + vk::ExtDebugMarkerFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDebugMarkerSetObjectNameEXT.html>"] + pub unsafe fn debug_marker_set_object_name( + &self, + device: vk::Device, + name_info: &vk::DebugMarkerObjectNameInfoEXT, + ) -> VkResult<()> { + let err_code = self + .debug_marker_fn + .debug_marker_set_object_name_ext(device, name_info); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerBeginEXT.html>"] + pub unsafe fn cmd_debug_marker_begin( + &self, + command_buffer: vk::CommandBuffer, + marker_info: &vk::DebugMarkerMarkerInfoEXT, + ) { + self.debug_marker_fn + .cmd_debug_marker_begin_ext(command_buffer, marker_info); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerEndEXT.html>"] + pub unsafe fn cmd_debug_marker_end(&self, command_buffer: vk::CommandBuffer) { + self.debug_marker_fn + .cmd_debug_marker_end_ext(command_buffer); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDebugMarkerInsertEXT.html>"] + pub unsafe fn cmd_debug_marker_insert( + &self, + command_buffer: vk::CommandBuffer, + marker_info: &vk::DebugMarkerMarkerInfoEXT, + ) { + self.debug_marker_fn + .cmd_debug_marker_insert_ext(command_buffer, marker_info); + } + + pub fn fp(&self) -> &vk::ExtDebugMarkerFn { + &self.debug_marker_fn + } +} 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..56dce80559 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_report.rs @@ -0,0 +1,69 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugReport { + handle: vk::Instance, + debug_report_fn: vk::ExtDebugReportFn, +} + +impl DebugReport { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> DebugReport { + let debug_report_fn = vk::ExtDebugReportFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + DebugReport { + handle: instance.handle(), + debug_report_fn, + } + } + + pub fn name() -> &'static CStr { + vk::ExtDebugReportFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugReportCallbackEXT.html>"] + pub unsafe fn destroy_debug_report_callback( + &self, + debug: vk::DebugReportCallbackEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.debug_report_fn.destroy_debug_report_callback_ext( + self.handle, + debug, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugReportCallbackEXT.html>"] + 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(); + let err_code = self.debug_report_fn.create_debug_report_callback_ext( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut debug_cb, + ); + match err_code { + vk::Result::SUCCESS => Ok(debug_cb), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::ExtDebugReportFn { + &self.debug_report_fn + } + + 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..fdafd3d2fc --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/debug_utils.rs @@ -0,0 +1,165 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::{vk, RawPtr}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DebugUtils { + handle: vk::Instance, + debug_utils_fn: vk::ExtDebugUtilsFn, +} + +impl DebugUtils { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> DebugUtils { + let debug_utils_fn = vk::ExtDebugUtilsFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + DebugUtils { + handle: instance.handle(), + debug_utils_fn, + } + } + + pub fn name() -> &'static CStr { + vk::ExtDebugUtilsFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectNameEXT.html>"] + pub unsafe fn debug_utils_set_object_name( + &self, + device: vk::Device, + name_info: &vk::DebugUtilsObjectNameInfoEXT, + ) -> VkResult<()> { + let err_code = self + .debug_utils_fn + .set_debug_utils_object_name_ext(device, name_info); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSetDebugUtilsObjectTagEXT.html>"] + pub unsafe fn debug_utils_set_object_tag( + &self, + device: vk::Device, + tag_info: &vk::DebugUtilsObjectTagInfoEXT, + ) -> VkResult<()> { + let err_code = self + .debug_utils_fn + .set_debug_utils_object_tag_ext(device, tag_info); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBeginDebugUtilsLabelEXT.html>"] + pub unsafe fn cmd_begin_debug_utils_label( + &self, + command_buffer: vk::CommandBuffer, + label: &vk::DebugUtilsLabelEXT, + ) { + self.debug_utils_fn + .cmd_begin_debug_utils_label_ext(command_buffer, label); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdEndDebugUtilsLabelEXT.html>"] + pub unsafe fn cmd_end_debug_utils_label(&self, command_buffer: vk::CommandBuffer) { + self.debug_utils_fn + .cmd_end_debug_utils_label_ext(command_buffer); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdInsertDebugUtilsLabelEXT.html>"] + pub unsafe fn cmd_insert_debug_utils_label( + &self, + command_buffer: vk::CommandBuffer, + label: &vk::DebugUtilsLabelEXT, + ) { + self.debug_utils_fn + .cmd_insert_debug_utils_label_ext(command_buffer, label); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueBeginDebugUtilsLabelEXT.html>"] + pub unsafe fn queue_begin_debug_utils_label( + &self, + queue: vk::Queue, + label: &vk::DebugUtilsLabelEXT, + ) { + self.debug_utils_fn + .queue_begin_debug_utils_label_ext(queue, label); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueEndDebugUtilsLabelEXT.html>"] + pub unsafe fn queue_end_debug_utils_label(&self, queue: vk::Queue) { + self.debug_utils_fn.queue_end_debug_utils_label_ext(queue); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueueInsertDebugUtilsLabelEXT.html>"] + pub unsafe fn queue_insert_debug_utils_label( + &self, + queue: vk::Queue, + label: &vk::DebugUtilsLabelEXT, + ) { + self.debug_utils_fn + .queue_insert_debug_utils_label_ext(queue, label); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDebugUtilsMessengerEXT.html>"] + pub unsafe fn create_debug_utils_messenger( + &self, + create_info: &vk::DebugUtilsMessengerCreateInfoEXT, + allocator: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DebugUtilsMessengerEXT> { + let mut messenger = mem::zeroed(); + let err_code = self.debug_utils_fn.create_debug_utils_messenger_ext( + self.handle, + create_info, + allocator.as_raw_ptr(), + &mut messenger, + ); + match err_code { + vk::Result::SUCCESS => Ok(messenger), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyDebugUtilsMessengerEXT.html>"] + pub unsafe fn destroy_debug_utils_messenger( + &self, + messenger: vk::DebugUtilsMessengerEXT, + allocator: Option<&vk::AllocationCallbacks>, + ) { + self.debug_utils_fn.destroy_debug_utils_messenger_ext( + self.handle, + messenger, + allocator.as_raw_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSubmitDebugUtilsMessageEXT.html>"] + pub unsafe fn submit_debug_utils_message( + &self, + instance: vk::Instance, + message_severity: vk::DebugUtilsMessageSeverityFlagsEXT, + message_types: vk::DebugUtilsMessageTypeFlagsEXT, + callback_data: &vk::DebugUtilsMessengerCallbackDataEXT, + ) { + self.debug_utils_fn.submit_debug_utils_message_ext( + instance, + message_severity, + message_types, + callback_data, + ); + } + + pub fn fp(&self) -> &vk::ExtDebugUtilsFn { + &self.debug_utils_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} 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..e3ff5542e7 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/metal_surface.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MetalSurface { + handle: vk::Instance, + metal_surface_fn: vk::ExtMetalSurfaceFn, +} + +impl MetalSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> MetalSurface { + let surface_fn = vk::ExtMetalSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + MetalSurface { + handle: instance.handle(), + metal_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::ExtMetalSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMetalSurfaceEXT.html>"] + pub unsafe fn create_metal_surface( + &self, + create_info: &vk::MetalSurfaceCreateInfoEXT, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.metal_surface_fn.create_metal_surface_ext( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::ExtMetalSurfaceFn { + &self.metal_surface_fn + } + + 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..1885933fa8 --- /dev/null +++ b/third_party/rust/ash/src/extensions/ext/mod.rs @@ -0,0 +1,9 @@ +pub use self::debug_marker::DebugMarker; +pub use self::debug_report::DebugReport; +pub use self::debug_utils::DebugUtils; +pub use self::metal_surface::MetalSurface; + +mod debug_marker; +mod debug_report; +mod debug_utils; +mod metal_surface; 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..0a22d47d5b --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/android_surface.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AndroidSurface { + handle: vk::Instance, + android_surface_fn: vk::KhrAndroidSurfaceFn, +} + +impl AndroidSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> AndroidSurface { + let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + AndroidSurface { + handle: instance.handle(), + android_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrAndroidSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"] + pub unsafe fn create_android_surface( + &self, + create_info: &vk::AndroidSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.android_surface_fn.create_android_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { + &self.android_surface_fn + } + + pub fn instance(&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..8ea5e62572 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display.rs @@ -0,0 +1,203 @@ +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Display { + handle: vk::Instance, + display_fn: vk::KhrDisplayFn, +} + +impl Display { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Display { + let display_fn = vk::KhrDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Display { + handle: instance.handle(), + display_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDisplayFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"] + pub unsafe fn get_physical_device_display_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { + let mut count = 0; + self.display_fn.get_physical_device_display_properties_khr( + physical_device, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_physical_device_display_properties_khr( + physical_device, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"] + pub unsafe fn get_physical_device_display_plane_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { + let mut count = 0; + self.display_fn + .get_physical_device_display_plane_properties_khr( + physical_device, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self + .display_fn + .get_physical_device_display_plane_properties_khr( + physical_device, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"] + pub unsafe fn get_display_plane_supported_displays( + &self, + physical_device: vk::PhysicalDevice, + plane_index: u32, + ) -> VkResult<Vec<vk::DisplayKHR>> { + let mut count = 0; + self.display_fn.get_display_plane_supported_displays_khr( + physical_device, + plane_index, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_display_plane_supported_displays_khr( + physical_device, + plane_index, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"] + pub unsafe fn get_display_mode_properties( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { + let mut count = 0; + self.display_fn.get_display_mode_properties_khr( + physical_device, + display, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_display_mode_properties_khr( + physical_device, + display, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayModeKHR.html>"] + 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(); + let err_code = self.display_fn.create_display_mode_khr( + physical_device, + display, + create_info, + allocation_callbacks.as_raw_ptr(), + display_mode.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(display_mode.assume_init()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"] + 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(); + let err_code = self.display_fn.get_display_plane_capabilities_khr( + physical_device, + mode, + plane_index, + display_plane_capabilities.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(display_plane_capabilities.assume_init()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"] + 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(); + let err_code = self.display_fn.create_display_plane_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + surface.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(surface.assume_init()), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrDisplayFn { + &self.display_fn + } + + 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..bb4cfe2891 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs @@ -0,0 +1,58 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DisplaySwapchain { + handle: vk::Device, + swapchain_fn: vk::KhrDisplaySwapchainFn, +} + +impl DisplaySwapchain { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DisplaySwapchain { + let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + DisplaySwapchain { + handle: device.handle(), + swapchain_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDisplaySwapchainFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"] + 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()); + let err_code = self.swapchain_fn.create_shared_swapchains_khr( + self.handle, + create_infos.len() as u32, + create_infos.as_ptr(), + allocation_callbacks.as_raw_ptr(), + swapchains.as_mut_ptr(), + ); + swapchains.set_len(create_infos.len()); + match err_code { + vk::Result::SUCCESS => Ok(swapchains), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { + &self.swapchain_fn + } + + 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..b91128237a --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DrawIndirectCount { + handle: vk::Device, + draw_indirect_count_fn: vk::KhrDrawIndirectCountFn, +} + +impl DrawIndirectCount { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DrawIndirectCount { + let draw_indirect_count_fn = vk::KhrDrawIndirectCountFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + + DrawIndirectCount { + handle: device.handle(), + draw_indirect_count_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDrawIndirectCountFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html>"] + 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.draw_indirect_count_fn + .cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndirectCountKHR.html>"] + 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.draw_indirect_count_fn + .cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } +} 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..070b33a190 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalMemoryFd { + handle: vk::Device, + external_memory_fd_fn: vk::KhrExternalMemoryFdFn, +} + +impl ExternalMemoryFd { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Self { + let external_memory_fd_fn = vk::KhrExternalMemoryFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + handle: device.handle(), + external_memory_fd_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrExternalMemoryFdFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"] + pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + let err_code = + self.external_memory_fd_fn + .get_memory_fd_khr(self.handle, create_info, &mut fd); + match err_code { + vk::Result::SUCCESS => Ok(fd), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>"] + pub unsafe fn get_memory_fd_properties_khr( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + fd: i32, + ) -> VkResult<vk::MemoryFdPropertiesKHR> { + let mut memory_fd_properties = mem::zeroed(); + let err_code = self.external_memory_fd_fn.get_memory_fd_properties_khr( + self.handle, + handle_type, + fd, + &mut memory_fd_properties, + ); + match err_code { + vk::Result::SUCCESS => Ok(memory_fd_properties), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { + &self.external_memory_fd_fn + } + + 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..6b5a788d35 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/mod.rs @@ -0,0 +1,29 @@ +pub use self::android_surface::AndroidSurface; +pub use self::display::Display; +pub use self::display_swapchain::DisplaySwapchain; +pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::external_memory_fd::ExternalMemoryFd; +pub use self::push_descriptor::PushDescriptor; +pub use self::ray_tracing::RayTracing; +pub use self::surface::Surface; +pub use self::swapchain::Swapchain; +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 android_surface; +mod display; +mod display_swapchain; +mod draw_indirect_count; +mod external_memory_fd; +mod push_descriptor; +mod ray_tracing; +mod surface; +mod swapchain; +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/push_descriptor.rs b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs new file mode 100644 index 0000000000..152568e84f --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs @@ -0,0 +1,75 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::c_void; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PushDescriptor { + handle: vk::Instance, + push_descriptors_fn: vk::KhrPushDescriptorFn, +} + +impl PushDescriptor { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> PushDescriptor { + let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + + PushDescriptor { + handle: instance.handle(), + push_descriptors_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrPushDescriptorFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetKHR.html>"] + 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.push_descriptors_fn.cmd_push_descriptor_set_khr( + command_buffer, + pipeline_bind_point, + layout, + set, + descriptor_writes.len() as u32, + descriptor_writes.as_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetWithTemplateKHR.html>"] + 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.push_descriptors_fn + .cmd_push_descriptor_set_with_template_khr( + command_buffer, + descriptor_update_template, + layout, + set, + p_data, + ); + } + + pub fn fp(&self) -> &vk::KhrPushDescriptorFn { + &self.push_descriptors_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing.rs new file mode 100644 index 0000000000..76a3011281 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing.rs @@ -0,0 +1,369 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracing { + handle: vk::Device, + ray_tracing_fn: vk::KhrRayTracingFn, +} + +impl RayTracing { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> RayTracing { + let ray_tracing_fn = vk::KhrRayTracingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + RayTracing { + handle: device.handle(), + ray_tracing_fn, + } + } + + pub unsafe fn get_properties<I: InstanceV1_1>( + instance: &I, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceRayTracingPropertiesKHR { + let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureKHR.html>"] + 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(); + let err_code = self.ray_tracing_fn.create_acceleration_structure_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ); + match err_code { + vk::Result::SUCCESS => Ok(accel_struct), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.ray_tracing_fn.destroy_acceleration_structure_khr( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsKHR.html>"] + pub unsafe fn get_acceleration_structure_memory_requirements( + &self, + info: &vk::AccelerationStructureMemoryRequirementsInfoKHR, + ) -> vk::MemoryRequirements2KHR { + let mut requirements = Default::default(); + self.ray_tracing_fn + .get_acceleration_structure_memory_requirements_khr( + self.handle, + info, + &mut requirements, + ); + requirements + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindAccelerationStructureMemoryKHR.html>"] + pub unsafe fn bind_acceleration_structure_memory( + &self, + bind_info: &[vk::BindAccelerationStructureMemoryInfoKHR], + ) -> VkResult<()> { + let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_khr( + self.handle, + bind_info.len() as u32, + bind_info.as_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureKHR.html>"] + pub unsafe fn cmd_build_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + offset_infos: &[&[vk::AccelerationStructureBuildOffsetInfoKHR]], + ) { + let offset_info_ptr = offset_infos + .iter() + .map(|slice| slice.as_ptr()) + .collect::<Vec<*const vk::AccelerationStructureBuildOffsetInfoKHR>>(); + + self.ray_tracing_fn.cmd_build_acceleration_structure_khr( + command_buffer, + infos.len() as u32, + infos.as_ptr(), + offset_info_ptr.as_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_acceleration_structure_khr(command_buffer, info); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdTraceRaysKHR.html>"] + pub unsafe fn cmd_trace_rays( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_tables: &[vk::StridedBufferRegionKHR], + miss_shader_binding_tables: &[vk::StridedBufferRegionKHR], + hit_shader_binding_tables: &[vk::StridedBufferRegionKHR], + callable_shader_binding_tables: &[vk::StridedBufferRegionKHR], + width: u32, + height: u32, + depth: u32, + ) { + self.ray_tracing_fn.cmd_trace_rays_khr( + command_buffer, + raygen_shader_binding_tables.as_ptr(), + miss_shader_binding_tables.as_ptr(), + hit_shader_binding_tables.as_ptr(), + callable_shader_binding_tables.as_ptr(), + width, + height, + depth, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRayTracingPipelinesKHR.html>"] + pub unsafe fn create_ray_tracing_pipelines( + &self, + 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()]; + let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_khr( + self.handle, + pipeline_cache, + create_info.len() as u32, + create_info.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(pipelines), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html>"] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data: &mut [u8], + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .get_ray_tracing_shader_group_handles_khr( + self.handle, + pipeline, + first_group, + group_count, + data.len(), + data.as_mut_ptr() as *mut std::ffi::c_void, + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"] + pub unsafe fn get_acceleration_structure_device_address( + &self, + info: &vk::AccelerationStructureDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + self.ray_tracing_fn + .get_acceleration_structure_device_address_khr(self.handle, info) + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html>"] + 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.ray_tracing_fn + .cmd_write_acceleration_structures_properties_khr( + command_buffer, + structures.len() as u32, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + pub unsafe fn cmd_build_acceleration_structure_indirect( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::AccelerationStructureBuildGeometryInfoKHR, + indirect_buffer: vk::Buffer, + indirect_offset: vk::DeviceSize, + indirect_stride: u32, + ) { + self.ray_tracing_fn + .cmd_build_acceleration_structure_indirect_khr( + command_buffer, + info, + indirect_buffer, + indirect_offset, + indirect_stride, + ); + } + + pub unsafe fn copy_acceleration_structure_to_memory( + &self, + device: vk::Device, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .copy_acceleration_structure_to_memory_khr(device, info); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub unsafe fn copy_memory_to_acceleration_structure( + &self, + device: vk::Device, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .copy_memory_to_acceleration_structure_khr(device, info); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub unsafe fn cmd_copy_acceleration_structure_to_memory( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info); + } + + pub unsafe fn cmd_copy_memory_to_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info); + } + + pub unsafe fn get_ray_tracing_capture_replay_shader_group_handles( + &self, + device: vk::Device, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data: Vec<u8> = Vec::with_capacity(data_size); + + let err_code = self + .ray_tracing_fn + .get_ray_tracing_capture_replay_shader_group_handles_khr( + device, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr() as *mut _, + ); + + match err_code { + vk::Result::SUCCESS => Ok(data), + _ => Err(err_code), + } + } + + pub unsafe fn cmd_trace_rays_indirect( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_table: &[vk::StridedBufferRegionKHR], + miss_shader_binding_table: &[vk::StridedBufferRegionKHR], + hit_shader_binding_table: &[vk::StridedBufferRegionKHR], + callable_shader_binding_table: &[vk::StridedBufferRegionKHR], + buffer: vk::Buffer, + offset: vk::DeviceSize, + ) { + self.ray_tracing_fn.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(), + buffer, + offset, + ); + } + + pub unsafe fn get_device_acceleration_structure_compatibility( + &self, + device: vk::Device, + version: &vk::AccelerationStructureVersionKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .get_device_acceleration_structure_compatibility_khr(device, version); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub fn name() -> &'static CStr { + vk::KhrRayTracingFn::name() + } + + pub fn fp(&self) -> &vk::KhrRayTracingFn { + &self.ray_tracing_fn + } + + 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..7cde5aa9f9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/surface.rs @@ -0,0 +1,149 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Surface { + handle: vk::Instance, + surface_fn: vk::KhrSurfaceFn, +} + +impl Surface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Surface { + let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Surface { + handle: instance.handle(), + surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"] + pub unsafe fn get_physical_device_surface_support( + &self, + physical_device: vk::PhysicalDevice, + queue_index: u32, + surface: vk::SurfaceKHR, + ) -> VkResult<bool> { + let mut b = mem::zeroed(); + let err_code = self.surface_fn.get_physical_device_surface_support_khr( + physical_device, + queue_index, + surface, + &mut b, + ); + + match err_code { + vk::Result::SUCCESS => Ok(b > 0), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"] + pub unsafe fn get_physical_device_surface_present_modes( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::PresentModeKHR>> { + let mut count = 0; + self.surface_fn + .get_physical_device_surface_present_modes_khr( + physical_device, + surface, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self + .surface_fn + .get_physical_device_surface_present_modes_khr( + physical_device, + surface, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"] + 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(); + let err_code = self + .surface_fn + .get_physical_device_surface_capabilities_khr( + physical_device, + surface, + &mut surface_capabilities, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface_capabilities), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"] + pub unsafe fn get_physical_device_surface_formats( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::SurfaceFormatKHR>> { + let mut count = 0; + self.surface_fn.get_physical_device_surface_formats_khr( + physical_device, + surface, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.surface_fn.get_physical_device_surface_formats_khr( + physical_device, + surface, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySurfaceKHR.html>"] + pub unsafe fn destroy_surface( + &self, + surface: vk::SurfaceKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.surface_fn.destroy_surface_khr( + self.handle, + surface, + allocation_callbacks.as_raw_ptr(), + ); + } + + pub fn fp(&self) -> &vk::KhrSurfaceFn { + &self.surface_fn + } + + 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..266b9875e4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/swapchain.rs @@ -0,0 +1,137 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Swapchain { + handle: vk::Device, + swapchain_fn: vk::KhrSwapchainFn, +} + +impl Swapchain { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Swapchain { + let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Swapchain { + handle: device.handle(), + swapchain_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrSwapchainFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySwapchainKHR.html>"] + pub unsafe fn destroy_swapchain( + &self, + swapchain: vk::SwapchainKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.swapchain_fn.destroy_swapchain_khr( + self.handle, + swapchain, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireNextImageKHR.html>"] + pub unsafe fn acquire_next_image( + &self, + swapchain: vk::SwapchainKHR, + timeout: u64, + semaphore: vk::Semaphore, + fence: vk::Fence, + ) -> VkResult<(u32, bool)> { + let mut index = mem::zeroed(); + let err_code = self.swapchain_fn.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), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSwapchainKHR.html>"] + pub unsafe fn create_swapchain( + &self, + create_info: &vk::SwapchainCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SwapchainKHR> { + let mut swapchain = mem::zeroed(); + let err_code = self.swapchain_fn.create_swapchain_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut swapchain, + ); + match err_code { + vk::Result::SUCCESS => Ok(swapchain), + _ => Err(err_code), + } + } + + /// On success, returns whether the swapchain is suboptimal for the surface. + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueuePresentKHR.html>"] + pub unsafe fn queue_present( + &self, + queue: vk::Queue, + create_info: &vk::PresentInfoKHR, + ) -> VkResult<bool> { + let err_code = self.swapchain_fn.queue_present_khr(queue, create_info); + match err_code { + vk::Result::SUCCESS => Ok(false), + vk::Result::SUBOPTIMAL_KHR => Ok(true), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSwapchainImagesKHR.html>"] + pub unsafe fn get_swapchain_images( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<Vec<vk::Image>> { + let mut count = 0; + self.swapchain_fn.get_swapchain_images_khr( + self.handle, + swapchain, + &mut count, + ptr::null_mut(), + ); + + let mut v = Vec::with_capacity(count as usize); + let err_code = self.swapchain_fn.get_swapchain_images_khr( + self.handle, + swapchain, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrSwapchainFn { + &self.swapchain_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} 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..57ab92fe77 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs @@ -0,0 +1,87 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct TimelineSemaphore { + handle: vk::Instance, + timeline_semaphore_fn: vk::KhrTimelineSemaphoreFn, +} + +impl TimelineSemaphore { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> TimelineSemaphore { + let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + + TimelineSemaphore { + handle: instance.handle(), + timeline_semaphore_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrTimelineSemaphoreFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"] + pub unsafe fn get_semaphore_counter_value( + &self, + device: vk::Device, + semaphore: vk::Semaphore, + ) -> VkResult<u64> { + let mut value = 0; + let err_code = self + .timeline_semaphore_fn + .get_semaphore_counter_value_khr(device, semaphore, &mut value); + + match err_code { + vk::Result::SUCCESS => Ok(value), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"] + pub unsafe fn wait_semaphores( + &self, + device: vk::Device, + wait_info: &vk::SemaphoreWaitInfo, + timeout: u64, + ) -> VkResult<()> { + let err_code = self + .timeline_semaphore_fn + .wait_semaphores_khr(device, wait_info, timeout); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"] + pub unsafe fn signal_semaphore( + &self, + device: vk::Device, + signal_info: &vk::SemaphoreSignalInfo, + ) -> VkResult<()> { + let err_code = self + .timeline_semaphore_fn + .signal_semaphore_khr(device, signal_info); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { + &self.timeline_semaphore_fn + } + + pub fn instance(&self) -> vk::Instance { + 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..d705f38030 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct WaylandSurface { + handle: vk::Instance, + wayland_surface_fn: vk::KhrWaylandSurfaceFn, +} + +impl WaylandSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> WaylandSurface { + let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + WaylandSurface { + handle: instance.handle(), + wayland_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrWaylandSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"] + pub unsafe fn create_wayland_surface( + &self, + create_info: &vk::WaylandSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.wayland_surface_fn.create_wayland_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html"] + 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 + .wayland_surface_fn + .get_physical_device_wayland_presentation_support_khr( + physical_device, + queue_family_index, + wl_display, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { + &self.wayland_surface_fn + } + + 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..ae604436d0 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/win32_surface.rs @@ -0,0 +1,72 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Win32Surface { + handle: vk::Instance, + win32_surface_fn: vk::KhrWin32SurfaceFn, +} + +impl Win32Surface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Win32Surface { + let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Win32Surface { + handle: instance.handle(), + win32_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrWin32SurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"] + pub unsafe fn create_win32_surface( + &self, + create_info: &vk::Win32SurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.win32_surface_fn.create_win32_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html"] + pub unsafe fn get_physical_device_win32_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + ) -> bool { + let b = self + .win32_surface_fn + .get_physical_device_win32_presentation_support_khr( + physical_device, + queue_family_index, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { + &self.win32_surface_fn + } + + 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..4785a37e09 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs @@ -0,0 +1,76 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XcbSurface { + handle: vk::Instance, + xcb_surface_fn: vk::KhrXcbSurfaceFn, +} + +impl XcbSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XcbSurface { + let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + XcbSurface { + handle: instance.handle(), + xcb_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrXcbSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"] + pub unsafe fn create_xcb_surface( + &self, + create_info: &vk::XcbSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.xcb_surface_fn.create_xcb_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html"] + 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 + .xcb_surface_fn + .get_physical_device_xcb_presentation_support_khr( + physical_device, + queue_family_index, + connection, + visual_id, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { + &self.xcb_surface_fn + } + + 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..0569006edd --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs @@ -0,0 +1,76 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XlibSurface { + handle: vk::Instance, + xlib_surface_fn: vk::KhrXlibSurfaceFn, +} + +impl XlibSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XlibSurface { + let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + XlibSurface { + handle: instance.handle(), + xlib_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrXlibSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXlibSurfaceKHR.html>"] + pub unsafe fn create_xlib_surface( + &self, + create_info: &vk::XlibSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.xlib_surface_fn.create_xlib_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html"] + 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 + .xlib_surface_fn + .get_physical_device_xlib_presentation_support_khr( + physical_device, + queue_family_index, + display, + visual_id, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { + &self.xlib_surface_fn + } + + 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..4de4222d61 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mod.rs @@ -0,0 +1,5 @@ +pub mod experimental; +pub mod ext; +pub mod khr; +pub mod mvk; +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..76b339f0fe --- /dev/null +++ b/third_party/rust/ash/src/extensions/mvk/ios_surface.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct IOSSurface { + handle: vk::Instance, + ios_surface_fn: vk::MvkIosSurfaceFn, +} + +impl IOSSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> IOSSurface { + let surface_fn = vk::MvkIosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + IOSSurface { + handle: instance.handle(), + ios_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::MvkIosSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateIOSSurfaceMVK.html>"] + pub unsafe fn create_ios_surface_mvk( + &self, + create_info: &vk::IOSSurfaceCreateInfoMVK, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.ios_surface_fn.create_ios_surface_mvk( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::MvkIosSurfaceFn { + &self.ios_surface_fn + } + + 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..6f2aea6966 --- /dev/null +++ b/third_party/rust/ash/src/extensions/mvk/macos_surface.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MacOSSurface { + handle: vk::Instance, + macos_surface_fn: vk::MvkMacosSurfaceFn, +} + +impl MacOSSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> MacOSSurface { + let surface_fn = vk::MvkMacosSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + MacOSSurface { + handle: instance.handle(), + macos_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::MvkMacosSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateMacOSSurfaceMVK.html>"] + pub unsafe fn create_mac_os_surface_mvk( + &self, + create_info: &vk::MacOSSurfaceCreateInfoMVK, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.macos_surface_fn.create_mac_os_surface_mvk( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::MvkMacosSurfaceFn { + &self.macos_surface_fn + } + + 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/nv/mesh_shader.rs b/third_party/rust/ash/src/extensions/nv/mesh_shader.rs new file mode 100755 index 0000000000..61822b3989 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/mesh_shader.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct MeshShader { + mesh_shader_fn: vk::NvMeshShaderFn, +} + +impl MeshShader { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> MeshShader { + let mesh_shader_fn = vk::NvMeshShaderFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + MeshShader { mesh_shader_fn } + } + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksNV.html>"] + pub unsafe fn cmd_draw_mesh_tasks( + &self, + command_buffer: vk::CommandBuffer, + task_count: u32, + first_task: u32, + ) { + self.mesh_shader_fn + .cmd_draw_mesh_tasks_nv(command_buffer, task_count, first_task); + } + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectNV.html>"] + 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.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_nv( + command_buffer, + buffer, + offset, + draw_count, + stride, + ); + } + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdDrawMeshTasksIndirectCountNV.html>"] + 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.mesh_shader_fn.cmd_draw_mesh_tasks_indirect_count_nv( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + pub fn name() -> &'static CStr { + vk::NvMeshShaderFn::name() + } + + pub fn fp(&self) -> &vk::NvMeshShaderFn { + &self.mesh_shader_fn + } +} 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..ffc0c01970 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/mod.rs @@ -0,0 +1,5 @@ +pub use self::mesh_shader::MeshShader; +pub use self::ray_tracing::RayTracing; + +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..af55f6bed7 --- /dev/null +++ b/third_party/rust/ash/src/extensions/nv/ray_tracing.rs @@ -0,0 +1,282 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracing { + handle: vk::Device, + ray_tracing_fn: vk::NvRayTracingFn, +} + +impl RayTracing { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> RayTracing { + let ray_tracing_fn = vk::NvRayTracingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + RayTracing { + handle: device.handle(), + ray_tracing_fn, + } + } + + pub unsafe fn get_properties<I: InstanceV1_1>( + instance: &I, + 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 + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureNV.html>"] + 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(); + let err_code = self.ray_tracing_fn.create_acceleration_structure_nv( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ); + match err_code { + vk::Result::SUCCESS => Ok(accel_struct), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureNV.html>"] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureNV, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.ray_tracing_fn.destroy_acceleration_structure_nv( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsNV.html>"] + pub unsafe fn get_acceleration_structure_memory_requirements( + &self, + info: &vk::AccelerationStructureMemoryRequirementsInfoNV, + ) -> vk::MemoryRequirements2KHR { + let mut requirements = mem::zeroed(); + self.ray_tracing_fn + .get_acceleration_structure_memory_requirements_nv( + self.handle, + info, + &mut requirements, + ); + requirements + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindAccelerationStructureMemoryNV.html>"] + pub unsafe fn bind_acceleration_structure_memory( + &self, + bind_info: &[vk::BindAccelerationStructureMemoryInfoNV], + ) -> VkResult<()> { + let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_nv( + self.handle, + bind_info.len() as u32, + bind_info.as_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureNV.html>"] + 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.ray_tracing_fn.cmd_build_acceleration_structure_nv( + command_buffer, + info, + instance_data, + instance_offset, + if update { vk::TRUE } else { vk::FALSE }, + dst, + src, + scratch, + scratch_offset, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureNV.html>"] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + dst: vk::AccelerationStructureNV, + src: vk::AccelerationStructureNV, + mode: vk::CopyAccelerationStructureModeNV, + ) { + self.ray_tracing_fn + .cmd_copy_acceleration_structure_nv(command_buffer, dst, src, mode); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdTraceRaysNV.html>"] + 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.ray_tracing_fn.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, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRayTracingPipelinesNV.html>"] + 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()]; + let err_code = self.ray_tracing_fn.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(), + ); + match err_code { + vk::Result::SUCCESS => Ok(pipelines), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesNV.html>"] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data: &mut [u8], + ) -> VkResult<()> { + let err_code = self.ray_tracing_fn.get_ray_tracing_shader_group_handles_nv( + self.handle, + pipeline, + first_group, + group_count, + data.len(), + data.as_mut_ptr() as *mut std::ffi::c_void, + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleNV.html>"] + 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; + let err_code = self.ray_tracing_fn.get_acceleration_structure_handle_nv( + self.handle, + accel_struct, + std::mem::size_of::<u64>(), + handle_ptr as *mut std::ffi::c_void, + ); + match err_code { + vk::Result::SUCCESS => Ok(handle), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesNV.html>"] + 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.ray_tracing_fn + .cmd_write_acceleration_structures_properties_nv( + command_buffer, + structures.len() as u32, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCompileDeferredNV.html>"] + pub unsafe fn compile_deferred(&self, pipeline: vk::Pipeline, shader: u32) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .compile_deferred_nv(self.handle, pipeline, shader); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub fn name() -> &'static CStr { + vk::NvRayTracingFn::name() + } + + pub fn fp(&self) -> &vk::NvRayTracingFn { + &self.ray_tracing_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} |