Skip to main content

jay_ash/extensions/khr/
win32_surface.rs

1//! <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_win32_surface.html>
2
3use crate::RawPtr;
4use crate::prelude::*;
5use crate::vk;
6use core::mem;
7
8impl crate::khr::win32_surface::Instance {
9    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateWin32SurfaceKHR.html>
10    #[inline]
11    pub unsafe fn create_win32_surface(
12        &self,
13        create_info: &vk::Win32SurfaceCreateInfoKHR<'_>,
14        allocation_callbacks: Option<&vk::AllocationCallbacks<'_>>,
15    ) -> VkResult<vk::SurfaceKHR> {
16        unsafe {
17            let mut surface = mem::MaybeUninit::uninit();
18            (self.fp.create_win32_surface_khr)(
19                self.handle,
20                create_info,
21                allocation_callbacks.as_raw_ptr(),
22                surface.as_mut_ptr(),
23            )
24            .assume_init_on_success(surface)
25        }
26    }
27
28    /// <https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html>
29    #[inline]
30    pub unsafe fn get_physical_device_win32_presentation_support(
31        &self,
32        physical_device: vk::PhysicalDevice,
33        queue_family_index: u32,
34    ) -> bool {
35        unsafe {
36            let b = (self.fp.get_physical_device_win32_presentation_support_khr)(
37                physical_device,
38                queue_family_index,
39            );
40
41            b > 0
42        }
43    }
44}