ash/extensions/khr/
wayland_surface.rs1use crate::prelude::*;
2use crate::vk;
3use crate::RawPtr;
4use crate::{Entry, Instance};
5use std::ffi::CStr;
6use std::mem;
7
8#[derive(Clone)]
9pub struct WaylandSurface {
10 handle: vk::Instance,
11 fp: vk::KhrWaylandSurfaceFn,
12}
13
14impl WaylandSurface {
15 pub fn new(entry: &Entry, instance: &Instance) -> Self {
16 let handle = instance.handle();
17 let fp = vk::KhrWaylandSurfaceFn::load(|name| unsafe {
18 mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
19 });
20 Self { handle, fp }
21 }
22
23 #[inline]
25 pub unsafe fn create_wayland_surface(
26 &self,
27 create_info: &vk::WaylandSurfaceCreateInfoKHR,
28 allocation_callbacks: Option<&vk::AllocationCallbacks>,
29 ) -> VkResult<vk::SurfaceKHR> {
30 let mut surface = mem::zeroed();
31 (self.fp.create_wayland_surface_khr)(
32 self.handle,
33 create_info,
34 allocation_callbacks.as_raw_ptr(),
35 &mut surface,
36 )
37 .result_with_success(surface)
38 }
39
40 #[inline]
42 pub unsafe fn get_physical_device_wayland_presentation_support(
43 &self,
44 physical_device: vk::PhysicalDevice,
45 queue_family_index: u32,
46 wl_display: &mut vk::wl_display,
47 ) -> bool {
48 let b = (self.fp.get_physical_device_wayland_presentation_support_khr)(
49 physical_device,
50 queue_family_index,
51 wl_display,
52 );
53
54 b > 0
55 }
56
57 #[inline]
58 pub const fn name() -> &'static CStr {
59 vk::KhrWaylandSurfaceFn::name()
60 }
61
62 #[inline]
63 pub fn fp(&self) -> &vk::KhrWaylandSurfaceFn {
64 &self.fp
65 }
66
67 #[inline]
68 pub fn instance(&self) -> vk::Instance {
69 self.handle
70 }
71}