Skip to main content

lava/vulkan/vk/
vk_subpass_description_flags.rs

1// Generated by `scripts/generate.js`
2
3use utils::vk_traits::*;
4
5/// Wrapper for [VkSubpassDescriptionFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkSubpassDescriptionFlags.html).
6///
7/// Use the macro `VkSubpassDescriptionFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
8/// ```
9/// VkSubpassDescriptionFlags!(per_view_attributes_nvx, per_view_position_x_only_nvx)
10/// ```
11/// ```
12/// VkSubpassDescriptionFlags {
13///     per_view_attributes_nvx: true,
14///     per_view_position_x_only_nvx: true,
15/// }
16/// ```
17#[derive(Debug, Clone)]
18pub struct VkSubpassDescriptionFlags {
19    pub per_view_attributes_nvx: bool,
20    pub per_view_position_x_only_nvx: bool,
21}
22
23#[doc(hidden)]
24pub type RawVkSubpassDescriptionFlags = u32;
25
26impl VkWrappedType<RawVkSubpassDescriptionFlags> for VkSubpassDescriptionFlags {
27    fn vk_to_raw(src: &VkSubpassDescriptionFlags, dst: &mut RawVkSubpassDescriptionFlags) {
28        *dst = 0;
29        if src.per_view_attributes_nvx { *dst |= 0x00000001; }
30        if src.per_view_position_x_only_nvx { *dst |= 0x00000002; }
31    }
32}
33
34impl VkRawType<VkSubpassDescriptionFlags> for RawVkSubpassDescriptionFlags {
35    fn vk_to_wrapped(src: &RawVkSubpassDescriptionFlags) -> VkSubpassDescriptionFlags {
36        VkSubpassDescriptionFlags {
37            per_view_attributes_nvx: (src & 0x00000001) != 0,
38            per_view_position_x_only_nvx: (src & 0x00000002) != 0,
39        }
40    }
41}
42
43impl Default for VkSubpassDescriptionFlags {
44    fn default() -> VkSubpassDescriptionFlags {
45        VkSubpassDescriptionFlags {
46            per_view_attributes_nvx: false,
47            per_view_position_x_only_nvx: false,
48        }
49    }
50}
51
52impl VkSubpassDescriptionFlags {
53    
54    /// Return a structure with all flags to `false`.
55    pub fn none() -> Self {
56        VkSubpassDescriptionFlags {
57            per_view_attributes_nvx: false,
58            per_view_position_x_only_nvx: false,
59        }
60    }
61    
62    /// Return a structure with all flags to `true`.
63    pub fn all() -> Self {
64        VkSubpassDescriptionFlags {
65            per_view_attributes_nvx: true,
66            per_view_position_x_only_nvx: true,
67        }
68    }
69    
70    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
71    pub fn to_u32(&self) -> u32 {
72        0
73        + if self.per_view_attributes_nvx { 0x00000001 } else { 0 }
74        + if self.per_view_position_x_only_nvx { 0x00000002 } else { 0 }
75    }
76    
77    /// Create a structure corresponding to the specified numerical bit flags.
78    pub fn from_u32(value: u32) -> Self {
79        VkSubpassDescriptionFlags {
80            per_view_attributes_nvx: value & 0x00000001 > 0,
81            per_view_position_x_only_nvx: value & 0x00000002 > 0,
82        }
83    }
84}
85
86#[doc(hidden)]
87#[macro_export]
88macro_rules! VkSubpassDescriptionFlags {
89    ( $( $x:ident ),* ) => {
90        VkSubpassDescriptionFlags {
91            $($x: true,)*
92            ..VkSubpassDescriptionFlags::none()
93        }
94    }
95}