Add all surface extensions
This commit is contained in:
parent
8a6a7823c4
commit
29ab08a36c
47
src/extensions/android_surface.rs
Normal file
47
src/extensions/android_surface.rs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
use prelude::*;
|
||||||
|
use std::mem;
|
||||||
|
use instance::Instance;
|
||||||
|
use entry::Entry;
|
||||||
|
use vk;
|
||||||
|
use std::ffi::CStr;
|
||||||
|
use ::RawPtr;
|
||||||
|
|
||||||
|
pub struct AndroidSurface {
|
||||||
|
handle: vk::Instance,
|
||||||
|
android_surface_fn: vk::AndroidSurfaceFn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AndroidSurface {
|
||||||
|
pub fn new(entry: &Entry, instance: &Instance) -> Result<AndroidSurface, String> {
|
||||||
|
let surface_fn = vk::AndroidSurfaceFn::load(|name| {
|
||||||
|
unsafe {
|
||||||
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
Ok(AndroidSurface {
|
||||||
|
handle: instance.handle(),
|
||||||
|
android_surface_fn: surface_fn,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name() -> &'static CStr {
|
||||||
|
CStr::from_bytes_with_nul(b"VK_KHR_android_surface\0").expect("Wrong extension string")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn create_android_surface_khr(&self,
|
||||||
|
create_info: &vk::AndroidSurfaceCreateInfoKHR,
|
||||||
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
|
-> VkResult<vk::SurfaceKHR> {
|
||||||
|
let mut surface = mem::uninitialized();
|
||||||
|
let err_code = self.android_surface_fn
|
||||||
|
.create_android_surface_khr(self.handle,
|
||||||
|
create_info,
|
||||||
|
allocation_callbacks.as_raw_ptr(),
|
||||||
|
&mut surface);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::Success => Ok(surface),
|
||||||
|
_ => Err(err_code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,9 +3,17 @@ pub use self::surface::Surface;
|
||||||
pub use self::xlibsurface::XlibSurface;
|
pub use self::xlibsurface::XlibSurface;
|
||||||
pub use self::debug_report::DebugReport;
|
pub use self::debug_report::DebugReport;
|
||||||
pub use self::win32_surface::Win32Surface;
|
pub use self::win32_surface::Win32Surface;
|
||||||
|
pub use self::mir_surface::MirSurface;
|
||||||
|
pub use self::xcb_surface::XcbSurface;
|
||||||
|
pub use self::wayland_surface::WaylandSurface;
|
||||||
|
pub use self::android_surface::AndroidSurface;
|
||||||
|
|
||||||
mod swapchain;
|
mod swapchain;
|
||||||
mod surface;
|
mod surface;
|
||||||
mod xlibsurface;
|
mod xlibsurface;
|
||||||
mod debug_report;
|
mod debug_report;
|
||||||
mod win32_surface;
|
mod win32_surface;
|
||||||
|
mod mir_surface;
|
||||||
|
mod android_surface;
|
||||||
|
mod wayland_surface;
|
||||||
|
mod xcb_surface;
|
||||||
|
|
46
src/extensions/wayland_surface.rs
Normal file
46
src/extensions/wayland_surface.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
use prelude::*;
|
||||||
|
use std::mem;
|
||||||
|
use instance::Instance;
|
||||||
|
use entry::Entry;
|
||||||
|
use vk;
|
||||||
|
use std::ffi::CStr;
|
||||||
|
use ::RawPtr;
|
||||||
|
|
||||||
|
pub struct WaylandSurface {
|
||||||
|
handle: vk::Instance,
|
||||||
|
wayland_surface_fn: vk::WaylandSurfaceFn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WaylandSurface {
|
||||||
|
pub fn new(entry: &Entry, instance: &Instance) -> Result<WaylandSurface, String> {
|
||||||
|
let surface_fn = vk::WaylandSurfaceFn::load(|name| {
|
||||||
|
unsafe {
|
||||||
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
Ok(WaylandSurface {
|
||||||
|
handle: instance.handle(),
|
||||||
|
wayland_surface_fn: surface_fn,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name() -> &'static CStr {
|
||||||
|
CStr::from_bytes_with_nul(b"VK_KHR_wayland_surface\0").expect("Wrong extension string")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn create_wayland_surface_khr(&self,
|
||||||
|
create_info: &vk::WaylandSurfaceCreateInfoKHR,
|
||||||
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
|
-> VkResult<vk::SurfaceKHR> {
|
||||||
|
let mut surface = mem::uninitialized();
|
||||||
|
let err_code = self.wayland_surface_fn
|
||||||
|
.create_wayland_surface_khr(self.handle,
|
||||||
|
create_info,
|
||||||
|
allocation_callbacks.as_raw_ptr(),
|
||||||
|
&mut surface);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::Success => Ok(surface),
|
||||||
|
_ => Err(err_code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
src/extensions/xcb_surface.rs
Normal file
46
src/extensions/xcb_surface.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
use prelude::*;
|
||||||
|
use std::mem;
|
||||||
|
use instance::Instance;
|
||||||
|
use entry::Entry;
|
||||||
|
use vk;
|
||||||
|
use std::ffi::CStr;
|
||||||
|
use ::RawPtr;
|
||||||
|
|
||||||
|
pub struct XcbSurface {
|
||||||
|
handle: vk::Instance,
|
||||||
|
xcb_surface_fn: vk::XcbSurfaceFn,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl XcbSurface {
|
||||||
|
pub fn new(entry: &Entry, instance: &Instance) -> Result<XcbSurface, String> {
|
||||||
|
let surface_fn = vk::XcbSurfaceFn::load(|name| {
|
||||||
|
unsafe {
|
||||||
|
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
Ok(XcbSurface {
|
||||||
|
handle: instance.handle(),
|
||||||
|
xcb_surface_fn: surface_fn,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name() -> &'static CStr {
|
||||||
|
CStr::from_bytes_with_nul(b"VK_KHR_xcb_surface\0").expect("Wrong extension string")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub unsafe fn create_xcb_surface_khr(&self,
|
||||||
|
create_info: &vk::XcbSurfaceCreateInfoKHR,
|
||||||
|
allocation_callbacks: Option<&vk::AllocationCallbacks>)
|
||||||
|
-> VkResult<vk::SurfaceKHR> {
|
||||||
|
let mut surface = mem::uninitialized();
|
||||||
|
let err_code = self.xcb_surface_fn
|
||||||
|
.create_xcb_surface_khr(self.handle,
|
||||||
|
create_info,
|
||||||
|
allocation_callbacks.as_raw_ptr(),
|
||||||
|
&mut surface);
|
||||||
|
match err_code {
|
||||||
|
vk::Result::Success => Ok(surface),
|
||||||
|
_ => Err(err_code),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue