Switch Instance to the new version extension

This commit is contained in:
maik klein 2016-12-30 03:44:05 +01:00
parent 9e2d28b301
commit d964453d2d
8 changed files with 25 additions and 20 deletions

View file

@ -16,7 +16,7 @@ use ash::device::Device;
use std::ptr; use std::ptr;
use std::ffi::{CStr, CString}; use std::ffi::{CStr, CString};
use std::ops::Drop; use std::ops::Drop;
use ash::instance::InstanceMajor1Minor0; use ash::instance::{V1_0, InstanceV1_0};
// Simple offset_of macro akin to C++ offsetof // Simple offset_of macro akin to C++ offsetof
#[macro_export] #[macro_export]
@ -80,7 +80,7 @@ pub fn record_submit_commandbuffer<F: FnOnce(&Device, vk::CommandBuffer)>(device
} }
#[cfg(all(unix, not(target_os = "android")))] #[cfg(all(unix, not(target_os = "android")))]
unsafe fn create_surface(instance: &Instance, unsafe fn create_surface(instance: &Instance<V1_0>,
entry: &Entry, entry: &Entry,
window: &winit::Window) window: &winit::Window)
-> Result<vk::SurfaceKHR, vk::Result> { -> Result<vk::SurfaceKHR, vk::Result> {
@ -187,7 +187,7 @@ fn resize_callback(width: u32, height: u32) {
pub struct ExampleBase { pub struct ExampleBase {
pub entry: Entry, pub entry: Entry,
pub instance: Instance, pub instance: Instance<V1_0>,
pub device: Device, pub device: Device,
pub surface_loader: Surface, pub surface_loader: Surface,
pub swapchain_loader: Swapchain, pub swapchain_loader: Swapchain,
@ -269,7 +269,7 @@ impl ExampleBase {
pp_enabled_extension_names: extension_names_raw.as_ptr(), pp_enabled_extension_names: extension_names_raw.as_ptr(),
enabled_extension_count: extension_names_raw.len() as u32, enabled_extension_count: extension_names_raw.len() as u32,
}; };
let instance: Instance = entry.create_instance(&create_info, None) let instance: Instance<V1_0> = entry.create_instance(&create_info, None)
.expect("Instance creation error"); .expect("Instance creation error");
let debug_info = vk::DebugReportCallbackCreateInfoEXT { let debug_info = vk::DebugReportCallbackCreateInfoEXT {
s_type: vk::StructureType::DebugReportCallbackCreateInfoExt, s_type: vk::StructureType::DebugReportCallbackCreateInfoExt,

View file

@ -5,6 +5,7 @@ use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr; use ::RawPtr;
use instance::{V1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct DebugReport { pub struct DebugReport {
@ -13,7 +14,7 @@ pub struct DebugReport {
} }
impl DebugReport { impl DebugReport {
pub fn new(entry: &Entry, instance: &Instance) -> Result<DebugReport, Vec<&'static str>> { pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<DebugReport, Vec<&'static str>> {
let debug_report_fn = vk::DebugReportFn::load(|name| { let debug_report_fn = vk::DebugReportFn::load(|name| {
unsafe { unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))

View file

@ -1,18 +1,18 @@
//pub use self::swapchain::Swapchain; pub use self::swapchain::Swapchain;
//pub use self::surface::Surface; pub use self::surface::Surface;
//pub use self::xlib_surface::XlibSurface; pub use self::xlib_surface::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::mir_surface::MirSurface;
//pub use self::xcb_surface::XcbSurface; //pub use self::xcb_surface::XcbSurface;
//pub use self::wayland_surface::WaylandSurface; //pub use self::wayland_surface::WaylandSurface;
//pub use self::android_surface::AndroidSurface; //pub use self::android_surface::AndroidSurface;
// //
//mod swapchain; mod swapchain;
//mod surface; mod surface;
//mod xlib_surface; mod xlib_surface;
//mod win32_surface; mod win32_surface;
//mod debug_report; mod debug_report;
//mod mir_surface; //mod mir_surface;
//mod android_surface; //mod android_surface;
//mod wayland_surface; //mod wayland_surface;

View file

@ -7,6 +7,7 @@ use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr; use ::RawPtr;
use instance::{V1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct Surface { pub struct Surface {
@ -15,7 +16,7 @@ pub struct Surface {
} }
impl Surface { impl Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<Surface, Vec<&'static str>> { pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<Surface, Vec<&'static str>> {
let surface_fn = vk::SurfaceFn::load(|name| { let surface_fn = vk::SurfaceFn::load(|name| {
unsafe { unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))

View file

@ -6,7 +6,7 @@ use device::Device;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr; use ::RawPtr;
use instance::InstanceMajor1Minor0; use instance::{V1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct Swapchain { pub struct Swapchain {
@ -15,7 +15,7 @@ pub struct Swapchain {
} }
impl Swapchain { impl Swapchain {
pub fn new(instance: &Instance, device: &Device) -> Result<Swapchain, Vec<&'static str>> { pub fn new(instance: &Instance<V1_0>, device: &Device) -> Result<Swapchain, Vec<&'static str>> {
let swapchain_fn = vk::SwapchainFn::load(|name| { let swapchain_fn = vk::SwapchainFn::load(|name| {
unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) } unsafe { mem::transmute(instance.get_device_proc_addr(device.handle(), name.as_ptr())) }
})?; })?;

View file

@ -6,6 +6,7 @@ use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr; use ::RawPtr;
use instance::{V1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct Win32Surface { pub struct Win32Surface {
@ -14,7 +15,7 @@ pub struct Win32Surface {
} }
impl Win32Surface { impl Win32Surface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<Win32Surface, Vec<&'static str>> { pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<Win32Surface, Vec<&'static str>> {
let surface_fn = vk::Win32SurfaceFn::load(|name| { let surface_fn = vk::Win32SurfaceFn::load(|name| {
unsafe { unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))

View file

@ -6,6 +6,7 @@ use entry::Entry;
use vk; use vk;
use std::ffi::CStr; use std::ffi::CStr;
use ::RawPtr; use ::RawPtr;
use instance::{V1_0, InstanceV1_0};
#[derive(Clone)] #[derive(Clone)]
pub struct XlibSurface { pub struct XlibSurface {
@ -14,7 +15,7 @@ pub struct XlibSurface {
} }
impl XlibSurface { impl XlibSurface {
pub fn new(entry: &Entry, instance: &Instance) -> Result<XlibSurface, Vec<&'static str>> { pub fn new(entry: &Entry, instance: &Instance<V1_0>) -> Result<XlibSurface, Vec<&'static str>> {
let surface_fn = vk::XlibSurfaceFn::load(|name| { let surface_fn = vk::XlibSurfaceFn::load(|name| {
unsafe { unsafe {
mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr())) mem::transmute(entry.get_instance_proc_addr(instance.handle(), name.as_ptr()))

View file

@ -17,6 +17,7 @@ pub trait VkVersion{
type DeviceFp; type DeviceFp;
} }
#[warn(non_camel_case_types)] #[warn(non_camel_case_types)]
pub struct V1_0; pub struct V1_0;
impl VkVersion for V1_0{ impl VkVersion for V1_0{