Add VK_NN_vi_surface extension (#398)

This commit is contained in:
Rua 2021-03-20 14:00:16 +01:00 committed by GitHub
parent 81b8e3a24a
commit 3094084c1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 0 deletions

View file

@ -2,4 +2,5 @@ pub mod experimental;
pub mod ext;
pub mod khr;
pub mod mvk;
pub mod nn;
pub mod nv;

View file

@ -0,0 +1,3 @@
pub use self::vi_surface::ViSurface;
mod vi_surface;

View file

@ -0,0 +1,54 @@
#![allow(dead_code)]
use crate::prelude::*;
use crate::version::{EntryV1_0, InstanceV1_0};
use crate::vk;
use crate::RawPtr;
use std::ffi::CStr;
use std::mem;
#[derive(Clone)]
pub struct ViSurface {
handle: vk::Instance,
vi_surface_fn: vk::NnViSurfaceFn,
}
impl ViSurface {
pub fn new<E: EntryV1_0, I: InstanceV1_0>(entry: &E, instance: &I) -> ViSurface {
let surface_fn = vk::NnViSurfaceFn::load(|name| unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
});
ViSurface {
handle: instance.handle(),
vi_surface_fn: surface_fn,
}
}
pub fn name() -> &'static CStr {
vk::NnViSurfaceFn::name()
}
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/vkCreateViSurfaceNN.html>"]
pub unsafe fn create_vi_surface(
&self,
create_info: &vk::ViSurfaceCreateInfoNN,
allocation_callbacks: Option<&vk::AllocationCallbacks>,
) -> VkResult<vk::SurfaceKHR> {
let mut surface = mem::zeroed();
self.vi_surface_fn
.create_vi_surface_nn(
self.handle,
create_info,
allocation_callbacks.as_raw_ptr(),
&mut surface,
)
.result_with_success(surface)
}
pub fn fp(&self) -> &vk::NnViSurfaceFn {
&self.vi_surface_fn
}
pub fn instance(&self) -> vk::Instance {
self.handle
}
}