Skip to main content

lava/vulkan/vk/
vk_format_feature_flags.rs

1// Generated by `scripts/generate.js`
2
3use utils::vk_traits::*;
4
5/// Wrapper for [VkFormatFeatureFlags](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkFormatFeatureFlags.html).
6///
7/// Use the macro `VkFormatFeatureFlags!` as an alternative method to create a structure. For example, these two snippets return the same value:
8/// ```
9/// VkFormatFeatureFlags!(sampled_image, storage_image)
10/// ```
11/// ```
12/// VkFormatFeatureFlags {
13///     sampled_image: true,
14///     storage_image: true,
15///     ..VkFormatFeatureFlags::none()
16/// }
17/// ```
18#[derive(Debug, Clone)]
19pub struct VkFormatFeatureFlags {
20    pub sampled_image: bool,
21    pub storage_image: bool,
22    pub storage_image_atomic: bool,
23    pub uniform_texel_buffer: bool,
24    pub storage_texel_buffer: bool,
25    pub storage_texel_buffer_atomic: bool,
26    pub vertex_buffer: bool,
27    pub color_attachment: bool,
28    pub color_attachment_blend: bool,
29    pub depth_stencil_attachment: bool,
30    pub blit_src: bool,
31    pub blit_dst: bool,
32    pub sampled_image_filter_linear: bool,
33    pub transfer_src: bool,
34    pub transfer_dst: bool,
35    pub midpoint_chroma_samples: bool,
36    pub sampled_image_ycbcr_conversion_linear_filter: bool,
37    pub sampled_image_ycbcr_conversion_separate_reconstruction_filter: bool,
38    pub sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: bool,
39    pub sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: bool,
40    pub disjoint: bool,
41    pub cosited_chroma_samples: bool,
42    pub sampled_image_filter_minmax: bool,
43    pub sampled_image_filter_cubic_img: bool,
44    pub acceleration_structure_vertex_buffer_khr: bool,
45    pub fragment_density_map_ext: bool,
46}
47
48#[doc(hidden)]
49pub type RawVkFormatFeatureFlags = u32;
50
51impl VkWrappedType<RawVkFormatFeatureFlags> for VkFormatFeatureFlags {
52    fn vk_to_raw(src: &VkFormatFeatureFlags, dst: &mut RawVkFormatFeatureFlags) {
53        *dst = 0;
54        if src.sampled_image { *dst |= 0x00000001; }
55        if src.storage_image { *dst |= 0x00000002; }
56        if src.storage_image_atomic { *dst |= 0x00000004; }
57        if src.uniform_texel_buffer { *dst |= 0x00000008; }
58        if src.storage_texel_buffer { *dst |= 0x00000010; }
59        if src.storage_texel_buffer_atomic { *dst |= 0x00000020; }
60        if src.vertex_buffer { *dst |= 0x00000040; }
61        if src.color_attachment { *dst |= 0x00000080; }
62        if src.color_attachment_blend { *dst |= 0x00000100; }
63        if src.depth_stencil_attachment { *dst |= 0x00000200; }
64        if src.blit_src { *dst |= 0x00000400; }
65        if src.blit_dst { *dst |= 0x00000800; }
66        if src.sampled_image_filter_linear { *dst |= 0x00001000; }
67        if src.transfer_src { *dst |= 0x00004000; }
68        if src.transfer_dst { *dst |= 0x00008000; }
69        if src.midpoint_chroma_samples { *dst |= 0x00020000; }
70        if src.sampled_image_ycbcr_conversion_linear_filter { *dst |= 0x00040000; }
71        if src.sampled_image_ycbcr_conversion_separate_reconstruction_filter { *dst |= 0x00080000; }
72        if src.sampled_image_ycbcr_conversion_chroma_reconstruction_explicit { *dst |= 0x00100000; }
73        if src.sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable { *dst |= 0x00200000; }
74        if src.disjoint { *dst |= 0x00400000; }
75        if src.cosited_chroma_samples { *dst |= 0x00800000; }
76        if src.sampled_image_filter_minmax { *dst |= 0x00010000; }
77        if src.sampled_image_filter_cubic_img { *dst |= 0x00002000; }
78        if src.acceleration_structure_vertex_buffer_khr { *dst |= 0x20000000; }
79        if src.fragment_density_map_ext { *dst |= 0x01000000; }
80    }
81}
82
83impl VkRawType<VkFormatFeatureFlags> for RawVkFormatFeatureFlags {
84    fn vk_to_wrapped(src: &RawVkFormatFeatureFlags) -> VkFormatFeatureFlags {
85        VkFormatFeatureFlags {
86            sampled_image: (src & 0x00000001) != 0,
87            storage_image: (src & 0x00000002) != 0,
88            storage_image_atomic: (src & 0x00000004) != 0,
89            uniform_texel_buffer: (src & 0x00000008) != 0,
90            storage_texel_buffer: (src & 0x00000010) != 0,
91            storage_texel_buffer_atomic: (src & 0x00000020) != 0,
92            vertex_buffer: (src & 0x00000040) != 0,
93            color_attachment: (src & 0x00000080) != 0,
94            color_attachment_blend: (src & 0x00000100) != 0,
95            depth_stencil_attachment: (src & 0x00000200) != 0,
96            blit_src: (src & 0x00000400) != 0,
97            blit_dst: (src & 0x00000800) != 0,
98            sampled_image_filter_linear: (src & 0x00001000) != 0,
99            transfer_src: (src & 0x00004000) != 0,
100            transfer_dst: (src & 0x00008000) != 0,
101            midpoint_chroma_samples: (src & 0x00020000) != 0,
102            sampled_image_ycbcr_conversion_linear_filter: (src & 0x00040000) != 0,
103            sampled_image_ycbcr_conversion_separate_reconstruction_filter: (src & 0x00080000) != 0,
104            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: (src & 0x00100000) != 0,
105            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: (src & 0x00200000) != 0,
106            disjoint: (src & 0x00400000) != 0,
107            cosited_chroma_samples: (src & 0x00800000) != 0,
108            sampled_image_filter_minmax: (src & 0x00010000) != 0,
109            sampled_image_filter_cubic_img: (src & 0x00002000) != 0,
110            acceleration_structure_vertex_buffer_khr: (src & 0x20000000) != 0,
111            fragment_density_map_ext: (src & 0x01000000) != 0,
112        }
113    }
114}
115
116impl Default for VkFormatFeatureFlags {
117    fn default() -> VkFormatFeatureFlags {
118        VkFormatFeatureFlags {
119            sampled_image: false,
120            storage_image: false,
121            storage_image_atomic: false,
122            uniform_texel_buffer: false,
123            storage_texel_buffer: false,
124            storage_texel_buffer_atomic: false,
125            vertex_buffer: false,
126            color_attachment: false,
127            color_attachment_blend: false,
128            depth_stencil_attachment: false,
129            blit_src: false,
130            blit_dst: false,
131            sampled_image_filter_linear: false,
132            transfer_src: false,
133            transfer_dst: false,
134            midpoint_chroma_samples: false,
135            sampled_image_ycbcr_conversion_linear_filter: false,
136            sampled_image_ycbcr_conversion_separate_reconstruction_filter: false,
137            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: false,
138            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: false,
139            disjoint: false,
140            cosited_chroma_samples: false,
141            sampled_image_filter_minmax: false,
142            sampled_image_filter_cubic_img: false,
143            acceleration_structure_vertex_buffer_khr: false,
144            fragment_density_map_ext: false,
145        }
146    }
147}
148
149impl VkFormatFeatureFlags {
150    
151    /// Return a structure with all flags to `false`.
152    pub fn none() -> Self {
153        VkFormatFeatureFlags {
154            sampled_image: false,
155            storage_image: false,
156            storage_image_atomic: false,
157            uniform_texel_buffer: false,
158            storage_texel_buffer: false,
159            storage_texel_buffer_atomic: false,
160            vertex_buffer: false,
161            color_attachment: false,
162            color_attachment_blend: false,
163            depth_stencil_attachment: false,
164            blit_src: false,
165            blit_dst: false,
166            sampled_image_filter_linear: false,
167            transfer_src: false,
168            transfer_dst: false,
169            midpoint_chroma_samples: false,
170            sampled_image_ycbcr_conversion_linear_filter: false,
171            sampled_image_ycbcr_conversion_separate_reconstruction_filter: false,
172            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: false,
173            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: false,
174            disjoint: false,
175            cosited_chroma_samples: false,
176            sampled_image_filter_minmax: false,
177            sampled_image_filter_cubic_img: false,
178            acceleration_structure_vertex_buffer_khr: false,
179            fragment_density_map_ext: false,
180        }
181    }
182    
183    /// Return a structure with all flags to `true`.
184    pub fn all() -> Self {
185        VkFormatFeatureFlags {
186            sampled_image: true,
187            storage_image: true,
188            storage_image_atomic: true,
189            uniform_texel_buffer: true,
190            storage_texel_buffer: true,
191            storage_texel_buffer_atomic: true,
192            vertex_buffer: true,
193            color_attachment: true,
194            color_attachment_blend: true,
195            depth_stencil_attachment: true,
196            blit_src: true,
197            blit_dst: true,
198            sampled_image_filter_linear: true,
199            transfer_src: true,
200            transfer_dst: true,
201            midpoint_chroma_samples: true,
202            sampled_image_ycbcr_conversion_linear_filter: true,
203            sampled_image_ycbcr_conversion_separate_reconstruction_filter: true,
204            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: true,
205            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: true,
206            disjoint: true,
207            cosited_chroma_samples: true,
208            sampled_image_filter_minmax: true,
209            sampled_image_filter_cubic_img: true,
210            acceleration_structure_vertex_buffer_khr: true,
211            fragment_density_map_ext: true,
212        }
213    }
214    
215    /// Return the numerical bit flags corresponding to the structure (as described in the Vulkan specs).
216    pub fn to_u32(&self) -> u32 {
217        0
218        + if self.sampled_image { 0x00000001 } else { 0 }
219        + if self.storage_image { 0x00000002 } else { 0 }
220        + if self.storage_image_atomic { 0x00000004 } else { 0 }
221        + if self.uniform_texel_buffer { 0x00000008 } else { 0 }
222        + if self.storage_texel_buffer { 0x00000010 } else { 0 }
223        + if self.storage_texel_buffer_atomic { 0x00000020 } else { 0 }
224        + if self.vertex_buffer { 0x00000040 } else { 0 }
225        + if self.color_attachment { 0x00000080 } else { 0 }
226        + if self.color_attachment_blend { 0x00000100 } else { 0 }
227        + if self.depth_stencil_attachment { 0x00000200 } else { 0 }
228        + if self.blit_src { 0x00000400 } else { 0 }
229        + if self.blit_dst { 0x00000800 } else { 0 }
230        + if self.sampled_image_filter_linear { 0x00001000 } else { 0 }
231        + if self.transfer_src { 0x00004000 } else { 0 }
232        + if self.transfer_dst { 0x00008000 } else { 0 }
233        + if self.midpoint_chroma_samples { 0x00020000 } else { 0 }
234        + if self.sampled_image_ycbcr_conversion_linear_filter { 0x00040000 } else { 0 }
235        + if self.sampled_image_ycbcr_conversion_separate_reconstruction_filter { 0x00080000 } else { 0 }
236        + if self.sampled_image_ycbcr_conversion_chroma_reconstruction_explicit { 0x00100000 } else { 0 }
237        + if self.sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable { 0x00200000 } else { 0 }
238        + if self.disjoint { 0x00400000 } else { 0 }
239        + if self.cosited_chroma_samples { 0x00800000 } else { 0 }
240        + if self.sampled_image_filter_minmax { 0x00010000 } else { 0 }
241        + if self.sampled_image_filter_cubic_img { 0x00002000 } else { 0 }
242        + if self.acceleration_structure_vertex_buffer_khr { 0x20000000 } else { 0 }
243        + if self.fragment_density_map_ext { 0x01000000 } else { 0 }
244    }
245    
246    /// Create a structure corresponding to the specified numerical bit flags.
247    pub fn from_u32(value: u32) -> Self {
248        VkFormatFeatureFlags {
249            sampled_image: value & 0x00000001 > 0,
250            storage_image: value & 0x00000002 > 0,
251            storage_image_atomic: value & 0x00000004 > 0,
252            uniform_texel_buffer: value & 0x00000008 > 0,
253            storage_texel_buffer: value & 0x00000010 > 0,
254            storage_texel_buffer_atomic: value & 0x00000020 > 0,
255            vertex_buffer: value & 0x00000040 > 0,
256            color_attachment: value & 0x00000080 > 0,
257            color_attachment_blend: value & 0x00000100 > 0,
258            depth_stencil_attachment: value & 0x00000200 > 0,
259            blit_src: value & 0x00000400 > 0,
260            blit_dst: value & 0x00000800 > 0,
261            sampled_image_filter_linear: value & 0x00001000 > 0,
262            transfer_src: value & 0x00004000 > 0,
263            transfer_dst: value & 0x00008000 > 0,
264            midpoint_chroma_samples: value & 0x00020000 > 0,
265            sampled_image_ycbcr_conversion_linear_filter: value & 0x00040000 > 0,
266            sampled_image_ycbcr_conversion_separate_reconstruction_filter: value & 0x00080000 > 0,
267            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit: value & 0x00100000 > 0,
268            sampled_image_ycbcr_conversion_chroma_reconstruction_explicit_forceable: value & 0x00200000 > 0,
269            disjoint: value & 0x00400000 > 0,
270            cosited_chroma_samples: value & 0x00800000 > 0,
271            sampled_image_filter_minmax: value & 0x00010000 > 0,
272            sampled_image_filter_cubic_img: value & 0x00002000 > 0,
273            acceleration_structure_vertex_buffer_khr: value & 0x20000000 > 0,
274            fragment_density_map_ext: value & 0x01000000 > 0,
275        }
276    }
277}
278
279#[doc(hidden)]
280#[macro_export]
281macro_rules! VkFormatFeatureFlags {
282    ( $( $x:ident ),* ) => {
283        VkFormatFeatureFlags {
284            $($x: true,)*
285            ..VkFormatFeatureFlags::none()
286        }
287    }
288}