ash/extensions/nn/
vi_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 ViSurface {
10 handle: vk::Instance,
11 fp: vk::NnViSurfaceFn,
12}
13
14impl ViSurface {
15 pub fn new(entry: &Entry, instance: &Instance) -> Self {
16 let handle = instance.handle();
17 let fp = vk::NnViSurfaceFn::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_vi_surface(
25 &self,
26 create_info: &vk::ViSurfaceCreateInfoNN,
27 allocation_callbacks: Option<&vk::AllocationCallbacks>,
28 ) -> VkResult<vk::SurfaceKHR> {
29 let mut surface = mem::zeroed();
30 (self.fp.create_vi_surface_nn)(
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::NnViSurfaceFn::name()
41 }
42
43 pub fn fp(&self) -> &vk::NnViSurfaceFn {
44 &self.fp
45 }
46
47 pub fn instance(&self) -> vk::Instance {
48 self.handle
49 }
50}