lava/vulkan/vk/
vk_framebuffer_create_flags.rs

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