diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/ash/src/extensions/khr | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/ash/src/extensions/khr')
38 files changed, 3403 insertions, 0 deletions
diff --git a/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs b/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs new file mode 100644 index 0000000000..9772e9baf4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/acceleration_structure.rs @@ -0,0 +1,322 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AccelerationStructure { + handle: vk::Device, + fp: vk::KhrAccelerationStructureFn, +} + +impl AccelerationStructure { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrAccelerationStructureFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceAccelerationStructurePropertiesKHR { + let mut props_rt = vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateAccelerationStructureKHR.html> + #[inline] + pub unsafe fn create_acceleration_structure( + &self, + create_info: &vk::AccelerationStructureCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::AccelerationStructureKHR> { + let mut accel_struct = mem::zeroed(); + (self.fp.create_acceleration_structure_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ) + .result_with_success(accel_struct) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_acceleration_structure_khr)( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBuildAccelerationStructuresKHR.html> + #[inline] + pub unsafe fn cmd_build_acceleration_structures( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], + ) { + assert_eq!(infos.len(), build_range_infos.len()); + + let build_range_infos = build_range_infos + .iter() + .zip(infos.iter()) + .map(|(range_info, info)| { + assert_eq!(range_info.len(), info.geometry_count as usize); + range_info.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.cmd_build_acceleration_structures_khr)( + command_buffer, + infos.len() as _, + infos.as_ptr(), + build_range_infos.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBuildAccelerationStructuresIndirectKHR.html> + #[inline] + pub unsafe fn cmd_build_acceleration_structures_indirect( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + indirect_device_addresses: &[vk::DeviceAddress], + indirect_strides: &[u32], + max_primitive_counts: &[&[u32]], + ) { + assert_eq!(infos.len(), indirect_device_addresses.len()); + assert_eq!(infos.len(), indirect_strides.len()); + assert_eq!(infos.len(), max_primitive_counts.len()); + + let max_primitive_counts = max_primitive_counts + .iter() + .zip(infos.iter()) + .map(|(cnt, info)| { + assert_eq!(cnt.len(), info.geometry_count as usize); + cnt.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.cmd_build_acceleration_structures_indirect_khr)( + command_buffer, + infos.len() as _, + infos.as_ptr(), + indirect_device_addresses.as_ptr(), + indirect_strides.as_ptr(), + max_primitive_counts.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkBuildAccelerationStructuresKHR.html> + #[inline] + pub unsafe fn build_acceleration_structures( + &self, + deferred_operation: vk::DeferredOperationKHR, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + build_range_infos: &[&[vk::AccelerationStructureBuildRangeInfoKHR]], + ) -> VkResult<()> { + assert_eq!(infos.len(), build_range_infos.len()); + + let build_range_infos = build_range_infos + .iter() + .zip(infos.iter()) + .map(|(range_info, info)| { + assert_eq!(range_info.len(), info.geometry_count as usize); + range_info.as_ptr() + }) + .collect::<Vec<_>>(); + + (self.fp.build_acceleration_structures_khr)( + self.handle, + deferred_operation, + infos.len() as _, + infos.as_ptr(), + build_range_infos.as_ptr(), + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn copy_acceleration_structure( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyAccelerationStructureInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_acceleration_structure_khr)(self.handle, deferred_operation, info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyAccelerationStructureToMemoryKHR.html> + #[inline] + pub unsafe fn copy_acceleration_structure_to_memory( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_acceleration_structure_to_memory_khr)(self.handle, deferred_operation, info) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCopyMemoryToAccelerationStructureKHR.html> + #[inline] + pub unsafe fn copy_memory_to_acceleration_structure( + &self, + deferred_operation: vk::DeferredOperationKHR, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) -> VkResult<()> { + (self.fp.copy_memory_to_acceleration_structure_khr)(self.handle, deferred_operation, info) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWriteAccelerationStructuresPropertiesKHR.html> + #[inline] + pub unsafe fn write_acceleration_structures_properties( + &self, + acceleration_structures: &[vk::AccelerationStructureKHR], + query_type: vk::QueryType, + data: &mut [u8], + stride: usize, + ) -> VkResult<()> { + (self.fp.write_acceleration_structures_properties_khr)( + self.handle, + acceleration_structures.len() as _, + acceleration_structures.as_ptr(), + query_type, + data.len(), + data.as_mut_ptr().cast(), + stride, + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html> + #[inline] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureInfoKHR, + ) { + (self.fp.cmd_copy_acceleration_structure_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyAccelerationStructureToMemoryKHR.html> + #[inline] + pub unsafe fn cmd_copy_acceleration_structure_to_memory( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) { + (self.fp.cmd_copy_acceleration_structure_to_memory_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyMemoryToAccelerationStructureKHR.html> + #[inline] + pub unsafe fn cmd_copy_memory_to_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) { + (self.fp.cmd_copy_memory_to_acceleration_structure_khr)(command_buffer, info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureHandleKHR.html> + #[inline] + pub unsafe fn get_acceleration_structure_device_address( + &self, + info: &vk::AccelerationStructureDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + (self.fp.get_acceleration_structure_device_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html> + #[inline] + pub unsafe fn cmd_write_acceleration_structures_properties( + &self, + command_buffer: vk::CommandBuffer, + structures: &[vk::AccelerationStructureKHR], + query_type: vk::QueryType, + query_pool: vk::QueryPool, + first_query: u32, + ) { + (self.fp.cmd_write_acceleration_structures_properties_khr)( + command_buffer, + structures.len() as _, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceAccelerationStructureCompatibilityKHR.html> + #[inline] + pub unsafe fn get_device_acceleration_structure_compatibility( + &self, + version: &vk::AccelerationStructureVersionInfoKHR, + ) -> vk::AccelerationStructureCompatibilityKHR { + let mut compatibility = vk::AccelerationStructureCompatibilityKHR::default(); + + (self.fp.get_device_acceleration_structure_compatibility_khr)( + self.handle, + version, + &mut compatibility, + ); + + compatibility + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetAccelerationStructureBuildSizesKHR.html> + #[inline] + pub unsafe fn get_acceleration_structure_build_sizes( + &self, + build_type: vk::AccelerationStructureBuildTypeKHR, + build_info: &vk::AccelerationStructureBuildGeometryInfoKHR, + max_primitive_counts: &[u32], + ) -> vk::AccelerationStructureBuildSizesInfoKHR { + assert_eq!(max_primitive_counts.len(), build_info.geometry_count as _); + + let mut size_info = vk::AccelerationStructureBuildSizesInfoKHR::default(); + + (self.fp.get_acceleration_structure_build_sizes_khr)( + self.handle, + build_type, + build_info, + max_primitive_counts.as_ptr(), + &mut size_info, + ); + + size_info + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrAccelerationStructureFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrAccelerationStructureFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/android_surface.rs b/third_party/rust/ash/src/extensions/khr/android_surface.rs new file mode 100755 index 0000000000..071d367510 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/android_surface.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AndroidSurface { + handle: vk::Instance, + fp: vk::KhrAndroidSurfaceFn, +} + +impl AndroidSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrAndroidSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateAndroidSurfaceKHR.html> + #[inline] + pub unsafe fn create_android_surface( + &self, + create_info: &vk::AndroidSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_android_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrAndroidSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs b/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs new file mode 100644 index 0000000000..65eae69681 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/buffer_device_address.rs @@ -0,0 +1,62 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct BufferDeviceAddress { + handle: vk::Device, + fp: vk::KhrBufferDeviceAddressFn, +} + +impl BufferDeviceAddress { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrBufferDeviceAddressFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferDeviceAddressKHR.html> + #[inline] + pub unsafe fn get_buffer_device_address( + &self, + info: &vk::BufferDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + (self.fp.get_buffer_device_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferOpaqueCaptureAddressKHR.html> + #[inline] + pub unsafe fn get_buffer_opaque_capture_address( + &self, + info: &vk::BufferDeviceAddressInfoKHR, + ) -> u64 { + (self.fp.get_buffer_opaque_capture_address_khr)(self.handle, info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceMemoryOpaqueCaptureAddressKHR.html> + #[inline] + pub unsafe fn get_device_memory_opaque_capture_address( + &self, + info: &vk::DeviceMemoryOpaqueCaptureAddressInfoKHR, + ) -> u64 { + (self.fp.get_device_memory_opaque_capture_address_khr)(self.handle, info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrBufferDeviceAddressFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrBufferDeviceAddressFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/copy_commands2.rs b/third_party/rust/ash/src/extensions/khr/copy_commands2.rs new file mode 100644 index 0000000000..b46593093a --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/copy_commands2.rs @@ -0,0 +1,84 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_copy_commands2.html> +#[derive(Clone)] +pub struct CopyCommands2 { + fp: vk::KhrCopyCommands2Fn, +} + +impl CopyCommands2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrCopyCommands2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBuffer2KHR.html> + #[inline] + pub unsafe fn cmd_copy_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_info: &vk::CopyBufferInfo2KHR, + ) { + (self.fp.cmd_copy_buffer2_khr)(command_buffer, copy_buffer_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImage2KHR.html> + #[inline] + pub unsafe fn cmd_copy_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_info: &vk::CopyImageInfo2KHR, + ) { + (self.fp.cmd_copy_image2_khr)(command_buffer, copy_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage2KHR.html> + #[inline] + pub unsafe fn cmd_copy_buffer_to_image2( + &self, + command_buffer: vk::CommandBuffer, + copy_buffer_to_image_info: &vk::CopyBufferToImageInfo2KHR, + ) { + (self.fp.cmd_copy_buffer_to_image2_khr)(command_buffer, copy_buffer_to_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdCopyImageToBuffer2KHR.html> + #[inline] + pub unsafe fn cmd_copy_image_to_buffer2( + &self, + command_buffer: vk::CommandBuffer, + copy_image_to_buffer_info: &vk::CopyImageToBufferInfo2KHR, + ) { + (self.fp.cmd_copy_image_to_buffer2_khr)(command_buffer, copy_image_to_buffer_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBlitImage2KHR.html> + #[inline] + pub unsafe fn cmd_blit_image2( + &self, + command_buffer: vk::CommandBuffer, + blit_image_info: &vk::BlitImageInfo2KHR, + ) { + (self.fp.cmd_blit_image2_khr)(command_buffer, blit_image_info) + } + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdResolveImage2KHR.html> + #[inline] + pub unsafe fn cmd_resolve_image2( + &self, + command_buffer: vk::CommandBuffer, + resolve_image_info: &vk::ResolveImageInfo2KHR, + ) { + (self.fp.cmd_resolve_image2_khr)(command_buffer, resolve_image_info) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrCopyCommands2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrCopyCommands2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs b/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs new file mode 100644 index 0000000000..bf78bc5f54 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/create_render_pass2.rs @@ -0,0 +1,90 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct CreateRenderPass2 { + handle: vk::Device, + fp: vk::KhrCreateRenderpass2Fn, +} + +impl CreateRenderPass2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrCreateRenderpass2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateRenderPass2.html> + #[inline] + pub unsafe fn create_render_pass2( + &self, + create_info: &vk::RenderPassCreateInfo2, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::RenderPass> { + let mut renderpass = mem::zeroed(); + (self.fp.create_render_pass2_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut renderpass, + ) + .result_with_success(renderpass) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBeginRenderPass2.html> + #[inline] + pub unsafe fn cmd_begin_render_pass2( + &self, + command_buffer: vk::CommandBuffer, + render_pass_begin_info: &vk::RenderPassBeginInfo, + subpass_begin_info: &vk::SubpassBeginInfo, + ) { + (self.fp.cmd_begin_render_pass2_khr)( + command_buffer, + render_pass_begin_info, + subpass_begin_info, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdNextSubpass2.html> + #[inline] + pub unsafe fn cmd_next_subpass2( + &self, + command_buffer: vk::CommandBuffer, + subpass_begin_info: &vk::SubpassBeginInfo, + subpass_end_info: &vk::SubpassEndInfo, + ) { + (self.fp.cmd_next_subpass2_khr)(command_buffer, subpass_begin_info, subpass_end_info); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdEndRenderPass2.html> + #[inline] + pub unsafe fn cmd_end_render_pass2( + &self, + command_buffer: vk::CommandBuffer, + subpass_end_info: &vk::SubpassEndInfo, + ) { + (self.fp.cmd_end_render_pass2_khr)(command_buffer, subpass_end_info); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrCreateRenderpass2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrCreateRenderpass2Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs b/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs new file mode 100644 index 0000000000..51aeaad8bb --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/deferred_host_operations.rs @@ -0,0 +1,93 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DeferredHostOperations { + handle: vk::Device, + fp: vk::KhrDeferredHostOperationsFn, +} + +impl DeferredHostOperations { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDeferredHostOperationsFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDeferredOperationKHR.html> + #[inline] + pub unsafe fn create_deferred_operation( + &self, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DeferredOperationKHR> { + let mut operation = mem::zeroed(); + (self.fp.create_deferred_operation_khr)( + self.handle, + allocation_callbacks.as_raw_ptr(), + &mut operation, + ) + .result_with_success(operation) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDeferredOperationJoinKHR.html> + #[inline] + pub unsafe fn deferred_operation_join( + &self, + operation: vk::DeferredOperationKHR, + ) -> VkResult<()> { + (self.fp.deferred_operation_join_khr)(self.handle, operation).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroyDeferredOperationKHR.html> + #[inline] + pub unsafe fn destroy_deferred_operation( + &self, + operation: vk::DeferredOperationKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_deferred_operation_khr)( + self.handle, + operation, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeferredOperationMaxConcurrencyKHR.html> + #[inline] + pub unsafe fn get_deferred_operation_max_concurrency( + &self, + operation: vk::DeferredOperationKHR, + ) -> u32 { + (self.fp.get_deferred_operation_max_concurrency_khr)(self.handle, operation) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeferredOperationResultKHR.html> + #[inline] + pub unsafe fn get_deferred_operation_result( + &self, + operation: vk::DeferredOperationKHR, + ) -> VkResult<()> { + (self.fp.get_deferred_operation_result_khr)(self.handle, operation).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeferredHostOperationsFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeferredHostOperationsFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/device_group.rs b/third_party/rust/ash/src/extensions/khr/device_group.rs new file mode 100644 index 0000000000..356db71e4d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/device_group.rs @@ -0,0 +1,169 @@ +#[cfg(doc)] +use super::Swapchain; +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group.html> +#[derive(Clone)] +pub struct DeviceGroup { + handle: vk::Device, + fp: vk::KhrDeviceGroupFn, +} + +impl DeviceGroup { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDeviceGroupFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPeerMemoryFeaturesKHR.html> + #[inline] + pub unsafe fn get_device_group_peer_memory_features( + &self, + heap_index: u32, + local_device_index: u32, + remote_device_index: u32, + ) -> vk::PeerMemoryFeatureFlags { + let mut peer_memory_features = mem::zeroed(); + (self.fp.get_device_group_peer_memory_features_khr)( + self.handle, + heap_index, + local_device_index, + remote_device_index, + &mut peer_memory_features, + ); + peer_memory_features + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetDeviceMaskKHR.html> + #[inline] + pub unsafe fn cmd_set_device_mask(&self, command_buffer: vk::CommandBuffer, device_mask: u32) { + (self.fp.cmd_set_device_mask_khr)(command_buffer, device_mask) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDispatchBaseKHR.html> + #[inline] + pub unsafe fn cmd_dispatch_base( + &self, + command_buffer: vk::CommandBuffer, + base_group: (u32, u32, u32), + group_count: (u32, u32, u32), + ) { + (self.fp.cmd_dispatch_base_khr)( + command_buffer, + base_group.0, + base_group.1, + base_group.2, + group_count.0, + group_count.1, + group_count.2, + ) + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_device_group_present_capabilities()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPresentCapabilitiesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_present_capabilities( + &self, + device_group_present_capabilities: &mut vk::DeviceGroupPresentCapabilitiesKHR, + ) -> VkResult<()> { + (self.fp.get_device_group_present_capabilities_khr)( + self.handle, + device_group_present_capabilities, + ) + .result() + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_device_group_surface_present_modes()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_surface_present_modes( + &self, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { + let mut modes = mem::zeroed(); + (self.fp.get_device_group_surface_present_modes_khr)(self.handle, surface, &mut modes) + .result_with_success(modes) + } + + /// Requires [`VK_KHR_surface`] to be enabled. + /// + /// Also available as [`Swapchain::get_physical_device_present_rectangles()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDevicePresentRectanglesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_physical_device_present_rectangles( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::Rect2D>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_present_rectangles_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// Requires [`VK_KHR_swapchain`] to be enabled. + /// + /// Also available as [`Swapchain::acquire_next_image2()`] since [Vulkan 1.1]. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImage2KHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_swapchain`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html + #[inline] + pub unsafe fn acquire_next_image2( + &self, + acquire_info: &vk::AcquireNextImageInfoKHR, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image2_khr)(self.handle, acquire_info, &mut index); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeviceGroupFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeviceGroupFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/device_group_creation.rs b/third_party/rust/ash/src/extensions/khr/device_group_creation.rs new file mode 100644 index 0000000000..9a21a714c9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/device_group_creation.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_device_group_creation.html> +#[derive(Clone)] +pub struct DeviceGroupCreation { + handle: vk::Instance, + fp: vk::KhrDeviceGroupCreationFn, +} + +impl DeviceGroupCreation { + pub fn new(entry: Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrDeviceGroupCreationFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// Retrieve the number of elements to pass to [`enumerate_physical_device_groups()`][Self::enumerate_physical_device_groups()] + #[inline] + pub unsafe fn enumerate_physical_device_groups_len(&self) -> VkResult<usize> { + let mut group_count = 0; + (self.fp.enumerate_physical_device_groups_khr)( + self.handle, + &mut group_count, + ptr::null_mut(), + ) + .result_with_success(group_count as usize) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkEnumeratePhysicalDeviceGroupsKHR.html> + /// + /// Call [`enumerate_physical_device_groups_len()`][Self::enumerate_physical_device_groups_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn enumerate_physical_device_groups( + &self, + out: &mut [vk::PhysicalDeviceGroupProperties], + ) -> VkResult<()> { + let mut count = out.len() as u32; + (self.fp.enumerate_physical_device_groups_khr)(self.handle, &mut count, out.as_mut_ptr()) + .result()?; + assert_eq!(count as usize, out.len()); + Ok(()) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDeviceGroupCreationFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDeviceGroupCreationFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display.rs b/third_party/rust/ash/src/extensions/khr/display.rs new file mode 100755 index 0000000000..b71c9c11e1 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display.rs @@ -0,0 +1,143 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Display { + handle: vk::Instance, + fp: vk::KhrDisplayFn, +} + +impl Display { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_display_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_display_properties_khr)(physical_device, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_display_plane_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_display_plane_properties_khr)(physical_device, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html> + #[inline] + pub unsafe fn get_display_plane_supported_displays( + &self, + physical_device: vk::PhysicalDevice, + plane_index: u32, + ) -> VkResult<Vec<vk::DisplayKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_display_plane_supported_displays_khr)( + physical_device, + plane_index, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayModePropertiesKHR.html> + #[inline] + pub unsafe fn get_display_mode_properties( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_display_mode_properties_khr)(physical_device, display, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDisplayModeKHR.html> + #[inline] + pub unsafe fn create_display_mode( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + create_info: &vk::DisplayModeCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DisplayModeKHR> { + let mut display_mode = mem::MaybeUninit::zeroed(); + (self.fp.create_display_mode_khr)( + physical_device, + display, + create_info, + allocation_callbacks.as_raw_ptr(), + display_mode.as_mut_ptr(), + ) + .assume_init_on_success(display_mode) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html> + #[inline] + pub unsafe fn get_display_plane_capabilities( + &self, + physical_device: vk::PhysicalDevice, + mode: vk::DisplayModeKHR, + plane_index: u32, + ) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> { + let mut display_plane_capabilities = mem::MaybeUninit::zeroed(); + (self.fp.get_display_plane_capabilities_khr)( + physical_device, + mode, + plane_index, + display_plane_capabilities.as_mut_ptr(), + ) + .assume_init_on_success(display_plane_capabilities) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html> + #[inline] + pub unsafe fn create_display_plane_surface( + &self, + create_info: &vk::DisplaySurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::MaybeUninit::zeroed(); + (self.fp.create_display_plane_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + surface.as_mut_ptr(), + ) + .assume_init_on_success(surface) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDisplayFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDisplayFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display_swapchain.rs b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs new file mode 100755 index 0000000000..e4a33b2bdb --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs @@ -0,0 +1,57 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DisplaySwapchain { + handle: vk::Device, + fp: vk::KhrDisplaySwapchainFn, +} + +impl DisplaySwapchain { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrDisplaySwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSharedSwapchainsKHR.html> + #[inline] + pub unsafe fn create_shared_swapchains( + &self, + create_infos: &[vk::SwapchainCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::SwapchainKHR>> { + let mut swapchains = Vec::with_capacity(create_infos.len()); + (self.fp.create_shared_swapchains_khr)( + self.handle, + create_infos.len() as u32, + create_infos.as_ptr(), + allocation_callbacks.as_raw_ptr(), + swapchains.as_mut_ptr(), + ) + .result()?; + swapchains.set_len(create_infos.len()); + Ok(swapchains) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDisplaySwapchainFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs new file mode 100644 index 0000000000..f35ecbe9e3 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs @@ -0,0 +1,74 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DrawIndirectCount { + fp: vk::KhrDrawIndirectCountFn, +} + +impl DrawIndirectCount { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrDrawIndirectCountFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html> + #[inline] + pub unsafe fn cmd_draw_indexed_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_indexed_indirect_count_khr)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdDrawIndirectCountKHR.html> + #[inline] + pub unsafe fn cmd_draw_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + (self.fp.cmd_draw_indirect_count_khr)( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDrawIndirectCountFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDrawIndirectCountFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs b/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs new file mode 100644 index 0000000000..ea6149a816 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/dynamic_rendering.rs @@ -0,0 +1,44 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DynamicRendering { + fp: vk::KhrDynamicRenderingFn, +} + +impl DynamicRendering { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrDynamicRenderingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdBeginRenderingKHR.html> + #[inline] + pub unsafe fn cmd_begin_rendering( + &self, + command_buffer: vk::CommandBuffer, + rendering_info: &vk::RenderingInfoKHR, + ) { + (self.fp.cmd_begin_rendering_khr)(command_buffer, rendering_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdEndRenderingKHR.html> + #[inline] + pub unsafe fn cmd_end_rendering(&self, command_buffer: vk::CommandBuffer) { + (self.fp.cmd_end_rendering_khr)(command_buffer) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrDynamicRenderingFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrDynamicRenderingFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs b/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs new file mode 100644 index 0000000000..6a3ec559d4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_fence_fd.rs @@ -0,0 +1,49 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalFenceFd { + handle: vk::Device, + fp: vk::KhrExternalFenceFdFn, +} + +impl ExternalFenceFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalFenceFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportFenceFdKHR.html> + #[inline] + pub unsafe fn import_fence_fd(&self, import_info: &vk::ImportFenceFdInfoKHR) -> VkResult<()> { + (self.fp.import_fence_fd_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceFdKHR.html> + #[inline] + pub unsafe fn get_fence_fd(&self, get_info: &vk::FenceGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_fence_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalFenceFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalFenceFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs b/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs new file mode 100644 index 0000000000..627bd1cca9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_fence_win32.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_fence_win32.html> +#[derive(Clone)] +pub struct ExternalFenceWin32 { + handle: vk::Device, + fp: vk::KhrExternalFenceWin32Fn, +} + +impl ExternalFenceWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalFenceWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportFenceWin32HandleKHR.html> + #[inline] + pub unsafe fn import_fence_win32_handle( + &self, + import_info: &vk::ImportFenceWin32HandleInfoKHR, + ) -> VkResult<()> { + (self.fp.import_fence_win32_handle_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetFenceWin32HandleKHR.html> + #[inline] + pub unsafe fn get_fence_win32_handle( + &self, + get_info: &vk::FenceGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_fence_win32_handle_khr)(self.handle, get_info, &mut handle) + .result_with_success(handle) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalFenceWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalFenceWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs new file mode 100644 index 0000000000..902349802f --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs @@ -0,0 +1,60 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalMemoryFd { + handle: vk::Device, + fp: vk::KhrExternalMemoryFdFn, +} + +impl ExternalMemoryFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalMemoryFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdKHR.html> + #[inline] + pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_memory_fd_khr)(self.handle, create_info, &mut fd).result_with_success(fd) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryFdPropertiesKHR.html> + #[inline] + pub unsafe fn get_memory_fd_properties( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + fd: i32, + ) -> VkResult<vk::MemoryFdPropertiesKHR> { + let mut memory_fd_properties = Default::default(); + (self.fp.get_memory_fd_properties_khr)( + self.handle, + handle_type, + fd, + &mut memory_fd_properties, + ) + .result_with_success(memory_fd_properties) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalMemoryFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs b/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs new file mode 100644 index 0000000000..8e43a26d48 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_win32.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_memory_win32.html> +#[derive(Clone)] +pub struct ExternalMemoryWin32 { + handle: vk::Device, + fp: vk::KhrExternalMemoryWin32Fn, +} + +impl ExternalMemoryWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalMemoryWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryWin32HandleKHR.html> + #[inline] + pub unsafe fn get_memory_win32_handle( + &self, + create_info: &vk::MemoryGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_memory_win32_handle_khr)(self.handle, create_info, &mut handle) + .result_with_success(handle) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetMemoryWin32HandlePropertiesKHR.html> + #[inline] + pub unsafe fn get_memory_win32_handle_properties( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + handle: vk::HANDLE, + ) -> VkResult<vk::MemoryWin32HandlePropertiesKHR> { + let mut memory_win32_handle_properties = Default::default(); + (self.fp.get_memory_win32_handle_properties_khr)( + self.handle, + handle_type, + handle, + &mut memory_win32_handle_properties, + ) + .result_with_success(memory_win32_handle_properties) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalMemoryWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalMemoryWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs b/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs new file mode 100644 index 0000000000..eadebef40d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_semaphore_fd.rs @@ -0,0 +1,52 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalSemaphoreFd { + handle: vk::Device, + fp: vk::KhrExternalSemaphoreFdFn, +} + +impl ExternalSemaphoreFd { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalSemaphoreFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportSemaphoreFdKHR.html> + #[inline] + pub unsafe fn import_semaphore_fd( + &self, + import_info: &vk::ImportSemaphoreFdInfoKHR, + ) -> VkResult<()> { + (self.fp.import_semaphore_fd_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreFdKHR.html> + #[inline] + pub unsafe fn get_semaphore_fd(&self, get_info: &vk::SemaphoreGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + (self.fp.get_semaphore_fd_khr)(self.handle, get_info, &mut fd).result_with_success(fd) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalSemaphoreFdFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalSemaphoreFdFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs b/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs new file mode 100644 index 0000000000..102da8c1ee --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_semaphore_win32.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_external_semaphore_win32.html> +#[derive(Clone)] +pub struct ExternalSemaphoreWin32 { + handle: vk::Device, + fp: vk::KhrExternalSemaphoreWin32Fn, +} + +impl ExternalSemaphoreWin32 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrExternalSemaphoreWin32Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkImportSemaphoreWin32HandleKHR.html> + #[inline] + pub unsafe fn import_semaphore_win32_handle( + &self, + import_info: &vk::ImportSemaphoreWin32HandleInfoKHR, + ) -> VkResult<()> { + (self.fp.import_semaphore_win32_handle_khr)(self.handle, import_info).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreWin32HandleKHR.html> + #[inline] + pub unsafe fn get_semaphore_win32_handle( + &self, + get_info: &vk::SemaphoreGetWin32HandleInfoKHR, + ) -> VkResult<vk::HANDLE> { + let mut handle = ptr::null_mut(); + (self.fp.get_semaphore_win32_handle_khr)(self.handle, get_info, &mut handle) + .result_with_success(handle) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrExternalSemaphoreWin32Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrExternalSemaphoreWin32Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs b/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs new file mode 100644 index 0000000000..13e5a1bf61 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_memory_requirements2.rs @@ -0,0 +1,92 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct GetMemoryRequirements2 { + handle: vk::Device, + fp: vk::KhrGetMemoryRequirements2Fn, +} + +impl GetMemoryRequirements2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrGetMemoryRequirements2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetBufferMemoryRequirements2KHR.html> + #[inline] + pub unsafe fn get_buffer_memory_requirements2( + &self, + info: &vk::BufferMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + (self.fp.get_buffer_memory_requirements2_khr)(self.handle, info, memory_requirements); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageMemoryRequirements2KHR.html> + #[inline] + pub unsafe fn get_image_memory_requirements2( + &self, + info: &vk::ImageMemoryRequirementsInfo2KHR, + memory_requirements: &mut vk::MemoryRequirements2KHR, + ) { + (self.fp.get_image_memory_requirements2_khr)(self.handle, info, memory_requirements); + } + + /// Retrieve the number of elements to pass to [`get_image_sparse_memory_requirements2()`][Self::get_image_sparse_memory_requirements2()] + #[inline] + pub unsafe fn get_image_sparse_memory_requirements2_len( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + ) -> usize { + let mut count = 0; + (self.fp.get_image_sparse_memory_requirements2_khr)( + self.handle, + info, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetImageSparseMemoryRequirements2KHR.html> + /// + /// Call [`get_image_sparse_memory_requirements2_len()`][Self::get_image_sparse_memory_requirements2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_image_sparse_memory_requirements2( + &self, + info: &vk::ImageSparseMemoryRequirementsInfo2KHR, + out: &mut [vk::SparseImageMemoryRequirements2KHR], + ) { + let mut count = out.len() as u32; + (self.fp.get_image_sparse_memory_requirements2_khr)( + self.handle, + info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetMemoryRequirements2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetMemoryRequirements2Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs b/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs new file mode 100644 index 0000000000..9e610b4831 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_physical_device_properties2.rs @@ -0,0 +1,167 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct GetPhysicalDeviceProperties2 { + fp: vk::KhrGetPhysicalDeviceProperties2Fn, +} + +impl GetPhysicalDeviceProperties2 { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::KhrGetPhysicalDeviceProperties2Fn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFeatures2KHR.html> + #[inline] + pub unsafe fn get_physical_device_features2( + &self, + physical_device: vk::PhysicalDevice, + features: &mut vk::PhysicalDeviceFeatures2KHR, + ) { + (self.fp.get_physical_device_features2_khr)(physical_device, features); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceFormatProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + format: vk::Format, + format_properties: &mut vk::FormatProperties2KHR, + ) { + (self.fp.get_physical_device_format_properties2_khr)( + physical_device, + format, + format_properties, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceImageFormatProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_image_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + image_format_info: &vk::PhysicalDeviceImageFormatInfo2KHR, + image_format_properties: &mut vk::ImageFormatProperties2KHR, + ) -> VkResult<()> { + (self.fp.get_physical_device_image_format_properties2_khr)( + physical_device, + image_format_info, + image_format_properties, + ) + .result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceMemoryProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_memory_properties2( + &self, + physical_device: vk::PhysicalDevice, + memory_properties: &mut vk::PhysicalDeviceMemoryProperties2KHR, + ) { + (self.fp.get_physical_device_memory_properties2_khr)(physical_device, memory_properties); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceProperties2KHR.html> + #[inline] + pub unsafe fn get_physical_device_properties2( + &self, + physical_device: vk::PhysicalDevice, + properties: &mut vk::PhysicalDeviceProperties2KHR, + ) { + (self.fp.get_physical_device_properties2_khr)(physical_device, properties); + } + + /// Retrieve the number of elements to pass to [`get_physical_device_queue_family_properties2()`][Self::get_physical_device_queue_family_properties2()] + #[inline] + pub unsafe fn get_physical_device_queue_family_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + ) -> usize { + let mut count = 0; + (self.fp.get_physical_device_queue_family_properties2_khr)( + physical_device, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceQueueFamilyProperties2KHR.html> + /// + /// Call [`get_physical_device_queue_family_properties2_len()`][Self::get_physical_device_queue_family_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_queue_family_properties2( + &self, + physical_device: vk::PhysicalDevice, + out: &mut [vk::QueueFamilyProperties2KHR], + ) { + let mut count = out.len() as u32; + (self.fp.get_physical_device_queue_family_properties2_khr)( + physical_device, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + /// Retrieve the number of elements to pass to [`get_physical_device_sparse_image_format_properties2()`][Self::get_physical_device_sparse_image_format_properties2()] + #[inline] + pub unsafe fn get_physical_device_sparse_image_format_properties2_len( + &self, + physical_device: vk::PhysicalDevice, + format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, + ) -> usize { + let mut count = 0; + (self + .fp + .get_physical_device_sparse_image_format_properties2_khr)( + physical_device, + format_info, + &mut count, + ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSparseImageFormatProperties2KHR.html> + /// + /// Call [`get_physical_device_sparse_image_format_properties2_len()`][Self::get_physical_device_sparse_image_format_properties2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_sparse_image_format_properties2( + &self, + physical_device: vk::PhysicalDevice, + format_info: &vk::PhysicalDeviceSparseImageFormatInfo2KHR, + out: &mut [vk::SparseImageFormatProperties2KHR], + ) { + let mut count = out.len() as u32; + (self + .fp + .get_physical_device_sparse_image_format_properties2_khr)( + physical_device, + format_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetPhysicalDeviceProperties2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetPhysicalDeviceProperties2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs b/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs new file mode 100644 index 0000000000..0208b7b4a5 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/get_surface_capabilities2.rs @@ -0,0 +1,84 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct GetSurfaceCapabilities2 { + fp: vk::KhrGetSurfaceCapabilities2Fn, +} + +impl GetSurfaceCapabilities2 { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let fp = vk::KhrGetSurfaceCapabilities2Fn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilities2KHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_capabilities2( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<vk::SurfaceCapabilities2KHR> { + let mut surface_capabilities = Default::default(); + (self.fp.get_physical_device_surface_capabilities2_khr)( + physical_device, + surface_info, + &mut surface_capabilities, + ) + .result_with_success(surface_capabilities) + } + + /// Retrieve the number of elements to pass to [`get_physical_device_surface_formats2()`][Self::get_physical_device_surface_formats2()] + #[inline] + pub unsafe fn get_physical_device_surface_formats2_len( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + ) -> VkResult<usize> { + let mut count = 0; + let err_code = (self.fp.get_physical_device_surface_formats2_khr)( + physical_device, + surface_info, + &mut count, + std::ptr::null_mut(), + ); + err_code.result_with_success(count as usize) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormats2KHR.html> + /// + /// Call [`get_physical_device_surface_formats2_len()`][Self::get_physical_device_surface_formats2_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_physical_device_surface_formats2( + &self, + physical_device: vk::PhysicalDevice, + surface_info: &vk::PhysicalDeviceSurfaceInfo2KHR, + out: &mut [vk::SurfaceFormat2KHR], + ) -> VkResult<()> { + let mut count = out.len() as u32; + let err_code = (self.fp.get_physical_device_surface_formats2_khr)( + physical_device, + surface_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + err_code.result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrGetSurfaceCapabilities2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrGetSurfaceCapabilities2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance1.rs b/third_party/rust/ash/src/extensions/khr/maintenance1.rs new file mode 100644 index 0000000000..1226d31cd5 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance1.rs @@ -0,0 +1,45 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance1 { + handle: vk::Device, + fp: vk::KhrMaintenance1Fn, +} + +impl Maintenance1 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance1Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkTrimCommandPoolKHR.html> + #[inline] + pub unsafe fn trim_command_pool( + &self, + command_pool: vk::CommandPool, + flags: vk::CommandPoolTrimFlagsKHR, + ) { + (self.fp.trim_command_pool_khr)(self.handle, command_pool, flags); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance1Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance1Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance3.rs b/third_party/rust/ash/src/extensions/khr/maintenance3.rs new file mode 100644 index 0000000000..3b22959332 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance3.rs @@ -0,0 +1,45 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance3 { + handle: vk::Device, + fp: vk::KhrMaintenance3Fn, +} + +impl Maintenance3 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance3Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDescriptorSetLayoutSupportKHR.html> + #[inline] + pub unsafe fn get_descriptor_set_layout_support( + &self, + create_info: &vk::DescriptorSetLayoutCreateInfo, + out: &mut vk::DescriptorSetLayoutSupportKHR, + ) { + (self.fp.get_descriptor_set_layout_support_khr)(self.handle, create_info, out); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance3Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance3Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/maintenance4.rs b/third_party/rust/ash/src/extensions/khr/maintenance4.rs new file mode 100644 index 0000000000..003e1a9cf2 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/maintenance4.rs @@ -0,0 +1,91 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Maintenance4 { + handle: vk::Device, + fp: vk::KhrMaintenance4Fn, +} + +impl Maintenance4 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrMaintenance4Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceBufferMemoryRequirementsKHR.html> + #[inline] + pub unsafe fn get_device_buffer_memory_requirements( + &self, + create_info: &vk::DeviceBufferMemoryRequirementsKHR, + out: &mut vk::MemoryRequirements2, + ) { + (self.fp.get_device_buffer_memory_requirements_khr)(self.handle, create_info, out) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageMemoryRequirementsKHR.html> + #[inline] + pub unsafe fn get_device_image_memory_requirements( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + out: &mut vk::MemoryRequirements2, + ) { + (self.fp.get_device_image_memory_requirements_khr)(self.handle, create_info, out) + } + + /// Retrieve the number of elements to pass to [`get_device_image_sparse_memory_requirements()`][Self::get_device_image_sparse_memory_requirements()] + #[inline] + pub unsafe fn get_device_image_sparse_memory_requirements_len( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + ) -> usize { + let mut count = 0; + (self.fp.get_device_image_sparse_memory_requirements_khr)( + self.handle, + create_info, + &mut count, + std::ptr::null_mut(), + ); + count as usize + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceImageSparseMemoryRequirementsKHR.html> + /// + /// Call [`get_device_image_sparse_memory_requirements_len()`][Self::get_device_image_sparse_memory_requirements_len()] to query the number of elements to pass to `out`. + /// Be sure to [`Default::default()`]-initialize these elements and optionally set their `p_next` pointer. + #[inline] + pub unsafe fn get_device_image_sparse_memory_requirements( + &self, + create_info: &vk::DeviceImageMemoryRequirementsKHR, + out: &mut [vk::SparseImageMemoryRequirements2], + ) { + let mut count = out.len() as u32; + (self.fp.get_device_image_sparse_memory_requirements_khr)( + self.handle, + create_info, + &mut count, + out.as_mut_ptr(), + ); + assert_eq!(count as usize, out.len()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrMaintenance4Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrMaintenance4Fn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/mod.rs b/third_party/rust/ash/src/extensions/khr/mod.rs new file mode 100644 index 0000000000..ea809b43da --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/mod.rs @@ -0,0 +1,75 @@ +pub use self::acceleration_structure::AccelerationStructure; +pub use self::android_surface::AndroidSurface; +pub use self::buffer_device_address::BufferDeviceAddress; +pub use self::copy_commands2::CopyCommands2; +pub use self::create_render_pass2::CreateRenderPass2; +pub use self::deferred_host_operations::DeferredHostOperations; +pub use self::device_group::DeviceGroup; +pub use self::device_group_creation::DeviceGroupCreation; +pub use self::display::Display; +pub use self::display_swapchain::DisplaySwapchain; +pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::dynamic_rendering::DynamicRendering; +pub use self::external_fence_fd::ExternalFenceFd; +pub use self::external_fence_win32::ExternalFenceWin32; +pub use self::external_memory_fd::ExternalMemoryFd; +pub use self::external_memory_win32::ExternalMemoryWin32; +pub use self::external_semaphore_fd::ExternalSemaphoreFd; +pub use self::external_semaphore_win32::ExternalSemaphoreWin32; +pub use self::get_memory_requirements2::GetMemoryRequirements2; +pub use self::get_physical_device_properties2::GetPhysicalDeviceProperties2; +pub use self::get_surface_capabilities2::GetSurfaceCapabilities2; +pub use self::maintenance1::Maintenance1; +pub use self::maintenance3::Maintenance3; +pub use self::maintenance4::Maintenance4; +pub use self::pipeline_executable_properties::PipelineExecutableProperties; +pub use self::present_wait::PresentWait; +pub use self::push_descriptor::PushDescriptor; +pub use self::ray_tracing_maintenance1::RayTracingMaintenance1; +pub use self::ray_tracing_pipeline::RayTracingPipeline; +pub use self::surface::Surface; +pub use self::swapchain::Swapchain; +pub use self::synchronization2::Synchronization2; +pub use self::timeline_semaphore::TimelineSemaphore; +pub use self::wayland_surface::WaylandSurface; +pub use self::win32_surface::Win32Surface; +pub use self::xcb_surface::XcbSurface; +pub use self::xlib_surface::XlibSurface; + +mod acceleration_structure; +mod android_surface; +mod buffer_device_address; +mod copy_commands2; +mod create_render_pass2; +mod deferred_host_operations; +mod device_group; +mod device_group_creation; +mod display; +mod display_swapchain; +mod draw_indirect_count; +mod dynamic_rendering; +mod external_fence_fd; +mod external_fence_win32; +mod external_memory_fd; +mod external_memory_win32; +mod external_semaphore_fd; +mod external_semaphore_win32; +mod get_memory_requirements2; +mod get_physical_device_properties2; +mod get_surface_capabilities2; +mod maintenance1; +mod maintenance3; +mod maintenance4; +mod pipeline_executable_properties; +mod present_wait; +mod push_descriptor; +mod ray_tracing_maintenance1; +mod ray_tracing_pipeline; +mod surface; +mod swapchain; +mod synchronization2; +mod timeline_semaphore; +mod wayland_surface; +mod win32_surface; +mod xcb_surface; +mod xlib_surface; diff --git a/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs b/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs new file mode 100644 index 0000000000..68e43b4a81 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/pipeline_executable_properties.rs @@ -0,0 +1,84 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PipelineExecutableProperties { + handle: vk::Device, + fp: vk::KhrPipelineExecutablePropertiesFn, +} + +impl PipelineExecutableProperties { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrPipelineExecutablePropertiesFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableInternalRepresentationsKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_internal_representations( + &self, + executable_info: &vk::PipelineExecutableInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutableInternalRepresentationKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_internal_representations_khr)( + self.handle, + executable_info, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutablePropertiesKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_properties( + &self, + pipeline_info: &vk::PipelineInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutablePropertiesKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_properties_khr)( + self.handle, + pipeline_info, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPipelineExecutableStatisticsKHR.html> + #[inline] + pub unsafe fn get_pipeline_executable_statistics( + &self, + executable_info: &vk::PipelineExecutableInfoKHR, + ) -> VkResult<Vec<vk::PipelineExecutableStatisticKHR>> { + read_into_defaulted_vector(|count, data| { + (self.fp.get_pipeline_executable_statistics_khr)( + self.handle, + executable_info, + count, + data, + ) + }) + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPipelineExecutablePropertiesFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPipelineExecutablePropertiesFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/present_wait.rs b/third_party/rust/ash/src/extensions/khr/present_wait.rs new file mode 100644 index 0000000000..4d8effe48d --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/present_wait.rs @@ -0,0 +1,47 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PresentWait { + handle: vk::Device, + fp: vk::KhrPresentWaitFn, +} + +impl PresentWait { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrPresentWaitFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWaitForPresentKHR.html> + #[inline] + pub unsafe fn wait_for_present( + &self, + swapchain: vk::SwapchainKHR, + present_id: u64, + timeout: u64, + ) -> VkResult<()> { + (self.fp.wait_for_present_khr)(self.handle, swapchain, present_id, timeout).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPresentWaitFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPresentWaitFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/push_descriptor.rs b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs new file mode 100644 index 0000000000..22d1572883 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs @@ -0,0 +1,68 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::c_void; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PushDescriptor { + fp: vk::KhrPushDescriptorFn, +} + +impl PushDescriptor { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrPushDescriptorFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetKHR.html> + #[inline] + pub unsafe fn cmd_push_descriptor_set( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + layout: vk::PipelineLayout, + set: u32, + descriptor_writes: &[vk::WriteDescriptorSet], + ) { + (self.fp.cmd_push_descriptor_set_khr)( + command_buffer, + pipeline_bind_point, + layout, + set, + descriptor_writes.len() as u32, + descriptor_writes.as_ptr(), + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPushDescriptorSetWithTemplateKHR.html> + #[inline] + pub unsafe fn cmd_push_descriptor_set_with_template( + &self, + command_buffer: vk::CommandBuffer, + descriptor_update_template: vk::DescriptorUpdateTemplate, + layout: vk::PipelineLayout, + set: u32, + p_data: *const c_void, + ) { + (self.fp.cmd_push_descriptor_set_with_template_khr)( + command_buffer, + descriptor_update_template, + layout, + set, + p_data, + ); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrPushDescriptorFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrPushDescriptorFn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs new file mode 100644 index 0000000000..a5159ad395 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing_maintenance1.rs @@ -0,0 +1,42 @@ +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +/// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_ray_tracing_maintenance1.html> +#[derive(Clone)] +pub struct RayTracingMaintenance1 { + fp: vk::KhrRayTracingMaintenance1Fn, +} + +impl RayTracingMaintenance1 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrRayTracingMaintenance1Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirect2KHR.html> + /// + /// `indirect_device_address` is a buffer device address which is a pointer to a [`vk::TraceRaysIndirectCommand2KHR`] structure containing the trace ray parameters. + #[inline] + pub unsafe fn cmd_trace_rays_indirect2( + &self, + command_buffer: vk::CommandBuffer, + indirect_device_address: vk::DeviceAddress, + ) { + (self.fp.cmd_trace_rays_indirect2_khr)(command_buffer, indirect_device_address); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrRayTracingMaintenance1Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrRayTracingMaintenance1Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs new file mode 100644 index 0000000000..af733430d1 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing_pipeline.rs @@ -0,0 +1,194 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracingPipeline { + handle: vk::Device, + fp: vk::KhrRayTracingPipelineFn, +} + +impl RayTracingPipeline { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrRayTracingPipelineFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + #[inline] + pub unsafe fn get_properties( + instance: &Instance, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceRayTracingPipelinePropertiesKHR { + let mut props_rt = vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysKHR.html> + #[inline] + pub unsafe fn cmd_trace_rays( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + miss_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + hit_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + callable_shader_binding_tables: &vk::StridedDeviceAddressRegionKHR, + width: u32, + height: u32, + depth: u32, + ) { + (self.fp.cmd_trace_rays_khr)( + command_buffer, + raygen_shader_binding_tables, + miss_shader_binding_tables, + hit_shader_binding_tables, + callable_shader_binding_tables, + width, + height, + depth, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateRayTracingPipelinesKHR.html> + #[inline] + pub unsafe fn create_ray_tracing_pipelines( + &self, + deferred_operation: vk::DeferredOperationKHR, + pipeline_cache: vk::PipelineCache, + create_info: &[vk::RayTracingPipelineCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::Pipeline>> { + let mut pipelines = vec![mem::zeroed(); create_info.len()]; + (self.fp.create_ray_tracing_pipelines_khr)( + self.handle, + deferred_operation, + pipeline_cache, + create_info.len() as u32, + create_info.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ) + .result_with_success(pipelines) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data = Vec::<u8>::with_capacity(data_size); + (self.fp.get_ray_tracing_shader_group_handles_khr)( + self.handle, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr().cast(), + ) + .result()?; + data.set_len(data_size); + Ok(data) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingCaptureReplayShaderGroupHandlesKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_capture_replay_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data = Vec::<u8>::with_capacity(data_size); + (self + .fp + .get_ray_tracing_capture_replay_shader_group_handles_khr)( + self.handle, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr().cast(), + ) + .result()?; + data.set_len(data_size); + Ok(data) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdTraceRaysIndirectKHR.html> + /// + /// `indirect_device_address` is a buffer device address which is a pointer to a [`vk::TraceRaysIndirectCommandKHR`] structure containing the trace ray parameters. + #[inline] + pub unsafe fn cmd_trace_rays_indirect( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + miss_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + hit_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + callable_shader_binding_table: &[vk::StridedDeviceAddressRegionKHR], + indirect_device_address: vk::DeviceAddress, + ) { + (self.fp.cmd_trace_rays_indirect_khr)( + command_buffer, + raygen_shader_binding_table.as_ptr(), + miss_shader_binding_table.as_ptr(), + hit_shader_binding_table.as_ptr(), + callable_shader_binding_table.as_ptr(), + indirect_device_address, + ); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetRayTracingShaderGroupStackSizeKHR.html> + #[inline] + pub unsafe fn get_ray_tracing_shader_group_stack_size( + &self, + pipeline: vk::Pipeline, + group: u32, + group_shader: vk::ShaderGroupShaderKHR, + ) -> vk::DeviceSize { + (self.fp.get_ray_tracing_shader_group_stack_size_khr)( + self.handle, + pipeline, + group, + group_shader, + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetRayTracingPipelineStackSizeKHR.html> + #[inline] + pub unsafe fn cmd_set_ray_tracing_pipeline_stack_size( + &self, + command_buffer: vk::CommandBuffer, + pipeline_stack_size: u32, + ) { + (self.fp.cmd_set_ray_tracing_pipeline_stack_size_khr)(command_buffer, pipeline_stack_size); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrRayTracingPipelineFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrRayTracingPipelineFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/surface.rs b/third_party/rust/ash/src/extensions/khr/surface.rs new file mode 100755 index 0000000000..11508bdcc9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/surface.rs @@ -0,0 +1,110 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Surface { + handle: vk::Instance, + fp: vk::KhrSurfaceFn, +} + +impl Surface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + surface: vk::SurfaceKHR, + ) -> VkResult<bool> { + let mut b = 0; + (self.fp.get_physical_device_surface_support_khr)( + physical_device, + queue_family_index, + surface, + &mut b, + ) + .result_with_success(b > 0) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_present_modes( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::PresentModeKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_surface_present_modes_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_capabilities( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::SurfaceCapabilitiesKHR> { + let mut surface_capabilities = mem::zeroed(); + (self.fp.get_physical_device_surface_capabilities_khr)( + physical_device, + surface, + &mut surface_capabilities, + ) + .result_with_success(surface_capabilities) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html> + #[inline] + pub unsafe fn get_physical_device_surface_formats( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::SurfaceFormatKHR>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_surface_formats_khr)(physical_device, surface, count, data) + }) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroySurfaceKHR.html> + #[inline] + pub unsafe fn destroy_surface( + &self, + surface: vk::SurfaceKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_surface_khr)(self.handle, surface, allocation_callbacks.as_raw_ptr()); + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/swapchain.rs b/third_party/rust/ash/src/extensions/khr/swapchain.rs new file mode 100755 index 0000000000..8f57729de7 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/swapchain.rs @@ -0,0 +1,211 @@ +#[cfg(doc)] +use super::DeviceGroup; +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Swapchain { + handle: vk::Device, + fp: vk::KhrSwapchainFn, +} + +impl Swapchain { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrSwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateSwapchainKHR.html> + #[inline] + pub unsafe fn create_swapchain( + &self, + create_info: &vk::SwapchainCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SwapchainKHR> { + let mut swapchain = mem::zeroed(); + (self.fp.create_swapchain_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut swapchain, + ) + .result_with_success(swapchain) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkDestroySwapchainKHR.html> + #[inline] + pub unsafe fn destroy_swapchain( + &self, + swapchain: vk::SwapchainKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + (self.fp.destroy_swapchain_khr)(self.handle, swapchain, allocation_callbacks.as_raw_ptr()); + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSwapchainImagesKHR.html> + #[inline] + pub unsafe fn get_swapchain_images( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<Vec<vk::Image>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_swapchain_images_khr)(self.handle, swapchain, count, data) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImageKHR.html> + #[inline] + pub unsafe fn acquire_next_image( + &self, + swapchain: vk::SwapchainKHR, + timeout: u64, + semaphore: vk::Semaphore, + fence: vk::Fence, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image_khr)( + self.handle, + swapchain, + timeout, + semaphore, + fence, + &mut index, + ); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + /// On success, returns whether the swapchain is suboptimal for the surface. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html> + #[inline] + pub unsafe fn queue_present( + &self, + queue: vk::Queue, + present_info: &vk::PresentInfoKHR, + ) -> VkResult<bool> { + let err_code = (self.fp.queue_present_khr)(queue, present_info); + match err_code { + vk::Result::SUCCESS => Ok(false), + vk::Result::SUBOPTIMAL_KHR => Ok(true), + _ => Err(err_code), + } + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_device_group_present_capabilities()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupPresentCapabilitiesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_present_capabilities( + &self, + device_group_present_capabilities: &mut vk::DeviceGroupPresentCapabilitiesKHR, + ) -> VkResult<()> { + (self.fp.get_device_group_present_capabilities_khr)( + self.handle, + device_group_present_capabilities, + ) + .result() + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_device_group_surface_present_modes()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetDeviceGroupSurfacePresentModesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_device_group_surface_present_modes( + &self, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::DeviceGroupPresentModeFlagsKHR> { + let mut modes = mem::zeroed(); + (self.fp.get_device_group_surface_present_modes_khr)(self.handle, surface, &mut modes) + .result_with_success(modes) + } + + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::get_physical_device_present_rectangles()`] + /// when [`VK_KHR_surface`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDevicePresentRectanglesKHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_surface`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html + #[inline] + pub unsafe fn get_physical_device_present_rectangles( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::Rect2D>> { + read_into_uninitialized_vector(|count, data| { + (self.fp.get_physical_device_present_rectangles_khr)( + physical_device, + surface, + count, + data, + ) + }) + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + /// + /// Only available since [Vulkan 1.1]. + /// + /// Also available as [`DeviceGroup::acquire_next_image2()`] + /// when [`VK_KHR_swapchain`] is enabled. + /// + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkAcquireNextImage2KHR.html> + /// + /// [Vulkan 1.1]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_VERSION_1_1.html + /// [`VK_KHR_swapchain`]: https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VK_KHR_swapchain.html + #[inline] + pub unsafe fn acquire_next_image2( + &self, + acquire_info: &vk::AcquireNextImageInfoKHR, + ) -> VkResult<(u32, bool)> { + let mut index = 0; + let err_code = (self.fp.acquire_next_image2_khr)(self.handle, acquire_info, &mut index); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSwapchainFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSwapchainFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/synchronization2.rs b/third_party/rust/ash/src/extensions/khr/synchronization2.rs new file mode 100644 index 0000000000..d8baefd602 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/synchronization2.rs @@ -0,0 +1,101 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Synchronization2 { + fp: vk::KhrSynchronization2Fn, +} + +impl Synchronization2 { + pub fn new(instance: &Instance, device: &Device) -> Self { + let fp = vk::KhrSynchronization2Fn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdPipelineBarrier2KHR.html> + #[inline] + pub unsafe fn cmd_pipeline_barrier2( + &self, + command_buffer: vk::CommandBuffer, + dependency_info: &vk::DependencyInfoKHR, + ) { + (self.fp.cmd_pipeline_barrier2_khr)(command_buffer, dependency_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdResetEvent2KHR.html> + #[inline] + pub unsafe fn cmd_reset_event2( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + stage_mask: vk::PipelineStageFlags2KHR, + ) { + (self.fp.cmd_reset_event2_khr)(command_buffer, event, stage_mask) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdSetEvent2KHR.html> + #[inline] + pub unsafe fn cmd_set_event2( + &self, + command_buffer: vk::CommandBuffer, + event: vk::Event, + dependency_info: &vk::DependencyInfoKHR, + ) { + (self.fp.cmd_set_event2_khr)(command_buffer, event, dependency_info) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWaitEvents2KHR.html> + #[inline] + pub unsafe fn cmd_wait_events2( + &self, + command_buffer: vk::CommandBuffer, + events: &[vk::Event], + dependency_infos: &[vk::DependencyInfoKHR], + ) { + assert_eq!(events.len(), dependency_infos.len()); + (self.fp.cmd_wait_events2_khr)( + command_buffer, + events.len() as u32, + events.as_ptr(), + dependency_infos.as_ptr(), + ) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCmdWriteTimestamp2KHR.html> + #[inline] + pub unsafe fn cmd_write_timestamp2( + &self, + command_buffer: vk::CommandBuffer, + stage: vk::PipelineStageFlags2KHR, + query_pool: vk::QueryPool, + query: u32, + ) { + (self.fp.cmd_write_timestamp2_khr)(command_buffer, stage, query_pool, query) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueueSubmit2KHR.html> + #[inline] + pub unsafe fn queue_submit2( + &self, + queue: vk::Queue, + submits: &[vk::SubmitInfo2KHR], + fence: vk::Fence, + ) -> VkResult<()> { + (self.fp.queue_submit2_khr)(queue, submits.len() as u32, submits.as_ptr(), fence).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrSynchronization2Fn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrSynchronization2Fn { + &self.fp + } +} diff --git a/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs new file mode 100644 index 0000000000..de9a492506 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs @@ -0,0 +1,60 @@ +use crate::prelude::*; +use crate::vk; +use crate::{Device, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct TimelineSemaphore { + handle: vk::Device, + fp: vk::KhrTimelineSemaphoreFn, +} + +impl TimelineSemaphore { + pub fn new(instance: &Instance, device: &Device) -> Self { + let handle = device.handle(); + let fp = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetSemaphoreCounterValue.html> + #[inline] + pub unsafe fn get_semaphore_counter_value(&self, semaphore: vk::Semaphore) -> VkResult<u64> { + let mut value = 0; + (self.fp.get_semaphore_counter_value_khr)(self.handle, semaphore, &mut value) + .result_with_success(value) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkWaitSemaphores.html> + #[inline] + pub unsafe fn wait_semaphores( + &self, + wait_info: &vk::SemaphoreWaitInfo, + timeout: u64, + ) -> VkResult<()> { + (self.fp.wait_semaphores_khr)(self.handle, wait_info, timeout).result() + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkSignalSemaphore.html> + #[inline] + pub unsafe fn signal_semaphore(&self, signal_info: &vk::SemaphoreSignalInfo) -> VkResult<()> { + (self.fp.signal_semaphore_khr)(self.handle, signal_info).result() + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrTimelineSemaphoreFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { + &self.fp + } + + #[inline] + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/wayland_surface.rs b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs new file mode 100755 index 0000000000..d51fcb9914 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs @@ -0,0 +1,71 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct WaylandSurface { + handle: vk::Instance, + fp: vk::KhrWaylandSurfaceFn, +} + +impl WaylandSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrWaylandSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateWaylandSurfaceKHR.html> + #[inline] + pub unsafe fn create_wayland_surface( + &self, + create_info: &vk::WaylandSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_wayland_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_wayland_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + wl_display: &mut vk::wl_display, + ) -> bool { + let b = (self.fp.get_physical_device_wayland_presentation_support_khr)( + physical_device, + queue_family_index, + wl_display, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrWaylandSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/win32_surface.rs b/third_party/rust/ash/src/extensions/khr/win32_surface.rs new file mode 100755 index 0000000000..be56a02e2e --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/win32_surface.rs @@ -0,0 +1,69 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Win32Surface { + handle: vk::Instance, + fp: vk::KhrWin32SurfaceFn, +} + +impl Win32Surface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrWin32SurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateWin32SurfaceKHR.html> + #[inline] + pub unsafe fn create_win32_surface( + &self, + create_info: &vk::Win32SurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_win32_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_win32_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + ) -> bool { + let b = (self.fp.get_physical_device_win32_presentation_support_khr)( + physical_device, + queue_family_index, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrWin32SurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xcb_surface.rs b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs new file mode 100755 index 0000000000..967376e7c6 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs @@ -0,0 +1,73 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XcbSurface { + handle: vk::Instance, + fp: vk::KhrXcbSurfaceFn, +} + +impl XcbSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrXcbSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateXcbSurfaceKHR.html> + #[inline] + pub unsafe fn create_xcb_surface( + &self, + create_info: &vk::XcbSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_xcb_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_xcb_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + connection: &mut vk::xcb_connection_t, + visual_id: vk::xcb_visualid_t, + ) -> bool { + let b = (self.fp.get_physical_device_xcb_presentation_support_khr)( + physical_device, + queue_family_index, + connection, + visual_id, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrXcbSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xlib_surface.rs b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs new file mode 100755 index 0000000000..59ad416e47 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs @@ -0,0 +1,73 @@ +use crate::prelude::*; +use crate::vk; +use crate::RawPtr; +use crate::{Entry, Instance}; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XlibSurface { + handle: vk::Instance, + fp: vk::KhrXlibSurfaceFn, +} + +impl XlibSurface { + pub fn new(entry: &Entry, instance: &Instance) -> Self { + let handle = instance.handle(); + let fp = vk::KhrXlibSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr())) + }); + Self { handle, fp } + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkCreateXlibSurfaceKHR.html> + #[inline] + pub unsafe fn create_xlib_surface( + &self, + create_info: &vk::XlibSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + (self.fp.create_xlib_surface_khr)( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ) + .result_with_success(surface) + } + + /// <https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html> + #[inline] + pub unsafe fn get_physical_device_xlib_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + display: &mut vk::Display, + visual_id: vk::VisualID, + ) -> bool { + let b = (self.fp.get_physical_device_xlib_presentation_support_khr)( + physical_device, + queue_family_index, + display, + visual_id, + ); + + b > 0 + } + + #[inline] + pub const fn name() -> &'static CStr { + vk::KhrXlibSurfaceFn::name() + } + + #[inline] + pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { + &self.fp + } + + #[inline] + pub fn instance(&self) -> vk::Instance { + self.handle + } +} |