| 1 | //! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_surface.html> |
| 2 | |
| 3 | use crate::prelude::*; |
| 4 | use crate::vk; |
| 5 | use crate::RawPtr; |
| 6 | use alloc::vec::Vec; |
| 7 | use core::mem; |
| 8 | |
| 9 | impl crate::khr::surface::Instance { |
| 10 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceSupportKHR.html> |
| 11 | #[inline] |
| 12 | pub unsafe fn get_physical_device_surface_support( |
| 13 | &self, |
| 14 | physical_device: vk::PhysicalDevice, |
| 15 | queue_family_index: u32, |
| 16 | surface: vk::SurfaceKHR, |
| 17 | ) -> VkResult<bool> { |
| 18 | let mut b = mem::MaybeUninit::uninit(); |
| 19 | (self.fp.get_physical_device_surface_support_khr)( |
| 20 | physical_device, |
| 21 | queue_family_index, |
| 22 | surface, |
| 23 | b.as_mut_ptr(), |
| 24 | ) |
| 25 | .result()?; |
| 26 | Ok(b.assume_init() > 0) |
| 27 | } |
| 28 | |
| 29 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfacePresentModesKHR.html> |
| 30 | #[inline] |
| 31 | pub unsafe fn get_physical_device_surface_present_modes( |
| 32 | &self, |
| 33 | physical_device: vk::PhysicalDevice, |
| 34 | surface: vk::SurfaceKHR, |
| 35 | ) -> VkResult<Vec<vk::PresentModeKHR>> { |
| 36 | read_into_uninitialized_vector(|count, data| { |
| 37 | (self.fp.get_physical_device_surface_present_modes_khr)( |
| 38 | physical_device, |
| 39 | surface, |
| 40 | count, |
| 41 | data, |
| 42 | ) |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceCapabilitiesKHR.html> |
| 47 | #[inline] |
| 48 | pub unsafe fn get_physical_device_surface_capabilities( |
| 49 | &self, |
| 50 | physical_device: vk::PhysicalDevice, |
| 51 | surface: vk::SurfaceKHR, |
| 52 | ) -> VkResult<vk::SurfaceCapabilitiesKHR> { |
| 53 | let mut surface_capabilities = mem::MaybeUninit::uninit(); |
| 54 | (self.fp.get_physical_device_surface_capabilities_khr)( |
| 55 | physical_device, |
| 56 | surface, |
| 57 | surface_capabilities.as_mut_ptr(), |
| 58 | ) |
| 59 | .assume_init_on_success(surface_capabilities) |
| 60 | } |
| 61 | |
| 62 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceSurfaceFormatsKHR.html> |
| 63 | #[inline] |
| 64 | pub unsafe fn get_physical_device_surface_formats( |
| 65 | &self, |
| 66 | physical_device: vk::PhysicalDevice, |
| 67 | surface: vk::SurfaceKHR, |
| 68 | ) -> VkResult<Vec<vk::SurfaceFormatKHR>> { |
| 69 | read_into_uninitialized_vector(|count, data| { |
| 70 | (self.fp.get_physical_device_surface_formats_khr)(physical_device, surface, count, data) |
| 71 | }) |
| 72 | } |
| 73 | |
| 74 | /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkDestroySurfaceKHR.html> |
| 75 | #[inline] |
| 76 | pub unsafe fn destroy_surface( |
| 77 | &self, |
| 78 | surface: vk::SurfaceKHR, |
| 79 | allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>, |
| 80 | ) { |
| 81 | (self.fp.destroy_surface_khr)(self.handle, surface, allocation_callbacks.as_raw_ptr()); |
| 82 | } |
| 83 | } |