maia/
types.rs

1// Copyright 2022 Google LLC
2
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use crate::enums::*;
10use crate::error::Error;
11use crate::ffi::*;
12use std::fmt::Debug;
13pub(crate) use std::sync::Arc;
14
15use std::num::NonZeroI32;
16
17#[repr(transparent)]
18#[derive(Debug, PartialEq, Eq, Copy, Clone)]
19/// A VkResult with a code other than VK_SUCCESS.
20pub struct VkError(pub NonZeroI32);
21
22impl std::fmt::Display for VkError {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        Debug::fmt(self, f)
25    }
26}
27impl std::error::Error for VkError {}
28
29#[doc = crate::man_link!(VkResult)]
30pub type VkResult = std::result::Result<(), VkError>;
31
32// Check that VkResult corresponds to Vulkan's definition. This allows wrapper
33// functions to use '?'.
34const _: () = assert!(std::mem::size_of::<VkResult>() == 4);
35const _: () =
36    assert!(unsafe { std::mem::transmute::<i32, VkResult>(0).is_ok() });
37const _EXPECTED: VkResult =
38    Err(VkError(unsafe { NonZeroI32::new_unchecked(-1) }));
39const _: () = assert!(matches!(
40    unsafe { std::mem::transmute::<i32, VkResult>(-1) },
41    _EXPECTED
42));
43
44#[doc = crate::man_link!(VK_DEFINE_HANDLE)]
45#[repr(transparent)]
46#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
47pub struct NonNullDispatchableHandle(NonNull<c_void>);
48#[doc = crate::man_link!(VK_DEFINE_NON_DISPATCHABLE_HANDLE)]
49#[repr(transparent)]
50#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
51pub struct NonNullNonDispatchableHandle(std::num::NonZeroU64);
52
53impl Debug for NonNullDispatchableHandle {
54    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55        f.write_fmt(format_args!("{:?}", self.0))
56    }
57}
58
59impl Debug for NonNullNonDispatchableHandle {
60    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61        f.write_fmt(format_args!("{:#x}", self.0))
62    }
63}
64
65// This hides its pointer and is thus thread safe. Theoretically, if we actually
66// used raw handle types anywhere they would be !Send + !Sync and the thread
67// safety would be provided by Handle, Ref, and Mut. But this appears
68// unneccesary.
69unsafe impl Send for NonNullDispatchableHandle {}
70unsafe impl Sync for NonNullDispatchableHandle {}
71impl std::panic::UnwindSafe for NonNullDispatchableHandle {}
72impl std::panic::RefUnwindSafe for NonNullDispatchableHandle {}
73
74/// Owned Vulkan handle.
75#[repr(transparent)]
76#[derive(PartialEq, Eq, Hash)]
77pub struct Handle<T> {
78    _value: T,
79}
80impl<T: Debug> Debug for Handle<T> {
81    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
82        self._value.fmt(f)
83    }
84}
85impl<T: Copy> Handle<T> {
86    /// Borrow the object
87    pub fn borrow(&self) -> Ref<'_, T> {
88        Ref { _value: self._value, _lt: PhantomData }
89    }
90    /// Mutably borrow the object
91    pub fn borrow_mut(&mut self) -> Mut<'_, T> {
92        Mut { _value: self._value, _lt: PhantomData }
93    }
94    /// Make a copy of the handle
95    /// # Safety
96    /// The caller must ensure that uses of the result are externally
97    /// synchronized as defined by Vulkan.
98    pub unsafe fn clone(&self) -> Self {
99        Self { ..*self }
100    }
101    /// Mutably borrow the object from a shared reference
102    /// # Safety
103    /// The caller must ensure that uses of the result are externally
104    /// synchronized as defined by Vulkan.
105    pub unsafe fn borrow_mut_unchecked(&self) -> Mut<'_, T> {
106        Mut { _value: self._value, _lt: PhantomData }
107    }
108}
109
110/// Borrowed Vulkan handle. Has the same representation as a Vulkan handle but
111/// carries a lifetime.
112#[repr(transparent)]
113#[derive(Copy, Clone, PartialEq, Eq)]
114pub struct Ref<'a, T> {
115    _value: T,
116    _lt: PhantomData<&'a T>,
117}
118impl<T: Debug> Debug for Ref<'_, T> {
119    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120        self._value.fmt(f)
121    }
122}
123
124/// Mutably borrowed Vulkan handle. Has the same representation as a Vulkan handle but
125/// carries a lifetime.
126#[repr(transparent)]
127pub struct Mut<'a, T> {
128    _value: T,
129    _lt: PhantomData<&'a T>,
130}
131impl<T: Debug> Debug for Mut<'_, T> {
132    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
133        self._value.fmt(f)
134    }
135}
136impl<'a, T: Copy> Mut<'a, T> {
137    /// Reborrow as a shared reference
138    // Note that this cannot be used to extend 'a, since &'b Self<'a>
139    // requires 'a: 'b
140    pub fn reborrow(&self) -> Ref<'_, T> {
141        Ref { _value: self._value, _lt: PhantomData }
142    }
143    /// Reborrow as a mutable reference
144    pub fn reborrow_mut(&mut self) -> Mut<'_, T> {
145        Self { ..*self }
146    }
147    /// Reborrow as a mutable reference with a new lifetime.
148    /// # Safety
149    /// The caller must ensure that uses of the result are externally
150    /// synchronized as defined by Vulkan. Note that this is more unsafe than
151    /// the other unchecked borrows, since it allows the lifetime to be extended
152    pub unsafe fn reborrow_mut_unchecked<'b>(&mut self) -> Mut<'b, T> {
153        Mut { _value: self._value, _lt: PhantomData }
154    }
155}
156
157macro_rules! raw_handle {
158    ($name:ident($kind:ident)) => {
159        #[repr(transparent)]
160        #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
161        /// Raw Vulkan handle. Used either in owned form ([`Handle`]), borrowed
162        /// form ([`Ref`]), or exclusive borrowed form ([`Mut`]).
163        pub struct $name($kind);
164    };
165}
166
167raw_handle!(VkInstance(NonNullDispatchableHandle));
168raw_handle!(VkPhysicalDevice(NonNullDispatchableHandle));
169raw_handle!(VkDevice(NonNullDispatchableHandle));
170raw_handle!(VkQueue(NonNullDispatchableHandle));
171
172raw_handle!(VkDeviceMemory(NonNullNonDispatchableHandle));
173raw_handle!(VkSemaphore(NonNullNonDispatchableHandle));
174raw_handle!(VkFence(NonNullNonDispatchableHandle));
175raw_handle!(VkSampler(NonNullNonDispatchableHandle));
176raw_handle!(VkDescriptorSetLayout(NonNullNonDispatchableHandle));
177raw_handle!(VkDescriptorPool(NonNullNonDispatchableHandle));
178raw_handle!(VkDescriptorSet(NonNullNonDispatchableHandle));
179raw_handle!(VkPipelineLayout(NonNullNonDispatchableHandle));
180raw_handle!(VkPipelineCache(NonNullNonDispatchableHandle));
181raw_handle!(VkPipeline(NonNullNonDispatchableHandle));
182raw_handle!(VkBuffer(NonNullNonDispatchableHandle));
183raw_handle!(VkBufferView(NonNullNonDispatchableHandle));
184raw_handle!(VkImage(NonNullNonDispatchableHandle));
185raw_handle!(VkImageView(NonNullNonDispatchableHandle));
186raw_handle!(VkFramebuffer(NonNullNonDispatchableHandle));
187raw_handle!(VkRenderPass(NonNullNonDispatchableHandle));
188raw_handle!(VkShaderModule(NonNullNonDispatchableHandle));
189raw_handle!(VkCommandPool(NonNullNonDispatchableHandle));
190raw_handle!(VkCommandBuffer(NonNullNonDispatchableHandle));
191raw_handle!(VkSurfaceKHR(NonNullNonDispatchableHandle));
192raw_handle!(VkSwapchainKHR(NonNullNonDispatchableHandle));
193
194/// u32 with only one allowed value
195macro_rules! structure_type {
196    ($name: ident, $value: literal) => {
197        #[repr(u32)]
198        #[derive(Debug)]
199        /// [Structure type](https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkStructureType.html) constant
200        #[doc = concat!("(", stringify!($value), ")")]
201        pub enum $name {
202            #[doc = "Has the value "]
203            #[doc = stringify!($value)]
204            Value = $value,
205        }
206        impl Default for $name {
207            fn default() -> Self {
208                Self::Value
209            }
210        }
211    };
212}
213
214#[repr(C)]
215#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
216pub struct Extent2D {
217    pub width: u32,
218    pub height: u32,
219}
220
221impl Extent2D {
222    /// Create a new `Extent2D` object
223    pub fn new(width: u32, height: u32) -> Self {
224        Self { width, height }
225    }
226}
227
228#[repr(C)]
229#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
230pub struct Extent3D {
231    pub width: u32,
232    pub height: u32,
233    pub depth: u32,
234}
235
236impl Extent3D {
237    /// Create a new `Extent3D` object
238    pub fn new(width: u32, height: u32, depth: u32) -> Self {
239        Self { width, height, depth }
240    }
241}
242
243impl From<Extent2D> for Extent3D {
244    fn from(e: Extent2D) -> Self {
245        Self { width: e.width, height: e.height, depth: 1 }
246    }
247}
248
249#[repr(C)]
250#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
251pub struct Offset2D {
252    pub x: i32,
253    pub y: i32,
254}
255
256impl Offset2D {
257    /// Create a new `Offeset2D` object
258    pub fn new(x: i32, y: i32) -> Self {
259        Self { x, y }
260    }
261}
262
263#[repr(C)]
264#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
265pub struct Offset3D {
266    pub x: i32,
267    pub y: i32,
268    pub z: i32,
269}
270
271impl Offset3D {
272    /// Create a new `Offeset3D` object
273    pub fn new(x: i32, y: i32, z: i32) -> Self {
274        Self { x, y, z }
275    }
276}
277
278#[repr(C)]
279#[derive(Debug, Clone, Copy, Default)]
280pub struct Rect2D {
281    pub offset: Offset2D,
282    pub extent: Extent2D,
283}
284
285#[repr(C)]
286#[derive(Clone, Copy)]
287#[doc = crate::man_link!(VkClearColorValue)]
288pub union ClearColorValue {
289    pub f32: [f32; 4],
290    pub i32: [i32; 4],
291    pub u32: [u32; 4],
292}
293impl Default for ClearColorValue {
294    /// Black for any format
295    fn default() -> Self {
296        Self { u32: [0, 0, 0, 0] }
297    }
298}
299
300#[repr(C)]
301#[derive(Clone, Copy)]
302#[doc = crate::man_link!(VkClearDepthStencilValue)]
303pub struct ClearDepthStencilValue {
304    pub depth: f32,
305    pub stencil: u32,
306}
307
308// Safety: If the user initializes the wrong member, leaving the struct partly
309// uninitialized, the uninitialized value is never read by *rust*, only passed
310// over the ffi.
311
312#[repr(C)]
313#[derive(Clone, Copy)]
314#[doc = crate::man_link!(VkClearValue)]
315pub union ClearValue {
316    pub color: ClearColorValue,
317    pub depth_stencil: ClearDepthStencilValue,
318}
319
320impl Default for ClearValue {
321    /// Black for color, zero for depth/stencil
322    fn default() -> Self {
323        Self { color: Default::default() }
324    }
325}
326
327#[repr(C)]
328#[derive(Debug, Clone, Copy)]
329#[doc = crate::man_link!(VkImageSubresourceRange)]
330pub struct ImageSubresourceRange {
331    pub aspect_mask: ImageAspectFlags,
332    pub base_mip_level: u32,
333    pub level_count: u32,
334    pub base_array_layer: u32,
335    pub layer_count: u32,
336}
337
338impl Default for ImageSubresourceRange {
339    /// The entirety of a color image
340    fn default() -> Self {
341        Self {
342            aspect_mask: ImageAspectFlags::COLOR,
343            base_mip_level: 0,
344            level_count: u32::MAX,
345            base_array_layer: 0,
346            layer_count: u32::MAX,
347        }
348    }
349}
350
351#[repr(C)]
352#[derive(Debug, Clone, Copy)]
353#[doc = crate::man_link!(VkImageSubresourceLayers)]
354pub struct ImageSubresourceLayers {
355    pub aspect_mask: ImageAspectFlags,
356    pub mip_level: u32,
357    pub base_array_layer: u32,
358    pub layer_count: u32,
359}
360
361impl Default for ImageSubresourceLayers {
362    /// The first level and layer of a color image
363    fn default() -> Self {
364        Self {
365            aspect_mask: ImageAspectFlags::COLOR,
366            mip_level: 0,
367            base_array_layer: 0,
368            layer_count: 1,
369        }
370    }
371}
372
373#[repr(C)]
374#[derive(Debug, Clone, Copy, Default)]
375#[doc = crate::man_link!(VkImageBlit)]
376pub struct ImageBlit {
377    pub src_subresource: ImageSubresourceLayers,
378    pub src_offsets: [Offset3D; 2],
379    pub dst_subresource: ImageSubresourceLayers,
380    pub dst_offsets: [Offset3D; 2],
381}
382
383#[repr(C)]
384#[derive(Debug, Clone, Copy, Default)]
385#[doc = crate::man_link!(VkComponentMapping)]
386pub struct ComponentMapping {
387    pub r: ComponentSwizzle,
388    pub g: ComponentSwizzle,
389    pub b: ComponentSwizzle,
390    pub a: ComponentSwizzle,
391}
392
393#[repr(C)]
394#[derive(Debug, Clone, Copy, Default)]
395#[doc = crate::man_link!(VkViewport)]
396pub struct Viewport {
397    pub x: f32,
398    pub y: f32,
399    pub width: f32,
400    pub height: f32,
401    pub min_depth: f32,
402    pub max_depth: f32,
403}
404
405#[repr(C)]
406#[derive(Debug, Clone, Copy)]
407#[doc = crate::man_link!(VkMemoryType)]
408pub struct MemoryType {
409    pub property_flags: MemoryPropertyFlags,
410    pub heap_index: u32,
411}
412
413#[repr(C)]
414#[derive(Debug, Clone, Copy)]
415#[doc = crate::man_link!(VkMemoryHeap)]
416pub struct MemoryHeap {
417    pub size: u64,
418    pub flags: MemoryHeapFlags,
419}
420
421#[repr(C)]
422#[derive(Debug, Default)]
423#[doc = crate::man_link!(VkPhysicalDeviceMemoryProperties)]
424pub struct PhysicalDeviceMemoryProperties {
425    pub memory_types: InlineSlice<MemoryType, 32>,
426    pub memory_heaps: InlineSlice<MemoryHeap, 16>,
427}
428
429#[repr(C)]
430#[derive(Debug, Default)]
431#[doc = crate::man_link!(VkMemoryRequirements)]
432pub struct MemoryRequirements {
433    pub size: u64,
434    pub alignment: u64,
435    pub memory_type_bits: u32,
436}
437
438impl MemoryRequirements {
439    pub(crate) fn clear_host_visible_types(
440        &mut self, props: &PhysicalDeviceMemoryProperties,
441    ) {
442        for (i, ty) in props.memory_types.iter().enumerate() {
443            if ty.property_flags.contains(MemoryPropertyFlags::HOST_VISIBLE) {
444                self.memory_type_bits &= !(1 << i);
445            }
446        }
447    }
448}
449
450#[repr(C)]
451#[derive(Debug, Default)]
452#[doc = crate::man_link!(VkBufferCopy)]
453pub struct BufferCopy {
454    pub src_offset: u64,
455    pub dst_offset: u64,
456    pub size: u64,
457}
458
459#[repr(C)]
460#[derive(Debug, Default)]
461#[doc = crate::man_link!(VkBufferImageCopy)]
462pub struct BufferImageCopy {
463    pub buffer_offset: u64,
464    pub buffer_row_length: u32,
465    pub buffer_image_height: u32,
466    pub image_subresource: ImageSubresourceLayers,
467    pub image_offset: Offset3D,
468    pub image_extent: Extent3D,
469}
470
471/// Not implemented
472pub enum AllocationCallbacks {}
473
474#[repr(C)]
475#[derive(Debug, Default)]
476#[doc = crate::man_link!(VkInstanceCreateInfo)]
477pub struct InstanceCreateInfo<'a, Next = Null, AINext = Null> {
478    pub stype: InstanceCreateInfoType,
479    pub next: Next,
480    pub flags: InstanceCreateFlags,
481    pub application_info: Option<&'a ApplicationInfo<'a, AINext>>,
482    pub enabled_layer_names: Slice<'a, Str<'a>>,
483    pub enabled_extension_names: Slice<'a, Str<'a>>,
484}
485structure_type!(InstanceCreateInfoType, 1);
486
487#[repr(C)]
488#[derive(Debug, Default)]
489#[doc = crate::man_link!(VkApplicationInfo)]
490pub struct ApplicationInfo<'a, Next> {
491    pub stype: ApplicationInfoType,
492    pub next: Next,
493    pub application_name: Str<'a>,
494    pub application_version: u32,
495    pub engine_name: Str<'a>,
496    pub engine_version: u32,
497    pub api_version: u32,
498}
499structure_type!(ApplicationInfoType, 0);
500
501#[repr(C)]
502#[derive(Debug)]
503#[doc = crate::man_link!(VkExtensionProperties)]
504pub struct ExtensionProperties {
505    pub extension_name: CharArray<MAX_EXTENSION_NAME_SIZE>,
506    pub spec_version: u32,
507}
508
509pub const MAX_EXTENSION_NAME_SIZE: usize = 256;
510
511#[repr(C)]
512#[derive(Debug)]
513#[doc = crate::man_link!(VkPhysicalDeviceProperties)]
514pub struct PhysicalDeviceProperties {
515    pub api_version: u32,
516    pub driver_version: u32,
517    pub vendor_id: u32,
518    pub device_id: u32,
519    pub device_type: PhysicalDeviceType,
520    pub device_name: CharArray<MAX_PHYSICAL_DEVICE_NAME_SIZE>,
521    pub pipeline_cache_uuid: UUID,
522    pub limits: PhysicalDeviceLimits,
523    pub sparse_properties: PhysicalDeviceSparseProperties,
524}
525
526pub const MAX_PHYSICAL_DEVICE_NAME_SIZE: usize = 256;
527
528#[repr(C)]
529#[derive(Debug)]
530#[doc = crate::man_link!(VkPhysicalDeviceLimits)]
531pub struct PhysicalDeviceLimits {
532    pub max_image_dimension_1d: u32,
533    pub max_image_dimension_2d: u32,
534    pub max_image_dimension_3d: u32,
535    pub max_image_dimension_cube: u32,
536    pub max_image_array_layers: u32,
537    pub max_texel_buffer_elements: u32,
538    pub max_uniform_buffer_range: u32,
539    pub max_storage_buffer_range: u32,
540    pub max_push_constants_size: u32,
541    pub max_memory_allocation_count: u32,
542    pub max_sampler_allocation_count: u32,
543    pub buffer_image_granularity: u64,
544    pub sparse_address_space_size: u64,
545    pub max_bound_descriptor_sets: u32,
546    pub max_per_stage_descriptor_samplers: u32,
547    pub max_per_stage_descriptor_uniform_buffers: u32,
548    pub max_per_stage_descriptor_storage_buffers: u32,
549    pub max_per_stage_descriptor_sampled_images: u32,
550    pub max_per_stage_descriptor_storage_images: u32,
551    pub max_per_stage_descriptor_input_attachments: u32,
552    pub max_per_stage_resources: u32,
553    pub max_descriptor_set_samplers: u32,
554    pub max_descriptor_set_uniform_buffers: u32,
555    pub max_descriptor_set_uniform_buffers_dynamic: u32,
556    pub max_descriptor_set_storage_buffers: u32,
557    pub max_descriptor_set_storage_buffers_dynamic: u32,
558    pub max_descriptor_set_sampled_images: u32,
559    pub max_descriptor_set_storage_images: u32,
560    pub max_descriptor_set_input_attachments: u32,
561    pub max_vertex_input_attributes: u32,
562    pub max_vertex_input_bindings: u32,
563    pub max_vertex_input_attribute_offset: u32,
564    pub max_vertex_input_binding_stride: u32,
565    pub max_vertex_output_components: u32,
566    pub max_tessellation_generation_level: u32,
567    pub max_tessellation_patch_size: u32,
568    pub max_tessellation_control_per_vertex_input_components: u32,
569    pub max_tessellation_control_per_vertex_output_components: u32,
570    pub max_tessellation_control_per_patch_output_components: u32,
571    pub max_tessellation_control_total_output_components: u32,
572    pub max_tessellation_evaluation_input_components: u32,
573    pub max_tessellation_evaluation_output_components: u32,
574    pub max_geometry_shader_invocations: u32,
575    pub max_geometry_input_components: u32,
576    pub max_geometry_output_components: u32,
577    pub max_geometry_output_vertices: u32,
578    pub max_geometry_total_output_components: u32,
579    pub max_fragment_input_components: u32,
580    pub max_fragment_output_attachments: u32,
581    pub max_fragment_dual_src_attachments: u32,
582    pub max_fragment_combined_output_resources: u32,
583    pub max_compute_shared_memory_size: u32,
584    pub max_compute_work_group_count: [u32; 3],
585    pub max_compute_work_group_invocations: u32,
586    pub max_compute_work_group_size: [u32; 3],
587    pub sub_pixel_precision_bits: u32,
588    pub sub_texel_precision_bits: u32,
589    pub mipmap_precision_bits: u32,
590    pub max_draw_indexed_index_value: u32,
591    pub max_draw_indirect_count: u32,
592    pub max_sampler_lod_bias: f32,
593    pub max_sampler_anisotropy: f32,
594    pub max_viewports: u32,
595    pub max_viewport_dimensions: [u32; 2],
596    pub viewport_bounds_range: [f32; 2],
597    pub viewport_sub_pixel_bits: u32,
598    pub min_memory_map_alignment: usize,
599    pub min_texel_buffer_offset_alignment: u64,
600    pub min_uniform_buffer_offset_alignment: u64,
601    pub min_storage_buffer_offset_alignment: u64,
602    pub min_texel_offset: i32,
603    pub max_texel_offset: u32,
604    pub min_texel_gather_offset: i32,
605    pub max_texel_gather_offset: u32,
606    pub min_interpolation_offset: f32,
607    pub max_interpolation_offset: f32,
608    pub sub_pixel_interpolation_offset_bits: u32,
609    pub max_framebuffer_width: u32,
610    pub max_framebuffer_height: u32,
611    pub max_framebuffer_layers: u32,
612    pub framebuffer_color_sample_counts: SampleCountFlags,
613    pub framebuffer_depth_sample_counts: SampleCountFlags,
614    pub framebuffer_stencil_sample_counts: SampleCountFlags,
615    pub framebuffer_no_attachments_sample_counts: SampleCountFlags,
616    pub max_color_attachments: u32,
617    pub sampled_image_color_sample_counts: SampleCountFlags,
618    pub sampled_image_integer_sample_counts: SampleCountFlags,
619    pub sampled_image_depth_sample_counts: SampleCountFlags,
620    pub sampled_image_stencil_sample_counts: SampleCountFlags,
621    pub storage_image_sample_counts: SampleCountFlags,
622    pub max_sample_mask_words: u32,
623    pub timestamp_compute_and_graphics: Bool,
624    pub timestamp_period: f32,
625    pub max_clip_distances: u32,
626    pub max_cull_distances: u32,
627    pub max_combined_clip_and_cull_distances: u32,
628    pub discrete_queue_priorities: u32,
629    pub point_size_range: [f32; 2],
630    pub line_width_range: [f32; 2],
631    pub point_size_granularity: f32,
632    pub line_width_granularity: f32,
633    pub strict_lines: Bool,
634    pub standard_sample_locations: Bool,
635    pub optimal_buffer_copy_offset_alignment: u64,
636    pub optimal_buffer_copy_row_pitch_alignment: u64,
637    pub non_coherent_atom_size: u64,
638}
639
640#[repr(C)]
641#[derive(Debug)]
642#[doc = crate::man_link!(VkPhysicalDeviceSparseProperties)]
643pub struct PhysicalDeviceSparseProperties {
644    pub residency_standard_2d_block_shape: Bool,
645    pub residency_standard_2d_multisample_block_shape: Bool,
646    pub residency_standard_3d_block_shape: Bool,
647    pub residency_aligned_mip_size: Bool,
648    pub residency_non_resident_strict: Bool,
649}
650
651#[repr(C)]
652#[derive(Debug)]
653#[doc = crate::man_link!(VkQueueFamilyProperties)]
654pub struct QueueFamilyProperties {
655    pub queue_flags: QueueFlags,
656    pub queue_count: u32,
657    pub timestamp_valid_bits: u32,
658    pub min_image_transfer_granularity: Extent3D,
659}
660
661#[repr(C)]
662#[derive(Debug, Default)]
663#[doc = crate::man_link!(VkDeviceCreateInfo)]
664pub struct DeviceCreateInfo<'a, Next = Null> {
665    pub stype: DeviceCreateInfoType,
666    pub next: Next,
667    pub flags: DeviceCreateFlags,
668    pub queue_create_infos: Slice_<'a, DeviceQueueCreateInfo<'a>>,
669    pub enabled_layer_names: Slice<'a, Str<'a>>,
670    pub enabled_extension_names: Slice<'a, Str<'a>>,
671    pub enabled_features: Option<&'a PhysicalDeviceFeatures>,
672}
673structure_type!(DeviceCreateInfoType, 3);
674
675#[repr(C)]
676#[derive(Debug, Default)]
677#[doc = crate::man_link!(VkDeviceQueueCreateInfo)]
678pub struct DeviceQueueCreateInfo<'a, Next = Null> {
679    pub stype: DeviceQueueCreateInfoType,
680    pub next: Next,
681    pub flags: DeviceQueueCreateFlags,
682    pub queue_family_index: u32,
683    pub queue_priorities: Slice<'a, f32>,
684}
685structure_type!(DeviceQueueCreateInfoType, 2);
686
687#[repr(C)]
688#[derive(Clone, Default, Debug)]
689#[doc = crate::man_link!(VkPhysicalDeviceFeatures)]
690pub struct PhysicalDeviceFeatures {
691    pub robust_buffer_access: Bool,
692    pub full_draw_index_uint32: Bool,
693    pub image_cube_array: Bool,
694    pub independent_blend: Bool,
695    pub geometry_shader: Bool,
696    pub tessellation_shader: Bool,
697    pub sample_rate_shading: Bool,
698    pub dual_src_blend: Bool,
699    pub logic_op: Bool,
700    pub multi_draw_indirect: Bool,
701    pub draw_indirect_first_instance: Bool,
702    pub depth_clamp: Bool,
703    pub depth_bias_clamp: Bool,
704    pub fill_mode_non_solid: Bool,
705    pub depth_bounds: Bool,
706    pub wide_lines: Bool,
707    pub large_points: Bool,
708    pub alpha_to_one: Bool,
709    pub multi_viewport: Bool,
710    pub sampler_anisotropy: Bool,
711    pub texture_compression_etc2: Bool,
712    pub texture_compression_astc_ldr: Bool,
713    pub texture_compression_bc: Bool,
714    pub occlusion_query_precise: Bool,
715    pub pipeline_statistics_query: Bool,
716    pub vertex_pipeline_stores_and_atomics: Bool,
717    pub fragment_stores_and_atomics: Bool,
718    pub shader_tessellation_and_geometry_point_size: Bool,
719    pub shader_image_gather_extended: Bool,
720    pub shader_storage_image_extended_formats: Bool,
721    pub shader_storage_image_multisample: Bool,
722    pub shader_storage_image_read_without_format: Bool,
723    pub shader_storage_image_write_without_format: Bool,
724    pub shader_uniform_buffer_array_dynamic_indexing: Bool,
725    pub shader_sampled_image_array_dynamic_indexing: Bool,
726    pub shader_storage_buffer_array_dynamic_indexing: Bool,
727    pub shader_storage_image_array_dynamic_indexing: Bool,
728    pub shader_clip_distance: Bool,
729    pub shader_cull_distance: Bool,
730    pub shader_float64: Bool,
731    pub shader_int64: Bool,
732    pub shader_int16: Bool,
733    pub shader_resource_residency: Bool,
734    pub shader_resource_min_lod: Bool,
735    pub sparse_binding: Bool,
736    pub sparse_residency_buffer: Bool,
737    pub sparse_residency_image_2d: Bool,
738    pub sparse_residency_image_3d: Bool,
739    pub sparse_residency2_samples: Bool,
740    pub sparse_residency4_samples: Bool,
741    pub sparse_residency8_samples: Bool,
742    pub sparse_residency16_samples: Bool,
743    pub sparse_residency_aliased: Bool,
744    pub variable_multisample_rate: Bool,
745    pub inherited_queries: Bool,
746}
747
748#[repr(C)]
749#[derive(Debug, Default)]
750#[doc = crate::man_link!(VkSubmitInfo)]
751pub struct VkSubmitInfo<'a, Next = Null> {
752    pub stype: SubmitInfoType,
753    pub next: Next,
754    pub wait_semaphores: Slice<'a, Ref<'a, VkSemaphore>>,
755    // Safety: Must be same length as wait_semaphores
756    pub wait_stage_masks: Option<Array<'a, PipelineStageFlags>>,
757    pub command_buffers: Slice<'a, Mut<'a, VkCommandBuffer>>,
758    pub signal_semaphores: Slice<'a, Ref<'a, VkSemaphore>>,
759}
760structure_type!(SubmitInfoType, 4);
761
762#[repr(C)]
763#[derive(Debug, Default)]
764#[doc = crate::man_link!(VkMemoryAllocateInfo)]
765pub struct MemoryAllocateInfo<Next = Null> {
766    pub stype: MemoryAllocateInfoType,
767    pub next: Next,
768    pub allocation_size: u64,
769    pub memory_type_index: u32,
770}
771structure_type!(MemoryAllocateInfoType, 5);
772
773#[repr(C)]
774#[derive(Debug, Default)]
775#[doc = crate::man_link!(VkFenceCreateInfo)]
776pub struct FenceCreateInfo<Next = Null> {
777    pub stype: FenceCreateInfoType,
778    pub next: Next,
779    pub flags: FenceCreateFlags,
780}
781structure_type!(FenceCreateInfoType, 8);
782
783#[repr(C)]
784#[derive(Debug, Default)]
785#[doc = crate::man_link!(VkSemaphoreCreateInfo)]
786pub struct SemaphoreCreateInfo<Next = Null> {
787    pub stype: SemaphoreCreateInfoType,
788    pub next: Next,
789    pub flags: SemaphoreCreateFlags,
790}
791structure_type!(SemaphoreCreateInfoType, 9);
792
793#[repr(C)]
794#[derive(Debug, Default)]
795#[doc = crate::man_link!(VkBufferCreateInfo)]
796pub struct BufferCreateInfo<'a, Next = Null> {
797    pub stype: BufferCreateInfoType,
798    pub next: Next,
799    pub flags: BufferCreateFlags,
800    pub size: u64,
801    pub usage: BufferUsageFlags,
802    pub sharing_mode: SharingMode,
803    pub queue_family_indices: Slice<'a, u32>,
804}
805structure_type!(BufferCreateInfoType, 12);
806
807#[repr(C)]
808#[derive(Debug)]
809#[doc = crate::man_link!(VkImageCreateInfo)]
810pub struct ImageCreateInfo<'a, Next = Null> {
811    pub stype: ImageCreateInfoType,
812    pub next: Next,
813    pub flags: ImageCreateFlags,
814    pub image_type: ImageType,
815    pub format: Format,
816    pub extent: Extent3D,
817    pub mip_levels: u32,
818    pub array_layers: u32,
819    pub samples: SampleCount,
820    pub tiling: ImageTiling,
821    pub usage: ImageUsageFlags,
822    pub sharing_mode: SharingMode,
823    pub queue_family_indices: Slice<'a, u32>,
824    pub initial_layout: ImageLayout,
825}
826structure_type!(ImageCreateInfoType, 14);
827
828impl<'a> Default for ImageCreateInfo<'a> {
829    fn default() -> Self {
830        Self {
831            stype: Default::default(),
832            next: Default::default(),
833            flags: Default::default(),
834            image_type: Default::default(),
835            format: Default::default(),
836            extent: Default::default(),
837            mip_levels: 1,
838            array_layers: 1,
839            samples: Default::default(),
840            tiling: Default::default(),
841            usage: Default::default(),
842            sharing_mode: Default::default(),
843            queue_family_indices: Default::default(),
844            initial_layout: Default::default(),
845        }
846    }
847}
848
849#[repr(C)]
850#[derive(Debug)]
851#[doc = crate::man_link!(VkImageViewCreateInfo)]
852pub struct VkImageViewCreateInfo<'a, Next = Null> {
853    pub stype: ImageViewCreateInfoType,
854    pub next: Next,
855    pub flags: ImageViewCreateFlags,
856    pub image: Ref<'a, VkImage>,
857    pub view_type: ImageViewType,
858    pub format: Format,
859    pub components: ComponentMapping,
860    pub subresource_range: ImageSubresourceRange,
861}
862structure_type!(ImageViewCreateInfoType, 15);
863
864#[repr(C)]
865#[derive(Debug)]
866#[doc = crate::man_link!(VkShaderModuleCreateInfo)]
867pub struct VkShaderModuleCreateInfo<'a, Next = Null> {
868    pub stype: ShaderModuleCreateInfoType,
869    pub next: Next,
870    pub flags: ShaderModuleCreateFlags,
871    pub code: Bytes<'a>,
872}
873structure_type!(ShaderModuleCreateInfoType, 16);
874
875#[repr(C)]
876#[derive(Debug)]
877#[doc = crate::man_link!(VkPipelineCacheCreateInfo)]
878pub struct PipelineCacheCreateInfo<'a, Next = Null> {
879    pub stype: ShaderModuleCreateInfoType,
880    pub next: Next,
881    pub flags: PipelineCacheCreateFlags,
882    pub initial_data: Bytes<'a>,
883}
884structure_type!(PipelineCacheCreateInfoType, 17);
885
886#[repr(C)]
887#[derive(Debug)]
888#[doc = crate::man_link!(VkSpecializationMapEntry)]
889pub struct SpecializationMapEntry {
890    pub constant_id: u32,
891    pub offset: u32,
892    pub size: usize,
893}
894
895#[repr(C)]
896#[derive(Debug)]
897#[doc = crate::man_link!(VkSpecializationInfo)]
898pub struct SpecializationInfo<'a> {
899    pub map_entries: Slice<'a, SpecializationMapEntry>,
900    pub data: Bytes<'a>,
901}
902
903#[repr(C)]
904#[derive(Debug)]
905#[doc = crate::man_link!(VkPipelineShaderStageCreateInfo)]
906pub struct PipelineShaderStageCreateInfo<'a, Next = Null> {
907    pub stype: PipelineShaderStageCreateInfoType,
908    pub next: Next,
909    pub flags: PipelineShaderStageCreateFlags,
910    pub stage: ShaderStage,
911    pub module: Ref<'a, VkShaderModule>,
912    pub name: Str<'a>,
913    pub specialization_info: Option<&'a SpecializationInfo<'a>>,
914}
915structure_type!(PipelineShaderStageCreateInfoType, 18);
916
917impl<'a> PipelineShaderStageCreateInfo<'a> {
918    const MAIN: Str<'static> = unsafe { Str::new_unchecked(b"main\0") };
919    /// Create a vertex shader with entry point "main"
920    pub fn vertex(module: &'a crate::shader::ShaderModule) -> Self {
921        Self {
922            stype: Default::default(),
923            next: Default::default(),
924            flags: Default::default(),
925            stage: ShaderStage::VERTEX,
926            module: module.handle(),
927            name: Self::MAIN,
928            specialization_info: None,
929        }
930    }
931    /// Create a fragment shader with entry point "main"
932    pub fn fragment(module: &'a crate::shader::ShaderModule) -> Self {
933        Self {
934            stype: Default::default(),
935            next: Default::default(),
936            flags: Default::default(),
937            stage: ShaderStage::FRAGMENT,
938            module: module.handle(),
939            name: Self::MAIN,
940            specialization_info: None,
941        }
942    }
943    /// Create a compute shader with entry point "main"
944    pub fn compute(module: &'a crate::shader::ShaderModule) -> Self {
945        Self {
946            stype: Default::default(),
947            next: Default::default(),
948            flags: Default::default(),
949            stage: ShaderStage::COMPUTE,
950            module: module.handle(),
951            name: Self::MAIN,
952            specialization_info: None,
953        }
954    }
955}
956
957#[repr(C)]
958#[derive(Debug)]
959#[doc = crate::man_link!(VkVertexInputBindingDescription)]
960pub struct VertexInputBindingDescription {
961    pub binding: u32,
962    pub stride: u32,
963    pub input_rate: VertexInputRate,
964}
965
966#[repr(C)]
967#[derive(Debug)]
968#[doc = crate::man_link!(VkVertexInputAttributeDescription)]
969pub struct VertexInputAttributeDescription {
970    pub location: u32,
971    pub binding: u32,
972    pub format: Format,
973    pub offset: u32,
974}
975
976#[repr(C)]
977#[derive(Debug, Default)]
978#[doc = crate::man_link!(VkPipelineVertexInputStateCreateInfo)]
979pub struct PipelineVertexInputStateCreateInfo<'a, Next = Null> {
980    pub stype: PipelineVertexInputStateCreateInfoType,
981    pub next: Next,
982    pub flags: PipelineVertexInputStateCreateFlags,
983    pub vertex_binding_descriptions: Slice_<'a, VertexInputBindingDescription>,
984    pub vertex_attribute_descriptions:
985        Slice<'a, VertexInputAttributeDescription>,
986}
987structure_type!(PipelineVertexInputStateCreateInfoType, 19);
988
989#[repr(C)]
990#[derive(Debug, Default)]
991#[doc = crate::man_link!(VkPipelineInputAssemblyStateCreateInfo)]
992pub struct PipelineInputAssemblyStateCreateInfo<Next = Null> {
993    pub stype: PipelineInputAssemblyStateCreateInfoType,
994    pub next: Next,
995    pub flags: PipelineInputAssemblyStateCreateFlags,
996    pub topology: PrimitiveTopology,
997    pub primitive_restart_enable: Bool,
998}
999structure_type!(PipelineInputAssemblyStateCreateInfoType, 20);
1000
1001#[repr(C)]
1002#[derive(Debug, Default)]
1003#[doc = crate::man_link!(VkPipelineTessellationStateCreateInfo)]
1004pub struct PipelineTessellationStateCreateInfo<Next = Null> {
1005    pub stype: PipelineTesselationStateCreateInfoType,
1006    pub next: Next,
1007    pub flags: PipelineTesselationStateCreateFlags,
1008    pub patch_control_points: u32,
1009}
1010structure_type!(PipelineTesselationStateCreateInfoType, 21);
1011
1012#[repr(C)]
1013#[derive(Debug)]
1014#[doc = crate::man_link!(VkPipelineViewportStateCreateInfo)]
1015pub struct PipelineViewportStateCreateInfo<'a, Next = Null> {
1016    pub stype: PipelineViewportStateCreateInfoType,
1017    pub next: Next,
1018    pub flags: PipelineViewportStateCreateFlags,
1019    pub viewports: Slice_<'a, Viewport>,
1020    pub scissors: Slice<'a, Rect2D>,
1021}
1022structure_type!(PipelineViewportStateCreateInfoType, 22);
1023
1024impl<'a> Default for PipelineViewportStateCreateInfo<'a> {
1025    /// Viewport state appropriate for dynamic viewport and scissor
1026    fn default() -> Self {
1027        const DYN_VIEWPORT: Viewport = Viewport {
1028            width: 0.,
1029            height: 0.,
1030            x: 0.,
1031            y: 0.,
1032            min_depth: 0.,
1033            max_depth: 0.,
1034        };
1035        const DYN_SCISSOR: Rect2D = Rect2D {
1036            offset: Offset2D { x: 0, y: 0 },
1037            extent: Extent2D { width: 0, height: 0 },
1038        };
1039        Self {
1040            stype: Default::default(),
1041            next: Default::default(),
1042            flags: Default::default(),
1043            viewports: slice(&[DYN_VIEWPORT]),
1044            scissors: slice(&[DYN_SCISSOR]),
1045        }
1046    }
1047}
1048
1049#[repr(C)]
1050#[derive(Debug)]
1051#[doc = crate::man_link!(VkPipelineRasterizationStateCreateInfo)]
1052pub struct PipelineRasterizationStateCreateInfo<Next = Null> {
1053    pub stype: PipelineRasterizationStateCreateInfoType,
1054    pub next: Next,
1055    pub flags: PipelineRasterizationStateCreateFlags,
1056    pub depth_clamp_enable: Bool,
1057    pub rasterizer_discard_enable: Bool,
1058    pub polygon_mode: PolygonMode,
1059    pub cull_mode: CullModeFlags,
1060    pub front_face: FrontFace,
1061    pub depth_bias_enable: Bool,
1062    pub depth_bias_constant_factor: f32,
1063    pub depth_bias_clamp: f32,
1064    pub depth_bias_slope_factor: f32,
1065    pub line_width: f32,
1066}
1067structure_type!(PipelineRasterizationStateCreateInfoType, 23);
1068
1069impl Default for PipelineRasterizationStateCreateInfo {
1070    fn default() -> Self {
1071        PipelineRasterizationStateCreateInfo {
1072            stype: Default::default(),
1073            next: Default::default(),
1074            flags: Default::default(),
1075            depth_clamp_enable: Bool::False,
1076            rasterizer_discard_enable: Bool::False,
1077            polygon_mode: PolygonMode::FILL,
1078            cull_mode: CullModeFlags::empty(),
1079            front_face: FrontFace::COUNTER_CLOCKWISE,
1080            depth_bias_enable: Bool::False,
1081            depth_bias_constant_factor: 0.0,
1082            depth_bias_clamp: 0.0,
1083            depth_bias_slope_factor: 0.0,
1084            line_width: 1.0,
1085        }
1086    }
1087}
1088
1089#[repr(C)]
1090#[derive(Debug, Default)]
1091#[doc = crate::man_link!(VkPipelineMultisampleStateCreateInfo)]
1092pub struct PipelineMultisampleStateCreateInfo<'a, Next = Null> {
1093    pub stype: PipelineMultisampleStateCreateInfoType,
1094    pub next: Next,
1095    pub flags: PipelineMultisampleStateCreateFlags,
1096    pub rasterization_samples: SampleCount,
1097    pub sample_shading_enable: Bool,
1098    pub min_sample_shading: f32,
1099    pub sample_mask: Option<&'a u64>,
1100    pub alpha_to_coverage_enable: Bool,
1101    pub alpha_to_one_enable: Bool,
1102}
1103structure_type!(PipelineMultisampleStateCreateInfoType, 24);
1104
1105#[repr(C)]
1106#[derive(Debug, Default)]
1107#[doc = crate::man_link!(VkStencilOpState)]
1108pub struct StencilOpState {
1109    pub fail_op: StencilOp,
1110    pub pass_op: StencilOp,
1111    pub depth_fail_op: StencilOp,
1112    pub compare_op: CompareOp,
1113    pub compare_mask: u32,
1114    pub write_mask: u32,
1115    pub reference: u32,
1116}
1117
1118#[repr(C)]
1119#[derive(Debug, Default)]
1120#[doc = crate::man_link!(VkPipelineDepthStencilStateCreateInfo)]
1121pub struct PipelineDepthStencilStateCreateInfo<Next = Null> {
1122    pub stype: PipelineDepthStencilStateCreateInfoType,
1123    pub next: Next,
1124    pub flags: PipelineDepthStencilStateCreateFlags,
1125    pub depth_test_enable: Bool,
1126    pub depth_write_enable: Bool,
1127    pub depth_compare_op: CompareOp,
1128    pub depth_bounds_test_enable: Bool,
1129    pub stencil_test_enable: Bool,
1130    pub front: StencilOpState,
1131    pub back: StencilOpState,
1132    pub min_depth_bounds: f32,
1133    pub max_depth_bounds: f32,
1134}
1135structure_type!(PipelineDepthStencilStateCreateInfoType, 25);
1136
1137#[repr(C)]
1138#[derive(Debug)]
1139#[doc = crate::man_link!(VkPipelineColorBlendAttachmentState)]
1140pub struct PipelineColorBlendAttachmentState {
1141    pub blend_enable: Bool,
1142    pub src_color_blend_factor: BlendFactor,
1143    pub dst_color_blend_factor: BlendFactor,
1144    pub color_blend_op: BlendOp,
1145    pub src_alpha_blend_factor: BlendFactor,
1146    pub dst_alpha_blend_factor: BlendFactor,
1147    pub alpha_blend_op: BlendOp,
1148    pub color_write_mask: ColorComponentFlags,
1149}
1150
1151const DEFAULT_BLEND: PipelineColorBlendAttachmentState =
1152    PipelineColorBlendAttachmentState {
1153        blend_enable: Bool::False,
1154        src_color_blend_factor: BlendFactor::ONE,
1155        dst_color_blend_factor: BlendFactor::ONE_MINUS_SRC_ALPHA,
1156        color_blend_op: BlendOp::ADD,
1157        src_alpha_blend_factor: BlendFactor::ONE,
1158        dst_alpha_blend_factor: BlendFactor::ONE_MINUS_SRC_ALPHA,
1159        alpha_blend_op: BlendOp::ADD,
1160        color_write_mask: ColorComponentFlags::RGBA,
1161    };
1162
1163impl Default for PipelineColorBlendAttachmentState {
1164    /// Blending disabled, and premultiplied alpha blending parameters.
1165    fn default() -> Self {
1166        DEFAULT_BLEND
1167    }
1168}
1169
1170#[repr(C)]
1171#[derive(Debug)]
1172#[doc = crate::man_link!(VkPipelineColorBlendStateCreateInfo)]
1173pub struct PipelineColorBlendStateCreateInfo<'a, Next = Null> {
1174    pub stype: PipelineColorBlendStateCreateInfoType,
1175    pub next: Next,
1176    pub flags: PipelineColorBlendStateCreateFlags,
1177    pub logic_op_enable: Bool,
1178    pub logic_op: LogicOp,
1179    pub attachments: Slice_<'a, PipelineColorBlendAttachmentState>,
1180    pub blend_constants: [f32; 4],
1181}
1182structure_type!(PipelineColorBlendStateCreateInfoType, 26);
1183
1184impl Default for PipelineColorBlendStateCreateInfo<'static> {
1185    /// One color attachment with blending disabled
1186    fn default() -> Self {
1187        Self {
1188            stype: Default::default(),
1189            next: Default::default(),
1190            flags: Default::default(),
1191            logic_op_enable: Bool::False,
1192            logic_op: LogicOp::CLEAR,
1193            attachments: std::slice::from_ref(&DEFAULT_BLEND).into(),
1194            blend_constants: Default::default(),
1195        }
1196    }
1197}
1198
1199#[repr(C)]
1200#[derive(Debug, Default)]
1201#[doc = crate::man_link!(VkPipelineDynamicStateCreateInfo)]
1202pub struct PipelineDynamicStateCreateInfo<'a, Next = Null> {
1203    pub stype: PipelineDynamicStateCreateInfoType,
1204    pub next: Next,
1205    pub flags: DynamicStateCreateFlags,
1206    pub dynamic_states: Slice_<'a, DynamicState>,
1207}
1208structure_type!(PipelineDynamicStateCreateInfoType, 27);
1209
1210#[repr(C)]
1211#[derive(Debug)]
1212#[doc = crate::man_link!(VkGraphicsPipelineCreateInfo)]
1213pub struct VkGraphicsPipelineCreateInfo<'a, Next = Null> {
1214    pub stype: GraphicsPipelineCreateInfoType,
1215    pub next: Next,
1216    pub flags: PipelineCreateFlags,
1217    pub stages: Slice_<'a, PipelineShaderStageCreateInfo<'a>>,
1218    pub vertex_input_state: &'a PipelineVertexInputStateCreateInfo<'a>,
1219    pub input_assembly_state: &'a PipelineInputAssemblyStateCreateInfo,
1220    pub tessellation_state: Option<&'a PipelineTessellationStateCreateInfo>,
1221    pub viewport_state: &'a PipelineViewportStateCreateInfo<'a>,
1222    pub rasterization_state: &'a PipelineRasterizationStateCreateInfo,
1223    pub multisample_state: &'a PipelineMultisampleStateCreateInfo<'a>,
1224    pub depth_stencil_state: Option<&'a PipelineDepthStencilStateCreateInfo>,
1225    pub color_blend_state: &'a PipelineColorBlendStateCreateInfo<'a>,
1226    pub dynamic_state: Option<&'a PipelineDynamicStateCreateInfo<'a>>,
1227    pub layout: Ref<'a, VkPipelineLayout>,
1228    pub render_pass: Ref<'a, VkRenderPass>,
1229    pub subpass: u32,
1230    pub base_pipeline_handle: Option<Ref<'a, VkPipeline>>,
1231    pub base_pipeline_index: u32,
1232}
1233structure_type!(GraphicsPipelineCreateInfoType, 28);
1234
1235#[repr(C)]
1236#[derive(Debug)]
1237#[doc = crate::man_link!(VkComputePipelineCreateInfo)]
1238pub struct ComputePipelineCreateInfo<'a, Next = Null> {
1239    pub stype: ComputePipelineCreateInfoType,
1240    pub next: Next,
1241    pub flags: PipelineCreateFlags,
1242    pub stage: PipelineShaderStageCreateInfo<'a>,
1243    pub layout: Ref<'a, VkPipelineLayout>,
1244    pub base_pipeline_handle: Option<Ref<'a, VkPipeline>>,
1245    pub base_pipeline_index: u32,
1246}
1247structure_type!(ComputePipelineCreateInfoType, 29);
1248
1249#[repr(C)]
1250#[derive(Debug)]
1251#[doc = crate::man_link!(VkPushConstantRange)]
1252pub struct PushConstantRange {
1253    pub stage_flags: ShaderStageFlags,
1254    pub offset: u32,
1255    pub size: u32,
1256}
1257
1258#[repr(C)]
1259#[derive(Debug, Default)]
1260#[doc = crate::man_link!(VkPipelineLayoutCreateInfo)]
1261pub struct PipelineLayoutCreateInfo<'a, Next = Null> {
1262    pub stype: PipelineLayoutCreateInfoType,
1263    pub next: Next,
1264    pub flags: PipelineLayoutCreateFlags,
1265    pub set_layouts: Slice_<'a, Ref<'a, VkDescriptorSetLayout>>,
1266    pub push_constant_ranges: Slice<'a, PushConstantRange>,
1267}
1268structure_type!(PipelineLayoutCreateInfoType, 30);
1269
1270#[repr(C)]
1271#[derive(Debug)]
1272#[doc = crate::man_link!(VkSamplerCreateInfo)]
1273pub struct SamplerCreateInfo<Next = Null> {
1274    pub stype: SamplerCreateInfoType,
1275    pub next: Next,
1276    pub flags: SamplerCreateFlags,
1277    pub mag_filter: Filter,
1278    pub min_filter: Filter,
1279    pub mipmap_mode: SamplerMipmapMode,
1280    pub address_mode_u: SamplerAddressMode,
1281    pub address_mode_v: SamplerAddressMode,
1282    pub address_mode_w: SamplerAddressMode,
1283    pub mip_lod_bias: f32,
1284    pub anisotropy_enable: Bool,
1285    pub max_anisotropy: f32,
1286    pub compare_enable: Bool,
1287    pub compare_op: CompareOp,
1288    pub min_lod: f32,
1289    pub max_lod: f32,
1290    pub border_color: BorderColor,
1291    pub unnormalized_coordinates: Bool,
1292}
1293structure_type!(SamplerCreateInfoType, 31);
1294
1295impl Default for SamplerCreateInfo {
1296    fn default() -> Self {
1297        Self {
1298            stype: Default::default(),
1299            next: Default::default(),
1300            flags: Default::default(),
1301            mag_filter: Default::default(),
1302            min_filter: Default::default(),
1303            mipmap_mode: Default::default(),
1304            address_mode_u: Default::default(),
1305            address_mode_v: Default::default(),
1306            address_mode_w: Default::default(),
1307            mip_lod_bias: Default::default(),
1308            anisotropy_enable: Default::default(),
1309            max_anisotropy: Default::default(),
1310            compare_enable: Default::default(),
1311            compare_op: Default::default(),
1312            min_lod: Default::default(),
1313            max_lod: 1000.0,
1314            border_color: Default::default(),
1315            unnormalized_coordinates: Default::default(),
1316        }
1317    }
1318}
1319
1320#[repr(C)]
1321#[derive(Debug)]
1322#[doc = crate::man_link!(VkDescriptorSetLayoutBinding)]
1323pub struct VkDescriptorSetLayoutBinding<'a> {
1324    pub binding: u32,
1325    pub descriptor_type: DescriptorType,
1326    pub descriptor_count: u32,
1327    pub stage_flags: ShaderStageFlags,
1328    // Safety: Must be descriptor_count long
1329    pub immutable_samplers: Option<Array<'a, Ref<'a, VkSampler>>>,
1330}
1331
1332#[repr(C)]
1333#[derive(Debug, Default)]
1334#[doc = crate::man_link!(VkDescriptorSetLayoutCreateInfo)]
1335pub struct VkDescriptorSetLayoutCreateInfo<'a, Next = Null> {
1336    pub stype: DescriptorSetLayoutCreateInfoType,
1337    pub next: Next,
1338    pub flags: DescriptorSetLayoutCreateFlags,
1339    pub bindings: Slice_<'a, VkDescriptorSetLayoutBinding<'a>>,
1340}
1341structure_type!(DescriptorSetLayoutCreateInfoType, 32);
1342
1343#[repr(C)]
1344#[derive(Debug)]
1345#[doc = crate::man_link!(VkDescriptorPoolSize)]
1346pub struct DescriptorPoolSize {
1347    pub descriptor_type: DescriptorType,
1348    pub descriptor_count: u32,
1349}
1350
1351#[repr(C)]
1352#[derive(Debug, Default)]
1353#[doc = crate::man_link!(VkDescriptorPoolCreateInfo)]
1354pub struct DescriptorPoolCreateInfo<'a, Next = Null> {
1355    pub stype: DescriptorPoolCreateInfoType,
1356    pub next: Next,
1357    pub flags: DescriptorPoolCreateFlags,
1358    pub max_sets: u32,
1359    pub pool_sizes: Slice<'a, DescriptorPoolSize>,
1360}
1361structure_type!(DescriptorPoolCreateInfoType, 33);
1362
1363#[repr(C)]
1364#[derive(Debug)]
1365#[doc = crate::man_link!(VkDescriptorSetAllocateInfo)]
1366pub struct DescriptorSetAllocateInfo<'a, Next = Null> {
1367    pub stype: DescriptorSetAllocateInfoType,
1368    pub next: Next,
1369    pub descriptor_pool: Mut<'a, VkDescriptorPool>,
1370    pub set_layouts: Slice<'a, Ref<'a, VkDescriptorSetLayout>>,
1371}
1372structure_type!(DescriptorSetAllocateInfoType, 34);
1373
1374#[repr(C)]
1375#[derive(Debug, Default)]
1376#[doc = crate::man_link!(VkDescriptorImageInfo)]
1377pub struct VkDescriptorImageInfo<'a> {
1378    pub sampler: Option<Ref<'a, VkSampler>>,
1379    pub image_view: Option<Ref<'a, VkImageView>>,
1380    pub image_layout: ImageLayout,
1381}
1382
1383#[repr(C)]
1384#[derive(Debug)]
1385#[doc = crate::man_link!(VkDescriptorBufferInfo)]
1386pub struct VkDescriptorBufferInfo<'a> {
1387    pub buffer: Ref<'a, VkBuffer>,
1388    pub offset: u64,
1389    pub range: u64,
1390}
1391
1392#[repr(C)]
1393#[derive(Debug)]
1394#[doc = crate::man_link!(VkWriteDescriptorSet)]
1395pub struct VkWriteDescriptorSet<'a, Next = Null> {
1396    pub stype: WriteDescriptorSetType,
1397    pub next: Next,
1398    pub dst_set: Mut<'a, VkDescriptorSet>,
1399    pub dst_binding: u32,
1400    pub dst_array_element: u32,
1401    pub descriptor_count: u32,
1402    pub descriptor_type: DescriptorType,
1403    pub image_info: Option<Array<'a, VkDescriptorImageInfo<'a>>>,
1404    pub buffer_info: Option<Array<'a, VkDescriptorBufferInfo<'a>>>,
1405    pub texel_buffer_view: Option<Array<'a, Ref<'a, VkBufferView>>>,
1406}
1407structure_type!(WriteDescriptorSetType, 35);
1408
1409#[repr(C)]
1410#[derive(Debug)]
1411#[doc = crate::man_link!(VkCopyDescriptorSet)]
1412pub struct VkCopyDescriptorSet<'a, Next = Null> {
1413    pub stype: WriteDescriptorSetType,
1414    pub next: Next,
1415    pub src_set: Ref<'a, VkDescriptorSet>,
1416    pub src_binding: u32,
1417    pub src_array_element: u32,
1418    pub dst_set: Mut<'a, VkDescriptorSet>,
1419    pub dst_binding: u32,
1420    pub dst_array_element: u32,
1421    pub descriptor_count: u32,
1422}
1423structure_type!(CopyDescriptorSetType, 35);
1424
1425#[repr(C)]
1426#[derive(Debug)]
1427#[doc = crate::man_link!(VkFramebufferCreateInfo)]
1428pub struct VkFramebufferCreateInfo<'a, Next = Null> {
1429    pub stype: FramebufferCreateInfoType,
1430    pub next: Next,
1431    pub flags: FramebufferCreateFlags,
1432    pub render_pass: Ref<'a, VkRenderPass>,
1433    pub attachments: Slice<'a, Ref<'a, VkImageView>>,
1434    pub width: u32,
1435    pub height: u32,
1436    pub layers: u32,
1437}
1438structure_type!(FramebufferCreateInfoType, 37);
1439
1440#[repr(C)]
1441#[derive(Debug, Default)]
1442#[doc = crate::man_link!(VkAttachmentDescription)]
1443pub struct AttachmentDescription {
1444    pub flags: AttachmentDescriptionFlags,
1445    pub format: Format,
1446    pub samples: SampleCount,
1447    pub load_op: AttachmentLoadOp,
1448    pub store_op: AttachmentStoreOp,
1449    pub stencil_load_op: AttachmentLoadOp,
1450    pub stencil_store_op: AttachmentStoreOp,
1451    pub initial_layout: ImageLayout,
1452    pub final_layout: ImageLayout,
1453}
1454
1455#[repr(C)]
1456#[derive(Debug, Default)]
1457#[doc = crate::man_link!(VkAttachmentReference)]
1458pub struct AttachmentReference {
1459    /// Either an index in the attachments member of [`RenderPassCreateInfo`] or
1460    /// u32::MAX if unused
1461    pub attachment: u32,
1462    pub layout: ImageLayout,
1463}
1464
1465#[repr(C)]
1466#[derive(Debug)]
1467/// Create with
1468/// [`vk::SubpassDescription::try_into`](SubpassDescription).
1469#[doc = crate::man_link!(VkSubpassDescription)]
1470pub struct VkSubpassDescription<'a> {
1471    flags: SubpassDescriptionFlags,
1472    pipeline_bind_point: PipelineBindPoint,
1473    pub(crate) input_attachments: Slice<'a, AttachmentReference>,
1474    pub(crate) color_attachments: Slice<'a, AttachmentReference>,
1475    /// Safety: Must be the same length as color_attachments
1476    pub(crate) resolve_attachments: Option<Array<'a, AttachmentReference>>,
1477    pub(crate) depth_stencil_attachments:
1478        Option<Array<'a, AttachmentReference>>,
1479    pub(crate) preserve_attachments: Slice<'a, AttachmentReference>,
1480}
1481
1482impl<'a> Default for VkSubpassDescription<'a> {
1483    fn default() -> Self {
1484        SubpassDescription::default().try_into().unwrap()
1485    }
1486}
1487
1488#[derive(Default)]
1489#[doc = crate::man_link!(VkSubpassDescription)]
1490pub struct SubpassDescription<'a> {
1491    pub input_attachments: &'a [AttachmentReference],
1492    pub color_attachments: &'a [AttachmentReference],
1493    /// Must be either empty or the same length as color_attachments
1494    pub resolve_attachments: &'a [AttachmentReference],
1495    /// Must be either empty or the same length as color_attachments
1496    pub depth_stencil_attachments: &'a [AttachmentReference],
1497    pub preserve_attachments: &'a [AttachmentReference],
1498}
1499impl<'a> TryFrom<SubpassDescription<'a>> for VkSubpassDescription<'a> {
1500    type Error = Error;
1501    #[inline]
1502    fn try_from(value: SubpassDescription<'a>) -> Result<Self, Self::Error> {
1503        if !value.resolve_attachments.is_empty()
1504            && value.resolve_attachments.len() != value.color_attachments.len()
1505        {
1506            return Err(Error::InvalidArgument);
1507        }
1508        if !value.depth_stencil_attachments.is_empty()
1509            && value.depth_stencil_attachments.len()
1510                != value.color_attachments.len()
1511        {
1512            return Err(Error::InvalidArgument);
1513        }
1514        Ok(Self {
1515            flags: Default::default(),
1516            pipeline_bind_point: PipelineBindPoint::GRAPHICS,
1517            input_attachments: value.input_attachments.into(),
1518            color_attachments: value.color_attachments.into(),
1519            resolve_attachments: Array::from_slice(value.resolve_attachments),
1520            depth_stencil_attachments: Array::from_slice(
1521                value.depth_stencil_attachments,
1522            ),
1523            preserve_attachments: value.preserve_attachments.into(),
1524        })
1525    }
1526}
1527
1528#[repr(C)]
1529#[derive(Debug, PartialEq, Eq, Clone)]
1530#[doc = crate::man_link!(VkSubpassDependency)]
1531pub struct SubpassDependency {
1532    pub src_subpass: u32,
1533    pub dst_subpass: u32,
1534    pub src_stage_mask: PipelineStageFlags,
1535    pub dst_stage_mask: PipelineStageFlags,
1536    pub src_access_mask: AccessFlags,
1537    pub dst_access_mask: AccessFlags,
1538    pub dependency_flags: DependencyFlags,
1539}
1540
1541#[repr(C)]
1542#[derive(Debug, Default)]
1543#[doc = crate::man_link!(VkRenderPassCreateInfo)]
1544pub struct RenderPassCreateInfo<'a, Next = Null> {
1545    pub stype: RenderPassCreateInfoType,
1546    pub next: Next,
1547    pub flags: RenderPassCreateFlags,
1548    pub attachments: Slice_<'a, AttachmentDescription>,
1549    pub subpasses: Slice<'a, VkSubpassDescription<'a>>,
1550    pub dependencies: Slice<'a, SubpassDependency>,
1551}
1552structure_type!(RenderPassCreateInfoType, 38);
1553
1554#[repr(C)]
1555#[derive(Debug, Default)]
1556#[doc = crate::man_link!(VkCommandPoolCreateInfo)]
1557pub struct CommandPoolCreateInfo<Next = Null> {
1558    pub stype: CommandPoolCreateInfoType,
1559    pub next: Next,
1560    pub flags: CommandPoolCreateFlags,
1561    pub queue_family_index: u32,
1562}
1563structure_type!(CommandPoolCreateInfoType, 39);
1564
1565#[repr(C)]
1566#[derive(Debug)]
1567#[doc = crate::man_link!(VkCommandBufferAllocateInfo)]
1568pub struct CommandBufferAllocateInfo<'a, Next = Null> {
1569    pub stype: CommandBufferAllocateInfoType,
1570    pub next: Next,
1571    pub pool: Mut<'a, VkCommandPool>,
1572    pub level: CommandBufferLevel,
1573    pub count: u32,
1574}
1575structure_type!(CommandBufferAllocateInfoType, 40);
1576
1577#[repr(C)]
1578#[derive(Debug)]
1579#[doc = crate::man_link!(VkCommandBufferInheritanceInfo)]
1580pub struct CommandBufferInheritanceInfo<'a, Next = Null> {
1581    pub stype: CommandBufferInheritanceInfoType,
1582    pub next: Next,
1583    pub render_pass: Ref<'a, VkRenderPass>,
1584    pub subpass: u32,
1585    pub framebuffer: Option<Ref<'a, VkFramebuffer>>,
1586    pub occlusion_query_enable: Bool,
1587    pub query_flags: QueryControlFlags,
1588    pub pipeline_statistics: QueryPipelineStatisticFlags,
1589}
1590structure_type!(CommandBufferInheritanceInfoType, 41);
1591
1592#[repr(C)]
1593#[derive(Debug, Default)]
1594#[doc = crate::man_link!(VkCommandBufferBeginInfo)]
1595pub struct CommandBufferBeginInfo<'a, Next = Null> {
1596    pub stype: CommandBufferBeginInfoType,
1597    pub next: Next,
1598    pub flags: CommandBufferUsageFlags,
1599    pub inheritance_info: Option<&'a CommandBufferInheritanceInfo<'a>>,
1600}
1601structure_type!(CommandBufferBeginInfoType, 42);
1602
1603#[repr(C)]
1604#[doc = crate::man_link!(VkRenderPassBeginInfo)]
1605pub struct RenderPassBeginInfo<'a, Next = Null> {
1606    pub stype: RenderPassBeginInfoType,
1607    pub next: Next,
1608    pub render_pass: Ref<'a, VkRenderPass>,
1609    pub framebuffer: Ref<'a, VkFramebuffer>,
1610    pub render_area: Rect2D,
1611    pub clear_values: Slice<'a, ClearValue>,
1612}
1613structure_type!(RenderPassBeginInfoType, 43);
1614
1615#[repr(C)]
1616#[derive(Debug)]
1617#[doc = crate::man_link!(VkBufferMemoryBarrier)]
1618pub struct VkBufferMemoryBarrier<'a, Next = Null> {
1619    pub stype: BufferMemoryBarrierType,
1620    pub next: Next,
1621    pub src_access_mask: AccessFlags,
1622    pub dst_access_mask: AccessFlags,
1623    pub src_queue_family_index: u32,
1624    pub dst_queue_family_index: u32,
1625    pub buffer: Ref<'a, VkBuffer>,
1626    pub offset: u64,
1627    pub size: u64,
1628}
1629structure_type!(BufferMemoryBarrierType, 44);
1630
1631#[repr(C)]
1632#[derive(Debug)]
1633#[doc = crate::man_link!(VkImageMemoryBarrier)]
1634pub struct VkImageMemoryBarrier<'a, Next = Null> {
1635    pub stype: ImageMemoryBarrierType,
1636    pub next: Next,
1637    pub src_access_mask: AccessFlags,
1638    pub dst_access_mask: AccessFlags,
1639    pub old_layout: ImageLayout,
1640    pub new_layout: ImageLayout,
1641    pub src_queue_family_index: u32,
1642    pub dst_queue_family_index: u32,
1643    pub image: Ref<'a, VkImage>,
1644    pub subresource_range: ImageSubresourceRange,
1645}
1646structure_type!(ImageMemoryBarrierType, 45);
1647
1648#[repr(C)]
1649#[derive(Debug, Default)]
1650#[doc = crate::man_link!(VkMemoryBarrier)]
1651pub struct MemoryBarrier<Next = Null> {
1652    pub stype: MemoryBarrierType,
1653    pub next: Next,
1654    pub src_access_mask: AccessFlags,
1655    pub dst_access_mask: AccessFlags,
1656}
1657structure_type!(MemoryBarrierType, 46);
1658
1659#[repr(C)]
1660#[derive(Debug)]
1661#[doc = crate::man_link!(VkMetalSurfaceCreateInfoEXT)]
1662pub struct MetalSurfaceCreateInfoEXT<Next = Null> {
1663    pub stype: MetalSurfaceCreateInfoEXTType,
1664    pub next: Next,
1665    pub flags: MetalSurfaceCreateFlagsEXT,
1666    pub layer: NonNull<c_void>,
1667}
1668structure_type!(MetalSurfaceCreateInfoEXTType, 1000217000);
1669
1670#[repr(C)]
1671#[derive(Debug)]
1672#[doc = crate::man_link!(VkXlibSurfaceCreateInfoKHR)]
1673pub struct XlibSurfaceCreateInfoKHR<Next = Null> {
1674    pub stype: XlibSurfaceCreateInfoKHRType,
1675    pub next: Next,
1676    pub flags: XlibSurfaceCreateFlagsKHR,
1677    pub display: NonNull<c_void>,
1678    pub window: usize,
1679}
1680structure_type!(XlibSurfaceCreateInfoKHRType, 1000004000);
1681
1682#[repr(C)]
1683#[derive(Debug)]
1684#[doc = crate::man_link!(VkWaylandSurfaceCreateInfoKHR)]
1685pub struct WaylandSurfaceCreateInfoKHR<Next = Null> {
1686    pub stype: WaylandSurfaceCreateInfoKHRType,
1687    pub next: Next,
1688    pub flags: WaylandSurfaceCreateFlagsKHR,
1689    pub display: NonNull<c_void>,
1690    pub surface: NonNull<c_void>,
1691}
1692structure_type!(WaylandSurfaceCreateInfoKHRType, 1000006000);
1693
1694#[repr(C)]
1695#[derive(Debug)]
1696#[doc = crate::man_link!(VkWin32SurfaceCreateInfoKHR)]
1697pub struct Win32SurfaceCreateInfoKHR<Next = Null> {
1698    pub stype: Win32SurfaceCreateInfoKHRType,
1699    pub next: Next,
1700    pub flags: Win32SurfaceCreateFlagsKHR,
1701    pub hinstance: NonNull<c_void>,
1702    pub hwnd: NonNull<c_void>,
1703}
1704structure_type!(Win32SurfaceCreateInfoKHRType, 1000009000);
1705
1706#[repr(C)]
1707#[derive(Debug)]
1708#[doc = crate::man_link!(VkSurfaceCapabilitiesKHR)]
1709pub struct SurfaceCapabilitiesKHR {
1710    pub min_image_count: u32,
1711    pub max_image_count: u32,
1712    pub current_extent: Extent2D,
1713    pub min_image_extent: Extent2D,
1714    pub max_image_extent: Extent2D,
1715    pub max_image_array_layers: u32,
1716    pub supported_transforms: SurfaceTransformFlagsKHR,
1717    pub current_transform: SurfaceTransformKHR,
1718    pub supported_composite_alpha: CompositeAlphaFlagsKHR,
1719    pub supported_usage_flags: ImageUsageFlags,
1720}
1721
1722#[repr(C)]
1723#[derive(Debug, PartialEq, Eq)]
1724#[doc = crate::man_link!(VkSurfaceFormatKHR)]
1725pub struct SurfaceFormatKHR {
1726    pub format: Format,
1727    pub color_space: ColorSpaceKHR,
1728}
1729
1730#[repr(C)]
1731#[derive(Debug)]
1732#[doc = crate::man_link!(VkSwapchainCreateInfoKHR)]
1733pub struct VkSwapchainCreateInfoKHR<'a, Next = Null> {
1734    pub stype: SwapchainCreateInfoKHRType,
1735    pub next: Next,
1736    pub flags: SwapchainCreateFlagsKHR,
1737    pub surface: Mut<'a, VkSurfaceKHR>,
1738    pub min_image_count: u32,
1739    pub image_format: Format,
1740    pub image_color_space: ColorSpaceKHR,
1741    pub image_extent: Extent2D,
1742    pub image_array_layers: u32,
1743    pub image_usage: ImageUsageFlags,
1744    pub image_sharing_mode: SharingMode,
1745    pub queue_family_indices: Slice<'a, u32>,
1746    pub pre_transform: SurfaceTransformKHR,
1747    pub composite_alpha: CompositeAlphaKHR,
1748    pub present_mode: PresentModeKHR,
1749    pub clipped: Bool,
1750    pub old_swapchain: Option<Mut<'a, VkSwapchainKHR>>,
1751}
1752structure_type!(SwapchainCreateInfoKHRType, 1000001000);
1753
1754#[repr(C)]
1755#[derive(Debug)]
1756#[doc = crate::man_link!(VkPresentInfoKHR)]
1757pub struct PresentInfoKHR<'a, Next = Null> {
1758    pub stype: PresentInfoType,
1759    pub next: Next,
1760    pub wait: Slice<'a, Mut<'a, VkSemaphore>>,
1761    /// Safety: The following members are arrays of the same length
1762    pub swapchains: Slice<'a, Mut<'a, VkSwapchainKHR>>,
1763    pub indices: Array<'a, u32>,
1764    pub results: Option<ArrayMut<'a, VkResult>>,
1765}
1766structure_type!(PresentInfoType, 1000001001);