lava/vulkan/vk/
vk_query_control_flags.rs

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