1#![allow(non_camel_case_types)]
8
9use core::ffi::{c_char, c_void};
10use core::fmt;
11
12use bitflags::bitflags;
13
14use crate as vk;
15
16bitflags! {
21 #[repr(transparent)]
22 #[derive(Default)]
23 pub struct LoaderFeatureFlags: vk::Flags {
24 const PHYSICAL_DEVICE_SORTING = 1;
25 }
26}
27
28#[repr(transparent)]
33#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
34pub struct LayerFunction(i32);
35
36impl LayerFunction {
37 pub const LAYER_LINK_INFO: Self = Self(0);
38 pub const LOADER_DATA_CALLBACK: Self = Self(1);
39 pub const LOADER_LAYER_CREATE_DEVICE_CALLBACK: Self = Self(2);
40 pub const LOADER_FEATURES: Self = Self(3);
41
42 #[inline]
44 pub const fn from_raw(value: i32) -> Self {
45 Self(value)
46 }
47
48 #[inline]
50 pub const fn as_raw(self) -> i32 {
51 self.0
52 }
53}
54
55impl fmt::Debug for LayerFunction {
56 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
57 match self.0 {
58 0 => write!(f, "LAYER_LINK_INFO"),
59 1 => write!(f, "LOADER_DATA_CALLBACK"),
60 2 => write!(f, "LOADER_LAYER_CREATE_DEVICE_CALLBACK"),
61 3 => write!(f, "LOADER_FEATURES"),
62 _ => self.0.fmt(f),
63 }
64 }
65}
66
67#[repr(transparent)]
68#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
69pub struct NegotiateLayerStructType(i32);
70
71impl NegotiateLayerStructType {
72 pub const UNINTIALIZED: Self = Self(0);
73 pub const INTERFACE_STRUCT: Self = Self(1);
74
75 #[inline]
77 pub const fn from_raw(value: i32) -> Self {
78 Self(value)
79 }
80
81 #[inline]
83 pub const fn as_raw(self) -> i32 {
84 self.0
85 }
86}
87
88impl fmt::Debug for NegotiateLayerStructType {
89 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90 match self.0 {
91 0 => write!(f, "UNINTIALIZED"),
92 1 => write!(f, "INTERFACE_STRUCT"),
93 _ => self.0.fmt(f),
94 }
95 }
96}
97
98pub type PFN_vkGetPhysicalDeviceProcAddr = unsafe extern "system" fn(
103 _instance: vk::Instance,
104 _name: *const c_char,
105) -> vk::PFN_vkVoidFunction;
106
107pub type PFN_vkLayerCreateDevice = unsafe extern "system" fn(
108 _instance: vk::Instance,
109 _physical_device: vk::PhysicalDevice,
110 _create_info: *const vk::DeviceCreateInfo,
111 _allocator: *const vk::AllocationCallbacks,
112 _device: *mut vk::Device,
113 _layer_gipa: vk::PFN_vkGetInstanceProcAddr,
114 _next_gdpa: *mut vk::PFN_vkGetInstanceProcAddr,
115) -> vk::Result;
116
117pub type PFN_vkLayerDestroyDevice = unsafe extern "system" fn(
118 _device: vk::Device,
119 _allocator: *const vk::AllocationCallbacks,
120 _destroy_function: vk::PFN_vkDestroyDevice,
121) -> vk::Result;
122
123pub type PFN_vkSetDeviceLoaderData =
124 unsafe extern "system" fn(_device: vk::Device, _object: *mut c_void) -> vk::Result;
125
126pub type PFN_vkSetInstanceLoaderData =
127 unsafe extern "system" fn(_instance: vk::Instance, _object: *mut c_void) -> vk::Result;
128
129#[repr(C)]
134#[derive(Copy, Clone, Debug)]
135pub struct LayerInstanceLink {
136 pub next: *mut Self,
137 pub next_get_instance_proc_addr: vk::PFN_vkGetInstanceProcAddr,
138 pub next_get_physical_device_proc_addr: PFN_vkGetPhysicalDeviceProcAddr,
139}
140
141#[repr(C)]
142#[derive(Copy, Clone, Debug)]
143pub struct LayerDevice {
144 pub layer_create_device: PFN_vkLayerCreateDevice,
145 pub layer_destroy_device: PFN_vkLayerDestroyDevice,
146}
147
148#[repr(C)]
149#[derive(Copy, Clone)]
150pub union LayerInstanceCreateInfoPayload {
151 pub layer_info: *mut LayerInstanceLink,
152 pub set_instance_loader_data: PFN_vkSetInstanceLoaderData,
153 pub layer_device: LayerDevice,
154 pub loader_features: LoaderFeatureFlags,
155}
156
157impl fmt::Debug for LayerInstanceCreateInfoPayload {
158 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
159 write!(f, "LayerInstanceCreateInfoPayload")
160 }
161}
162
163#[repr(C)]
164#[derive(Copy, Clone, Debug)]
165pub struct LayerInstanceCreateInfo {
166 pub s_type: vk::StructureType,
167 pub next: *const c_void,
168 pub function: LayerFunction,
169 pub payload: LayerInstanceCreateInfoPayload,
170}
171
172#[repr(C)]
177#[derive(Copy, Clone, Debug)]
178pub struct LayerDeviceLink {
179 pub next: *mut Self,
180 pub next_get_instance_proc_addr: vk::PFN_vkGetInstanceProcAddr,
181 pub next_get_device_proc_addr: vk::PFN_vkGetDeviceProcAddr,
182}
183
184#[repr(C)]
185#[derive(Copy, Clone)]
186pub union LayerDeviceCreateInfoPayload {
187 pub layer_info: *mut LayerDeviceLink,
188 pub set_device_loader_data: PFN_vkSetDeviceLoaderData,
189}
190
191impl fmt::Debug for LayerDeviceCreateInfoPayload {
192 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
193 write!(f, "LayerDeviceCreateInfoPayload")
194 }
195}
196
197#[repr(C)]
198#[derive(Copy, Clone, Debug)]
199pub struct LayerDeviceCreateInfo {
200 pub s_type: vk::StructureType,
201 pub next: *const c_void,
202 pub function: LayerFunction,
203 pub payload: LayerDeviceCreateInfoPayload,
204}
205
206#[repr(C)]
211#[derive(Copy, Clone, Debug)]
212pub struct NegotiateLayerInterface {
213 pub s_type: NegotiateLayerStructType,
214 pub next: *const c_void,
215 pub loader_layer_interface_version: u32,
216 pub get_instance_proc_addr: vk::PFN_vkGetInstanceProcAddr,
217 pub get_device_proc_addr: vk::PFN_vkGetDeviceProcAddr,
218 pub get_get_physical_device_proc_addr: PFN_vkGetPhysicalDeviceProcAddr,
219}