Vulkan 1.2 Support (#264)
* Updated vk-parse and Vulkan-Headers to Vulkan 1.2 * First pass at generating vk.rs * Support double * Generate from EnumSpec::Value * Remove println * Fix mutable pointer bug * cargo fmt * Update document link * Remove mention of Vulkan 1.2 support for now * Add clippy::wrong_self_convention
This commit is contained in:
parent
17edc8c13c
commit
00f52cc5ad
4 changed files with 8710 additions and 2719 deletions
11402
ash/src/vk.rs
11402
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@ authors = ["Maik Klein <maikklein@googlemail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
vk-parse = "0.2"
|
vk-parse = "0.3.0"
|
||||||
vkxml = "0.3"
|
vkxml = "0.3"
|
||||||
nom = "4.0"
|
nom = "4.0"
|
||||||
heck = "0.3"
|
heck = "0.3"
|
||||||
|
@ -18,4 +18,3 @@ version = "0.4.2"
|
||||||
[dependencies.syn]
|
[dependencies.syn]
|
||||||
version = "0.12.14"
|
version = "0.12.14"
|
||||||
features = ["full", "extra-traits"]
|
features = ["full", "extra-traits"]
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fd568d51ed3d9bc6132e1639d7492453a08fe1bc
|
Subproject commit 881bbb347a08d1b5aa77f61a52a30b506de9f2bf
|
|
@ -89,7 +89,7 @@ named!(cfloat<&str, f32>,
|
||||||
|
|
||||||
fn khronos_link<S: Display>(name: &S) -> Literal {
|
fn khronos_link<S: Display>(name: &S) -> Literal {
|
||||||
Literal::string(&format!(
|
Literal::string(&format!(
|
||||||
"<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/{name}.html>",
|
"<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/{name}.html>",
|
||||||
name = name
|
name = name
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -185,22 +185,22 @@ pub fn handle_nondispatchable_macro() -> Tokens {
|
||||||
}
|
}
|
||||||
pub fn vk_version_macros() -> Tokens {
|
pub fn vk_version_macros() -> Tokens {
|
||||||
quote! {
|
quote! {
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_MAKE_VERSION.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_MAKE_VERSION.html>"]
|
||||||
pub const fn make_version(major: u32, minor: u32, patch: u32) -> u32 {
|
pub const fn make_version(major: u32, minor: u32, patch: u32) -> u32 {
|
||||||
(major << 22) | (minor << 12) | patch
|
(major << 22) | (minor << 12) | patch
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_MAJOR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_MAJOR.html>"]
|
||||||
pub const fn version_major(version: u32) -> u32 {
|
pub const fn version_major(version: u32) -> u32 {
|
||||||
version >> 22
|
version >> 22
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_MINOR.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_MINOR.html>"]
|
||||||
pub const fn version_minor(version: u32) -> u32 {
|
pub const fn version_minor(version: u32) -> u32 {
|
||||||
(version >> 12) & 0x3ff
|
(version >> 12) & 0x3ff
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VK_VERSION_PATCH.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_VERSION_PATCH.html>"]
|
||||||
pub const fn version_patch(version: u32) -> u32 {
|
pub const fn version_patch(version: u32) -> u32 {
|
||||||
version & 0xfff
|
version & 0xfff
|
||||||
}
|
}
|
||||||
|
@ -648,6 +648,7 @@ fn name_to_tokens(type_name: &str) -> Ident {
|
||||||
"void" => "c_void",
|
"void" => "c_void",
|
||||||
"char" => "c_char",
|
"char" => "c_char",
|
||||||
"float" => "f32",
|
"float" => "f32",
|
||||||
|
"double" => "f64",
|
||||||
"long" => "c_ulong",
|
"long" => "c_ulong",
|
||||||
_ => {
|
_ => {
|
||||||
if type_name.starts_with("Vk") {
|
if type_name.starts_with("Vk") {
|
||||||
|
@ -945,6 +946,13 @@ pub fn generate_extension_constants<'a>(
|
||||||
let value = if *positive { value } else { -value };
|
let value = if *positive { value } else { -value };
|
||||||
Some((Constant::Number(value as i32), Some(extends.clone())))
|
Some((Constant::Number(value as i32), Some(extends.clone())))
|
||||||
}
|
}
|
||||||
|
EnumSpec::Value { value, extends } => {
|
||||||
|
if let (Some(extends), Ok(value)) = (extends, value.parse::<i32>()) {
|
||||||
|
Some((Constant::Number(value), Some(extends.clone())))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}?;
|
}?;
|
||||||
let extends = extends?;
|
let extends = extends?;
|
||||||
|
@ -1587,7 +1595,7 @@ pub fn derive_setters(
|
||||||
// *mut
|
// *mut
|
||||||
let slice_type = ¶m_ty_string[5..];
|
let slice_type = ¶m_ty_string[5..];
|
||||||
if slice_type == "c_void" {
|
if slice_type == "c_void" {
|
||||||
slice_param_ty_tokens = "&mut 'a [u8]".to_string();
|
slice_param_ty_tokens = "&'a mut [u8]".to_string();
|
||||||
ptr = ".as_mut_ptr() as *mut c_void";
|
ptr = ".as_mut_ptr() as *mut c_void";
|
||||||
} else {
|
} else {
|
||||||
slice_param_ty_tokens = "&'a mut [".to_string() + slice_type + "]";
|
slice_param_ty_tokens = "&'a mut [".to_string() + slice_type + "]";
|
||||||
|
@ -2273,7 +2281,7 @@ pub fn write_source_code(path: &Path) {
|
||||||
let version_macros = vk_version_macros();
|
let version_macros = vk_version_macros();
|
||||||
let platform_specific_types = platform_specific_types();
|
let platform_specific_types = platform_specific_types();
|
||||||
let source_code = quote! {
|
let source_code = quote! {
|
||||||
#![allow(clippy::too_many_arguments, clippy::cognitive_complexity)]
|
#![allow(clippy::too_many_arguments, clippy::cognitive_complexity, clippy::wrong_self_convention)]
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
/// Iterates through the pointer chain. Includes the item that is passed into the function.
|
/// Iterates through the pointer chain. Includes the item that is passed into the function.
|
||||||
|
|
Loading…
Add table
Reference in a new issue