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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
// Generated by `scripts/generate.js`

use utils::vk_traits::*;

/// Wrapper for [VkAccessFlags](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkAccessFlags.html).
///
/// Use the macro `VkAccessFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
/// ```
/// VkAccessFlags!(indirect_command_read, index_read)
/// ```
/// ```
/// VkAccessFlags {
///     indirect_command_read: true,
///     index_read: true,
///     ..VkAccessFlags::none()
/// }
/// ```
#[derive(Debug, Clone)]
pub struct VkAccessFlags {
    pub indirect_command_read: bool,
    pub index_read: bool,
    pub vertex_attribute_read: bool,
    pub uniform_read: bool,
    pub input_attachment_read: bool,
    pub shader_read: bool,
    pub shader_write: bool,
    pub color_attachment_read: bool,
    pub color_attachment_write: bool,
    pub depth_stencil_attachment_read: bool,
    pub depth_stencil_attachment_write: bool,
    pub transfer_read: bool,
    pub transfer_write: bool,
    pub host_read: bool,
    pub host_write: bool,
    pub memory_read: bool,
    pub memory_write: bool,
    pub transform_feedback_write_ext: bool,
    pub transform_feedback_counter_read_ext: bool,
    pub transform_feedback_counter_write_ext: bool,
    pub conditional_rendering_read_ext: bool,
    pub command_process_read_nvx: bool,
    pub command_process_write_nvx: bool,
    pub color_attachment_read_noncoherent_ext: bool,
    pub shading_rate_image_read_nv: bool,
    pub acceleration_structure_read_nv: bool,
    pub acceleration_structure_write_nv: bool,
    pub fragment_density_map_read_ext: bool,
}

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

impl VkWrappedType<RawVkAccessFlags> for VkAccessFlags {
    fn vk_to_raw(src: &VkAccessFlags, dst: &mut RawVkAccessFlags) {
        *dst = 0;
        if src.indirect_command_read { *dst |= 0x00000001; }
        if src.index_read { *dst |= 0x00000002; }
        if src.vertex_attribute_read { *dst |= 0x00000004; }
        if src.uniform_read { *dst |= 0x00000008; }
        if src.input_attachment_read { *dst |= 0x00000010; }
        if src.shader_read { *dst |= 0x00000020; }
        if src.shader_write { *dst |= 0x00000040; }
        if src.color_attachment_read { *dst |= 0x00000080; }
        if src.color_attachment_write { *dst |= 0x00000100; }
        if src.depth_stencil_attachment_read { *dst |= 0x00000200; }
        if src.depth_stencil_attachment_write { *dst |= 0x00000400; }
        if src.transfer_read { *dst |= 0x00000800; }
        if src.transfer_write { *dst |= 0x00001000; }
        if src.host_read { *dst |= 0x00002000; }
        if src.host_write { *dst |= 0x00004000; }
        if src.memory_read { *dst |= 0x00008000; }
        if src.memory_write { *dst |= 0x00010000; }
        if src.transform_feedback_write_ext { *dst |= 0x02000000; }
        if src.transform_feedback_counter_read_ext { *dst |= 0x04000000; }
        if src.transform_feedback_counter_write_ext { *dst |= 0x08000000; }
        if src.conditional_rendering_read_ext { *dst |= 0x00100000; }
        if src.command_process_read_nvx { *dst |= 0x00020000; }
        if src.command_process_write_nvx { *dst |= 0x00040000; }
        if src.color_attachment_read_noncoherent_ext { *dst |= 0x00080000; }
        if src.shading_rate_image_read_nv { *dst |= 0x00800000; }
        if src.acceleration_structure_read_nv { *dst |= 0x00200000; }
        if src.acceleration_structure_write_nv { *dst |= 0x00400000; }
        if src.fragment_density_map_read_ext { *dst |= 0x01000000; }
    }
}

impl VkRawType<VkAccessFlags> for RawVkAccessFlags {
    fn vk_to_wrapped(src: &RawVkAccessFlags) -> VkAccessFlags {
        VkAccessFlags {
            indirect_command_read: (src & 0x00000001) != 0,
            index_read: (src & 0x00000002) != 0,
            vertex_attribute_read: (src & 0x00000004) != 0,
            uniform_read: (src & 0x00000008) != 0,
            input_attachment_read: (src & 0x00000010) != 0,
            shader_read: (src & 0x00000020) != 0,
            shader_write: (src & 0x00000040) != 0,
            color_attachment_read: (src & 0x00000080) != 0,
            color_attachment_write: (src & 0x00000100) != 0,
            depth_stencil_attachment_read: (src & 0x00000200) != 0,
            depth_stencil_attachment_write: (src & 0x00000400) != 0,
            transfer_read: (src & 0x00000800) != 0,
            transfer_write: (src & 0x00001000) != 0,
            host_read: (src & 0x00002000) != 0,
            host_write: (src & 0x00004000) != 0,
            memory_read: (src & 0x00008000) != 0,
            memory_write: (src & 0x00010000) != 0,
            transform_feedback_write_ext: (src & 0x02000000) != 0,
            transform_feedback_counter_read_ext: (src & 0x04000000) != 0,
            transform_feedback_counter_write_ext: (src & 0x08000000) != 0,
            conditional_rendering_read_ext: (src & 0x00100000) != 0,
            command_process_read_nvx: (src & 0x00020000) != 0,
            command_process_write_nvx: (src & 0x00040000) != 0,
            color_attachment_read_noncoherent_ext: (src & 0x00080000) != 0,
            shading_rate_image_read_nv: (src & 0x00800000) != 0,
            acceleration_structure_read_nv: (src & 0x00200000) != 0,
            acceleration_structure_write_nv: (src & 0x00400000) != 0,
            fragment_density_map_read_ext: (src & 0x01000000) != 0,
        }
    }
}

impl Default for VkAccessFlags {
    fn default() -> VkAccessFlags {
        VkAccessFlags {
            indirect_command_read: false,
            index_read: false,
            vertex_attribute_read: false,
            uniform_read: false,
            input_attachment_read: false,
            shader_read: false,
            shader_write: false,
            color_attachment_read: false,
            color_attachment_write: false,
            depth_stencil_attachment_read: false,
            depth_stencil_attachment_write: false,
            transfer_read: false,
            transfer_write: false,
            host_read: false,
            host_write: false,
            memory_read: false,
            memory_write: false,
            transform_feedback_write_ext: false,
            transform_feedback_counter_read_ext: false,
            transform_feedback_counter_write_ext: false,
            conditional_rendering_read_ext: false,
            command_process_read_nvx: false,
            command_process_write_nvx: false,
            color_attachment_read_noncoherent_ext: false,
            shading_rate_image_read_nv: false,
            acceleration_structure_read_nv: false,
            acceleration_structure_write_nv: false,
            fragment_density_map_read_ext: false,
        }
    }
}

impl VkAccessFlags {
    
    /// Return a structure with all flags to `false`.
    pub fn none() -> Self {
        VkAccessFlags {
            indirect_command_read: false,
            index_read: false,
            vertex_attribute_read: false,
            uniform_read: false,
            input_attachment_read: false,
            shader_read: false,
            shader_write: false,
            color_attachment_read: false,
            color_attachment_write: false,
            depth_stencil_attachment_read: false,
            depth_stencil_attachment_write: false,
            transfer_read: false,
            transfer_write: false,
            host_read: false,
            host_write: false,
            memory_read: false,
            memory_write: false,
            transform_feedback_write_ext: false,
            transform_feedback_counter_read_ext: false,
            transform_feedback_counter_write_ext: false,
            conditional_rendering_read_ext: false,
            command_process_read_nvx: false,
            command_process_write_nvx: false,
            color_attachment_read_noncoherent_ext: false,
            shading_rate_image_read_nv: false,
            acceleration_structure_read_nv: false,
            acceleration_structure_write_nv: false,
            fragment_density_map_read_ext: false,
        }
    }
    
    /// Return a structure with all flags to `true`.
    pub fn all() -> Self {
        VkAccessFlags {
            indirect_command_read: true,
            index_read: true,
            vertex_attribute_read: true,
            uniform_read: true,
            input_attachment_read: true,
            shader_read: true,
            shader_write: true,
            color_attachment_read: true,
            color_attachment_write: true,
            depth_stencil_attachment_read: true,
            depth_stencil_attachment_write: true,
            transfer_read: true,
            transfer_write: true,
            host_read: true,
            host_write: true,
            memory_read: true,
            memory_write: true,
            transform_feedback_write_ext: true,
            transform_feedback_counter_read_ext: true,
            transform_feedback_counter_write_ext: true,
            conditional_rendering_read_ext: true,
            command_process_read_nvx: true,
            command_process_write_nvx: true,
            color_attachment_read_noncoherent_ext: true,
            shading_rate_image_read_nv: true,
            acceleration_structure_read_nv: true,
            acceleration_structure_write_nv: true,
            fragment_density_map_read_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.indirect_command_read { 0x00000001 } else { 0 }
        + if self.index_read { 0x00000002 } else { 0 }
        + if self.vertex_attribute_read { 0x00000004 } else { 0 }
        + if self.uniform_read { 0x00000008 } else { 0 }
        + if self.input_attachment_read { 0x00000010 } else { 0 }
        + if self.shader_read { 0x00000020 } else { 0 }
        + if self.shader_write { 0x00000040 } else { 0 }
        + if self.color_attachment_read { 0x00000080 } else { 0 }
        + if self.color_attachment_write { 0x00000100 } else { 0 }
        + if self.depth_stencil_attachment_read { 0x00000200 } else { 0 }
        + if self.depth_stencil_attachment_write { 0x00000400 } else { 0 }
        + if self.transfer_read { 0x00000800 } else { 0 }
        + if self.transfer_write { 0x00001000 } else { 0 }
        + if self.host_read { 0x00002000 } else { 0 }
        + if self.host_write { 0x00004000 } else { 0 }
        + if self.memory_read { 0x00008000 } else { 0 }
        + if self.memory_write { 0x00010000 } else { 0 }
        + if self.transform_feedback_write_ext { 0x02000000 } else { 0 }
        + if self.transform_feedback_counter_read_ext { 0x04000000 } else { 0 }
        + if self.transform_feedback_counter_write_ext { 0x08000000 } else { 0 }
        + if self.conditional_rendering_read_ext { 0x00100000 } else { 0 }
        + if self.command_process_read_nvx { 0x00020000 } else { 0 }
        + if self.command_process_write_nvx { 0x00040000 } else { 0 }
        + if self.color_attachment_read_noncoherent_ext { 0x00080000 } else { 0 }
        + if self.shading_rate_image_read_nv { 0x00800000 } else { 0 }
        + if self.acceleration_structure_read_nv { 0x00200000 } else { 0 }
        + if self.acceleration_structure_write_nv { 0x00400000 } else { 0 }
        + if self.fragment_density_map_read_ext { 0x01000000 } else { 0 }
    }
    
    /// Create a structure corresponding to the specified numerical bit flags.
    pub fn from_u32(value: u32) -> Self {
        VkAccessFlags {
            indirect_command_read: value & 0x00000001 > 0,
            index_read: value & 0x00000002 > 0,
            vertex_attribute_read: value & 0x00000004 > 0,
            uniform_read: value & 0x00000008 > 0,
            input_attachment_read: value & 0x00000010 > 0,
            shader_read: value & 0x00000020 > 0,
            shader_write: value & 0x00000040 > 0,
            color_attachment_read: value & 0x00000080 > 0,
            color_attachment_write: value & 0x00000100 > 0,
            depth_stencil_attachment_read: value & 0x00000200 > 0,
            depth_stencil_attachment_write: value & 0x00000400 > 0,
            transfer_read: value & 0x00000800 > 0,
            transfer_write: value & 0x00001000 > 0,
            host_read: value & 0x00002000 > 0,
            host_write: value & 0x00004000 > 0,
            memory_read: value & 0x00008000 > 0,
            memory_write: value & 0x00010000 > 0,
            transform_feedback_write_ext: value & 0x02000000 > 0,
            transform_feedback_counter_read_ext: value & 0x04000000 > 0,
            transform_feedback_counter_write_ext: value & 0x08000000 > 0,
            conditional_rendering_read_ext: value & 0x00100000 > 0,
            command_process_read_nvx: value & 0x00020000 > 0,
            command_process_write_nvx: value & 0x00040000 > 0,
            color_attachment_read_noncoherent_ext: value & 0x00080000 > 0,
            shading_rate_image_read_nv: value & 0x00800000 > 0,
            acceleration_structure_read_nv: value & 0x00200000 > 0,
            acceleration_structure_write_nv: value & 0x00400000 > 0,
            fragment_density_map_read_ext: value & 0x01000000 > 0,
        }
    }
}

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