ash/extensions/ext/
metal_surface.rs
1use 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 MetalSurface {
10 handle: vk::Instance,
11 fp: vk::ExtMetalSurfaceFn,
12}
13
14impl MetalSurface {
15 pub fn new(entry: &Entry, instance: &Instance) -> Self {
16 let handle = instance.handle();
17 let fp = vk::ExtMetalSurfaceFn::load(|name| unsafe {
18 mem::transmute(entry.get_instance_proc_addr(handle, name.as_ptr()))
19 });
20 Self { handle, fp }
21 }
22
23 pub unsafe fn create_metal_surface(
25 &self,
26 create_info: &vk::MetalSurfaceCreateInfoEXT,
27 allocation_callbacks: Option<&vk::AllocationCallbacks>,
28 ) -> VkResult<vk::SurfaceKHR> {
29 let mut surface = mem::zeroed();
30 (self.fp.create_metal_surface_ext)(
31 self.handle,
32 create_info,
33 allocation_callbacks.as_raw_ptr(),
34 &mut surface,
35 )
36 .result_with_success(surface)
37 }
38
39 pub const fn name() -> &'static CStr {
40 vk::ExtMetalSurfaceFn::name()
41 }
42
43 pub fn fp(&self) -> &vk::ExtMetalSurfaceFn {
44 &self.fp
45 }
46
47 pub fn instance(&self) -> vk::Instance {
48 self.handle
49 }
50}