1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkQueueFlagBits](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkQueueFlagBits.html)
#[derive(Debug, Clone, Copy)]
pub struct VkQueueFlags {
    pub graphics: bool,
    pub compute: bool,
    pub transfer: bool,
    pub sparse_binding: bool,
    pub protected: bool,
}

#[doc(hidden)]
pub type RawVkQueueFlags = u32;

impl VkWrappedType<RawVkQueueFlags> for VkQueueFlags {
    fn vk_to_raw(src: &VkQueueFlags, dst: &mut RawVkQueueFlags) {
        *dst = 0;
        if src.graphics { *dst |= 0x00000001; }
        if src.compute { *dst |= 0x00000002; }
        if src.transfer { *dst |= 0x00000004; }
        if src.sparse_binding { *dst |= 0x00000008; }
        if src.protected { *dst |= 0x00000010; }
    }
}

impl VkRawType<VkQueueFlags> for RawVkQueueFlags {
    fn vk_to_wrapped(src: &RawVkQueueFlags) -> VkQueueFlags {
        VkQueueFlags {
            graphics: (src & 0x00000001) != 0,
            compute: (src & 0x00000002) != 0,
            transfer: (src & 0x00000004) != 0,
            sparse_binding: (src & 0x00000008) != 0,
            protected: (src & 0x00000010) != 0,
        }
    }
}

impl Default for VkQueueFlags {
    fn default() -> VkQueueFlags {
        VkQueueFlags {
            graphics: false,
            compute: false,
            transfer: false,
            sparse_binding: false,
            protected: false,
        }
    }
}

impl VkQueueFlags {
    
    pub fn none() -> VkQueueFlags {
        VkQueueFlags {
            graphics: false,
            compute: false,
            transfer: false,
            sparse_binding: false,
            protected: false,
        }
    }
    
    pub fn all() -> VkQueueFlags {
        VkQueueFlags {
            graphics: true,
            compute: true,
            transfer: true,
            sparse_binding: true,
            protected: true,
        }
    }
}

#[macro_export]
macro_rules! VkQueueFlags {
    ( $( $x:ident ),* ) => {
        VkQueueFlags {
            $($x: true,)*
            ..VkQueueFlags::none()
        }
    }
}

impl VkQueueFlags {
    
    pub fn to_u32(&self) -> u32 {
        0
        + if self.graphics { 0x00000001 } else { 0 }
        + if self.compute { 0x00000002 } else { 0 }
        + if self.transfer { 0x00000004 } else { 0 }
        + if self.sparse_binding { 0x00000008 } else { 0 }
        + if self.protected { 0x00000010 } else { 0 }
    }
}