Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VK_NN_vi_surface extension #398

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}