Skip to content

Commit

Permalink
Add VK_NN_vi_surface extension (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rua committed Mar 20, 2021
1 parent 81b8e3a commit 3094084
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions ash/src/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pub mod experimental;
pub mod ext;
pub mod khr;
pub mod mvk;
pub mod nn;
pub mod nv;
3 changes: 3 additions & 0 deletions ash/src/extensions/nn/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub use self::vi_surface::ViSurface;

mod vi_surface;
54 changes: 54 additions & 0 deletions ash/src/extensions/nn/vi_surface.rs
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 3094084

Please sign in to comment.