Replace version macros with const fns
This commit is contained in:
parent
9838cf9566
commit
4e8090f0bb
|
@ -181,13 +181,11 @@ pub trait EntryV1_1: EntryV1_0 {
|
||||||
|
|
||||||
impl EntryCustom<Arc<DynamicLibrary>> {
|
impl EntryCustom<Arc<DynamicLibrary>> {
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #[macro_use]
|
|
||||||
/// # extern crate ash;
|
|
||||||
/// use ash::{vk, Entry, version::EntryV1_0};
|
/// use ash::{vk, Entry, version::EntryV1_0};
|
||||||
/// # fn main() -> Result<(), Box<std::error::Error>> {
|
/// # fn main() -> Result<(), Box<std::error::Error>> {
|
||||||
/// let entry = Entry::new()?;
|
/// let entry = Entry::new()?;
|
||||||
/// let app_info = vk::ApplicationInfo {
|
/// let app_info = vk::ApplicationInfo {
|
||||||
/// api_version: vk_make_version!(1, 0, 0),
|
/// api_version: vk::make_version(1, 0, 0),
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// };
|
/// };
|
||||||
/// let create_info = vk::InstanceCreateInfo {
|
/// let create_info = vk::InstanceCreateInfo {
|
||||||
|
@ -240,17 +238,15 @@ impl<L> EntryCustom<L> {
|
||||||
|
|
||||||
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
|
#[doc = "<https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkEnumerateInstanceVersion.html>"]
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # #[macro_use]
|
/// # use ash::{Entry, vk};
|
||||||
/// # extern crate ash;
|
|
||||||
/// # use ash::Entry;
|
|
||||||
/// # fn main() -> Result<(), Box<std::error::Error>> {
|
/// # fn main() -> Result<(), Box<std::error::Error>> {
|
||||||
/// let entry = Entry::new()?;
|
/// let entry = Entry::new()?;
|
||||||
/// match entry.try_enumerate_instance_version()? {
|
/// match entry.try_enumerate_instance_version()? {
|
||||||
/// // Vulkan 1.1+
|
/// // Vulkan 1.1+
|
||||||
/// Some(version) => {
|
/// Some(version) => {
|
||||||
/// let major = vk_version_major!(version);
|
/// let major = vk::version_major(version);
|
||||||
/// let minor = vk_version_minor!(version);
|
/// let minor = vk::version_minor(version);
|
||||||
/// let patch = vk_version_patch!(version);
|
/// let patch = vk::version_patch(version);
|
||||||
/// },
|
/// },
|
||||||
/// // Vulkan 1.0
|
/// // Vulkan 1.0
|
||||||
/// None => {},
|
/// None => {},
|
||||||
|
|
|
@ -5,13 +5,11 @@
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! # #[macro_use]
|
|
||||||
//! # extern crate ash;
|
|
||||||
//! use ash::{vk, Entry, version::EntryV1_0};
|
//! use ash::{vk, Entry, version::EntryV1_0};
|
||||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let entry = Entry::new()?;
|
//! let entry = Entry::new()?;
|
||||||
//! let app_info = vk::ApplicationInfo {
|
//! let app_info = vk::ApplicationInfo {
|
||||||
//! api_version: vk_make_version!(1, 0, 0),
|
//! api_version: vk::make_version(1, 0, 0),
|
||||||
//! ..Default::default()
|
//! ..Default::default()
|
||||||
//! };
|
//! };
|
||||||
//! let create_info = vk::InstanceCreateInfo {
|
//! let create_info = vk::InstanceCreateInfo {
|
||||||
|
|
|
@ -21,32 +21,20 @@ pub trait Handle {
|
||||||
fn from_raw(_: u64) -> Self;
|
fn from_raw(_: u64) -> Self;
|
||||||
}
|
}
|
||||||
#[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.1-extensions/man/html/VK_MAKE_VERSION.html>"]
|
||||||
#[macro_export]
|
pub const fn make_version(major: u32, minor: u32, patch: u32) -> u32 {
|
||||||
macro_rules! vk_make_version {
|
(major << 22) | (minor << 12) | patch
|
||||||
( $ major : expr , $ minor : expr , $ patch : expr ) => {
|
|
||||||
(($major as u32) << 22) | (($minor as u32) << 12) | $patch as u32
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
#[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.1-extensions/man/html/VK_VERSION_MAJOR.html>"]
|
||||||
#[macro_export]
|
pub const fn version_major(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_major {
|
version >> 22
|
||||||
( $ major : expr ) => {
|
|
||||||
($major as u32) >> 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.1-extensions/man/html/VK_VERSION_MINOR.html>"]
|
||||||
#[macro_export]
|
pub const fn version_minor(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_minor {
|
(version >> 12) & 0x3ff
|
||||||
( $ minor : expr ) => {
|
|
||||||
(($minor as u32) >> 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.1-extensions/man/html/VK_VERSION_PATCH.html>"]
|
||||||
#[macro_export]
|
pub const fn version_patch(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_patch {
|
version & 0xfff
|
||||||
( $ minor : expr ) => {
|
|
||||||
($minor as u32) & 0xfff
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
pub type RROutput = c_ulong;
|
pub type RROutput = c_ulong;
|
||||||
pub type VisualID = c_uint;
|
pub type VisualID = c_uint;
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl ExampleBase {
|
||||||
.application_version(0)
|
.application_version(0)
|
||||||
.engine_name(&app_name)
|
.engine_name(&app_name)
|
||||||
.engine_version(0)
|
.engine_version(0)
|
||||||
.api_version(vk_make_version!(1, 0, 0));
|
.api_version(vk::make_version(1, 0, 0));
|
||||||
|
|
||||||
let create_info = vk::InstanceCreateInfo::builder()
|
let create_info = vk::InstanceCreateInfo::builder()
|
||||||
.application_info(&appinfo)
|
.application_info(&appinfo)
|
||||||
|
|
|
@ -185,35 +185,23 @@ 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.1-extensions/man/html/VK_MAKE_VERSION.html>"]
|
||||||
#[macro_export]
|
pub const fn make_version(major: u32, minor: u32, patch: u32) -> u32 {
|
||||||
macro_rules! vk_make_version {
|
(major << 22) | (minor << 12) | patch
|
||||||
($major:expr, $minor:expr, $patch:expr) => {
|
|
||||||
(($major as u32) << 22) | (($minor as u32) << 12) | $patch as u32
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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.1-extensions/man/html/VK_VERSION_MAJOR.html>"]
|
||||||
#[macro_export]
|
pub const fn version_major(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_major {
|
version >> 22
|
||||||
($major:expr) => {
|
|
||||||
($major as u32) >> 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.1-extensions/man/html/VK_VERSION_MINOR.html>"]
|
||||||
#[macro_export]
|
pub const fn version_minor(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_minor {
|
(version >> 12) & 0x3ff
|
||||||
($minor:expr) => {
|
|
||||||
(($minor as u32) >> 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.1-extensions/man/html/VK_VERSION_PATCH.html>"]
|
||||||
#[macro_export]
|
pub const fn version_patch(version: u32) -> u32 {
|
||||||
macro_rules! vk_version_patch {
|
version & 0xfff
|
||||||
($minor:expr) => {
|
|
||||||
($minor as u32) & 0xfff
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue