rFactor2_vk_hud/src/enums.rs

70 lines
1.8 KiB
Rust
Raw Normal View History

2023-01-10 13:24:04 +00:00
#![allow(non_camel_case_types)]
use std::{mem, ptr};
2023-01-11 20:46:17 +00:00
use vulkan_rs::prelude::*;
2023-01-10 13:24:04 +00:00
2023-01-13 08:27:58 +00:00
use crate::*;
2023-01-10 13:24:04 +00:00
pub use VkLayerFunction::*;
pub use VkNegotiateLayerStructType::*;
#[derive(Clone)]
pub enum VkNegotiateLayerStructType {
LAYER_NEGOTIATE_INTERFACE_STRUCT = 1,
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum VkLayerFunction {
VK_LAYER_LINK_INFO = 0,
VK_LOADER_DATA_CALLBACK = 1,
VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2,
VK_LOADER_FEATURES = 3,
}
2023-01-13 08:27:58 +00:00
macro_rules! create_functions_enum {
($([$pfn:ident, $func:ident],)+) => {
paste::paste! {
pub enum Functions {
Null,
$(
$pfn ( [<PFN_vk $pfn>] ),
)+
}
impl Functions {
pub fn convert(self) -> PFN_vkVoidFunction {
match self {
Functions::Null => unsafe {
mem::transmute::<*const (), PFN_vkVoidFunction>(ptr::null())
},
$(
Functions::$pfn(foo) => unsafe { mem::transmute(foo) },
)+
}
}
2023-01-10 13:24:04 +00:00
2023-01-13 08:27:58 +00:00
pub fn get_vk_func(s:&str) -> Option<Functions> {
match s {
$(
stringify!([<vk $pfn>]) => Some(Functions::$pfn($func)),
)+
_ => None
}
}
}
2023-01-10 13:24:04 +00:00
}
2023-01-13 08:27:58 +00:00
};
2023-01-10 13:24:04 +00:00
}
2023-01-13 08:27:58 +00:00
create_functions_enum!(
[CreateInstance, create_instance],
[DestroyInstance, destroy_instance],
[CreateDevice, create_device],
[DestroyDevice, destroy_device],
[CreateSwapchainKHR, create_swapchain],
[AcquireNextImageKHR, acquire_next_image],
2023-01-13 14:00:01 +00:00
[QueuePresentKHR, present_queue],
2023-01-13 08:27:58 +00:00
);