• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::prelude::*;
2 use crate::vk;
3 use crate::RawPtr;
4 use crate::{EntryCustom, Instance};
5 use std::ffi::CStr;
6 use std::mem;
7 
8 #[derive(Clone)]
9 pub struct Win32Surface {
10     handle: vk::Instance,
11     win32_surface_fn: vk::KhrWin32SurfaceFn,
12 }
13 
14 impl Win32Surface {
new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self15     pub fn new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self {
16         let surface_fn = vk::KhrWin32SurfaceFn::load(|name| unsafe {
17             mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
18         });
19         Self {
20             handle: instance.handle(),
21             win32_surface_fn: surface_fn,
22         }
23     }
24 
name() -> &'static CStr25     pub fn name() -> &'static CStr {
26         vk::KhrWin32SurfaceFn::name()
27     }
28 
29     #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateWin32SurfaceKHR.html>"]
create_win32_surface( &self, create_info: &vk::Win32SurfaceCreateInfoKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult<vk::SurfaceKHR>30     pub unsafe fn create_win32_surface(
31         &self,
32         create_info: &vk::Win32SurfaceCreateInfoKHR,
33         allocation_callbacks: Option<&vk::AllocationCallbacks>,
34     ) -> VkResult<vk::SurfaceKHR> {
35         let mut surface = mem::zeroed();
36         self.win32_surface_fn
37             .create_win32_surface_khr(
38                 self.handle,
39                 create_info,
40                 allocation_callbacks.as_raw_ptr(),
41                 &mut surface,
42             )
43             .result_with_success(surface)
44     }
45 
46     #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkGetPhysicalDeviceWin32PresentationSupportKHR.html>"]
get_physical_device_win32_presentation_support( &self, physical_device: vk::PhysicalDevice, queue_family_index: u32, ) -> bool47     pub unsafe fn get_physical_device_win32_presentation_support(
48         &self,
49         physical_device: vk::PhysicalDevice,
50         queue_family_index: u32,
51     ) -> bool {
52         let b = self
53             .win32_surface_fn
54             .get_physical_device_win32_presentation_support_khr(
55                 physical_device,
56                 queue_family_index,
57             );
58 
59         b > 0
60     }
61 
fp(&self) -> &vk::KhrWin32SurfaceFn62     pub fn fp(&self) -> &vk::KhrWin32SurfaceFn {
63         &self.win32_surface_fn
64     }
65 
instance(&self) -> vk::Instance66     pub fn instance(&self) -> vk::Instance {
67         self.handle
68     }
69 }
70