-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VK_NN_vi_surface extension (#398)
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pub mod experimental; | |
pub mod ext; | ||
pub mod khr; | ||
pub mod mvk; | ||
pub mod nn; | ||
pub mod nv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub use self::vi_surface::ViSurface; | ||
|
||
mod vi_surface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |