diff options
Diffstat (limited to 'third_party/rust/ash/src/extensions/khr')
15 files changed, 1601 insertions, 0 deletions
diff --git a/third_party/rust/ash/src/extensions/khr/android_surface.rs b/third_party/rust/ash/src/extensions/khr/android_surface.rs new file mode 100755 index 0000000000..0a22d47d5b --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/android_surface.rs @@ -0,0 +1,56 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct AndroidSurface { + handle: vk::Instance, + android_surface_fn: vk::KhrAndroidSurfaceFn, +} + +impl AndroidSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> AndroidSurface { + let surface_fn = vk::KhrAndroidSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + AndroidSurface { + handle: instance.handle(), + android_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrAndroidSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAndroidSurfaceKHR.html>"] + pub unsafe fn create_android_surface( + &self, + create_info: &vk::AndroidSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.android_surface_fn.create_android_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrAndroidSurfaceFn { + &self.android_surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display.rs b/third_party/rust/ash/src/extensions/khr/display.rs new file mode 100755 index 0000000000..8ea5e62572 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display.rs @@ -0,0 +1,203 @@ +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Display { + handle: vk::Instance, + display_fn: vk::KhrDisplayFn, +} + +impl Display { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Display { + let display_fn = vk::KhrDisplayFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Display { + handle: instance.handle(), + display_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDisplayFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>"] + pub unsafe fn get_physical_device_display_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPropertiesKHR>> { + let mut count = 0; + self.display_fn.get_physical_device_display_properties_khr( + physical_device, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_physical_device_display_properties_khr( + physical_device, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>"] + pub unsafe fn get_physical_device_display_plane_properties( + &self, + physical_device: vk::PhysicalDevice, + ) -> VkResult<Vec<vk::DisplayPlanePropertiesKHR>> { + let mut count = 0; + self.display_fn + .get_physical_device_display_plane_properties_khr( + physical_device, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self + .display_fn + .get_physical_device_display_plane_properties_khr( + physical_device, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>"] + pub unsafe fn get_display_plane_supported_displays( + &self, + physical_device: vk::PhysicalDevice, + plane_index: u32, + ) -> VkResult<Vec<vk::DisplayKHR>> { + let mut count = 0; + self.display_fn.get_display_plane_supported_displays_khr( + physical_device, + plane_index, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_display_plane_supported_displays_khr( + physical_device, + plane_index, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayModePropertiesKHR.html>"] + pub unsafe fn get_display_mode_properties( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + ) -> VkResult<Vec<vk::DisplayModePropertiesKHR>> { + let mut count = 0; + self.display_fn.get_display_mode_properties_khr( + physical_device, + display, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.display_fn.get_display_mode_properties_khr( + physical_device, + display, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayModeKHR.html>"] + pub unsafe fn create_display_mode( + &self, + physical_device: vk::PhysicalDevice, + display: vk::DisplayKHR, + create_info: &vk::DisplayModeCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::DisplayModeKHR> { + let mut display_mode = mem::MaybeUninit::zeroed(); + let err_code = self.display_fn.create_display_mode_khr( + physical_device, + display, + create_info, + allocation_callbacks.as_raw_ptr(), + display_mode.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(display_mode.assume_init()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>"] + pub unsafe fn get_display_plane_capabilities( + &self, + physical_device: vk::PhysicalDevice, + mode: vk::DisplayModeKHR, + plane_index: u32, + ) -> VkResult<vk::DisplayPlaneCapabilitiesKHR> { + let mut display_plane_capabilities = mem::MaybeUninit::zeroed(); + let err_code = self.display_fn.get_display_plane_capabilities_khr( + physical_device, + mode, + plane_index, + display_plane_capabilities.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(display_plane_capabilities.assume_init()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateDisplayPlaneSurfaceKHR.html>"] + pub unsafe fn create_display_plane_surface( + &self, + create_info: &vk::DisplaySurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::MaybeUninit::zeroed(); + let err_code = self.display_fn.create_display_plane_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + surface.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(surface.assume_init()), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrDisplayFn { + &self.display_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/display_swapchain.rs b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs new file mode 100755 index 0000000000..bb4cfe2891 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/display_swapchain.rs @@ -0,0 +1,58 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DisplaySwapchain { + handle: vk::Device, + swapchain_fn: vk::KhrDisplaySwapchainFn, +} + +impl DisplaySwapchain { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DisplaySwapchain { + let swapchain_fn = vk::KhrDisplaySwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + DisplaySwapchain { + handle: device.handle(), + swapchain_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDisplaySwapchainFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSharedSwapchainsKHR.html>"] + pub unsafe fn create_shared_swapchains( + &self, + create_infos: &[vk::SwapchainCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::SwapchainKHR>> { + let mut swapchains = Vec::with_capacity(create_infos.len()); + let err_code = self.swapchain_fn.create_shared_swapchains_khr( + self.handle, + create_infos.len() as u32, + create_infos.as_ptr(), + allocation_callbacks.as_raw_ptr(), + swapchains.as_mut_ptr(), + ); + swapchains.set_len(create_infos.len()); + match err_code { + vk::Result::SUCCESS => Ok(swapchains), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrDisplaySwapchainFn { + &self.swapchain_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs new file mode 100644 index 0000000000..b91128237a --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/draw_indirect_count.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct DrawIndirectCount { + handle: vk::Device, + draw_indirect_count_fn: vk::KhrDrawIndirectCountFn, +} + +impl DrawIndirectCount { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> DrawIndirectCount { + let draw_indirect_count_fn = vk::KhrDrawIndirectCountFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + + DrawIndirectCount { + handle: device.handle(), + draw_indirect_count_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrDrawIndirectCountFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndexedIndirectCountKHR.html>"] + pub unsafe fn cmd_draw_indexed_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + self.draw_indirect_count_fn + .cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdDrawIndirectCountKHR.html>"] + pub unsafe fn cmd_draw_indirect_count( + &self, + command_buffer: vk::CommandBuffer, + buffer: vk::Buffer, + offset: vk::DeviceSize, + count_buffer: vk::Buffer, + count_buffer_offset: vk::DeviceSize, + max_draw_count: u32, + stride: u32, + ) { + self.draw_indirect_count_fn + .cmd_draw_indexed_indirect_count_khr( + command_buffer, + buffer, + offset, + count_buffer, + count_buffer_offset, + max_draw_count, + stride, + ); + } +} diff --git a/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs new file mode 100644 index 0000000000..070b33a190 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/external_memory_fd.rs @@ -0,0 +1,66 @@ +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct ExternalMemoryFd { + handle: vk::Device, + external_memory_fd_fn: vk::KhrExternalMemoryFdFn, +} + +impl ExternalMemoryFd { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Self { + let external_memory_fd_fn = vk::KhrExternalMemoryFdFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Self { + handle: device.handle(), + external_memory_fd_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrExternalMemoryFdFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdKHR.html>"] + pub unsafe fn get_memory_fd(&self, create_info: &vk::MemoryGetFdInfoKHR) -> VkResult<i32> { + let mut fd = -1; + let err_code = + self.external_memory_fd_fn + .get_memory_fd_khr(self.handle, create_info, &mut fd); + match err_code { + vk::Result::SUCCESS => Ok(fd), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetMemoryFdPropertiesKHR.html>"] + pub unsafe fn get_memory_fd_properties_khr( + &self, + handle_type: vk::ExternalMemoryHandleTypeFlags, + fd: i32, + ) -> VkResult<vk::MemoryFdPropertiesKHR> { + let mut memory_fd_properties = mem::zeroed(); + let err_code = self.external_memory_fd_fn.get_memory_fd_properties_khr( + self.handle, + handle_type, + fd, + &mut memory_fd_properties, + ); + match err_code { + vk::Result::SUCCESS => Ok(memory_fd_properties), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrExternalMemoryFdFn { + &self.external_memory_fd_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/mod.rs b/third_party/rust/ash/src/extensions/khr/mod.rs new file mode 100644 index 0000000000..6b5a788d35 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/mod.rs @@ -0,0 +1,29 @@ +pub use self::android_surface::AndroidSurface; +pub use self::display::Display; +pub use self::display_swapchain::DisplaySwapchain; +pub use self::draw_indirect_count::DrawIndirectCount; +pub use self::external_memory_fd::ExternalMemoryFd; +pub use self::push_descriptor::PushDescriptor; +pub use self::ray_tracing::RayTracing; +pub use self::surface::Surface; +pub use self::swapchain::Swapchain; +pub use self::timeline_semaphore::TimelineSemaphore; +pub use self::wayland_surface::WaylandSurface; +pub use self::win32_surface::Win32Surface; +pub use self::xcb_surface::XcbSurface; +pub use self::xlib_surface::XlibSurface; + +mod android_surface; +mod display; +mod display_swapchain; +mod draw_indirect_count; +mod external_memory_fd; +mod push_descriptor; +mod ray_tracing; +mod surface; +mod swapchain; +mod timeline_semaphore; +mod wayland_surface; +mod win32_surface; +mod xcb_surface; +mod xlib_surface; diff --git a/third_party/rust/ash/src/extensions/khr/push_descriptor.rs b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs new file mode 100644 index 0000000000..152568e84f --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/push_descriptor.rs @@ -0,0 +1,75 @@ +#![allow(dead_code)] +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::c_void; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct PushDescriptor { + handle: vk::Instance, + push_descriptors_fn: vk::KhrPushDescriptorFn, +} + +impl PushDescriptor { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> PushDescriptor { + let push_descriptors_fn = vk::KhrPushDescriptorFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + + PushDescriptor { + handle: instance.handle(), + push_descriptors_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrPushDescriptorFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetKHR.html>"] + pub unsafe fn cmd_push_descriptor_set( + &self, + command_buffer: vk::CommandBuffer, + pipeline_bind_point: vk::PipelineBindPoint, + layout: vk::PipelineLayout, + set: u32, + descriptor_writes: &[vk::WriteDescriptorSet], + ) { + self.push_descriptors_fn.cmd_push_descriptor_set_khr( + command_buffer, + pipeline_bind_point, + layout, + set, + descriptor_writes.len() as u32, + descriptor_writes.as_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdPushDescriptorSetWithTemplateKHR.html>"] + pub unsafe fn cmd_push_descriptor_set_with_template( + &self, + command_buffer: vk::CommandBuffer, + descriptor_update_template: vk::DescriptorUpdateTemplate, + layout: vk::PipelineLayout, + set: u32, + p_data: *const c_void, + ) { + self.push_descriptors_fn + .cmd_push_descriptor_set_with_template_khr( + command_buffer, + descriptor_update_template, + layout, + set, + p_data, + ); + } + + pub fn fp(&self) -> &vk::KhrPushDescriptorFn { + &self.push_descriptors_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/ray_tracing.rs b/third_party/rust/ash/src/extensions/khr/ray_tracing.rs new file mode 100644 index 0000000000..76a3011281 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/ray_tracing.rs @@ -0,0 +1,369 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0, InstanceV1_1}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct RayTracing { + handle: vk::Device, + ray_tracing_fn: vk::KhrRayTracingFn, +} + +impl RayTracing { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> RayTracing { + let ray_tracing_fn = vk::KhrRayTracingFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + RayTracing { + handle: device.handle(), + ray_tracing_fn, + } + } + + pub unsafe fn get_properties<I: InstanceV1_1>( + instance: &I, + pdevice: vk::PhysicalDevice, + ) -> vk::PhysicalDeviceRayTracingPropertiesKHR { + let mut props_rt = vk::PhysicalDeviceRayTracingPropertiesKHR::default(); + { + let mut props = vk::PhysicalDeviceProperties2::builder().push_next(&mut props_rt); + instance.get_physical_device_properties2(pdevice, &mut props); + } + props_rt + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateAccelerationStructureKHR.html>"] + pub unsafe fn create_acceleration_structure( + &self, + create_info: &vk::AccelerationStructureCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::AccelerationStructureKHR> { + let mut accel_struct = mem::zeroed(); + let err_code = self.ray_tracing_fn.create_acceleration_structure_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut accel_struct, + ); + match err_code { + vk::Result::SUCCESS => Ok(accel_struct), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroyAccelerationStructureKHR.html>"] + pub unsafe fn destroy_acceleration_structure( + &self, + accel_struct: vk::AccelerationStructureKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.ray_tracing_fn.destroy_acceleration_structure_khr( + self.handle, + accel_struct, + allocation_callbacks.as_raw_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureMemoryRequirementsKHR.html>"] + pub unsafe fn get_acceleration_structure_memory_requirements( + &self, + info: &vk::AccelerationStructureMemoryRequirementsInfoKHR, + ) -> vk::MemoryRequirements2KHR { + let mut requirements = Default::default(); + self.ray_tracing_fn + .get_acceleration_structure_memory_requirements_khr( + self.handle, + info, + &mut requirements, + ); + requirements + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkBindAccelerationStructureMemoryKHR.html>"] + pub unsafe fn bind_acceleration_structure_memory( + &self, + bind_info: &[vk::BindAccelerationStructureMemoryInfoKHR], + ) -> VkResult<()> { + let err_code = self.ray_tracing_fn.bind_acceleration_structure_memory_khr( + self.handle, + bind_info.len() as u32, + bind_info.as_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdBuildAccelerationStructureKHR.html>"] + pub unsafe fn cmd_build_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + infos: &[vk::AccelerationStructureBuildGeometryInfoKHR], + offset_infos: &[&[vk::AccelerationStructureBuildOffsetInfoKHR]], + ) { + let offset_info_ptr = offset_infos + .iter() + .map(|slice| slice.as_ptr()) + .collect::<Vec<*const vk::AccelerationStructureBuildOffsetInfoKHR>>(); + + self.ray_tracing_fn.cmd_build_acceleration_structure_khr( + command_buffer, + infos.len() as u32, + infos.as_ptr(), + offset_info_ptr.as_ptr(), + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdCopyAccelerationStructureKHR.html>"] + pub unsafe fn cmd_copy_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_acceleration_structure_khr(command_buffer, info); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdTraceRaysKHR.html>"] + pub unsafe fn cmd_trace_rays( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_tables: &[vk::StridedBufferRegionKHR], + miss_shader_binding_tables: &[vk::StridedBufferRegionKHR], + hit_shader_binding_tables: &[vk::StridedBufferRegionKHR], + callable_shader_binding_tables: &[vk::StridedBufferRegionKHR], + width: u32, + height: u32, + depth: u32, + ) { + self.ray_tracing_fn.cmd_trace_rays_khr( + command_buffer, + raygen_shader_binding_tables.as_ptr(), + miss_shader_binding_tables.as_ptr(), + hit_shader_binding_tables.as_ptr(), + callable_shader_binding_tables.as_ptr(), + width, + height, + depth, + ); + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateRayTracingPipelinesKHR.html>"] + pub unsafe fn create_ray_tracing_pipelines( + &self, + pipeline_cache: vk::PipelineCache, + create_info: &[vk::RayTracingPipelineCreateInfoKHR], + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<Vec<vk::Pipeline>> { + let mut pipelines = vec![mem::zeroed(); create_info.len()]; + let err_code = self.ray_tracing_fn.create_ray_tracing_pipelines_khr( + self.handle, + pipeline_cache, + create_info.len() as u32, + create_info.as_ptr(), + allocation_callbacks.as_raw_ptr(), + pipelines.as_mut_ptr(), + ); + match err_code { + vk::Result::SUCCESS => Ok(pipelines), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetRayTracingShaderGroupHandlesKHR.html>"] + pub unsafe fn get_ray_tracing_shader_group_handles( + &self, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data: &mut [u8], + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .get_ray_tracing_shader_group_handles_khr( + self.handle, + pipeline, + first_group, + group_count, + data.len(), + data.as_mut_ptr() as *mut std::ffi::c_void, + ); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetAccelerationStructureHandleKHR.html>"] + pub unsafe fn get_acceleration_structure_device_address( + &self, + info: &vk::AccelerationStructureDeviceAddressInfoKHR, + ) -> vk::DeviceAddress { + self.ray_tracing_fn + .get_acceleration_structure_device_address_khr(self.handle, info) + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCmdWriteAccelerationStructuresPropertiesKHR.html>"] + pub unsafe fn cmd_write_acceleration_structures_properties( + &self, + command_buffer: vk::CommandBuffer, + structures: &[vk::AccelerationStructureKHR], + query_type: vk::QueryType, + query_pool: vk::QueryPool, + first_query: u32, + ) { + self.ray_tracing_fn + .cmd_write_acceleration_structures_properties_khr( + command_buffer, + structures.len() as u32, + structures.as_ptr(), + query_type, + query_pool, + first_query, + ); + } + + pub unsafe fn cmd_build_acceleration_structure_indirect( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::AccelerationStructureBuildGeometryInfoKHR, + indirect_buffer: vk::Buffer, + indirect_offset: vk::DeviceSize, + indirect_stride: u32, + ) { + self.ray_tracing_fn + .cmd_build_acceleration_structure_indirect_khr( + command_buffer, + info, + indirect_buffer, + indirect_offset, + indirect_stride, + ); + } + + pub unsafe fn copy_acceleration_structure_to_memory( + &self, + device: vk::Device, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .copy_acceleration_structure_to_memory_khr(device, info); + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub unsafe fn copy_memory_to_acceleration_structure( + &self, + device: vk::Device, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .copy_memory_to_acceleration_structure_khr(device, info); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub unsafe fn cmd_copy_acceleration_structure_to_memory( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyAccelerationStructureToMemoryInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_acceleration_structure_to_memory_khr(command_buffer, info); + } + + pub unsafe fn cmd_copy_memory_to_acceleration_structure( + &self, + command_buffer: vk::CommandBuffer, + info: &vk::CopyMemoryToAccelerationStructureInfoKHR, + ) { + self.ray_tracing_fn + .cmd_copy_memory_to_acceleration_structure_khr(command_buffer, info); + } + + pub unsafe fn get_ray_tracing_capture_replay_shader_group_handles( + &self, + device: vk::Device, + pipeline: vk::Pipeline, + first_group: u32, + group_count: u32, + data_size: usize, + ) -> VkResult<Vec<u8>> { + let mut data: Vec<u8> = Vec::with_capacity(data_size); + + let err_code = self + .ray_tracing_fn + .get_ray_tracing_capture_replay_shader_group_handles_khr( + device, + pipeline, + first_group, + group_count, + data_size, + data.as_mut_ptr() as *mut _, + ); + + match err_code { + vk::Result::SUCCESS => Ok(data), + _ => Err(err_code), + } + } + + pub unsafe fn cmd_trace_rays_indirect( + &self, + command_buffer: vk::CommandBuffer, + raygen_shader_binding_table: &[vk::StridedBufferRegionKHR], + miss_shader_binding_table: &[vk::StridedBufferRegionKHR], + hit_shader_binding_table: &[vk::StridedBufferRegionKHR], + callable_shader_binding_table: &[vk::StridedBufferRegionKHR], + buffer: vk::Buffer, + offset: vk::DeviceSize, + ) { + self.ray_tracing_fn.cmd_trace_rays_indirect_khr( + command_buffer, + raygen_shader_binding_table.as_ptr(), + miss_shader_binding_table.as_ptr(), + hit_shader_binding_table.as_ptr(), + callable_shader_binding_table.as_ptr(), + buffer, + offset, + ); + } + + pub unsafe fn get_device_acceleration_structure_compatibility( + &self, + device: vk::Device, + version: &vk::AccelerationStructureVersionKHR, + ) -> VkResult<()> { + let err_code = self + .ray_tracing_fn + .get_device_acceleration_structure_compatibility_khr(device, version); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub fn name() -> &'static CStr { + vk::KhrRayTracingFn::name() + } + + pub fn fp(&self) -> &vk::KhrRayTracingFn { + &self.ray_tracing_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/surface.rs b/third_party/rust/ash/src/extensions/khr/surface.rs new file mode 100755 index 0000000000..7cde5aa9f9 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/surface.rs @@ -0,0 +1,149 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Surface { + handle: vk::Instance, + surface_fn: vk::KhrSurfaceFn, +} + +impl Surface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Surface { + let surface_fn = vk::KhrSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Surface { + handle: instance.handle(), + surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html>"] + pub unsafe fn get_physical_device_surface_support( + &self, + physical_device: vk::PhysicalDevice, + queue_index: u32, + surface: vk::SurfaceKHR, + ) -> VkResult<bool> { + let mut b = mem::zeroed(); + let err_code = self.surface_fn.get_physical_device_surface_support_khr( + physical_device, + queue_index, + surface, + &mut b, + ); + + match err_code { + vk::Result::SUCCESS => Ok(b > 0), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html>"] + pub unsafe fn get_physical_device_surface_present_modes( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::PresentModeKHR>> { + let mut count = 0; + self.surface_fn + .get_physical_device_surface_present_modes_khr( + physical_device, + surface, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self + .surface_fn + .get_physical_device_surface_present_modes_khr( + physical_device, + surface, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html>"] + pub unsafe fn get_physical_device_surface_capabilities( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<vk::SurfaceCapabilitiesKHR> { + let mut surface_capabilities = mem::zeroed(); + let err_code = self + .surface_fn + .get_physical_device_surface_capabilities_khr( + physical_device, + surface, + &mut surface_capabilities, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface_capabilities), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html>"] + pub unsafe fn get_physical_device_surface_formats( + &self, + physical_device: vk::PhysicalDevice, + surface: vk::SurfaceKHR, + ) -> VkResult<Vec<vk::SurfaceFormatKHR>> { + let mut count = 0; + self.surface_fn.get_physical_device_surface_formats_khr( + physical_device, + surface, + &mut count, + ptr::null_mut(), + ); + let mut v = Vec::with_capacity(count as usize); + let err_code = self.surface_fn.get_physical_device_surface_formats_khr( + physical_device, + surface, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySurfaceKHR.html>"] + pub unsafe fn destroy_surface( + &self, + surface: vk::SurfaceKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.surface_fn.destroy_surface_khr( + self.handle, + surface, + allocation_callbacks.as_raw_ptr(), + ); + } + + pub fn fp(&self) -> &vk::KhrSurfaceFn { + &self.surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/swapchain.rs b/third_party/rust/ash/src/extensions/khr/swapchain.rs new file mode 100755 index 0000000000..266b9875e4 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/swapchain.rs @@ -0,0 +1,137 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{DeviceV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; +use std::ptr; + +#[derive(Clone)] +pub struct Swapchain { + handle: vk::Device, + swapchain_fn: vk::KhrSwapchainFn, +} + +impl Swapchain { + pub fn new<I: InstanceV1_0, D: DeviceV1_0>(instance: &I, device: &D) -> Swapchain { + let swapchain_fn = vk::KhrSwapchainFn::load(|name| unsafe { + mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) + }); + Swapchain { + handle: device.handle(), + swapchain_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrSwapchainFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkDestroySwapchainKHR.html>"] + pub unsafe fn destroy_swapchain( + &self, + swapchain: vk::SwapchainKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) { + self.swapchain_fn.destroy_swapchain_khr( + self.handle, + swapchain, + allocation_callbacks.as_raw_ptr(), + ); + } + + /// On success, returns the next image's index and whether the swapchain is suboptimal for the surface. + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkAcquireNextImageKHR.html>"] + pub unsafe fn acquire_next_image( + &self, + swapchain: vk::SwapchainKHR, + timeout: u64, + semaphore: vk::Semaphore, + fence: vk::Fence, + ) -> VkResult<(u32, bool)> { + let mut index = mem::zeroed(); + let err_code = self.swapchain_fn.acquire_next_image_khr( + self.handle, + swapchain, + timeout, + semaphore, + fence, + &mut index, + ); + match err_code { + vk::Result::SUCCESS => Ok((index, false)), + vk::Result::SUBOPTIMAL_KHR => Ok((index, true)), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateSwapchainKHR.html>"] + pub unsafe fn create_swapchain( + &self, + create_info: &vk::SwapchainCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SwapchainKHR> { + let mut swapchain = mem::zeroed(); + let err_code = self.swapchain_fn.create_swapchain_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut swapchain, + ); + match err_code { + vk::Result::SUCCESS => Ok(swapchain), + _ => Err(err_code), + } + } + + /// On success, returns whether the swapchain is suboptimal for the surface. + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkQueuePresentKHR.html>"] + pub unsafe fn queue_present( + &self, + queue: vk::Queue, + create_info: &vk::PresentInfoKHR, + ) -> VkResult<bool> { + let err_code = self.swapchain_fn.queue_present_khr(queue, create_info); + match err_code { + vk::Result::SUCCESS => Ok(false), + vk::Result::SUBOPTIMAL_KHR => Ok(true), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSwapchainImagesKHR.html>"] + pub unsafe fn get_swapchain_images( + &self, + swapchain: vk::SwapchainKHR, + ) -> VkResult<Vec<vk::Image>> { + let mut count = 0; + self.swapchain_fn.get_swapchain_images_khr( + self.handle, + swapchain, + &mut count, + ptr::null_mut(), + ); + + let mut v = Vec::with_capacity(count as usize); + let err_code = self.swapchain_fn.get_swapchain_images_khr( + self.handle, + swapchain, + &mut count, + v.as_mut_ptr(), + ); + v.set_len(count as usize); + match err_code { + vk::Result::SUCCESS => Ok(v), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrSwapchainFn { + &self.swapchain_fn + } + + pub fn device(&self) -> vk::Device { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs new file mode 100644 index 0000000000..57ab92fe77 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/timeline_semaphore.rs @@ -0,0 +1,87 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct TimelineSemaphore { + handle: vk::Instance, + timeline_semaphore_fn: vk::KhrTimelineSemaphoreFn, +} + +impl TimelineSemaphore { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> TimelineSemaphore { + let timeline_semaphore_fn = vk::KhrTimelineSemaphoreFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + + TimelineSemaphore { + handle: instance.handle(), + timeline_semaphore_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrTimelineSemaphoreFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetSemaphoreCounterValue.html>"] + pub unsafe fn get_semaphore_counter_value( + &self, + device: vk::Device, + semaphore: vk::Semaphore, + ) -> VkResult<u64> { + let mut value = 0; + let err_code = self + .timeline_semaphore_fn + .get_semaphore_counter_value_khr(device, semaphore, &mut value); + + match err_code { + vk::Result::SUCCESS => Ok(value), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkWaitSemaphores.html>"] + pub unsafe fn wait_semaphores( + &self, + device: vk::Device, + wait_info: &vk::SemaphoreWaitInfo, + timeout: u64, + ) -> VkResult<()> { + let err_code = self + .timeline_semaphore_fn + .wait_semaphores_khr(device, wait_info, timeout); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkSignalSemaphore.html>"] + pub unsafe fn signal_semaphore( + &self, + device: vk::Device, + signal_info: &vk::SemaphoreSignalInfo, + ) -> VkResult<()> { + let err_code = self + .timeline_semaphore_fn + .signal_semaphore_khr(device, signal_info); + + match err_code { + vk::Result::SUCCESS => Ok(()), + _ => Err(err_code), + } + } + + pub fn fp(&self) -> &vk::KhrTimelineSemaphoreFn { + &self.timeline_semaphore_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/wayland_surface.rs b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs new file mode 100755 index 0000000000..d705f38030 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/wayland_surface.rs @@ -0,0 +1,74 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct WaylandSurface { + handle: vk::Instance, + wayland_surface_fn: vk::KhrWaylandSurfaceFn, +} + +impl WaylandSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> WaylandSurface { + let surface_fn = vk::KhrWaylandSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + WaylandSurface { + handle: instance.handle(), + wayland_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrWaylandSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWaylandSurfaceKHR.html>"] + pub unsafe fn create_wayland_surface( + &self, + create_info: &vk::WaylandSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.wayland_surface_fn.create_wayland_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWaylandPresentationSupportKHR.html"] + pub unsafe fn get_physical_device_wayland_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + wl_display: &mut vk::wl_display, + ) -> bool { + let b = self + .wayland_surface_fn + .get_physical_device_wayland_presentation_support_khr( + physical_device, + queue_family_index, + wl_display, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn { + &self.wayland_surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/win32_surface.rs b/third_party/rust/ash/src/extensions/khr/win32_surface.rs new file mode 100755 index 0000000000..ae604436d0 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/win32_surface.rs @@ -0,0 +1,72 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct Win32Surface { + handle: vk::Instance, + win32_surface_fn: vk::KhrWin32SurfaceFn, +} + +impl Win32Surface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> Win32Surface { + let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + Win32Surface { + handle: instance.handle(), + win32_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrWin32SurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"] + pub unsafe fn create_win32_surface( + &self, + create_info: &vk::Win32SurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.win32_surface_fn.create_win32_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html"] + pub unsafe fn get_physical_device_win32_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + ) -> bool { + let b = self + .win32_surface_fn + .get_physical_device_win32_presentation_support_khr( + physical_device, + queue_family_index, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrWin32SurfaceFn { + &self.win32_surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xcb_surface.rs b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs new file mode 100755 index 0000000000..4785a37e09 --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xcb_surface.rs @@ -0,0 +1,76 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XcbSurface { + handle: vk::Instance, + xcb_surface_fn: vk::KhrXcbSurfaceFn, +} + +impl XcbSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XcbSurface { + let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + XcbSurface { + handle: instance.handle(), + xcb_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrXcbSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"] + pub unsafe fn create_xcb_surface( + &self, + create_info: &vk::XcbSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.xcb_surface_fn.create_xcb_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXcbPresentationSupportKHR.html"] + pub unsafe fn get_physical_device_xcb_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + connection: &mut vk::xcb_connection_t, + visual_id: vk::xcb_visualid_t, + ) -> bool { + let b = self + .xcb_surface_fn + .get_physical_device_xcb_presentation_support_khr( + physical_device, + queue_family_index, + connection, + visual_id, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrXcbSurfaceFn { + &self.xcb_surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} diff --git a/third_party/rust/ash/src/extensions/khr/xlib_surface.rs b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs new file mode 100755 index 0000000000..0569006edd --- /dev/null +++ b/third_party/rust/ash/src/extensions/khr/xlib_surface.rs @@ -0,0 +1,76 @@ +#![allow(dead_code)] +use crate::prelude::*; +use crate::version::{EntryV1_0, InstanceV1_0}; +use crate::vk; +use crate::RawPtr; +use std::ffi::CStr; +use std::mem; + +#[derive(Clone)] +pub struct XlibSurface { + handle: vk::Instance, + xlib_surface_fn: vk::KhrXlibSurfaceFn, +} + +impl XlibSurface { + pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> XlibSurface { + let surface_fn = vk::KhrXlibSurfaceFn::load(|name| unsafe { + mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) + }); + XlibSurface { + handle: instance.handle(), + xlib_surface_fn: surface_fn, + } + } + + pub fn name() -> &'static CStr { + vk::KhrXlibSurfaceFn::name() + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXlibSurfaceKHR.html>"] + pub unsafe fn create_xlib_surface( + &self, + create_info: &vk::XlibSurfaceCreateInfoKHR, + allocation_callbacks: Option<&vk::AllocationCallbacks>, + ) -> VkResult<vk::SurfaceKHR> { + let mut surface = mem::zeroed(); + let err_code = self.xlib_surface_fn.create_xlib_surface_khr( + self.handle, + create_info, + allocation_callbacks.as_raw_ptr(), + &mut surface, + ); + match err_code { + vk::Result::SUCCESS => Ok(surface), + _ => Err(err_code), + } + } + + #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceXlibPresentationSupportKHR.html"] + pub unsafe fn get_physical_device_xlib_presentation_support( + &self, + physical_device: vk::PhysicalDevice, + queue_family_index: u32, + display: &mut vk::Display, + visual_id: vk::VisualID, + ) -> bool { + let b = self + .xlib_surface_fn + .get_physical_device_xlib_presentation_support_khr( + physical_device, + queue_family_index, + display, + visual_id, + ); + + b > 0 + } + + pub fn fp(&self) -> &vk::KhrXlibSurfaceFn { + &self.xlib_surface_fn + } + + pub fn instance(&self) -> vk::Instance { + self.handle + } +} |