Skip to main content

lava/vulkan/ext/
vk_surface_counter_flags.rs

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