#![allow(non_camel_case_types)] use std::{mem, ptr}; use vulkan_rs::prelude::*; use crate::*; 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, } macro_rules! create_functions_enum { ($([$pfn:ident, $func:ident],)+) => { paste::paste! { pub enum Functions { Null, $( $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) }, )+ } } pub fn get_vk_func(s:&str) -> Option { match s { $( stringify!([]) => Some(Functions::$pfn($func)), )+ _ => None } } } } }; } create_functions_enum!( [CreateInstance, create_instance], [DestroyInstance, destroy_instance], [CreateDevice, create_device], [DestroyDevice, destroy_device], [CreateSwapchainKHR, create_swapchain], [AcquireNextImageKHR, acquire_next_image], [QueuePresentKHR, present_queue], );