Add initial support for 1.1

This commit is contained in:
Maik Klein 2018-07-31 08:04:07 +02:00
parent e9db6b516a
commit 60915eacb2
3 changed files with 136 additions and 28 deletions

View file

@ -1,10 +1,22 @@
#![allow(dead_code)]
use prelude::*;
use std::mem;
use version::{FunctionPointers, V1_0};
use version::{FunctionPointers, V1_0, V1_1};
use vk;
use RawPtr;
#[allow(non_camel_case_types)]
pub trait DeviceV1_1: DeviceV1_0 {
fn fp_v1_1(&self) -> &vk::DeviceFnV1_1;
unsafe fn bind_buffer_memory2(&self, bind_infos: &[vk::BindBufferMemoryInfo]) -> vk::Result {
self.fp_v1_1().bind_buffer_memory2(
self.handle(),
bind_infos.len() as _,
bind_infos.as_ptr(),
)
}
}
#[allow(non_camel_case_types)]
pub trait DeviceV1_0 {
fn handle(&self) -> vk::Device;
@ -1495,6 +1507,22 @@ impl DeviceV1_0 for Device<V1_0> {
}
}
impl DeviceV1_0 for Device<V1_1> {
fn handle(&self) -> vk::Device {
self.handle
}
fn fp_v1_0(&self) -> &vk::DeviceFnV1_0 {
&self.device_fn.device_fn_1_0
}
}
impl DeviceV1_1 for Device<V1_1> {
fn fp_v1_1(&self) -> &vk::DeviceFnV1_1 {
&self.device_fn.device_fn_1_1
}
}
impl<V: FunctionPointers> Device<V> {
pub fn handle(&self) -> vk::Device {
self.handle

View file

@ -6,7 +6,7 @@ use std::fmt;
use std::mem;
use std::ptr;
use version::DeviceLoader;
use version::{FunctionPointers, V1_0};
use version::{FunctionPointers, V1_0, V1_1};
use vk;
use RawPtr;
@ -51,6 +51,24 @@ impl InstanceV1_0 for Instance<V1_0> {
&self.instance_fp.instance_fn
}
}
impl InstanceV1_0 for Instance<V1_1> {
type Fp = V1_1;
fn handle(&self) -> vk::Instance {
self.handle
}
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 {
&self.instance_fp.instance_fn_1_0
}
}
impl InstanceV1_1 for Instance<V1_1> {
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1 {
&self.instance_fp.instance_fn_1_1
}
}
impl<V: FunctionPointers> Instance<V> {
pub fn handle(&self) -> vk::Instance {
self.handle
@ -64,6 +82,15 @@ impl<V: FunctionPointers> Instance<V> {
}
}
#[allow(non_camel_case_types)]
pub trait InstanceV1_1: InstanceV1_0 {
fn fp_v1_1(&self) -> &vk::InstanceFnV1_1;
unsafe fn enumerate_instance_version(&self, api_version: &vk::uint32_t) -> vk::Result {
self.fp_v1_1()
.enumerate_instance_version(api_version as *const _)
}
}
#[allow(non_camel_case_types)]
pub trait InstanceV1_0 {
type Fp: FunctionPointers;
@ -253,6 +280,3 @@ pub trait InstanceV1_0 {
}
}
}
// pub trait InstanceMajor1Minor1: InstanceMajor1Minor0 {}
// pub trait InstanceMajor1Minor2: InstanceMajor1Minor1 {}

View file

@ -11,17 +11,20 @@ pub trait FunctionPointers {
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct V1_0;
impl FunctionPointers for V1_0 {
type InstanceFp = InstanceFpV1_0;
type DeviceFp = DeviceFpV1_0;
pub struct V1_1;
impl FunctionPointers for V1_1 {
type InstanceFp = InstanceFpV1_1;
type DeviceFp = DeviceFpV1_1;
type EntryFp = EntryFpV1_0;
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct InstanceFpV1_0 {
pub instance_fn: vk::InstanceFnV1_0,
pub struct V1_0;
impl FunctionPointers for V1_0 {
type InstanceFp = InstanceFpV1_0;
type DeviceFp = DeviceFpV1_0;
type EntryFp = EntryFpV1_0;
}
#[allow(non_camel_case_types)]
@ -48,13 +51,58 @@ pub trait EntryLoader: Sized {
}
pub trait InstanceLoader: Sized {
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0;
unsafe fn load(
static_fn: &vk::StaticFn,
instance: vk::Instance,
) -> Result<Self, Vec<&'static str>>;
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct InstanceFpV1_0 {
pub instance_fn: vk::InstanceFnV1_0,
}
impl InstanceLoader for InstanceFpV1_0 {
unsafe fn load(
static_fn: &vk::StaticFn,
instance: vk::Instance,
) -> Result<Self, Vec<&'static str>> {
let instance_fn = vk::InstanceFnV1_0::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})?;
Ok(InstanceFpV1_0 {
instance_fn: instance_fn,
})
}
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct InstanceFpV1_1 {
pub instance_fn_1_0: vk::InstanceFnV1_0,
pub instance_fn_1_1: vk::InstanceFnV1_1,
}
impl InstanceLoader for InstanceFpV1_1 {
unsafe fn load(
static_fn: &vk::StaticFn,
instance: vk::Instance,
) -> Result<Self, Vec<&'static str>> {
let instance_fn_1_0 = vk::InstanceFnV1_0::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})?;
let instance_fn_1_1 = vk::InstanceFnV1_1::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
})?;
Ok(InstanceFpV1_1 {
instance_fn_1_0,
instance_fn_1_1,
})
}
}
pub trait DeviceLoader: Sized {
unsafe fn load(
instance_fn: &vk::InstanceFnV1_0,
@ -62,6 +110,12 @@ pub trait DeviceLoader: Sized {
) -> Result<Self, Vec<&'static str>>;
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct DeviceFpV1_0 {
pub device_fn: vk::DeviceFnV1_0,
}
impl DeviceLoader for DeviceFpV1_0 {
unsafe fn load(
instance_fn: &vk::InstanceFnV1_0,
@ -76,25 +130,27 @@ impl DeviceLoader for DeviceFpV1_0 {
}
}
impl InstanceLoader for InstanceFpV1_0 {
fn fp_v1_0(&self) -> &vk::InstanceFnV1_0 {
&self.instance_fn
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct DeviceFpV1_1 {
pub device_fn_1_0: vk::DeviceFnV1_0,
pub device_fn_1_1: vk::DeviceFnV1_1,
}
impl DeviceLoader for DeviceFpV1_1 {
unsafe fn load(
static_fn: &vk::StaticFn,
instance: vk::Instance,
instance_fn: &vk::InstanceFnV1_0,
device: vk::Device,
) -> Result<Self, Vec<&'static str>> {
let instance_fn = vk::InstanceFnV1_0::load(|name| {
mem::transmute(static_fn.get_instance_proc_addr(instance, name.as_ptr()))
let device_fn_1_0 = vk::DeviceFnV1_0::load(|name| {
mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr()))
})?;
Ok(InstanceFpV1_0 {
instance_fn: instance_fn,
let device_fn_1_1 = vk::DeviceFnV1_1::load(|name| {
mem::transmute(instance_fn.get_device_proc_addr(device, name.as_ptr()))
})?;
Ok(DeviceFpV1_1 {
device_fn_1_0,
device_fn_1_1,
})
}
}
#[allow(non_camel_case_types)]
#[derive(Clone)]
pub struct DeviceFpV1_0 {
pub device_fn: vk::DeviceFnV1_0,
}