• 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 XcbSurface {
10     handle: vk::Instance,
11     xcb_surface_fn: vk::KhrXcbSurfaceFn,
12 }
13 
14 impl XcbSurface {
new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self15     pub fn new<L>(entry: &EntryCustom<L>, instance: &Instance) -> Self {
16         let surface_fn = vk::KhrXcbSurfaceFn::load(|name| unsafe {
17             mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
18         });
19         Self {
20             handle: instance.handle(),
21             xcb_surface_fn: surface_fn,
22         }
23     }
24 
name() -> &'static CStr25     pub fn name() -> &'static CStr {
26         vk::KhrXcbSurfaceFn::name()
27     }
28 
29     #[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateXcbSurfaceKHR.html>"]
create_xcb_surface( &self, create_info: &vk::XcbSurfaceCreateInfoKHR, allocation_callbacks: Option<&vk::AllocationCallbacks>, ) -> VkResult<vk::SurfaceKHR>30     pub unsafe fn create_xcb_surface(
31         &self,
32         create_info: &vk::XcbSurfaceCreateInfoKHR,
33         allocation_callbacks: Option<&vk::AllocationCallbacks>,
34     ) -> VkResult<vk::SurfaceKHR> {
35         let mut surface = mem::zeroed();
36         self.xcb_surface_fn
37             .create_xcb_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/vkGetPhysicalDeviceXcbPresentationSupportKHR.html>"]
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, ) -> bool47     pub unsafe fn get_physical_device_xcb_presentation_support(
48         &self,
49         physical_device: vk::PhysicalDevice,
50         queue_family_index: u32,
51         connection: &mut vk::xcb_connection_t,
52         visual_id: vk::xcb_visualid_t,
53     ) -> bool {
54         let b = self
55             .xcb_surface_fn
56             .get_physical_device_xcb_presentation_support_khr(
57                 physical_device,
58                 queue_family_index,
59                 connection,
60                 visual_id,
61             );
62 
63         b > 0
64     }
65 
fp(&self) -> &vk::KhrXcbSurfaceFn66     pub fn fp(&self) -> &vk::KhrXcbSurfaceFn {
67         &self.xcb_surface_fn
68     }
69 
instance(&self) -> vk::Instance70     pub fn instance(&self) -> vk::Instance {
71         self.handle
72     }
73 }
74