kazan 0.3.9+1.4.359

Vulkan bindings for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
//! <https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_display.html>
#![allow(unused_imports)]
use crate::{vk::Result as VkResult, vk::*, *};
use core::ffi::{CStr, c_char, c_int, c_void};
use core::mem::transmute;
use core::ptr;

pub const EXTENSION_NAME: &CStr = c"VK_KHR_display";

pub(super) mod defs {
    #![allow(non_camel_case_types, unused_imports)]
    use crate::{vk::*, *};
    use core::ffi::{CStr, c_char, c_int, c_void};
    use core::fmt;
    use core::marker::PhantomData;
    use core::ptr;

    handle_nondispatchable!(
        DisplayKHR,
        DISPLAY_KHR,
        doc = "<https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayKHR.html>"
    );
    handle_nondispatchable!(
        DisplayModeKHR,
        DISPLAY_MODE_KHR,
        doc = "<https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayModeKHR.html>"
    );

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayPropertiesKHR.html>
    #[repr(C)]
    #[derive(Copy, Clone)]
    #[must_use]
    pub struct DisplayPropertiesKHR<'a> {
        pub display: DisplayKHR,
        pub display_name: *const c_char,
        pub physical_dimensions: Extent2D,
        pub physical_resolution: Extent2D,
        pub supported_transforms: SurfaceTransformFlagsKHR,
        pub plane_reorder_possible: Bool32,
        pub persistent_content: Bool32,
        pub _marker: PhantomData<&'a ()>,
    }

    #[cfg(feature = "debug")]
    impl fmt::Debug for DisplayPropertiesKHR<'_> {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            f.debug_struct("DisplayPropertiesKHR")
                .field("display", &self.display)
                .field("display_name", &unsafe { as_c_str(self.display_name) })
                .field("physical_dimensions", &self.physical_dimensions)
                .field("physical_resolution", &self.physical_resolution)
                .field("supported_transforms", &self.supported_transforms)
                .field("plane_reorder_possible", &self.plane_reorder_possible)
                .field("persistent_content", &self.persistent_content)
                .finish()
        }
    }

    impl Default for DisplayPropertiesKHR<'_> {
        fn default() -> Self {
            Self {
                display: Default::default(),
                display_name: ptr::null(),
                physical_dimensions: Default::default(),
                physical_resolution: Default::default(),
                supported_transforms: Default::default(),
                plane_reorder_possible: Default::default(),
                persistent_content: Default::default(),
                _marker: PhantomData,
            }
        }
    }

    impl<'a> DisplayPropertiesKHR<'a> {
        #[inline]
        pub fn display(mut self, display: DisplayKHR) -> Self {
            self.display = display;
            self
        }

        #[inline]
        pub fn display_name(mut self, display_name: &'a CStr) -> Self {
            self.display_name = display_name.as_ptr();
            self
        }

        #[inline]
        pub fn physical_dimensions(mut self, physical_dimensions: Extent2D) -> Self {
            self.physical_dimensions = physical_dimensions;
            self
        }

        #[inline]
        pub fn physical_resolution(mut self, physical_resolution: Extent2D) -> Self {
            self.physical_resolution = physical_resolution;
            self
        }

        #[inline]
        pub fn supported_transforms(
            mut self,
            supported_transforms: SurfaceTransformFlagsKHR,
        ) -> Self {
            self.supported_transforms = supported_transforms;
            self
        }

        #[inline]
        pub fn plane_reorder_possible(mut self, plane_reorder_possible: bool) -> Self {
            self.plane_reorder_possible = plane_reorder_possible.into();
            self
        }

        #[inline]
        pub fn persistent_content(mut self, persistent_content: bool) -> Self {
            self.persistent_content = persistent_content.into();
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayPlanePropertiesKHR.html>
    #[repr(C)]
    #[cfg_attr(feature = "debug", derive(Debug))]
    #[derive(Copy, Clone, Default)]
    #[must_use]
    pub struct DisplayPlanePropertiesKHR {
        pub current_display: DisplayKHR,
        pub current_stack_index: u32,
    }

    impl DisplayPlanePropertiesKHR {
        #[inline]
        pub fn current_display(mut self, current_display: DisplayKHR) -> Self {
            self.current_display = current_display;
            self
        }

        #[inline]
        pub fn current_stack_index(mut self, current_stack_index: u32) -> Self {
            self.current_stack_index = current_stack_index;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayModeParametersKHR.html>
    #[repr(C)]
    #[cfg_attr(feature = "debug", derive(Debug))]
    #[derive(Copy, Clone, Default)]
    #[must_use]
    pub struct DisplayModeParametersKHR {
        pub visible_region: Extent2D,
        pub refresh_rate: u32,
    }

    impl DisplayModeParametersKHR {
        #[inline]
        pub fn visible_region(mut self, visible_region: Extent2D) -> Self {
            self.visible_region = visible_region;
            self
        }

        #[inline]
        pub fn refresh_rate(mut self, refresh_rate: u32) -> Self {
            self.refresh_rate = refresh_rate;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayModePropertiesKHR.html>
    #[repr(C)]
    #[cfg_attr(feature = "debug", derive(Debug))]
    #[derive(Copy, Clone, Default)]
    #[must_use]
    pub struct DisplayModePropertiesKHR {
        pub display_mode: DisplayModeKHR,
        pub parameters: DisplayModeParametersKHR,
    }

    impl DisplayModePropertiesKHR {
        #[inline]
        pub fn display_mode(mut self, display_mode: DisplayModeKHR) -> Self {
            self.display_mode = display_mode;
            self
        }

        #[inline]
        pub fn parameters(mut self, parameters: DisplayModeParametersKHR) -> Self {
            self.parameters = parameters;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayModeCreateInfoKHR.html>
    #[repr(C)]
    #[derive(Copy, Clone)]
    #[must_use]
    pub struct DisplayModeCreateInfoKHR<'a> {
        pub s_type: StructureType,
        pub p_next: *const c_void,
        pub flags: DisplayModeCreateFlagsKHR,
        pub parameters: DisplayModeParametersKHR,
        pub _marker: PhantomData<&'a ()>,
    }

    #[cfg(feature = "debug")]
    impl fmt::Debug for DisplayModeCreateInfoKHR<'_> {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            f.debug_struct("DisplayModeCreateInfoKHR")
                .field("s_type", &self.s_type)
                .field("p_next", &self.p_next)
                .field("flags", &self.flags)
                .field("parameters", &self.parameters)
                .finish()
        }
    }

    unsafe impl<'a> TaggedStructure<'a> for DisplayModeCreateInfoKHR<'a> {
        const STRUCTURE_TYPE: StructureType = StructureType::DISPLAY_MODE_CREATE_INFO_KHR;
    }

    impl Default for DisplayModeCreateInfoKHR<'_> {
        fn default() -> Self {
            Self {
                s_type: Self::STRUCTURE_TYPE,
                p_next: ptr::null(),
                flags: Default::default(),
                parameters: Default::default(),
                _marker: PhantomData,
            }
        }
    }

    impl<'a> DisplayModeCreateInfoKHR<'a> {
        #[inline]
        pub fn flags(mut self, flags: DisplayModeCreateFlagsKHR) -> Self {
            self.flags = flags;
            self
        }

        #[inline]
        pub fn parameters(mut self, parameters: DisplayModeParametersKHR) -> Self {
            self.parameters = parameters;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayPlaneCapabilitiesKHR.html>
    #[repr(C)]
    #[cfg_attr(feature = "debug", derive(Debug))]
    #[derive(Copy, Clone, Default)]
    #[must_use]
    pub struct DisplayPlaneCapabilitiesKHR {
        pub supported_alpha: DisplayPlaneAlphaFlagsKHR,
        pub min_src_position: Offset2D,
        pub max_src_position: Offset2D,
        pub min_src_extent: Extent2D,
        pub max_src_extent: Extent2D,
        pub min_dst_position: Offset2D,
        pub max_dst_position: Offset2D,
        pub min_dst_extent: Extent2D,
        pub max_dst_extent: Extent2D,
    }

    impl DisplayPlaneCapabilitiesKHR {
        #[inline]
        pub fn supported_alpha(mut self, supported_alpha: DisplayPlaneAlphaFlagsKHR) -> Self {
            self.supported_alpha = supported_alpha;
            self
        }

        #[inline]
        pub fn min_src_position(mut self, min_src_position: Offset2D) -> Self {
            self.min_src_position = min_src_position;
            self
        }

        #[inline]
        pub fn max_src_position(mut self, max_src_position: Offset2D) -> Self {
            self.max_src_position = max_src_position;
            self
        }

        #[inline]
        pub fn min_src_extent(mut self, min_src_extent: Extent2D) -> Self {
            self.min_src_extent = min_src_extent;
            self
        }

        #[inline]
        pub fn max_src_extent(mut self, max_src_extent: Extent2D) -> Self {
            self.max_src_extent = max_src_extent;
            self
        }

        #[inline]
        pub fn min_dst_position(mut self, min_dst_position: Offset2D) -> Self {
            self.min_dst_position = min_dst_position;
            self
        }

        #[inline]
        pub fn max_dst_position(mut self, max_dst_position: Offset2D) -> Self {
            self.max_dst_position = max_dst_position;
            self
        }

        #[inline]
        pub fn min_dst_extent(mut self, min_dst_extent: Extent2D) -> Self {
            self.min_dst_extent = min_dst_extent;
            self
        }

        #[inline]
        pub fn max_dst_extent(mut self, max_dst_extent: Extent2D) -> Self {
            self.max_dst_extent = max_dst_extent;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplaySurfaceCreateInfoKHR.html>
    #[repr(C)]
    #[derive(Copy, Clone)]
    #[must_use]
    pub struct DisplaySurfaceCreateInfoKHR<'a> {
        pub s_type: StructureType,
        pub p_next: *const c_void,
        pub flags: DisplaySurfaceCreateFlagsKHR,
        pub display_mode: DisplayModeKHR,
        pub plane_index: u32,
        pub plane_stack_index: u32,
        pub transform: SurfaceTransformFlagBitsKHR,
        pub global_alpha: f32,
        pub alpha_mode: DisplayPlaneAlphaFlagBitsKHR,
        pub image_extent: Extent2D,
        pub _marker: PhantomData<&'a ()>,
    }

    #[cfg(feature = "debug")]
    impl fmt::Debug for DisplaySurfaceCreateInfoKHR<'_> {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            f.debug_struct("DisplaySurfaceCreateInfoKHR")
                .field("s_type", &self.s_type)
                .field("p_next", &self.p_next)
                .field("flags", &self.flags)
                .field("display_mode", &self.display_mode)
                .field("plane_index", &self.plane_index)
                .field("plane_stack_index", &self.plane_stack_index)
                .field("transform", &self.transform)
                .field("global_alpha", &self.global_alpha)
                .field("alpha_mode", &self.alpha_mode)
                .field("image_extent", &self.image_extent)
                .finish()
        }
    }

    unsafe impl<'a> TaggedStructure<'a> for DisplaySurfaceCreateInfoKHR<'a> {
        const STRUCTURE_TYPE: StructureType = StructureType::DISPLAY_SURFACE_CREATE_INFO_KHR;
    }

    impl Default for DisplaySurfaceCreateInfoKHR<'_> {
        fn default() -> Self {
            Self {
                s_type: Self::STRUCTURE_TYPE,
                p_next: ptr::null(),
                flags: Default::default(),
                display_mode: Default::default(),
                plane_index: Default::default(),
                plane_stack_index: Default::default(),
                transform: Default::default(),
                global_alpha: Default::default(),
                alpha_mode: Default::default(),
                image_extent: Default::default(),
                _marker: PhantomData,
            }
        }
    }

    impl<'a> DisplaySurfaceCreateInfoKHR<'a> {
        #[inline]
        pub fn flags(mut self, flags: DisplaySurfaceCreateFlagsKHR) -> Self {
            self.flags = flags;
            self
        }

        #[inline]
        pub fn display_mode(mut self, display_mode: DisplayModeKHR) -> Self {
            self.display_mode = display_mode;
            self
        }

        #[inline]
        pub fn plane_index(mut self, plane_index: u32) -> Self {
            self.plane_index = plane_index;
            self
        }

        #[inline]
        pub fn plane_stack_index(mut self, plane_stack_index: u32) -> Self {
            self.plane_stack_index = plane_stack_index;
            self
        }

        #[inline]
        pub fn transform(mut self, transform: SurfaceTransformFlagBitsKHR) -> Self {
            self.transform = transform;
            self
        }

        #[inline]
        pub fn global_alpha(mut self, global_alpha: f32) -> Self {
            self.global_alpha = global_alpha;
            self
        }

        #[inline]
        pub fn alpha_mode(mut self, alpha_mode: DisplayPlaneAlphaFlagBitsKHR) -> Self {
            self.alpha_mode = alpha_mode;
            self
        }

        #[inline]
        pub fn image_extent(mut self, image_extent: Extent2D) -> Self {
            self.image_extent = image_extent;
            self
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayPlaneAlphaFlagsKHR.html>
    #[repr(transparent)]
    #[derive(Copy, Clone, PartialEq, Eq, Hash)]
    pub struct DisplayPlaneAlphaFlagsKHR(Flags);
    vk_bitflags_wrapped!(
        DisplayPlaneAlphaFlagsKHR,
        Flags,
        DisplayPlaneAlphaFlagBitsKHR
    );

    impl fmt::Debug for DisplayPlaneAlphaFlagsKHR {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            const KNOWN: &[(Flags, &str)] = &[
                (DisplayPlaneAlphaFlagBitsKHR::OPAQUE_KHR.0, "OPAQUE_KHR"),
                (DisplayPlaneAlphaFlagBitsKHR::GLOBAL_KHR.0, "GLOBAL_KHR"),
                (
                    DisplayPlaneAlphaFlagBitsKHR::PER_PIXEL_KHR.0,
                    "PER_PIXEL_KHR",
                ),
                (
                    DisplayPlaneAlphaFlagBitsKHR::PER_PIXEL_PREMULTIPLIED_KHR.0,
                    "PER_PIXEL_PREMULTIPLIED_KHR",
                ),
            ];
            debug_flags(f, KNOWN, self.0)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayPlaneAlphaFlagBitsKHR.html>
    #[repr(transparent)]
    #[derive(Copy, Clone, Default, PartialEq, Eq, Hash)]
    pub struct DisplayPlaneAlphaFlagBitsKHR(u32);

    impl DisplayPlaneAlphaFlagBitsKHR {
        pub const OPAQUE_KHR: Self = Self(1 << 0);
        pub const GLOBAL_KHR: Self = Self(1 << 1);
        pub const PER_PIXEL_KHR: Self = Self(1 << 2);
        pub const PER_PIXEL_PREMULTIPLIED_KHR: Self = Self(1 << 3);
    }

    impl fmt::Debug for DisplayPlaneAlphaFlagBitsKHR {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            let name = match *self {
                Self::OPAQUE_KHR => Some("OPAQUE_KHR"),
                Self::GLOBAL_KHR => Some("GLOBAL_KHR"),
                Self::PER_PIXEL_KHR => Some("PER_PIXEL_KHR"),
                Self::PER_PIXEL_PREMULTIPLIED_KHR => Some("PER_PIXEL_PREMULTIPLIED_KHR"),
                _ => None,
            };
            if let Some(name) = name {
                f.write_str(name)
            } else {
                self.0.fmt(f)
            }
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplayModeCreateFlagsKHR.html>
    #[repr(transparent)]
    #[derive(Copy, Clone, PartialEq, Eq, Hash)]
    pub struct DisplayModeCreateFlagsKHR(Flags);
    vk_bitflags_wrapped!(DisplayModeCreateFlagsKHR, Flags);

    impl fmt::Debug for DisplayModeCreateFlagsKHR {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            debug_flags(f, &[], self.0)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/VkDisplaySurfaceCreateFlagsKHR.html>
    #[repr(transparent)]
    #[derive(Copy, Clone, PartialEq, Eq, Hash)]
    pub struct DisplaySurfaceCreateFlagsKHR(Flags);
    vk_bitflags_wrapped!(DisplaySurfaceCreateFlagsKHR, Flags);

    impl fmt::Debug for DisplaySurfaceCreateFlagsKHR {
        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
            debug_flags(f, &[], self.0)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>
    pub type PFN_vkGetPhysicalDeviceDisplayPropertiesKHR = unsafe extern "system" fn(
        physical_device: PhysicalDevice,
        p_property_count: *mut u32,
        p_properties: *mut DisplayPropertiesKHR<'_>,
    )
        -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>
    pub type PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR =
        unsafe extern "system" fn(
            physical_device: PhysicalDevice,
            p_property_count: *mut u32,
            p_properties: *mut DisplayPlanePropertiesKHR,
        ) -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>
    pub type PFN_vkGetDisplayPlaneSupportedDisplaysKHR = unsafe extern "system" fn(
        physical_device: PhysicalDevice,
        plane_index: u32,
        p_display_count: *mut u32,
        p_displays: *mut DisplayKHR,
    )
        -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayModePropertiesKHR.html>
    pub type PFN_vkGetDisplayModePropertiesKHR = unsafe extern "system" fn(
        physical_device: PhysicalDevice,
        display: DisplayKHR,
        p_property_count: *mut u32,
        p_properties: *mut DisplayModePropertiesKHR,
    ) -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkCreateDisplayModeKHR.html>
    pub type PFN_vkCreateDisplayModeKHR = unsafe extern "system" fn(
        physical_device: PhysicalDevice,
        display: DisplayKHR,
        p_create_info: *const DisplayModeCreateInfoKHR<'_>,
        p_allocator: *const AllocationCallbacks<'_>,
        p_mode: *mut DisplayModeKHR,
    ) -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>
    pub type PFN_vkGetDisplayPlaneCapabilitiesKHR = unsafe extern "system" fn(
        physical_device: PhysicalDevice,
        mode: DisplayModeKHR,
        plane_index: u32,
        p_capabilities: *mut DisplayPlaneCapabilitiesKHR,
    ) -> vk::Result;
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkCreateDisplayPlaneSurfaceKHR.html>
    pub type PFN_vkCreateDisplayPlaneSurfaceKHR = unsafe extern "system" fn(
        instance: Instance,
        p_create_info: *const DisplaySurfaceCreateInfoKHR<'_>,
        p_allocator: *const AllocationCallbacks<'_>,
        p_surface: *mut SurfaceKHR,
    ) -> vk::Result;
}

#[cfg(feature = "ffi")]
pub(super) mod ffi {
    #![allow(non_camel_case_types)]
    use super::defs::*;

    pub type VkDisplayKHR = DisplayKHR;
    pub type VkDisplayModeKHR = DisplayModeKHR;
    pub type VkDisplayPropertiesKHR = DisplayPropertiesKHR<'static>;
    pub type VkDisplayPlanePropertiesKHR = DisplayPlanePropertiesKHR;
    pub type VkDisplayModeParametersKHR = DisplayModeParametersKHR;
    pub type VkDisplayModePropertiesKHR = DisplayModePropertiesKHR;
    pub type VkDisplayModeCreateInfoKHR = DisplayModeCreateInfoKHR<'static>;
    pub type VkDisplayPlaneCapabilitiesKHR = DisplayPlaneCapabilitiesKHR;
    pub type VkDisplaySurfaceCreateInfoKHR = DisplaySurfaceCreateInfoKHR<'static>;
    pub type VkDisplayPlaneAlphaFlagsKHR = DisplayPlaneAlphaFlagsKHR;
    pub type VkDisplayPlaneAlphaFlagBitsKHR = DisplayPlaneAlphaFlagBitsKHR;
    pub type VkDisplayModeCreateFlagsKHR = DisplayModeCreateFlagsKHR;
    pub type VkDisplaySurfaceCreateFlagsKHR = DisplaySurfaceCreateFlagsKHR;
    impl DisplayPropertiesKHR<'_> {
        #[inline]
        pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkDisplayPropertiesKHR {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl DisplayModeCreateInfoKHR<'_> {
        #[inline]
        pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkDisplayModeCreateInfoKHR {
            unsafe { core::mem::transmute(self) }
        }
    }
    impl DisplaySurfaceCreateInfoKHR<'_> {
        #[inline]
        pub unsafe fn drop_lifetime_for_ffi(&self) -> &VkDisplaySurfaceCreateInfoKHR {
            unsafe { core::mem::transmute(self) }
        }
    }
}

pub struct InstanceFn {
    get_physical_device_display_properties: PFN_vkGetPhysicalDeviceDisplayPropertiesKHR,
    get_physical_device_display_plane_properties: PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR,
    get_display_plane_supported_displays: PFN_vkGetDisplayPlaneSupportedDisplaysKHR,
    get_display_mode_properties: PFN_vkGetDisplayModePropertiesKHR,
    create_display_mode: PFN_vkCreateDisplayModeKHR,
    get_display_plane_capabilities: PFN_vkGetDisplayPlaneCapabilitiesKHR,
    create_display_plane_surface: PFN_vkCreateDisplayPlaneSurfaceKHR,
}

impl LoadInstanceFn for InstanceFn {
    unsafe fn load_with(
        load: impl Fn(&CStr) -> Option<PFN_vkVoidFunction>,
    ) -> core::result::Result<Self, MissingEntryPointError> {
        unsafe {
            Ok(Self {
                get_physical_device_display_properties: transmute(
                    load(c"vkGetPhysicalDeviceDisplayPropertiesKHR")
                        .ok_or(MissingEntryPointError)?,
                ),
                get_physical_device_display_plane_properties: transmute(
                    load(c"vkGetPhysicalDeviceDisplayPlanePropertiesKHR")
                        .ok_or(MissingEntryPointError)?,
                ),
                get_display_plane_supported_displays: transmute(
                    load(c"vkGetDisplayPlaneSupportedDisplaysKHR").ok_or(MissingEntryPointError)?,
                ),
                get_display_mode_properties: transmute(
                    load(c"vkGetDisplayModePropertiesKHR").ok_or(MissingEntryPointError)?,
                ),
                create_display_mode: transmute(
                    load(c"vkCreateDisplayModeKHR").ok_or(MissingEntryPointError)?,
                ),
                get_display_plane_capabilities: transmute(
                    load(c"vkGetDisplayPlaneCapabilitiesKHR").ok_or(MissingEntryPointError)?,
                ),
                create_display_plane_surface: transmute(
                    load(c"vkCreateDisplayPlaneSurfaceKHR").ok_or(MissingEntryPointError)?,
                ),
            })
        }
    }
}

impl InstanceFn {
    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceDisplayPropertiesKHR.html>
    #[inline]
    pub unsafe fn get_physical_device_display_properties<'a>(
        &self,
        physical_device: PhysicalDevice,
        mut properties: impl EnumerateInto<DisplayPropertiesKHR<'a>>,
    ) -> crate::Result<()> {
        unsafe {
            let call = |property_count, properties| {
                let result = (self.get_physical_device_display_properties)(
                    physical_device,
                    property_count,
                    properties as _,
                );

                match result {
                    VkResult::SUCCESS => Ok(()),
                    VkResult::INCOMPLETE => Ok(()),
                    err => Err(err),
                }
            };
            let mut len = 0;
            call(&mut len, std::ptr::null_mut())?;
            let capacity = len.try_into().expect("failed to convert `N` to usize");
            let properties_buf = properties.reserve(capacity);
            len = properties_buf.len().try_into().unwrap();
            let result = call(&mut len, properties_buf.as_mut_ptr() as *mut _)?;
            properties.set_len(len.try_into().unwrap());
            Ok(result)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceDisplayPlanePropertiesKHR.html>
    #[inline]
    pub unsafe fn get_physical_device_display_plane_properties(
        &self,
        physical_device: PhysicalDevice,
        mut properties: impl EnumerateInto<DisplayPlanePropertiesKHR>,
    ) -> crate::Result<()> {
        unsafe {
            let call = |property_count, properties| {
                let result = (self.get_physical_device_display_plane_properties)(
                    physical_device,
                    property_count,
                    properties as _,
                );

                match result {
                    VkResult::SUCCESS => Ok(()),
                    VkResult::INCOMPLETE => Ok(()),
                    err => Err(err),
                }
            };
            let mut len = 0;
            call(&mut len, std::ptr::null_mut())?;
            let capacity = len.try_into().expect("failed to convert `N` to usize");
            let properties_buf = properties.reserve(capacity);
            len = properties_buf.len().try_into().unwrap();
            let result = call(&mut len, properties_buf.as_mut_ptr() as *mut _)?;
            properties.set_len(len.try_into().unwrap());
            Ok(result)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayPlaneSupportedDisplaysKHR.html>
    #[inline]
    pub unsafe fn get_display_plane_supported_displays(
        &self,
        physical_device: PhysicalDevice,
        plane_index: u32,
        mut displays: impl EnumerateInto<DisplayKHR>,
    ) -> crate::Result<()> {
        unsafe {
            let call = |display_count, displays| {
                let result = (self.get_display_plane_supported_displays)(
                    physical_device,
                    plane_index,
                    display_count,
                    displays as _,
                );

                match result {
                    VkResult::SUCCESS => Ok(()),
                    VkResult::INCOMPLETE => Ok(()),
                    err => Err(err),
                }
            };
            let mut len = 0;
            call(&mut len, std::ptr::null_mut())?;
            let capacity = len.try_into().expect("failed to convert `N` to usize");
            let displays_buf = displays.reserve(capacity);
            len = displays_buf.len().try_into().unwrap();
            let result = call(&mut len, displays_buf.as_mut_ptr() as *mut _)?;
            displays.set_len(len.try_into().unwrap());
            Ok(result)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayModePropertiesKHR.html>
    #[inline]
    pub unsafe fn get_display_mode_properties(
        &self,
        physical_device: PhysicalDevice,
        display: DisplayKHR,
        mut properties: impl EnumerateInto<DisplayModePropertiesKHR>,
    ) -> crate::Result<()> {
        unsafe {
            let call = |property_count, properties| {
                let result = (self.get_display_mode_properties)(
                    physical_device,
                    display,
                    property_count,
                    properties as _,
                );

                match result {
                    VkResult::SUCCESS => Ok(()),
                    VkResult::INCOMPLETE => Ok(()),
                    err => Err(err),
                }
            };
            let mut len = 0;
            call(&mut len, std::ptr::null_mut())?;
            let capacity = len.try_into().expect("failed to convert `N` to usize");
            let properties_buf = properties.reserve(capacity);
            len = properties_buf.len().try_into().unwrap();
            let result = call(&mut len, properties_buf.as_mut_ptr() as *mut _)?;
            properties.set_len(len.try_into().unwrap());
            Ok(result)
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkCreateDisplayModeKHR.html>
    #[inline]
    pub unsafe fn create_display_mode(
        &self,
        physical_device: PhysicalDevice,
        display: DisplayKHR,
        create_info: &DisplayModeCreateInfoKHR<'_>,
        allocator: Option<&AllocationCallbacks<'_>>,
    ) -> crate::Result<DisplayModeKHR> {
        unsafe {
            let mut mode = core::mem::MaybeUninit::uninit();
            let result = (self.create_display_mode)(
                physical_device,
                display,
                create_info,
                allocator.to_raw_ptr(),
                mode.as_mut_ptr(),
            );

            match result {
                VkResult::SUCCESS => Ok(mode.assume_init()),
                err => Err(err),
            }
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetDisplayPlaneCapabilitiesKHR.html>
    #[inline]
    pub unsafe fn get_display_plane_capabilities(
        &self,
        physical_device: PhysicalDevice,
        mode: DisplayModeKHR,
        plane_index: u32,
    ) -> crate::Result<DisplayPlaneCapabilitiesKHR> {
        unsafe {
            let mut capabilities = core::mem::MaybeUninit::uninit();
            let result = (self.get_display_plane_capabilities)(
                physical_device,
                mode,
                plane_index,
                capabilities.as_mut_ptr(),
            );

            match result {
                VkResult::SUCCESS => Ok(capabilities.assume_init()),
                err => Err(err),
            }
        }
    }

    /// <https://registry.khronos.org/vulkan/specs/latest/man/html/vkCreateDisplayPlaneSurfaceKHR.html>
    #[inline]
    pub unsafe fn create_display_plane_surface(
        &self,
        instance: Instance,
        create_info: &DisplaySurfaceCreateInfoKHR<'_>,
        allocator: Option<&AllocationCallbacks<'_>>,
    ) -> crate::Result<SurfaceKHR> {
        unsafe {
            let mut surface = core::mem::MaybeUninit::uninit();
            let result = (self.create_display_plane_surface)(
                instance,
                create_info,
                allocator.to_raw_ptr(),
                surface.as_mut_ptr(),
            );

            match result {
                VkResult::SUCCESS => Ok(surface.assume_init()),
                err => Err(err),
            }
        }
    }
}