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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkImageCreateFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkImageCreateFlags.html).
///
/// Use the macro `VkImageCreateFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkImageCreateFlags!(sparse_binding, sparse_residency)
/// ```
/// ```
/// VkImageCreateFlags {
///     sparse_binding: true,
///     sparse_residency: true,
///     ..VkImageCreateFlags::none()
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkImageCreateFlags {
    pub sparse_binding: bool,
    pub sparse_residency: bool,
    pub sparse_aliased: bool,
    pub mutable_format: bool,
    pub cube_compatible: bool,
    pub alias: bool,
    pub split_instance_bind_regions: bool,
    pub _2d_array_compatible: bool,
    pub block_texel_view_compatible: bool,
    pub extended_usage: bool,
    pub protected: bool,
    pub disjoint: bool,
    pub corner_sampled_nv: bool,
    pub sample_locations_compatible_depth_ext: bool,
    pub subsampled_ext: bool,
}

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

impl VkWrappedType<RawVkImageCreateFlags> for VkImageCreateFlags {
    fn vk_to_raw(src: &VkImageCreateFlags, dst: &mut RawVkImageCreateFlags) {
        *dst = 0;
        if src.sparse_binding { *dst |= 0x00000001; }
        if src.sparse_residency { *dst |= 0x00000002; }
        if src.sparse_aliased { *dst |= 0x00000004; }
        if src.mutable_format { *dst |= 0x00000008; }
        if src.cube_compatible { *dst |= 0x00000010; }
        if src.alias { *dst |= 0x00000400; }
        if src.split_instance_bind_regions { *dst |= 0x00000040; }
        if src._2d_array_compatible { *dst |= 0x00000020; }
        if src.block_texel_view_compatible { *dst |= 0x00000080; }
        if src.extended_usage { *dst |= 0x00000100; }
        if src.protected { *dst |= 0x00000800; }
        if src.disjoint { *dst |= 0x00000200; }
        if src.corner_sampled_nv { *dst |= 0x00002000; }
        if src.sample_locations_compatible_depth_ext { *dst |= 0x00001000; }
        if src.subsampled_ext { *dst |= 0x00004000; }
    }
}

impl VkRawType<VkImageCreateFlags> for RawVkImageCreateFlags {
    fn vk_to_wrapped(src: &RawVkImageCreateFlags) -> VkImageCreateFlags {
        VkImageCreateFlags {
            sparse_binding: (src & 0x00000001) != 0,
            sparse_residency: (src & 0x00000002) != 0,
            sparse_aliased: (src & 0x00000004) != 0,
            mutable_format: (src & 0x00000008) != 0,
            cube_compatible: (src & 0x00000010) != 0,
            alias: (src & 0x00000400) != 0,
            split_instance_bind_regions: (src & 0x00000040) != 0,
            _2d_array_compatible: (src & 0x00000020) != 0,
            block_texel_view_compatible: (src & 0x00000080) != 0,
            extended_usage: (src & 0x00000100) != 0,
            protected: (src & 0x00000800) != 0,
            disjoint: (src & 0x00000200) != 0,
            corner_sampled_nv: (src & 0x00002000) != 0,
            sample_locations_compatible_depth_ext: (src & 0x00001000) != 0,
            subsampled_ext: (src & 0x00004000) != 0,
        }
    }
}

impl Default for VkImageCreateFlags {
    fn default() -> VkImageCreateFlags {
        VkImageCreateFlags {
            sparse_binding: false,
            sparse_residency: false,
            sparse_aliased: false,
            mutable_format: false,
            cube_compatible: false,
            alias: false,
            split_instance_bind_regions: false,
            _2d_array_compatible: false,
            block_texel_view_compatible: false,
            extended_usage: false,
            protected: false,
            disjoint: false,
            corner_sampled_nv: false,
            sample_locations_compatible_depth_ext: false,
            subsampled_ext: false,
        }
    }
}

impl VkImageCreateFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkImageCreateFlags {
            sparse_binding: false,
            sparse_residency: false,
            sparse_aliased: false,
            mutable_format: false,
            cube_compatible: false,
            alias: false,
            split_instance_bind_regions: false,
            _2d_array_compatible: false,
            block_texel_view_compatible: false,
            extended_usage: false,
            protected: false,
            disjoint: false,
            corner_sampled_nv: false,
            sample_locations_compatible_depth_ext: false,
            subsampled_ext: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkImageCreateFlags {
            sparse_binding: true,
            sparse_residency: true,
            sparse_aliased: true,
            mutable_format: true,
            cube_compatible: true,
            alias: true,
            split_instance_bind_regions: true,
            _2d_array_compatible: true,
            block_texel_view_compatible: true,
            extended_usage: true,
            protected: true,
            disjoint: true,
            corner_sampled_nv: true,
            sample_locations_compatible_depth_ext: true,
            subsampled_ext: true,
        }
    }
    
    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
    pub fn to_u32(&self) -> u32 {
        0
        + if self.sparse_binding { 0x00000001 } else { 0 }
        + if self.sparse_residency { 0x00000002 } else { 0 }
        + if self.sparse_aliased { 0x00000004 } else { 0 }
        + if self.mutable_format { 0x00000008 } else { 0 }
        + if self.cube_compatible { 0x00000010 } else { 0 }
        + if self.alias { 0x00000400 } else { 0 }
        + if self.split_instance_bind_regions { 0x00000040 } else { 0 }
        + if self._2d_array_compatible { 0x00000020 } else { 0 }
        + if self.block_texel_view_compatible { 0x00000080 } else { 0 }
        + if self.extended_usage { 0x00000100 } else { 0 }
        + if self.protected { 0x00000800 } else { 0 }
        + if self.disjoint { 0x00000200 } else { 0 }
        + if self.corner_sampled_nv { 0x00002000 } else { 0 }
        + if self.sample_locations_compatible_depth_ext { 0x00001000 } else { 0 }
        + if self.subsampled_ext { 0x00004000 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkImageCreateFlags {
            sparse_binding: value & 0x00000001 > 0,
            sparse_residency: value & 0x00000002 > 0,
            sparse_aliased: value & 0x00000004 > 0,
            mutable_format: value & 0x00000008 > 0,
            cube_compatible: value & 0x00000010 > 0,
            alias: value & 0x00000400 > 0,
            split_instance_bind_regions: value & 0x00000040 > 0,
            _2d_array_compatible: value & 0x00000020 > 0,
            block_texel_view_compatible: value & 0x00000080 > 0,
            extended_usage: value & 0x00000100 > 0,
            protected: value & 0x00000800 > 0,
            disjoint: value & 0x00000200 > 0,
            corner_sampled_nv: value & 0x00002000 > 0,
            sample_locations_compatible_depth_ext: value & 0x00001000 > 0,
            subsampled_ext: value & 0x00004000 > 0,
        }
    }
}

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