vk_graph/driver/physical_device.rs
1//! Physical device types.
2
3use {
4 super::{
5 DriverError,
6 instance::{ApiVersion, Instance},
7 },
8 crate::driver::device::Device,
9 ash::{ext, khr as ash_khr, vk},
10 log::{debug, error, warn},
11 std::{
12 collections::HashSet,
13 ffi::{CStr, c_char},
14 fmt::{Debug, Formatter},
15 iter::repeat_n,
16 },
17};
18
19const UNKNOWN_C_STRING: &str = "unknown";
20const MAX_C_STRING_UTF8_BYTES: usize = 128;
21
22fn vk_cstr_to_utf8_string(cstr: &[c_char]) -> String {
23 let scan_len = cstr.len().min(MAX_C_STRING_UTF8_BYTES + 1);
24 let mut bytes = Vec::with_capacity(scan_len.min(MAX_C_STRING_UTF8_BYTES));
25
26 for (idx, &ch) in cstr.iter().take(scan_len).enumerate() {
27 let byte = ch as u8;
28
29 if byte == 0 {
30 let Ok(res) = String::from_utf8(bytes) else {
31 break;
32 };
33
34 return res;
35 }
36
37 if idx == MAX_C_STRING_UTF8_BYTES {
38 break;
39 }
40
41 bytes.push(byte);
42 }
43
44 UNKNOWN_C_STRING.to_owned()
45}
46
47fn vk_extension_name(extension_name: &'static CStr) -> &'static str {
48 extension_name
49 .to_str()
50 .expect("Vulkan extension name should be UTF-8")
51}
52
53/// Physical-device support types for `VK_KHR_*` extensions.
54pub mod khr {
55 use ash::vk;
56
57 /// Properties of the physical device for acceleration structures.
58 ///
59 /// See [`VkPhysicalDeviceAccelerationStructurePropertiesKHR`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceAccelerationStructurePropertiesKHR.html).
60 #[derive(Clone, Copy, Debug)]
61 pub struct AccelerationStructureProperties {
62 /// The maximum number of geometries in a bottom-level acceleration structure.
63 pub max_geometry_count: u64,
64
65 /// The maximum number of instances in a top-level acceleration structure.
66 pub max_instance_count: u64,
67
68 /// The maximum number of triangles or AABBs in all geometries in a bottom-level acceleration
69 /// structure.
70 pub max_primitive_count: u64,
71
72 /// The maximum number of acceleration structure bindings that can be accessible to a single
73 /// shader stage in a pipeline layout.
74 ///
75 /// Descriptor bindings with a descriptor type of
76 /// `VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR` count against this limit.
77 pub max_per_stage_descriptor_accel_structs: u32,
78
79 /// The maximum number of acceleration structure descriptors that can be included in descriptor
80 /// bindings in a pipeline layout across all pipeline shader stages and descriptor set numbers.
81 ///
82 /// Descriptor bindings with a descriptor type of
83 /// `VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR` count against this limit.
84 pub max_descriptor_set_accel_structs: u32,
85
86 /// The minimum required alignment, in bytes, for scratch data passed in to an acceleration
87 /// structure build command.
88 pub min_accel_struct_scratch_offset_alignment: u32,
89 }
90
91 impl From<vk::PhysicalDeviceAccelerationStructurePropertiesKHR<'_>>
92 for AccelerationStructureProperties
93 {
94 fn from(props: vk::PhysicalDeviceAccelerationStructurePropertiesKHR<'_>) -> Self {
95 Self {
96 max_geometry_count: props.max_geometry_count,
97 max_instance_count: props.max_instance_count,
98 max_primitive_count: props.max_primitive_count,
99 max_per_stage_descriptor_accel_structs: props
100 .max_per_stage_descriptor_acceleration_structures,
101 max_descriptor_set_accel_structs: props.max_descriptor_set_acceleration_structures,
102 min_accel_struct_scratch_offset_alignment: props
103 .min_acceleration_structure_scratch_offset_alignment,
104 }
105 }
106 }
107
108 /// Features of the physical device for acceleration structures.
109 #[derive(Clone, Copy, Debug)]
110 pub struct AccelerationStructureFeatures {
111 /// Indicates whether the implementation supports acceleration structure functionality.
112 pub acceleration_structure: bool,
113
114 /// Indicates whether acceleration structure capture and replay is supported.
115 pub acceleration_structure_capture_replay: bool,
116
117 /// Indicates whether indirect acceleration structure build commands are supported.
118 pub acceleration_structure_indirect_build: bool,
119
120 /// Indicates whether acceleration structures can be built on the host.
121 pub acceleration_structure_host_commands: bool,
122
123 /// Indicates whether acceleration structure descriptors can be updated after bind.
124 pub descriptor_binding_acceleration_structure_update_after_bind: bool,
125 }
126
127 impl From<vk::PhysicalDeviceAccelerationStructureFeaturesKHR<'_>>
128 for AccelerationStructureFeatures
129 {
130 fn from(features: vk::PhysicalDeviceAccelerationStructureFeaturesKHR<'_>) -> Self {
131 Self {
132 acceleration_structure: features.acceleration_structure == vk::TRUE,
133 acceleration_structure_capture_replay: features
134 .acceleration_structure_capture_replay
135 == vk::TRUE,
136 acceleration_structure_indirect_build: features
137 .acceleration_structure_indirect_build
138 == vk::TRUE,
139 acceleration_structure_host_commands: features.acceleration_structure_host_commands
140 == vk::TRUE,
141 descriptor_binding_acceleration_structure_update_after_bind: features
142 .descriptor_binding_acceleration_structure_update_after_bind
143 == vk::TRUE,
144 }
145 }
146 }
147
148 /// Features and properties advertised by `VK_KHR_acceleration_structure`.
149 #[derive(Clone, Copy, Debug)]
150 pub struct AccelerationStructure {
151 /// Features advertised by `VK_KHR_acceleration_structure`.
152 pub features: AccelerationStructureFeatures,
153
154 /// Properties advertised by `VK_KHR_acceleration_structure`.
155 pub properties: AccelerationStructureProperties,
156 }
157
158 /// Features of the physical device for ray tracing.
159 ///
160 /// See [`VkPhysicalDeviceRayTracingPipelineFeaturesKHR`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceRayTracingPipelineFeaturesKHR.html).
161 #[derive(Clone, Copy, Debug)]
162 pub struct RayTracingPipelineFeatures {
163 /// Indicates whether the implementation supports the ray tracing pipeline functionality.
164 ///
165 /// See the [ray tracing pipeline chapter](https://docs.vulkan.org/spec/latest/chapters/raytracing.html).
166 ///
167 pub ray_tracing_pipeline: bool,
168
169 /// Indicates whether the implementation supports saving and reusing shader group handles, e.g.
170 /// for trace capture and replay.
171 pub ray_tracing_pipeline_shader_group_handle_capture_replay: bool,
172
173 /// Indicates whether the implementation supports reuse of shader group handles being
174 /// arbitrarily mixed with creation of non-reused shader group handles.
175 ///
176 /// If this is `false`, all reused shader group handles must be specified before any non-reused
177 /// handles may be created.
178 pub ray_tracing_pipeline_shader_group_handle_capture_replay_mixed: bool,
179
180 /// Indicates whether the implementation supports indirect ray tracing commands, e.g.
181 /// `vkCmdTraceRaysIndirectKHR`.
182 pub ray_tracing_pipeline_trace_rays_indirect: bool,
183
184 /// Indicates whether the implementation supports primitive culling during ray traversal.
185 pub ray_traversal_primitive_culling: bool,
186 }
187
188 impl From<vk::PhysicalDeviceRayTracingPipelineFeaturesKHR<'_>> for RayTracingPipelineFeatures {
189 fn from(features: vk::PhysicalDeviceRayTracingPipelineFeaturesKHR<'_>) -> Self {
190 Self {
191 ray_tracing_pipeline: features.ray_tracing_pipeline == vk::TRUE,
192 ray_tracing_pipeline_shader_group_handle_capture_replay: features
193 .ray_tracing_pipeline_shader_group_handle_capture_replay
194 == vk::TRUE,
195 ray_tracing_pipeline_shader_group_handle_capture_replay_mixed: features
196 .ray_tracing_pipeline_shader_group_handle_capture_replay_mixed
197 == vk::TRUE,
198 ray_tracing_pipeline_trace_rays_indirect: features
199 .ray_tracing_pipeline_trace_rays_indirect
200 == vk::TRUE,
201 ray_traversal_primitive_culling: features.ray_traversal_primitive_culling
202 == vk::TRUE,
203 }
204 }
205 }
206
207 /// Properties of the physical device for ray tracing.
208 ///
209 /// See [`VkPhysicalDeviceRayTracingPipelinePropertiesKHR`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceRayTracingPipelinePropertiesKHR.html).
210 #[derive(Clone, Copy, Debug)]
211 pub struct RayTracingPipelineProperties {
212 /// The size in bytes of the shader header.
213 pub shader_group_handle_size: u32,
214
215 /// The maximum number of levels of ray recursion allowed in a trace command.
216 pub max_ray_recursion_depth: u32,
217
218 /// The maximum stride in bytes allowed between shader groups in the shader binding table.
219 pub max_shader_group_stride: u32,
220
221 /// The required alignment in bytes for the base of the shader binding table.
222 pub shader_group_base_alignment: u32,
223
224 /// The number of bytes for the information required to do capture and replay for shader group
225 /// handles.
226 pub shader_group_handle_capture_replay_size: u32,
227
228 /// The maximum number of ray generation shader invocations which may be produced by a single
229 /// `vkCmdTraceRaysIndirectKHR` or `vkCmdTraceRaysKHR` command.
230 pub max_ray_dispatch_invocation_count: u32,
231
232 /// The required alignment in bytes for each shader binding table entry.
233 ///
234 /// The value must be a power of two.
235 pub shader_group_handle_alignment: u32,
236
237 /// The maximum size in bytes for a ray attribute structure.
238 pub max_ray_hit_attribute_size: u32,
239 }
240
241 impl From<vk::PhysicalDeviceRayTracingPipelinePropertiesKHR<'_>> for RayTracingPipelineProperties {
242 fn from(props: vk::PhysicalDeviceRayTracingPipelinePropertiesKHR<'_>) -> Self {
243 Self {
244 shader_group_handle_size: props.shader_group_handle_size,
245 max_ray_recursion_depth: props.max_ray_recursion_depth,
246 max_shader_group_stride: props.max_shader_group_stride,
247 shader_group_base_alignment: props.shader_group_base_alignment,
248 shader_group_handle_capture_replay_size: props
249 .shader_group_handle_capture_replay_size,
250 max_ray_dispatch_invocation_count: props.max_ray_dispatch_invocation_count,
251 shader_group_handle_alignment: props.shader_group_handle_alignment,
252 max_ray_hit_attribute_size: props.max_ray_hit_attribute_size,
253 }
254 }
255 }
256
257 /// Features and properties advertised by `VK_KHR_ray_tracing_pipeline`.
258 #[derive(Clone, Copy, Debug)]
259 pub struct RayTracingPipeline {
260 /// Features advertised by `VK_KHR_ray_tracing_pipeline`.
261 pub features: RayTracingPipelineFeatures,
262
263 /// Properties advertised by `VK_KHR_ray_tracing_pipeline`.
264 pub properties: RayTracingPipelineProperties,
265 }
266
267 /// Features advertised by `VK_KHR_present_id`.
268 #[derive(Clone, Copy, Debug)]
269 pub struct PresentId {
270 /// Features advertised by `VK_KHR_present_id`.
271 pub features: PresentIdFeatures,
272 }
273
274 /// Features of the physical device for present IDs.
275 #[derive(Clone, Copy, Debug)]
276 pub struct PresentIdFeatures {
277 /// Indicates whether present IDs are supported.
278 pub present_id: bool,
279 }
280
281 impl From<vk::PhysicalDevicePresentIdFeaturesKHR<'_>> for PresentIdFeatures {
282 fn from(features: vk::PhysicalDevicePresentIdFeaturesKHR<'_>) -> Self {
283 Self {
284 present_id: features.present_id == vk::TRUE,
285 }
286 }
287 }
288
289 /// Features advertised by `VK_KHR_present_wait`.
290 #[derive(Clone, Copy, Debug)]
291 pub struct PresentWait {
292 /// Features advertised by `VK_KHR_present_wait`.
293 pub features: PresentWaitFeatures,
294 }
295
296 /// Features of the physical device for present wait.
297 #[derive(Clone, Copy, Debug)]
298 pub struct PresentWaitFeatures {
299 /// Indicates whether present wait is supported.
300 pub present_wait: bool,
301 }
302
303 impl From<vk::PhysicalDevicePresentWaitFeaturesKHR<'_>> for PresentWaitFeatures {
304 fn from(features: vk::PhysicalDevicePresentWaitFeaturesKHR<'_>) -> Self {
305 Self {
306 present_wait: features.present_wait == vk::TRUE,
307 }
308 }
309 }
310}
311
312/// Structure describing depth/stencil resolve properties that can be supported by an
313/// implementation.
314///
315/// See [`VkPhysicalDeviceDepthStencilResolveProperties`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceDepthStencilResolveProperties.html).
316#[derive(Clone, Copy, Debug)]
317pub struct DepthStencilResolveProperties {
318 /// A bitmask indicating the set of supported depth resolve modes.
319 ///
320 /// `VK_RESOLVE_MODE_SAMPLE_ZERO_BIT` must be included in the set but implementations may
321 /// support additional modes.
322 pub supported_depth_resolve_modes: vk::ResolveModeFlags,
323
324 /// A bitmask indicating the set of supported stencil resolve modes.
325 ///
326 /// `VK_RESOLVE_MODE_SAMPLE_ZERO_BIT` must be included in the set but implementations may
327 /// support additional modes. `VK_RESOLVE_MODE_AVERAGE_BIT` must not be included in the set.
328 pub supported_stencil_resolve_modes: vk::ResolveModeFlags,
329
330 /// `true` if the implementation supports setting the depth and stencil resolve modes to
331 /// different values when one of those modes is `VK_RESOLVE_MODE_NONE`. Otherwise the
332 /// implementation only supports setting both modes to the same value.
333 pub independent_resolve_none: bool,
334
335 /// `true` if the implementation supports all combinations of the supported depth and stencil
336 /// resolve modes, including setting either depth or stencil resolve mode to
337 /// `VK_RESOLVE_MODE_NONE`.
338 ///
339 /// An implementation that supports `independent_resolve` must also support
340 /// `independent_resolve_none`.
341 pub independent_resolve: bool,
342}
343
344impl From<vk::PhysicalDeviceDepthStencilResolveProperties<'_>> for DepthStencilResolveProperties {
345 fn from(props: vk::PhysicalDeviceDepthStencilResolveProperties<'_>) -> Self {
346 Self {
347 supported_depth_resolve_modes: props.supported_depth_resolve_modes,
348 supported_stencil_resolve_modes: props.supported_stencil_resolve_modes,
349 independent_resolve_none: props.independent_resolve_none == vk::TRUE,
350 independent_resolve: props.independent_resolve == vk::TRUE,
351 }
352 }
353}
354
355/// Structure which holds data about a physical device.
356///
357/// Extension support is exposed through fields named after Vulkan extension names. Extensions that
358/// only need a support check are booleans, such as [`Self::vk_ext_private_data`] and
359/// [`Self::vk_khr_swapchain`]. Extensions with feature or property data are `Option` fields, such
360/// as [`Self::vk_khr_acceleration_structure`] and [`Self::vk_khr_ray_tracing_pipeline`].
361///
362/// Use [`Device::physical`](super::device::Device::physical) for the selected physical device of a
363/// logical device.
364///
365/// See [`VkPhysicalDevice`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDevice.html).
366#[derive(Clone)]
367#[read_only::cast]
368pub struct PhysicalDevice {
369 /// Describes the properties of the device which relate to depth/stencil resolve operations.
370 ///
371 /// _Note:_ This field is read-only.
372 pub depth_stencil_resolve_properties: DepthStencilResolveProperties,
373
374 /// Describes the features of the physical device which are part of the Vulkan 1.0 base feature
375 /// set.
376 ///
377 /// _Note:_ This field is read-only.
378 pub features_v1_0: Vulkan10Features,
379
380 /// Describes the features of the physical device which are part of the Vulkan 1.1 base feature
381 /// set.
382 ///
383 /// _Note:_ This field is read-only.
384 pub features_v1_1: Vulkan11Features,
385
386 /// Describes the features of the physical device which are part of the Vulkan 1.2 base feature
387 /// set.
388 ///
389 /// _Note:_ This field is read-only.
390 pub features_v1_2: Vulkan12Features,
391
392 /// The native Vulkan resource handle of this physical device.
393 ///
394 /// _Note:_ This field is read-only.
395 pub handle: vk::PhysicalDevice,
396
397 /// The Vulkan instance which owns this device.
398 ///
399 /// _Note:_ This field is read-only.
400 pub instance: Instance,
401
402 /// Memory properties of the physical device.
403 ///
404 /// _Note:_ This field is read-only.
405 pub memory_properties: vk::PhysicalDeviceMemoryProperties,
406
407 /// Device properties of the physical device which are part of the Vulkan 1.0 base property set.
408 ///
409 /// _Note:_ This field is read-only.
410 pub properties_v1_0: Vulkan10Properties,
411
412 /// Describes the properties of the physical device which are part of the Vulkan 1.1 base
413 /// property set.
414 ///
415 /// _Note:_ This field is read-only.
416 pub properties_v1_1: Vulkan11Properties,
417
418 /// Describes the properties of the physical device which are part of the Vulkan 1.2 base
419 /// property set.
420 ///
421 /// _Note:_ This field is read-only.
422 pub properties_v1_2: Vulkan12Properties,
423
424 /// Describes the queues offered by this physical device.
425 ///
426 /// _Note:_ This field is read-only.
427 pub queue_families: Box<[vk::QueueFamilyProperties]>,
428
429 pub(crate) queue_family_indices: Box<[u32]>,
430
431 /// `VK_KHR_ray_tracing_pipeline` features and properties, when supported.
432 ///
433 /// _Note:_ This field is read-only.
434 pub vk_khr_ray_tracing_pipeline: Option<khr::RayTracingPipeline>,
435
436 /// Describes the properties of the device which relate to min/max sampler filtering.
437 ///
438 /// _Note:_ This field is read-only.
439 pub sampler_filter_minmax_properties: SamplerFilterMinmaxProperties,
440
441 /// Whether `VK_EXT_index_type_uint8` support is available.
442 ///
443 /// _Note:_ This field is read-only.
444 pub vk_ext_index_type_uint8: bool,
445
446 /// Whether `VK_EXT_private_data` support is available.
447 ///
448 /// _Note:_ This field is read-only.
449 pub vk_ext_private_data: bool,
450
451 /// `VK_KHR_acceleration_structure` features and properties, when supported.
452 ///
453 /// _Note:_ This field is read-only.
454 pub vk_khr_acceleration_structure: Option<khr::AccelerationStructure>,
455
456 /// `VK_KHR_present_id` features, when supported.
457 ///
458 /// _Note:_ This field is read-only.
459 pub vk_khr_present_id: Option<khr::PresentId>,
460
461 /// `VK_KHR_present_wait` features, when supported.
462 ///
463 /// _Note:_ This field is read-only.
464 pub vk_khr_present_wait: Option<khr::PresentWait>,
465
466 /// Whether `VK_KHR_ray_query` support is available.
467 ///
468 /// _Note:_ This field is read-only.
469 pub vk_khr_ray_query: bool,
470
471 /// Whether `VK_KHR_swapchain` support is available.
472 ///
473 /// _Note:_ This field is read-only.
474 pub vk_khr_swapchain: bool,
475
476 /// Whether synchronization2 support is available through Vulkan 1.3 core or
477 /// `VK_KHR_synchronization2`.
478 ///
479 /// _Note:_ This field is read-only.
480 pub vk_khr_synchronization2: bool,
481}
482
483impl PhysicalDevice {
484 /// Prepares device creation information and calls the provided callback to allow an application
485 /// to control the device creation process.
486 ///
487 /// _Note:_ This is only useful for interoperating with other libraries as device creation is
488 /// normally handled by the [`Device::try_from_display`] and [`Device::create`]
489 /// functions.
490 ///
491 /// # Safety
492 ///
493 /// This comes with all the caveats of using `ash` builder types, which are inherently
494 /// dangerous. Use with extreme caution.
495 ///
496 /// See [`VkDeviceCreateInfo`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkDeviceCreateInfo.html).
497 #[profiling::function]
498 pub unsafe fn create_ash_device<F>(&self, create_fn: F) -> ash::prelude::VkResult<ash::Device>
499 where
500 F: FnOnce(vk::DeviceCreateInfo) -> ash::prelude::VkResult<ash::Device>,
501 {
502 let mut enabled_ext_names = Vec::with_capacity(11);
503
504 if self.vk_khr_acceleration_structure.is_some() {
505 enabled_ext_names.push(ash_khr::acceleration_structure::NAME.as_ptr());
506 enabled_ext_names.push(ash_khr::deferred_host_operations::NAME.as_ptr());
507 }
508
509 if self.vk_ext_index_type_uint8 {
510 enabled_ext_names.push(ext::index_type_uint8::NAME.as_ptr());
511 }
512
513 if self.vk_khr_present_id.is_some() {
514 enabled_ext_names.push(ash_khr::present_id::NAME.as_ptr());
515 }
516
517 if self.vk_khr_present_wait.is_some() {
518 enabled_ext_names.push(ash_khr::present_wait::NAME.as_ptr());
519 }
520
521 if self.vk_khr_synchronization2 && self.instance.info.api_version < ApiVersion::Vulkan13 {
522 enabled_ext_names.push(ash_khr::synchronization2::NAME.as_ptr());
523 }
524
525 if self.vk_ext_private_data {
526 enabled_ext_names.push(ext::private_data::NAME.as_ptr());
527 }
528
529 if self.vk_khr_ray_query {
530 enabled_ext_names.push(ash_khr::ray_query::NAME.as_ptr());
531 }
532
533 if self
534 .vk_khr_ray_tracing_pipeline
535 .as_ref()
536 .is_some_and(|ext| ext.features.ray_tracing_pipeline)
537 {
538 enabled_ext_names.push(ash_khr::ray_tracing_pipeline::NAME.as_ptr());
539 }
540
541 /*
542 The swapchain extension is required for presentation support, so we enable it whenever the
543 physical device reports support. Imported instances may already carry the required instance
544 extensions even though vk-graph did not create them.
545 */
546 if self.vk_khr_swapchain {
547 enabled_ext_names.push(ash_khr::swapchain::NAME.as_ptr());
548 }
549
550 // MoltenVK doesn't support the full Vulkan feature set, hence the portability subset
551 // extension must be enabled
552 #[cfg(all(target_os = "macos", feature = "loaded"))]
553 enabled_ext_names.push(ash_khr::portability_subset::NAME.as_ptr());
554
555 let priorities = repeat_n(
556 1.0,
557 self.queue_families
558 .iter()
559 .map(|family| family.queue_count)
560 .max()
561 .unwrap_or_default() as _,
562 )
563 .collect::<Box<_>>();
564
565 let queue_infos = self
566 .queue_families
567 .iter()
568 .enumerate()
569 .map(|(idx, family)| {
570 let mut queue_info = vk::DeviceQueueCreateInfo::default()
571 .queue_family_index(idx as _)
572 .queue_priorities(&priorities[0..family.queue_count as usize]);
573 queue_info.queue_count = family.queue_count;
574
575 queue_info
576 })
577 .collect::<Box<_>>();
578
579 let ash::InstanceFnV1_1 {
580 get_physical_device_features2,
581 ..
582 } = self.instance.fp_v1_1();
583 let mut features_v1_1 = vk::PhysicalDeviceVulkan11Features::default();
584 let mut features_v1_2 = vk::PhysicalDeviceVulkan12Features::default();
585 let mut acceleration_structure_features =
586 vk::PhysicalDeviceAccelerationStructureFeaturesKHR::default();
587 let mut index_type_uint8_features = vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::default();
588 let mut present_id_features = vk::PhysicalDevicePresentIdFeaturesKHR::default();
589 let mut present_wait_features = vk::PhysicalDevicePresentWaitFeaturesKHR::default();
590 let mut ray_query_features = vk::PhysicalDeviceRayQueryFeaturesKHR::default();
591 let mut ray_tracing_pipeline_features =
592 vk::PhysicalDeviceRayTracingPipelineFeaturesKHR::default();
593 let mut synchronization2_features = vk::PhysicalDeviceSynchronization2Features::default();
594 let mut private_data_features = vk::PhysicalDevicePrivateDataFeaturesEXT::default();
595 let mut features = vk::PhysicalDeviceFeatures2::default()
596 .push_next(&mut features_v1_1)
597 .push_next(&mut features_v1_2);
598
599 if self.vk_khr_acceleration_structure.is_some() {
600 features = features.push_next(&mut acceleration_structure_features);
601 }
602
603 if self.vk_ext_index_type_uint8 {
604 features = features.push_next(&mut index_type_uint8_features);
605 }
606
607 if self.vk_khr_present_id.is_some() {
608 features = features.push_next(&mut present_id_features);
609 }
610
611 if self.vk_khr_present_wait.is_some() {
612 features = features.push_next(&mut present_wait_features);
613 }
614
615 if self.vk_khr_ray_query {
616 features = features.push_next(&mut ray_query_features);
617 }
618
619 if self
620 .vk_khr_ray_tracing_pipeline
621 .as_ref()
622 .is_some_and(|ext| ext.features.ray_tracing_pipeline)
623 {
624 features = features.push_next(&mut ray_tracing_pipeline_features);
625 }
626
627 if self.vk_khr_synchronization2 {
628 features = features.push_next(&mut synchronization2_features);
629 }
630
631 if self.vk_ext_private_data {
632 features = features.push_next(&mut private_data_features);
633 }
634
635 unsafe { get_physical_device_features2(self.handle, &mut features) };
636
637 let device_create_info = vk::DeviceCreateInfo::default()
638 .queue_create_infos(&queue_infos)
639 .enabled_extension_names(&enabled_ext_names)
640 .push_next(&mut features);
641
642 create_fn(device_create_info)
643 }
644
645 /// Helper for times when you already know that the device supports the ray tracing pipeline
646 /// extension.
647 ///
648 /// # Panics
649 ///
650 /// Panics if [`Self::vk_khr_ray_tracing_pipeline`] is `None`.
651 pub(crate) fn expect_ray_tracing_pipeline_properties(
652 &self,
653 ) -> &khr::RayTracingPipelineProperties {
654 self.vk_khr_ray_tracing_pipeline
655 .as_ref()
656 .map(|ext| &ext.properties)
657 .expect("missing VK_KHR_ray_tracing_pipeline")
658 }
659
660 /// Lists the capabilities of a given format.
661 ///
662 /// See [`vkGetPhysicalDeviceFormatProperties`](https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceFormatProperties.html).
663 #[profiling::function]
664 pub fn format_properties(&self, format: vk::Format) -> vk::FormatProperties {
665 unsafe {
666 self.instance
667 .get_physical_device_format_properties(self.handle, format)
668 }
669 }
670
671 /// Lists the physical device's image format capabilities.
672 ///
673 /// A result of `None` indicates the format is not supported.
674 ///
675 /// See [`vkGetPhysicalDeviceImageFormatProperties`](https://registry.khronos.org/vulkan/specs/latest/man/html/vkGetPhysicalDeviceImageFormatProperties.html).
676 #[profiling::function]
677 pub fn image_format_properties(
678 &self,
679 format: vk::Format,
680 image_type: vk::ImageType,
681 tiling: vk::ImageTiling,
682 usage: vk::ImageUsageFlags,
683 flags: vk::ImageCreateFlags,
684 ) -> Result<Option<vk::ImageFormatProperties>, DriverError> {
685 unsafe {
686 match self.instance.get_physical_device_image_format_properties(
687 self.handle,
688 format,
689 image_type,
690 tiling,
691 usage,
692 flags,
693 ) {
694 Ok(properties) => Ok(Some(properties)),
695 Err(err) if err == vk::Result::ERROR_FORMAT_NOT_SUPPORTED => {
696 // We don't log this condition because it is normal for unsupported
697 // formats to be checked - we use the result to inform callers they
698 // cannot use those formats
699
700 Ok(None)
701 }
702 Err(err) => {
703 warn!("unable to query image format properties: {err}");
704
705 Err(DriverError::OutOfMemory)
706 }
707 }
708 }
709 }
710
711 /// Creates a physical device wrapper which reports features and properties.
712 ///
713 /// # Safety
714 ///
715 /// `physical_device` must be a valid handle enumerated from `instance`, and it must remain
716 /// valid for the lifetime of the returned wrapper.
717 pub unsafe fn try_from_ash(
718 instance: &Instance,
719 physical_device: vk::PhysicalDevice,
720 ) -> Result<Self, DriverError> {
721 if physical_device == vk::PhysicalDevice::null() {
722 warn!("invalid physical device handle: null");
723
724 return Err(DriverError::InvalidData);
725 }
726
727 let (memory_properties, queue_families) = unsafe {
728 (
729 instance.get_physical_device_memory_properties(physical_device),
730 instance.get_physical_device_queue_family_properties(physical_device),
731 )
732 };
733
734 let mut queue_family_indices = Vec::with_capacity(queue_families.len());
735 for idx in 0..queue_families.len() as u32 {
736 queue_family_indices.push(idx);
737 }
738
739 let queue_families = queue_families.into();
740 let queue_family_indices = queue_family_indices.into();
741
742 let ash::InstanceFnV1_1 {
743 get_physical_device_features2,
744 get_physical_device_properties2,
745 ..
746 } = instance.fp_v1_1();
747
748 let extension_properties = unsafe {
749 instance
750 .enumerate_device_extension_properties(physical_device)
751 .map_err(|err| {
752 error!("unable to enumerate device extensions: {err}");
753
754 DriverError::Unsupported
755 })?
756 };
757
758 // Check for supported extensions
759 let extension_names = extension_properties
760 .iter()
761 .map(|prop| {
762 let extension_name = vk_cstr_to_utf8_string(&prop.extension_name);
763
764 debug!("extension {:?} v{}", extension_name, prop.spec_version);
765
766 extension_name
767 })
768 .collect::<HashSet<_>>();
769 let vk_khr_acceleration_structure = extension_names
770 .contains(vk_extension_name(ash_khr::acceleration_structure::NAME))
771 && extension_names.contains(vk_extension_name(ash_khr::deferred_host_operations::NAME));
772 let mut vk_ext_index_type_uint8 =
773 extension_names.contains(vk_extension_name(ext::index_type_uint8::NAME));
774 let mut vk_ext_private_data =
775 extension_names.contains(vk_extension_name(ext::private_data::NAME));
776 let mut vk_khr_present_id =
777 extension_names.contains(vk_extension_name(ash_khr::present_id::NAME));
778 let mut vk_khr_present_wait =
779 extension_names.contains(vk_extension_name(ash_khr::present_wait::NAME));
780 let mut vk_khr_ray_query =
781 extension_names.contains(vk_extension_name(ash_khr::ray_query::NAME));
782 let vk_khr_ray_tracing_pipeline =
783 extension_names.contains(vk_extension_name(ash_khr::ray_tracing_pipeline::NAME));
784 let vk_khr_swapchain = instance.khr_surface
785 && extension_names.contains(vk_extension_name(ash_khr::swapchain::NAME));
786 let mut vk_khr_synchronization2 = extension_names
787 .contains(vk_extension_name(ash_khr::synchronization2::NAME))
788 || instance.info.api_version >= ApiVersion::Vulkan13;
789
790 // Gather advertised features of the physical device
791 let mut features_v1_1 = vk::PhysicalDeviceVulkan11Features::default();
792 let mut features_v1_2 = vk::PhysicalDeviceVulkan12Features::default();
793 let mut acceleration_structure_features =
794 vk::PhysicalDeviceAccelerationStructureFeaturesKHR::default();
795 let mut index_type_u8_features = vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::default();
796 let mut present_id_features = vk::PhysicalDevicePresentIdFeaturesKHR::default();
797 let mut present_wait_features = vk::PhysicalDevicePresentWaitFeaturesKHR::default();
798 let mut ray_query_features = vk::PhysicalDeviceRayQueryFeaturesKHR::default();
799 let mut ray_tracing_pipeline_features =
800 vk::PhysicalDeviceRayTracingPipelineFeaturesKHR::default();
801 let mut synchronization2_features = vk::PhysicalDeviceSynchronization2Features::default();
802 let mut private_data_features = vk::PhysicalDevicePrivateDataFeaturesEXT::default();
803 let mut features = vk::PhysicalDeviceFeatures2::default()
804 .push_next(&mut features_v1_1)
805 .push_next(&mut features_v1_2);
806
807 if vk_khr_acceleration_structure {
808 features = features.push_next(&mut acceleration_structure_features);
809 }
810
811 if vk_ext_index_type_uint8 {
812 features = features.push_next(&mut index_type_u8_features);
813 }
814
815 if vk_ext_private_data {
816 features = features.push_next(&mut private_data_features);
817 }
818
819 if vk_khr_present_id {
820 features = features.push_next(&mut present_id_features);
821 }
822
823 if vk_khr_present_wait {
824 features = features.push_next(&mut present_wait_features);
825 }
826
827 if vk_khr_ray_query {
828 features = features.push_next(&mut ray_query_features);
829 }
830
831 if vk_khr_ray_tracing_pipeline {
832 features = features.push_next(&mut ray_tracing_pipeline_features);
833 }
834
835 if vk_khr_synchronization2 {
836 features = features.push_next(&mut synchronization2_features);
837 }
838
839 unsafe {
840 get_physical_device_features2(physical_device, &mut features);
841 }
842 let features_v1_0 = features.features.into();
843 let features_v1_1 = features_v1_1.into();
844 let features_v1_2 = features_v1_2.into();
845 vk_ext_index_type_uint8 &= index_type_u8_features.index_type_uint8 == vk::TRUE;
846 vk_khr_present_id &= present_id_features.present_id == vk::TRUE;
847 vk_khr_present_wait &= present_wait_features.present_wait == vk::TRUE && vk_khr_present_id;
848 vk_khr_ray_query &= ray_query_features.ray_query == vk::TRUE;
849 vk_khr_synchronization2 &= synchronization2_features.synchronization2 == vk::TRUE;
850 vk_ext_private_data &= private_data_features.private_data == vk::TRUE;
851
852 // Gather advertised properties of the physical device
853 let mut properties_v1_1 = vk::PhysicalDeviceVulkan11Properties::default();
854 let mut properties_v1_2 = vk::PhysicalDeviceVulkan12Properties::default();
855 let mut accel_struct_properties =
856 vk::PhysicalDeviceAccelerationStructurePropertiesKHR::default();
857 let mut depth_stencil_resolve_properties =
858 vk::PhysicalDeviceDepthStencilResolveProperties::default();
859 let mut ray_tracing_pipeline_properties =
860 vk::PhysicalDeviceRayTracingPipelinePropertiesKHR::default();
861 let mut sampler_filter_minmax_properties =
862 vk::PhysicalDeviceSamplerFilterMinmaxProperties::default();
863 let mut properties = vk::PhysicalDeviceProperties2::default()
864 .push_next(&mut properties_v1_1)
865 .push_next(&mut properties_v1_2)
866 .push_next(&mut accel_struct_properties)
867 .push_next(&mut depth_stencil_resolve_properties)
868 .push_next(&mut ray_tracing_pipeline_properties)
869 .push_next(&mut sampler_filter_minmax_properties);
870 unsafe {
871 get_physical_device_properties2(physical_device, &mut properties);
872 }
873 let properties_v1_0: Vulkan10Properties = properties.properties.into();
874 let properties_v1_1 = properties_v1_1.into();
875 let properties_v1_2 = properties_v1_2.into();
876 let depth_stencil_resolve_properties = depth_stencil_resolve_properties.into();
877 let sampler_filter_minmax_properties = sampler_filter_minmax_properties.into();
878
879 let vk_khr_acceleration_structure =
880 vk_khr_acceleration_structure.then(|| khr::AccelerationStructure {
881 features: acceleration_structure_features.into(),
882 properties: accel_struct_properties.into(),
883 });
884 let vk_khr_present_id = vk_khr_present_id.then(|| khr::PresentId {
885 features: present_id_features.into(),
886 });
887 let vk_khr_present_wait = vk_khr_present_wait.then(|| khr::PresentWait {
888 features: present_wait_features.into(),
889 });
890 let vk_khr_ray_tracing_pipeline =
891 vk_khr_ray_tracing_pipeline.then(|| khr::RayTracingPipeline {
892 features: ray_tracing_pipeline_features.into(),
893 properties: ray_tracing_pipeline_properties.into(),
894 });
895
896 Ok(Self {
897 depth_stencil_resolve_properties,
898 features_v1_0,
899 features_v1_1,
900 features_v1_2,
901 handle: physical_device,
902 instance: instance.clone(),
903 memory_properties,
904 properties_v1_0,
905 properties_v1_1,
906 properties_v1_2,
907 queue_families,
908 queue_family_indices,
909 sampler_filter_minmax_properties,
910 vk_ext_index_type_uint8,
911 vk_ext_private_data,
912 vk_khr_acceleration_structure,
913 vk_khr_present_id,
914 vk_khr_present_wait,
915 vk_khr_ray_query,
916 vk_khr_ray_tracing_pipeline,
917 vk_khr_swapchain,
918 vk_khr_synchronization2,
919 })
920 }
921
922 /// Creates a logical [`Device`] from this selected physical device.
923 pub fn try_into_device(self) -> Result<Device, DriverError> {
924 Device::try_from_physical_device(self)
925 }
926}
927
928impl Debug for PhysicalDevice {
929 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
930 write!(
931 f,
932 "{} ({:?})",
933 &self.properties_v1_0.device_name, self.properties_v1_0.device_type
934 )
935 }
936}
937
938/// Properties of the physical device for min/max sampler filtering.
939///
940/// See [`VkPhysicalDeviceSamplerFilterMinmaxProperties`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceSamplerFilterMinmaxProperties.html).
941#[derive(Clone, Copy, Debug)]
942pub struct SamplerFilterMinmaxProperties {
943 /// When `false` the component mapping of the image view used with min/max filtering must have
944 /// been created with the r component set to the identity swizzle. Only the r component of the
945 /// sampled image value is defined and the other component values are undefined.
946 ///
947 /// When `true` this restriction does not apply and image component mapping works as normal.
948 pub image_component_mapping: bool,
949
950 /// When `true` the following formats support the
951 /// `VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT` feature with `VK_IMAGE_TILING_OPTIMAL`,
952 /// if they support `VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT`:
953 ///
954 /// * [`vk::Format::R8_UNORM`]
955 /// * [`vk::Format::R8_SNORM`]
956 /// * [`vk::Format::R16_UNORM`]
957 /// * [`vk::Format::R16_SNORM`]
958 /// * [`vk::Format::R16_SFLOAT`]
959 /// * [`vk::Format::R32_SFLOAT`]
960 /// * [`vk::Format::D16_UNORM`]
961 /// * [`vk::Format::X8_D24_UNORM_PACK32`]
962 /// * [`vk::Format::D32_SFLOAT`]
963 /// * [`vk::Format::D16_UNORM_S8_UINT`]
964 /// * [`vk::Format::D24_UNORM_S8_UINT`]
965 /// * [`vk::Format::D32_SFLOAT_S8_UINT`]
966 ///
967 /// If the format is a depth/stencil format, this bit only specifies that the depth aspect (not
968 /// the stencil aspect) of an image of this format supports min/max filtering, and that min/max
969 /// filtering of the depth aspect is supported when depth compare is disabled in the sampler.
970 pub single_component_formats: bool,
971}
972
973impl From<vk::PhysicalDeviceSamplerFilterMinmaxProperties<'_>> for SamplerFilterMinmaxProperties {
974 fn from(value: vk::PhysicalDeviceSamplerFilterMinmaxProperties<'_>) -> Self {
975 Self {
976 image_component_mapping: value.filter_minmax_image_component_mapping == vk::TRUE,
977 single_component_formats: value.filter_minmax_single_component_formats == vk::TRUE,
978 }
979 }
980}
981
982/// Description of Vulkan 1.0 features.
983///
984/// See [`VkPhysicalDeviceFeatures`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceFeatures.html).
985#[derive(Clone, Copy, Debug)]
986pub struct Vulkan10Features {
987 /// Specifies that accesses to buffers are bounds-checked against the range of the buffer
988 /// descriptor.
989 pub robust_buffer_access: bool,
990
991 /// Specifies the full 32-bit range of indices is supported for indexed draw calls when using a
992 /// `VkIndexType` of `VK_INDEX_TYPE_UINT32`.
993 ///
994 /// `maxDrawIndexedIndexValue` is the maximum index value that may be used (aside from the
995 /// primitive restart index, which is always 2^32 - 1 when the `VkIndexType` is
996 /// `VK_INDEX_TYPE_UINT32`).
997 ///
998 /// If this feature is supported, `maxDrawIndexedIndexValue` must be 2^32 - 1; otherwise it
999 /// must be no smaller than 2^24 - 1.
1000 pub full_draw_index_uint32: bool,
1001
1002 /// Specifies whether image views with a `VkImageViewType` of `VK_IMAGE_VIEW_TYPE_CUBE_ARRAY`
1003 /// can be created, and that the corresponding `SampledCubeArray` and `ImageCubeArray` SPIR-V
1004 /// capabilities can be used in shader code.
1005 pub image_cube_array: bool,
1006
1007 /// Specifies whether the `VkPipelineColorBlendAttachmentState` settings are controlled
1008 /// independently per-attachment.
1009 ///
1010 /// If this feature is not enabled, the `VkPipelineColorBlendAttachmentState` settings for all
1011 /// color attachments must be identical. Otherwise, a different
1012 /// `VkPipelineColorBlendAttachmentState` can be provided for each bound color attachment.
1013 pub independent_blend: bool,
1014
1015 /// Specifies whether geometry shaders are supported.
1016 ///
1017 /// If this feature is not enabled, the `VK_SHADER_STAGE_GEOMETRY_BIT` and
1018 /// `VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT` enum values must not be used.
1019 ///
1020 /// This also specifies whether shader modules can declare the `Geometry` capability.
1021 pub geometry_shader: bool,
1022
1023 /// Specifies whether tessellation control and evaluation shaders are supported.
1024 ///
1025 /// If this feature is not enabled, the `VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT`,
1026 /// `VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT`,
1027 /// `VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT`,
1028 /// `VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT`, and
1029 /// `VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO` enum values must not be used.
1030 ///
1031 /// This also specifies whether shader modules can declare the `Tessellation` capability.
1032 pub tessellation_shader: bool,
1033
1034 /// Specifies whether Sample Shading and multisample interpolation are supported.
1035 ///
1036 /// If this feature is not enabled, the `sampleShadingEnable` member of the
1037 /// `VkPipelineMultisampleStateCreateInfo` structure must be set to `VK_FALSE` and the
1038 /// `minSampleShading` member is ignored.
1039 ///
1040 /// This also specifies whether shader modules can declare the `SampleRateShading` capability.
1041 pub sample_rate_shading: bool,
1042
1043 /// Specifies whether blend operations which take two sources are supported.
1044 ///
1045 /// If this feature is not enabled, the `VK_BLEND_FACTOR_SRC1_COLOR`,
1046 /// `VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR`, `VK_BLEND_FACTOR_SRC1_ALPHA`, and
1047 /// `VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA` enum values must not be used as source or
1048 /// destination blending factors.
1049 ///
1050 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
1051 pub dual_src_blend: bool,
1052
1053 /// Specifies whether logic operations are supported.
1054 ///
1055 /// If this feature is not enabled, the `logicOpEnable` member of the
1056 /// `VkPipelineColorBlendStateCreateInfo` structure must be set to `VK_FALSE`, and the
1057 /// `logicOp` member is ignored.
1058 pub logic_op: bool,
1059
1060 /// Specifies whether multiple draw indirect is supported.
1061 ///
1062 /// If this feature is not enabled, the `drawCount` parameter to the `vkCmdDrawIndirect` and
1063 /// `vkCmdDrawIndexedIndirect` commands must be `0` or `1`. The `maxDrawIndirectCount` member
1064 /// of the `VkPhysicalDeviceLimits` structure must also be `1` if this feature is not
1065 /// supported.
1066 ///
1067 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
1068 pub multi_draw_indirect: bool,
1069
1070 /// Specifies whether indirect drawing calls support the `firstInstance` parameter.
1071 ///
1072 /// If this feature is not enabled, the `firstInstance` member of all `VkDrawIndirectCommand`
1073 /// and `VkDrawIndexedIndirectCommand` structures that are provided to the `vkCmdDrawIndirect`
1074 /// and `vkCmdDrawIndexedIndirect` commands must be `0`.
1075 pub draw_indirect_first_instance: bool,
1076
1077 /// Specifies whether depth clamping is supported.
1078 ///
1079 /// If this feature is not enabled, the `depthClampEnable` member of the
1080 /// `VkPipelineRasterizationStateCreateInfo` structure must be set to `VK_FALSE`. Otherwise,
1081 /// setting `depthClampEnable` to `VK_TRUE` will enable depth clamping.
1082 pub depth_clamp: bool,
1083
1084 /// Specifies whether depth bias clamping is supported.
1085 ///
1086 /// If this feature is not enabled, the `depthBiasClamp` member of the
1087 /// `VkPipelineRasterizationStateCreateInfo` structure must be set to `0.0` unless the
1088 /// `VK_DYNAMIC_STATE_DEPTH_BIAS` dynamic state is enabled, and the `depthBiasClamp` parameter
1089 /// to `vkCmdSetDepthBias` must be set to `0.0`.
1090 pub depth_bias_clamp: bool,
1091
1092 /// Specifies whether point and wireframe fill modes are supported.
1093 ///
1094 /// If this feature is not enabled, the `VK_POLYGON_MODE_POINT` and `VK_POLYGON_MODE_LINE` enum
1095 /// values must not be used.
1096 pub fill_mode_non_solid: bool,
1097
1098 /// Specifies whether depth bounds tests are supported.
1099 ///
1100 /// If this feature is not enabled, the `depthBoundsTestEnable` member of the
1101 /// `VkPipelineDepthStencilStateCreateInfo` structure must be set to `VK_FALSE`. When
1102 /// `depthBoundsTestEnable` is set to `VK_FALSE`, the `minDepthBounds` and `maxDepthBounds`
1103 /// members of the `VkPipelineDepthStencilStateCreateInfo` structure are ignored.
1104 pub depth_bounds: bool,
1105
1106 /// Specifies whether lines with width other than `1.0` are supported.
1107 ///
1108 /// If this feature is not enabled, the `lineWidth` member of the
1109 /// `VkPipelineRasterizationStateCreateInfo` structure must be set to `1.0` unless the
1110 /// `VK_DYNAMIC_STATE_LINE_WIDTH` dynamic state is enabled, and the `lineWidth` parameter to
1111 /// `vkCmdSetLineWidth` must be set to `1.0`.
1112 ///
1113 /// When this feature is supported, the range and granularity of supported line widths are
1114 /// indicated by the `lineWidthRange` and `lineWidthGranularity` members of the
1115 /// `VkPhysicalDeviceLimits` structure, respectively.
1116 pub wide_lines: bool,
1117
1118 /// Specifies whether points with size greater than `1.0` are supported.
1119 ///
1120 /// If this feature is not enabled, only a point size of `1.0` written by a shader is
1121 /// supported.
1122 ///
1123 /// The range and granularity of supported point sizes are indicated by the `pointSizeRange`
1124 /// and `pointSizeGranularity` members of the `VkPhysicalDeviceLimits` structure,
1125 /// respectively.
1126 pub large_points: bool,
1127
1128 /// Specifies whether the implementation is able to replace the alpha value of the fragment
1129 /// shader output in the multisample fragment operation.
1130 ///
1131 /// If this feature is not enabled, then the `alphaToOneEnable` member of the
1132 /// `VkPipelineMultisampleStateCreateInfo` structure must be set to `VK_FALSE`. Otherwise
1133 /// setting `alphaToOneEnable` to `VK_TRUE` will enable alpha-to-one behavior.
1134 pub alpha_to_one: bool,
1135
1136 /// Specifies whether more than one viewport is supported.
1137 ///
1138 /// If this feature is not enabled:
1139 ///
1140 /// - The `viewportCount` and `scissorCount` members of the `VkPipelineViewportStateCreateInfo`
1141 /// structure must be set to `1`.
1142 /// - The `firstViewport` and `viewportCount` parameters to the `vkCmdSetViewport` command must
1143 /// be set to `0` and `1`, respectively.
1144 /// - The `firstScissor` and `scissorCount` parameters to the `vkCmdSetScissor` command must be
1145 /// set to `0` and `1`, respectively.
1146 pub multi_viewport: bool,
1147
1148 /// Specifies whether anisotropic filtering is supported.
1149 ///
1150 /// If this feature is not enabled, the `anisotropyEnable` member of the `VkSamplerCreateInfo`
1151 /// structure must be `VK_FALSE`.
1152 pub sampler_anisotropy: bool,
1153
1154 /// Specifies whether all of the ETC2 and EAC compressed texture formats are supported.
1155 ///
1156 /// If this feature is enabled, then the `VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT`,
1157 /// `VK_FORMAT_FEATURE_BLIT_SRC_BIT` and `VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT`
1158 /// features must be supported in `optimalTilingFeatures` for the following formats:
1159 ///
1160 /// - VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
1161 /// - VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK
1162 /// - VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK
1163 /// - VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK
1164 /// - VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK
1165 /// - VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK
1166 /// - VK_FORMAT_EAC_R11_UNORM_BLOCK
1167 /// - VK_FORMAT_EAC_R11_SNORM_BLOCK
1168 /// - VK_FORMAT_EAC_R11G11_UNORM_BLOCK
1169 /// - VK_FORMAT_EAC_R11G11_SNORM_BLOCK
1170 ///
1171 /// To query for additional properties, or if the feature is not enabled,
1172 /// `vkGetPhysicalDeviceFormatProperties` and `vkGetPhysicalDeviceImageFormatProperties` can be
1173 /// used to check for supported properties of individual formats as normal.
1174 pub texture_compression_etc2: bool,
1175
1176 /// Specifies whether all of the ASTC LDR compressed texture formats are supported.
1177 ///
1178 /// If this feature is enabled, then the `VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT`,
1179 /// `VK_FORMAT_FEATURE_BLIT_SRC_BIT` and `VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT`
1180 /// features must be supported in `optimalTilingFeatures` for the following formats:
1181 ///
1182 /// - VK_FORMAT_ASTC_4x4_UNORM_BLOCK
1183 /// - VK_FORMAT_ASTC_4x4_SRGB_BLOCK
1184 /// - VK_FORMAT_ASTC_5x4_UNORM_BLOCK
1185 /// - VK_FORMAT_ASTC_5x4_SRGB_BLOCK
1186 /// - VK_FORMAT_ASTC_5x5_UNORM_BLOCK
1187 /// - VK_FORMAT_ASTC_5x5_SRGB_BLOCK
1188 /// - VK_FORMAT_ASTC_6x5_UNORM_BLOCK
1189 /// - VK_FORMAT_ASTC_6x5_SRGB_BLOCK
1190 /// - VK_FORMAT_ASTC_6x6_UNORM_BLOCK
1191 /// - VK_FORMAT_ASTC_6x6_SRGB_BLOCK
1192 /// - VK_FORMAT_ASTC_8x5_UNORM_BLOCK
1193 /// - VK_FORMAT_ASTC_8x5_SRGB_BLOCK
1194 /// - VK_FORMAT_ASTC_8x6_UNORM_BLOCK
1195 /// - VK_FORMAT_ASTC_8x6_SRGB_BLOCK
1196 /// - VK_FORMAT_ASTC_8x8_UNORM_BLOCK
1197 /// - VK_FORMAT_ASTC_8x8_SRGB_BLOCK
1198 /// - VK_FORMAT_ASTC_10x5_UNORM_BLOCK
1199 /// - VK_FORMAT_ASTC_10x5_SRGB_BLOCK
1200 /// - VK_FORMAT_ASTC_10x6_UNORM_BLOCK
1201 /// - VK_FORMAT_ASTC_10x6_SRGB_BLOCK
1202 /// - VK_FORMAT_ASTC_10x8_UNORM_BLOCK
1203 /// - VK_FORMAT_ASTC_10x8_SRGB_BLOCK
1204 /// - VK_FORMAT_ASTC_10x10_UNORM_BLOCK
1205 /// - VK_FORMAT_ASTC_10x10_SRGB_BLOCK
1206 /// - VK_FORMAT_ASTC_12x10_UNORM_BLOCK
1207 /// - VK_FORMAT_ASTC_12x10_SRGB_BLOCK
1208 /// - VK_FORMAT_ASTC_12x12_UNORM_BLOCK
1209 /// - VK_FORMAT_ASTC_12x12_SRGB_BLOCK
1210 ///
1211 /// To query for additional properties, or if the feature is not enabled,
1212 /// `vkGetPhysicalDeviceFormatProperties` and `vkGetPhysicalDeviceImageFormatProperties` can be
1213 /// used to check for supported properties of individual formats as normal.
1214 pub texture_compression_astc_ldr: bool,
1215
1216 /// Specifies whether all of the BC compressed texture formats are supported.
1217 ///
1218 /// If this feature is enabled, then the `VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT`,
1219 /// `VK_FORMAT_FEATURE_BLIT_SRC_BIT` and `VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT`
1220 /// features must be supported in `optimalTilingFeatures` for the following formats:
1221 ///
1222 /// - VK_FORMAT_BC1_RGB_UNORM_BLOCK
1223 /// - VK_FORMAT_BC1_RGB_SRGB_BLOCK
1224 /// - VK_FORMAT_BC1_RGBA_UNORM_BLOCK
1225 /// - VK_FORMAT_BC1_RGBA_SRGB_BLOCK
1226 /// - VK_FORMAT_BC2_UNORM_BLOCK
1227 /// - VK_FORMAT_BC2_SRGB_BLOCK
1228 /// - VK_FORMAT_BC3_UNORM_BLOCK
1229 /// - VK_FORMAT_BC3_SRGB_BLOCK
1230 /// - VK_FORMAT_BC4_UNORM_BLOCK
1231 /// - VK_FORMAT_BC4_SNORM_BLOCK
1232 /// - VK_FORMAT_BC5_UNORM_BLOCK
1233 /// - VK_FORMAT_BC5_SNORM_BLOCK
1234 /// - VK_FORMAT_BC6H_UFLOAT_BLOCK
1235 /// - VK_FORMAT_BC6H_SFLOAT_BLOCK
1236 /// - VK_FORMAT_BC7_UNORM_BLOCK
1237 /// - VK_FORMAT_BC7_SRGB_BLOCK
1238 ///
1239 /// To query for additional properties, or if the feature is not enabled,
1240 /// `vkGetPhysicalDeviceFormatProperties` and `vkGetPhysicalDeviceImageFormatProperties` can be
1241 /// used to check for supported properties of individual formats as normal.
1242 pub texture_compression_bc: bool,
1243
1244 /// Specifies whether storage buffers and images support stores and atomic operations in the
1245 /// vertex, tessellation, and geometry shader stages.
1246 ///
1247 /// If this feature is not enabled, all storage image, storage texel buffer, and storage buffer
1248 /// variables used by these stages in shader modules must be decorated with the `NonWritable`
1249 /// decoration (or the `readonly` memory qualifier in GLSL).
1250 pub vertex_pipeline_stores_and_atomics: bool,
1251
1252 /// Specifies whether storage buffers and images support stores and atomic operations in the
1253 /// fragment shader stage.
1254 ///
1255 /// If this feature is not enabled, all storage image, storage texel buffer, and storage buffer
1256 /// variables used by the fragment stage in shader modules must be decorated with the
1257 /// `NonWritable` decoration (or the `readonly` memory qualifier in GLSL).
1258 pub fragment_stores_and_atomics: bool,
1259
1260 /// Specifies whether the `PointSize` built-in decoration is available in the tessellation
1261 /// control, tessellation evaluation, and geometry shader stages.
1262 ///
1263 /// If this feature is not enabled, members decorated with the `PointSize` built-in decoration
1264 /// must not be read from or written to and all points written from a tessellation or geometry
1265 /// shader will have a size of `1.0`.
1266 ///
1267 /// This also specifies whether shader modules can declare the `TessellationPointSize`
1268 /// capability for tessellation control and evaluation shaders, or if the shader modules can
1269 /// declare the `GeometryPointSize` capability for geometry shaders.
1270 ///
1271 /// An implementation supporting this feature must also support one or both of the
1272 /// `tessellationShader` or `geometryShader` features.
1273 pub shader_tessellation_and_geometry_point_size: bool,
1274
1275 /// Specifies whether the extended set of image gather instructions are available in shader
1276 /// code.
1277 ///
1278 /// If this feature is not enabled, the `OpImage*Gather` instructions do not support the
1279 /// `Offset` and `ConstOffsets` operands.
1280 ///
1281 /// This also specifies whether shader modules can declare the `ImageGatherExtended`
1282 /// capability.
1283 pub shader_image_gather_extended: bool,
1284
1285 /// Specifies whether all the “storage image extended formats” below are supported.
1286 ///
1287 /// If this feature is supported, then the `VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT` must be
1288 /// supported in `optimalTilingFeatures` for the following formats:
1289 ///
1290 /// - VK_FORMAT_R16G16_SFLOAT
1291 /// - VK_FORMAT_B10G11R11_UFLOAT_PACK32
1292 /// - VK_FORMAT_R16_SFLOAT
1293 /// - VK_FORMAT_R16G16B16A16_UNORM
1294 /// - VK_FORMAT_A2B10G10R10_UNORM_PACK32
1295 /// - VK_FORMAT_R16G16_UNORM
1296 /// - VK_FORMAT_R8G8_UNORM
1297 /// - VK_FORMAT_R16_UNORM
1298 /// - VK_FORMAT_R8_UNORM
1299 /// - VK_FORMAT_R16G16B16A16_SNORM
1300 /// - VK_FORMAT_R16G16_SNORM
1301 /// - VK_FORMAT_R8G8_SNORM
1302 /// - VK_FORMAT_R16_SNORM
1303 /// - VK_FORMAT_R8_SNORM
1304 /// - VK_FORMAT_R16G16_SINT
1305 /// - VK_FORMAT_R8G8_SINT
1306 /// - VK_FORMAT_R16_SINT
1307 /// - VK_FORMAT_R8_SINT
1308 /// - VK_FORMAT_A2B10G10R10_UINT_PACK32
1309 /// - VK_FORMAT_R16G16_UINT
1310 /// - VK_FORMAT_R8G8_UINT
1311 /// - VK_FORMAT_R16_UINT
1312 /// - VK_FORMAT_R8_UINT
1313 ///
1314 /// _Note:_ The `shaderStorageImageExtendedFormats` feature only adds a guarantee of format
1315 /// support, which is specified for the whole physical device. Therefore enabling or
1316 /// disabling the feature via `vkCreateDevice` has no practical effect.
1317 ///
1318 /// To query for additional properties, or if the feature is not supported,
1319 /// `vkGetPhysicalDeviceFormatProperties` and `vkGetPhysicalDeviceImageFormatProperties` can be
1320 /// used to check for supported properties of individual formats, as usual rules allow.
1321 ///
1322 /// `VK_FORMAT_R32G32_UINT`, `VK_FORMAT_R32G32_SINT`, and `VK_FORMAT_R32G32_SFLOAT` from the
1323 /// `StorageImageExtendedFormats` SPIR-V capability are already covered by core Vulkan.
1324 pub shader_storage_image_extended_formats: bool,
1325
1326 /// Specifies whether multisampled storage images are supported.
1327 ///
1328 /// If this feature is not enabled, images that are created with a usage that includes
1329 /// `VK_IMAGE_USAGE_STORAGE_BIT` must be created with samples equal to `VK_SAMPLE_COUNT_1_BIT`.
1330 ///
1331 /// This also specifies whether shader modules can declare the `StorageImageMultisample` and
1332 /// `ImageMSArray` capabilities.
1333 pub shader_storage_image_multisample: bool,
1334
1335 /// Specifies whether storage images and storage texel buffers require a format qualifier to be
1336 /// specified when reading.
1337 ///
1338 /// `shaderStorageImageReadWithoutFormat` applies only to formats listed in the features
1339 /// chapter's storage image read without format list.
1340 pub shader_storage_image_read_without_format: bool,
1341
1342 /// Specifies whether storage images and storage texel buffers require a format qualifier to be
1343 /// specified when writing.
1344 ///
1345 /// `shaderStorageImageWriteWithoutFormat` applies only to formats listed in the features
1346 /// chapter's storage image write without format list.
1347 pub shader_storage_image_write_without_format: bool,
1348
1349 /// Specifies whether arrays of uniform buffers can be indexed by dynamically uniform integer
1350 /// expressions in shader code.
1351 ///
1352 /// If this feature is not enabled, resources with a descriptor type of
1353 /// `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER` or `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC` must be
1354 /// indexed only by constant integral expressions when aggregated into arrays in shader code.
1355 ///
1356 /// This also specifies whether shader modules can declare the
1357 /// `UniformBufferArrayDynamicIndexing` capability.
1358 pub shader_uniform_buffer_array_dynamic_indexing: bool,
1359
1360 /// Specifies whether arrays of samplers or sampled images can be indexed by dynamically
1361 /// uniform integer expressions in shader code.
1362 ///
1363 /// If this feature is not enabled, resources with a descriptor type of
1364 /// `VK_DESCRIPTOR_TYPE_SAMPLER`, `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER`, or
1365 /// `VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE` must be indexed only by constant integral expressions
1366 /// when aggregated into arrays in shader code.
1367 ///
1368 /// This also specifies whether shader modules can declare the
1369 /// `SampledImageArrayDynamicIndexing` capability.
1370 pub shader_sampled_image_array_dynamic_indexing: bool,
1371
1372 /// Specifies whether arrays of storage buffers can be indexed by dynamically uniform integer
1373 /// expressions in shader code.
1374 ///
1375 /// If this feature is not enabled, resources with a descriptor type of
1376 /// `VK_DESCRIPTOR_TYPE_STORAGE_BUFFER` or `VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC` must be
1377 /// indexed only by constant integral expressions when aggregated into arrays in shader code.
1378 ///
1379 /// This also specifies whether shader modules can declare the
1380 /// `StorageBufferArrayDynamicIndexing` capability.
1381 pub shader_storage_buffer_array_dynamic_indexing: bool,
1382
1383 /// Specifies whether arrays of storage images can be indexed by dynamically uniform integer
1384 /// expressions in shader code.
1385 ///
1386 /// If this feature is not enabled, resources with a descriptor type of
1387 /// `VK_DESCRIPTOR_TYPE_STORAGE_IMAGE` must be indexed only by constant integral expressions
1388 /// when aggregated into arrays in shader code.
1389 ///
1390 /// This also specifies whether shader modules can declare the
1391 /// `StorageImageArrayDynamicIndexing` capability.
1392 pub shader_storage_image_array_dynamic_indexing: bool,
1393
1394 /// Specifies whether clip distances are supported in shader code.
1395 ///
1396 /// If this feature is not enabled, any members decorated with the `ClipDistance` built-in
1397 /// decoration must not be read from or written to in shader modules.
1398 ///
1399 /// This also specifies whether shader modules can declare the `ClipDistance` capability.
1400 pub shader_clip_distance: bool,
1401
1402 /// Specifies whether cull distances are supported in shader code.
1403 ///
1404 /// If this feature is not enabled, any members decorated with the `CullDistance` built-in
1405 /// decoration must not be read from or written to in shader modules.
1406 ///
1407 /// This also specifies whether shader modules can declare the `CullDistance` capability.
1408 pub shader_cull_distance: bool,
1409
1410 /// Specifies whether 64-bit floats (doubles) are supported in shader code.
1411 ///
1412 /// If this feature is not enabled, 64-bit floating-point types must not be used in shader
1413 /// code.
1414 ///
1415 /// This also specifies whether shader modules can declare the `Float64` capability. Declaring
1416 /// and using 64-bit floats is enabled for all storage classes that SPIR-V allows with the
1417 /// `Float64` capability.
1418 pub shader_float64: bool,
1419
1420 /// Specifies whether 64-bit integers (signed and unsigned) are supported in shader code.
1421 ///
1422 /// If this feature is not enabled, 64-bit integer types must not be used in shader code.
1423 ///
1424 /// This also specifies whether shader modules can declare the `Int64` capability. Declaring
1425 /// and using 64-bit integers is enabled for all storage classes that SPIR-V allows with
1426 /// the `Int64` capability.
1427 pub shader_int64: bool,
1428
1429 /// Specifies whether 16-bit integers (signed and unsigned) are supported in shader code.
1430 ///
1431 /// If this feature is not enabled, 16-bit integer types must not be used in shader code.
1432 ///
1433 /// This also specifies whether shader modules can declare the `Int16` capability. However,
1434 /// this only enables a subset of the storage classes that SPIR-V allows for the `Int16`
1435 /// SPIR-V capability: Declaring and using 16-bit integers in the `Private`, `Workgroup`
1436 /// (for non-Block variables), and `Function` storage classes is enabled, while declaring
1437 /// them in the interface storage classes (e.g., `UniformConstant`, `Uniform`,
1438 /// `StorageBuffer`, `Input`, `Output`, and `PushConstant`) is not enabled.
1439 pub shader_int16: bool,
1440
1441 /// Specifies whether image operations specifying the minimum resource LOD are supported in
1442 /// shader code.
1443 ///
1444 /// If this feature is not enabled, the `MinLod` image operand must not be used in shader code.
1445 ///
1446 /// This also specifies whether shader modules can declare the `MinLod` capability.
1447 pub shader_resource_min_lod: bool,
1448
1449 /// Specifies whether all pipelines that will be bound to a command buffer during a subpass
1450 /// which uses no attachments must have the same value for
1451 /// `VkPipelineMultisampleStateCreateInfo::rasterizationSamples`.
1452 ///
1453 /// If set to `VK_TRUE`, the implementation supports variable multisample rates in a subpass
1454 /// which uses no attachments.
1455 ///
1456 /// If set to `VK_FALSE`, then all pipelines bound in such a subpass must have the same
1457 /// multisample rate.
1458 ///
1459 /// This has no effect in situations where a subpass uses any attachments.
1460 pub variable_multisample_rate: bool,
1461 // Unsupported (queries):
1462 // pub occlusion_query_precise: bool,
1463 // pub pipeline_statistics_query: bool,
1464 // pub inherited_queries: bool,
1465
1466 // Unsupported (sparse residency):
1467 // pub shader_resource_residency: bool,
1468 // pub sparse_binding: bool,
1469 // pub sparse_residency_buffer: bool,
1470 // pub sparse_residency_image2_d: bool,
1471 // pub sparse_residency_image3_d: bool,
1472 // pub sparse_residency2_samples: bool,
1473 // pub sparse_residency4_samples: bool,
1474 // pub sparse_residency8_samples: bool,
1475 // pub sparse_residency16_samples: bool,
1476 // pub sparse_residency_aliased: bool,
1477}
1478
1479impl From<vk::PhysicalDeviceFeatures> for Vulkan10Features {
1480 fn from(features: vk::PhysicalDeviceFeatures) -> Self {
1481 Self {
1482 robust_buffer_access: features.robust_buffer_access == vk::TRUE,
1483 full_draw_index_uint32: features.full_draw_index_uint32 == vk::TRUE,
1484 image_cube_array: features.image_cube_array == vk::TRUE,
1485 independent_blend: features.independent_blend == vk::TRUE,
1486 geometry_shader: features.geometry_shader == vk::TRUE,
1487 tessellation_shader: features.tessellation_shader == vk::TRUE,
1488 sample_rate_shading: features.sample_rate_shading == vk::TRUE,
1489 dual_src_blend: features.dual_src_blend == vk::TRUE,
1490 logic_op: features.logic_op == vk::TRUE,
1491 multi_draw_indirect: features.multi_draw_indirect == vk::TRUE,
1492 draw_indirect_first_instance: features.draw_indirect_first_instance == vk::TRUE,
1493 depth_clamp: features.depth_clamp == vk::TRUE,
1494 depth_bias_clamp: features.depth_bias_clamp == vk::TRUE,
1495 fill_mode_non_solid: features.fill_mode_non_solid == vk::TRUE,
1496 depth_bounds: features.depth_bounds == vk::TRUE,
1497 wide_lines: features.wide_lines == vk::TRUE,
1498 large_points: features.large_points == vk::TRUE,
1499 alpha_to_one: features.alpha_to_one == vk::TRUE,
1500 multi_viewport: features.multi_viewport == vk::TRUE,
1501 sampler_anisotropy: features.sampler_anisotropy == vk::TRUE,
1502 texture_compression_etc2: features.texture_compression_etc2 == vk::TRUE,
1503 texture_compression_astc_ldr: features.texture_compression_astc_ldr == vk::TRUE,
1504 texture_compression_bc: features.texture_compression_bc == vk::TRUE,
1505 vertex_pipeline_stores_and_atomics: features.vertex_pipeline_stores_and_atomics
1506 == vk::TRUE,
1507 fragment_stores_and_atomics: features.fragment_stores_and_atomics == vk::TRUE,
1508 shader_tessellation_and_geometry_point_size: features
1509 .shader_tessellation_and_geometry_point_size
1510 == vk::TRUE,
1511 shader_image_gather_extended: features.shader_image_gather_extended == vk::TRUE,
1512 shader_storage_image_extended_formats: features.shader_storage_image_extended_formats
1513 == vk::TRUE,
1514 shader_storage_image_multisample: features.shader_storage_image_multisample == vk::TRUE,
1515 shader_storage_image_read_without_format: features
1516 .shader_storage_image_read_without_format
1517 == vk::TRUE,
1518 shader_storage_image_write_without_format: features
1519 .shader_storage_image_write_without_format
1520 == vk::TRUE,
1521 shader_uniform_buffer_array_dynamic_indexing: features
1522 .shader_uniform_buffer_array_dynamic_indexing
1523 == vk::TRUE,
1524 shader_sampled_image_array_dynamic_indexing: features
1525 .shader_sampled_image_array_dynamic_indexing
1526 == vk::TRUE,
1527 shader_storage_buffer_array_dynamic_indexing: features
1528 .shader_storage_buffer_array_dynamic_indexing
1529 == vk::TRUE,
1530 shader_storage_image_array_dynamic_indexing: features
1531 .shader_storage_image_array_dynamic_indexing
1532 == vk::TRUE,
1533 shader_clip_distance: features.shader_clip_distance == vk::TRUE,
1534 shader_cull_distance: features.shader_cull_distance == vk::TRUE,
1535 shader_float64: features.shader_float64 == vk::TRUE,
1536 shader_int64: features.shader_int64 == vk::TRUE,
1537 shader_int16: features.shader_int16 == vk::TRUE,
1538 shader_resource_min_lod: features.shader_resource_min_lod == vk::TRUE,
1539 variable_multisample_rate: features.variable_multisample_rate == vk::TRUE,
1540 }
1541 }
1542}
1543
1544/// Description of Vulkan 1.0 limits.
1545///
1546/// See [`VkPhysicalDeviceLimits`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceLimits.html).
1547#[derive(Clone, Copy, Debug)]
1548pub struct Vulkan10Limits {
1549 /// The largest dimension (width) that is guaranteed to be supported for all images created
1550 /// with an image type of [`vk::ImageType::TYPE_1D`].
1551 ///
1552 /// Some combinations of image parameters (format, usage, etc.) may allow support for larger
1553 /// dimensions, which can be queried using
1554 /// [`PhysicalDevice::image_format_properties`].
1555 pub max_image_dimension1_d: u32,
1556
1557 /// The largest dimension (width or height) that is guaranteed to be supported for all images
1558 /// created with an image type of [`vk::ImageType::TYPE_2D`] and without
1559 /// [`vk::ImageCreateFlags::CUBE_COMPATIBLE`] set in
1560 /// [`ImageInfo::flags`](super::image::ImageInfo::flags).
1561 ///
1562 /// Some combinations of image parameters (format, usage, etc.) may allow support for larger
1563 /// dimensions, which can be queried using
1564 /// [`PhysicalDevice::image_format_properties`].
1565 pub max_image_dimension2_d: u32,
1566
1567 /// The largest dimension (width, height, or depth) that is guaranteed to be supported for all
1568 /// images created with an image type of [`vk::ImageType::TYPE_3D`].
1569 ///
1570 /// Some combinations of image parameters (format, usage, etc.) may allow support for larger
1571 /// dimensions, which can be queried using
1572 /// [`PhysicalDevice::image_format_properties`].
1573 pub max_image_dimension3_d: u32,
1574
1575 /// The largest dimension (width or height) that is guaranteed to be supported for all images
1576 /// created with an image type of [`vk::ImageType::TYPE_2D`] and with
1577 /// [`vk::ImageCreateFlags::CUBE_COMPATIBLE`] set in
1578 /// [`ImageInfo::flags`](super::image::ImageInfo::flags).
1579 ///
1580 /// Some combinations of image parameters (format, usage, etc.) may allow support for larger
1581 /// dimensions, which can be queried using
1582 /// [`PhysicalDevice::image_format_properties`].
1583 pub max_image_dimension_cube: u32,
1584
1585 /// The maximum number of layers
1586 /// ([`ImageInfo::array_layer_count`](super::image::ImageInfo::array_layer_count)) for an
1587 /// image.
1588 pub max_image_array_layers: u32,
1589
1590 /// The maximum number of addressable texels for a buffer view created on a buffer which was
1591 /// created with the [`vk::BufferUsageFlags::UNIFORM_TEXEL_BUFFER`] or
1592 /// [`vk::BufferUsageFlags::STORAGE_TEXEL_BUFFER`] set in
1593 /// [`BufferInfo::usage`](super::buffer::BufferInfo::usage).
1594 pub max_texel_buffer_elements: u32,
1595
1596 /// The maximum range, in bytes, for a uniform buffer binding.
1597 pub max_uniform_buffer_range: u32,
1598
1599 /// The maximum range, in bytes, for a storage buffer binding.
1600 pub max_storage_buffer_range: u32,
1601
1602 /// The maximum size, in bytes, of the push constant storage available to a pipeline layout.
1603 pub max_push_constants_size: u32,
1604
1605 /// The maximum number of simultaneously active device memory allocations.
1606 pub max_memory_allocation_count: u32,
1607
1608 /// The maximum number of sampler objects that may exist at one time.
1609 pub max_sampler_allocation_count: u32,
1610
1611 /// The required granularity, in bytes, for aliasing linear and optimal resources in memory.
1612 pub buffer_image_granularity: vk::DeviceSize,
1613
1614 /// The maximum size, in bytes, of the address space available for sparse resources.
1615 pub sparse_address_space_size: vk::DeviceSize,
1616
1617 /// The maximum number of descriptor sets that can be bound simultaneously.
1618 pub max_bound_descriptor_sets: u32,
1619
1620 /// The maximum number of sampler descriptors accessible from a single shader stage.
1621 pub max_per_stage_descriptor_samplers: u32,
1622
1623 /// The maximum number of uniform buffer descriptors accessible from a single shader stage.
1624 pub max_per_stage_descriptor_uniform_buffers: u32,
1625
1626 /// The maximum number of storage buffer descriptors accessible from a single shader stage.
1627 pub max_per_stage_descriptor_storage_buffers: u32,
1628
1629 /// The maximum number of sampled image descriptors accessible from a single shader stage.
1630 pub max_per_stage_descriptor_sampled_images: u32,
1631
1632 /// The maximum number of storage image descriptors accessible from a single shader stage.
1633 pub max_per_stage_descriptor_storage_images: u32,
1634
1635 /// The maximum number of input attachment descriptors accessible from a single shader stage.
1636 pub max_per_stage_descriptor_input_attachments: u32,
1637
1638 /// The maximum total number of resources accessible from a single shader stage.
1639 pub max_per_stage_resources: u32,
1640
1641 /// The maximum number of sampler descriptors available across a single descriptor set.
1642 pub max_descriptor_set_samplers: u32,
1643
1644 /// The maximum number of uniform buffer descriptors available across a single descriptor set.
1645 pub max_descriptor_set_uniform_buffers: u32,
1646
1647 /// The maximum number of dynamic uniform buffer descriptors available across a descriptor set.
1648 pub max_descriptor_set_uniform_buffers_dynamic: u32,
1649
1650 /// The maximum number of storage buffer descriptors available across a single descriptor set.
1651 pub max_descriptor_set_storage_buffers: u32,
1652
1653 /// The maximum number of dynamic storage buffer descriptors available across a descriptor set.
1654 pub max_descriptor_set_storage_buffers_dynamic: u32,
1655
1656 /// The maximum number of sampled image descriptors available across a single descriptor set.
1657 pub max_descriptor_set_sampled_images: u32,
1658
1659 /// The maximum number of storage image descriptors available across a single descriptor set.
1660 pub max_descriptor_set_storage_images: u32,
1661
1662 /// The maximum number of input attachment descriptors available across a descriptor set.
1663 pub max_descriptor_set_input_attachments: u32,
1664
1665 /// The maximum number of vertex input attributes for a graphics pipeline.
1666 pub max_vertex_input_attributes: u32,
1667
1668 /// The maximum number of vertex input bindings for a graphics pipeline.
1669 pub max_vertex_input_bindings: u32,
1670
1671 /// The maximum offset, in bytes, allowed for a vertex input attribute.
1672 pub max_vertex_input_attribute_offset: u32,
1673
1674 /// The maximum stride, in bytes, for a vertex input binding.
1675 pub max_vertex_input_binding_stride: u32,
1676
1677 /// The maximum number of components output by the vertex stage.
1678 pub max_vertex_output_components: u32,
1679
1680 /// The maximum tessellation generation level.
1681 pub max_tessellation_generation_level: u32,
1682
1683 /// The maximum number of control points in a tessellation patch.
1684 pub max_tessellation_patch_size: u32,
1685
1686 /// The maximum number of per-vertex input components to tessellation control shaders.
1687 pub max_tessellation_control_per_vertex_input_components: u32,
1688
1689 /// The maximum number of per-vertex output components from tessellation control shaders.
1690 pub max_tessellation_control_per_vertex_output_components: u32,
1691
1692 /// The maximum number of per-patch output components from tessellation control shaders.
1693 pub max_tessellation_control_per_patch_output_components: u32,
1694
1695 /// The maximum total number of output components from tessellation control shaders.
1696 pub max_tessellation_control_total_output_components: u32,
1697
1698 /// The maximum number of input components to tessellation evaluation shaders.
1699 pub max_tessellation_evaluation_input_components: u32,
1700
1701 /// The maximum number of output components from tessellation evaluation shaders.
1702 pub max_tessellation_evaluation_output_components: u32,
1703
1704 /// The maximum number of geometry shader invocations per primitive.
1705 pub max_geometry_shader_invocations: u32,
1706
1707 /// The maximum number of input components to geometry shaders.
1708 pub max_geometry_input_components: u32,
1709
1710 /// The maximum number of output components from geometry shaders.
1711 pub max_geometry_output_components: u32,
1712
1713 /// The maximum number of vertices a geometry shader may emit.
1714 pub max_geometry_output_vertices: u32,
1715
1716 /// The maximum total number of output components from a geometry shader invocation.
1717 pub max_geometry_total_output_components: u32,
1718
1719 /// The maximum number of input components to fragment shaders.
1720 pub max_fragment_input_components: u32,
1721
1722 /// The maximum number of color attachments written by a fragment shader.
1723 pub max_fragment_output_attachments: u32,
1724
1725 /// The maximum number of dual-source attachments written by a fragment shader.
1726 pub max_fragment_dual_src_attachments: u32,
1727
1728 /// The maximum combined number of fragment shader output resources.
1729 pub max_fragment_combined_output_resources: u32,
1730
1731 /// The maximum amount of shared memory, in bytes, available to a compute workgroup.
1732 pub max_compute_shared_memory_size: u32,
1733
1734 /// The maximum workgroup counts for compute dispatch in each dimension.
1735 pub max_compute_work_group_count: [u32; 3],
1736
1737 /// The maximum total number of invocations in a single compute workgroup.
1738 pub max_compute_work_group_invocations: u32,
1739
1740 /// The maximum workgroup size for compute dispatch in each dimension.
1741 pub max_compute_work_group_size: [u32; 3],
1742
1743 /// The number of bits of sub-pixel precision in framebuffer coordinates.
1744 pub sub_pixel_precision_bits: u32,
1745
1746 /// The number of bits of sub-texel precision for image sampling.
1747 pub sub_texel_precision_bits: u32,
1748
1749 /// The number of bits of precision available for mipmap level selection.
1750 pub mipmap_precision_bits: u32,
1751
1752 /// The maximum value of an index used with indexed drawing.
1753 pub max_draw_indexed_index_value: u32,
1754
1755 /// The maximum number of draws executed by an indirect draw-count command.
1756 pub max_draw_indirect_count: u32,
1757
1758 /// The maximum absolute value of sampler LOD bias.
1759 pub max_sampler_lod_bias: f32,
1760
1761 /// The maximum sampler anisotropy level.
1762 pub max_sampler_anisotropy: f32,
1763
1764 /// The maximum number of simultaneously active viewports.
1765 pub max_viewports: u32,
1766
1767 /// The maximum viewport width and height.
1768 pub max_viewport_dimensions: [u32; 2],
1769
1770 /// The minimum and maximum supported viewport bounds.
1771 pub viewport_bounds_range: [f32; 2],
1772
1773 /// The number of bits of precision for viewport sub-pixel coordinates.
1774 pub viewport_sub_pixel_bits: u32,
1775
1776 /// The minimum alignment, in bytes, of host pointer values passed to mapping functions.
1777 pub min_memory_map_alignment: usize,
1778
1779 /// The minimum alignment, in bytes, for texel buffer offsets.
1780 pub min_texel_buffer_offset_alignment: vk::DeviceSize,
1781
1782 /// The minimum alignment, in bytes, for uniform buffer offsets.
1783 pub min_uniform_buffer_offset_alignment: vk::DeviceSize,
1784
1785 /// The minimum alignment, in bytes, for storage buffer offsets.
1786 pub min_storage_buffer_offset_alignment: vk::DeviceSize,
1787
1788 /// The minimum offset allowed for texel fetch operations.
1789 pub min_texel_offset: i32,
1790
1791 /// The maximum offset allowed for texel fetch operations.
1792 pub max_texel_offset: u32,
1793
1794 /// The minimum offset allowed for texel gather operations.
1795 pub min_texel_gather_offset: i32,
1796
1797 /// The maximum offset allowed for texel gather operations.
1798 pub max_texel_gather_offset: u32,
1799
1800 /// The minimum interpolation offset supported by the implementation.
1801 pub min_interpolation_offset: f32,
1802
1803 /// The maximum interpolation offset supported by the implementation.
1804 pub max_interpolation_offset: f32,
1805
1806 /// The number of bits of sub-pixel precision for interpolation offsets.
1807 pub sub_pixel_interpolation_offset_bits: u32,
1808
1809 /// The maximum framebuffer width.
1810 pub max_framebuffer_width: u32,
1811
1812 /// The maximum framebuffer height.
1813 pub max_framebuffer_height: u32,
1814
1815 /// The maximum number of framebuffer layers.
1816 pub max_framebuffer_layers: u32,
1817
1818 /// The sample counts supported for color framebuffer attachments.
1819 pub framebuffer_color_sample_counts: vk::SampleCountFlags,
1820
1821 /// The sample counts supported for depth framebuffer attachments.
1822 pub framebuffer_depth_sample_counts: vk::SampleCountFlags,
1823
1824 /// The sample counts supported for stencil framebuffer attachments.
1825 pub framebuffer_stencil_sample_counts: vk::SampleCountFlags,
1826
1827 /// The sample counts supported for framebuffers with no attachments.
1828 pub framebuffer_no_attachments_sample_counts: vk::SampleCountFlags,
1829
1830 /// The maximum number of color attachments in a framebuffer.
1831 pub max_color_attachments: u32,
1832
1833 /// The sample counts supported for sampled color images.
1834 pub sampled_image_color_sample_counts: vk::SampleCountFlags,
1835
1836 /// The sample counts supported for sampled integer images.
1837 pub sampled_image_integer_sample_counts: vk::SampleCountFlags,
1838
1839 /// The sample counts supported for sampled depth images.
1840 pub sampled_image_depth_sample_counts: vk::SampleCountFlags,
1841
1842 /// The sample counts supported for sampled stencil images.
1843 pub sampled_image_stencil_sample_counts: vk::SampleCountFlags,
1844
1845 /// The sample counts supported for storage images.
1846 pub storage_image_sample_counts: vk::SampleCountFlags,
1847
1848 /// The maximum number of words in a sample mask.
1849 pub max_sample_mask_words: u32,
1850
1851 /// True if timestamps are supported in both graphics and compute queues.
1852 pub timestamp_compute_and_graphics: bool,
1853
1854 /// The number of nanoseconds per timestamp increment.
1855 pub timestamp_period: f32,
1856
1857 /// The maximum number of clip distances.
1858 pub max_clip_distances: u32,
1859
1860 /// The maximum number of cull distances.
1861 pub max_cull_distances: u32,
1862
1863 /// The maximum combined number of clip and cull distances.
1864 pub max_combined_clip_and_cull_distances: u32,
1865
1866 /// The number of discrete queue priorities supported by the implementation.
1867 pub discrete_queue_priorities: u32,
1868
1869 /// The supported range of point sizes.
1870 pub point_size_range: [f32; 2],
1871
1872 /// The supported range of line widths.
1873 pub line_width_range: [f32; 2],
1874
1875 /// The granularity of point-size values.
1876 pub point_size_granularity: f32,
1877
1878 /// The granularity of line-width values.
1879 pub line_width_granularity: f32,
1880
1881 /// True if line rasterization follows strict diamond-exit rules.
1882 pub strict_lines: bool,
1883
1884 /// True if standard sample locations are supported.
1885 pub standard_sample_locations: bool,
1886
1887 /// The optimal alignment, in bytes, for buffer copy source and destination offsets.
1888 pub optimal_buffer_copy_offset_alignment: vk::DeviceSize,
1889
1890 /// The optimal alignment, in bytes, for buffer copy row pitch values.
1891 pub optimal_buffer_copy_row_pitch_alignment: vk::DeviceSize,
1892
1893 /// The non-coherent atom size, in bytes, used for host cache management.
1894 pub non_coherent_atom_size: vk::DeviceSize,
1895}
1896
1897impl From<vk::PhysicalDeviceLimits> for Vulkan10Limits {
1898 fn from(limits: vk::PhysicalDeviceLimits) -> Self {
1899 Self {
1900 max_image_dimension1_d: limits.max_image_dimension1_d,
1901 max_image_dimension2_d: limits.max_image_dimension2_d,
1902 max_image_dimension3_d: limits.max_image_dimension3_d,
1903 max_image_dimension_cube: limits.max_image_dimension_cube,
1904 max_image_array_layers: limits.max_image_array_layers,
1905 max_texel_buffer_elements: limits.max_texel_buffer_elements,
1906 max_uniform_buffer_range: limits.max_uniform_buffer_range,
1907 max_storage_buffer_range: limits.max_storage_buffer_range,
1908 max_push_constants_size: limits.max_push_constants_size,
1909 max_memory_allocation_count: limits.max_memory_allocation_count,
1910 max_sampler_allocation_count: limits.max_sampler_allocation_count,
1911 buffer_image_granularity: limits.buffer_image_granularity,
1912 sparse_address_space_size: limits.sparse_address_space_size,
1913 max_bound_descriptor_sets: limits.max_bound_descriptor_sets,
1914 max_per_stage_descriptor_samplers: limits.max_per_stage_descriptor_samplers,
1915 max_per_stage_descriptor_uniform_buffers: limits
1916 .max_per_stage_descriptor_uniform_buffers,
1917 max_per_stage_descriptor_storage_buffers: limits
1918 .max_per_stage_descriptor_storage_buffers,
1919 max_per_stage_descriptor_sampled_images: limits.max_per_stage_descriptor_sampled_images,
1920 max_per_stage_descriptor_storage_images: limits.max_per_stage_descriptor_storage_images,
1921 max_per_stage_descriptor_input_attachments: limits
1922 .max_per_stage_descriptor_input_attachments,
1923 max_per_stage_resources: limits.max_per_stage_resources,
1924 max_descriptor_set_samplers: limits.max_descriptor_set_samplers,
1925 max_descriptor_set_uniform_buffers: limits.max_descriptor_set_uniform_buffers,
1926 max_descriptor_set_uniform_buffers_dynamic: limits
1927 .max_descriptor_set_uniform_buffers_dynamic,
1928 max_descriptor_set_storage_buffers: limits.max_descriptor_set_storage_buffers,
1929 max_descriptor_set_storage_buffers_dynamic: limits
1930 .max_descriptor_set_storage_buffers_dynamic,
1931 max_descriptor_set_sampled_images: limits.max_descriptor_set_sampled_images,
1932 max_descriptor_set_storage_images: limits.max_descriptor_set_storage_images,
1933 max_descriptor_set_input_attachments: limits.max_descriptor_set_input_attachments,
1934 max_vertex_input_attributes: limits.max_vertex_input_attributes,
1935 max_vertex_input_bindings: limits.max_vertex_input_bindings,
1936 max_vertex_input_attribute_offset: limits.max_vertex_input_attribute_offset,
1937 max_vertex_input_binding_stride: limits.max_vertex_input_binding_stride,
1938 max_vertex_output_components: limits.max_vertex_output_components,
1939 max_tessellation_generation_level: limits.max_tessellation_generation_level,
1940 max_tessellation_patch_size: limits.max_tessellation_patch_size,
1941 max_tessellation_control_per_vertex_input_components: limits
1942 .max_tessellation_control_per_vertex_input_components,
1943 max_tessellation_control_per_vertex_output_components: limits
1944 .max_tessellation_control_per_vertex_output_components,
1945 max_tessellation_control_per_patch_output_components: limits
1946 .max_tessellation_control_per_patch_output_components,
1947 max_tessellation_control_total_output_components: limits
1948 .max_tessellation_control_total_output_components,
1949 max_tessellation_evaluation_input_components: limits
1950 .max_tessellation_evaluation_input_components,
1951 max_tessellation_evaluation_output_components: limits
1952 .max_tessellation_evaluation_output_components,
1953 max_geometry_shader_invocations: limits.max_geometry_shader_invocations,
1954 max_geometry_input_components: limits.max_geometry_input_components,
1955 max_geometry_output_components: limits.max_geometry_output_components,
1956 max_geometry_output_vertices: limits.max_geometry_output_vertices,
1957 max_geometry_total_output_components: limits.max_geometry_total_output_components,
1958 max_fragment_input_components: limits.max_fragment_input_components,
1959 max_fragment_output_attachments: limits.max_fragment_output_attachments,
1960 max_fragment_dual_src_attachments: limits.max_fragment_dual_src_attachments,
1961 max_fragment_combined_output_resources: limits.max_fragment_combined_output_resources,
1962 max_compute_shared_memory_size: limits.max_compute_shared_memory_size,
1963 max_compute_work_group_count: limits.max_compute_work_group_count,
1964 max_compute_work_group_invocations: limits.max_compute_work_group_invocations,
1965 max_compute_work_group_size: limits.max_compute_work_group_size,
1966 sub_pixel_precision_bits: limits.sub_pixel_precision_bits,
1967 sub_texel_precision_bits: limits.sub_texel_precision_bits,
1968 mipmap_precision_bits: limits.mipmap_precision_bits,
1969 max_draw_indexed_index_value: limits.max_draw_indexed_index_value,
1970 max_draw_indirect_count: limits.max_draw_indirect_count,
1971 max_sampler_lod_bias: limits.max_sampler_lod_bias,
1972 max_sampler_anisotropy: limits.max_sampler_anisotropy,
1973 max_viewports: limits.max_viewports,
1974 max_viewport_dimensions: limits.max_viewport_dimensions,
1975 viewport_bounds_range: limits.viewport_bounds_range,
1976 viewport_sub_pixel_bits: limits.viewport_sub_pixel_bits,
1977 min_memory_map_alignment: limits.min_memory_map_alignment,
1978 min_texel_buffer_offset_alignment: limits.min_texel_buffer_offset_alignment,
1979 min_uniform_buffer_offset_alignment: limits.min_uniform_buffer_offset_alignment,
1980 min_storage_buffer_offset_alignment: limits.min_storage_buffer_offset_alignment,
1981 min_texel_offset: limits.min_texel_offset,
1982 max_texel_offset: limits.max_texel_offset,
1983 min_texel_gather_offset: limits.min_texel_gather_offset,
1984 max_texel_gather_offset: limits.max_texel_gather_offset,
1985 min_interpolation_offset: limits.min_interpolation_offset,
1986 max_interpolation_offset: limits.max_interpolation_offset,
1987 sub_pixel_interpolation_offset_bits: limits.sub_pixel_interpolation_offset_bits,
1988 max_framebuffer_width: limits.max_framebuffer_width,
1989 max_framebuffer_height: limits.max_framebuffer_height,
1990 max_framebuffer_layers: limits.max_framebuffer_layers,
1991 framebuffer_color_sample_counts: limits.framebuffer_color_sample_counts,
1992 framebuffer_depth_sample_counts: limits.framebuffer_depth_sample_counts,
1993 framebuffer_stencil_sample_counts: limits.framebuffer_stencil_sample_counts,
1994 framebuffer_no_attachments_sample_counts: limits
1995 .framebuffer_no_attachments_sample_counts,
1996 max_color_attachments: limits.max_color_attachments,
1997 sampled_image_color_sample_counts: limits.sampled_image_color_sample_counts,
1998 sampled_image_integer_sample_counts: limits.sampled_image_integer_sample_counts,
1999 sampled_image_depth_sample_counts: limits.sampled_image_depth_sample_counts,
2000 sampled_image_stencil_sample_counts: limits.sampled_image_stencil_sample_counts,
2001 storage_image_sample_counts: limits.storage_image_sample_counts,
2002 max_sample_mask_words: limits.max_sample_mask_words,
2003 timestamp_compute_and_graphics: limits.timestamp_compute_and_graphics == vk::TRUE,
2004 timestamp_period: limits.timestamp_period,
2005 max_clip_distances: limits.max_clip_distances,
2006 max_cull_distances: limits.max_cull_distances,
2007 max_combined_clip_and_cull_distances: limits.max_combined_clip_and_cull_distances,
2008 discrete_queue_priorities: limits.discrete_queue_priorities,
2009 point_size_range: limits.point_size_range,
2010 line_width_range: limits.line_width_range,
2011 point_size_granularity: limits.point_size_granularity,
2012 line_width_granularity: limits.line_width_granularity,
2013 strict_lines: limits.strict_lines == vk::TRUE,
2014 standard_sample_locations: limits.standard_sample_locations == vk::TRUE,
2015 optimal_buffer_copy_offset_alignment: limits.optimal_buffer_copy_offset_alignment,
2016 optimal_buffer_copy_row_pitch_alignment: limits.optimal_buffer_copy_row_pitch_alignment,
2017 non_coherent_atom_size: limits.non_coherent_atom_size,
2018 }
2019 }
2020}
2021
2022/// Description of Vulkan 1.0 properties.
2023///
2024/// See [`VkPhysicalDeviceProperties`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceProperties.html).
2025#[derive(Clone, Debug)]
2026pub struct Vulkan10Properties {
2027 /// The version of Vulkan supported by the device.
2028 pub api_version: u32,
2029
2030 /// The vendor-specified version of the driver.
2031 pub driver_version: u32,
2032
2033 /// A unique identifier for the vendor of the physical device.
2034 pub vendor_id: u32,
2035
2036 /// A unique identifier for the physical device among devices available from the vendor.
2037 pub device_id: u32,
2038
2039 /// The type of physical device.
2040 pub device_type: vk::PhysicalDeviceType,
2041
2042 /// A UTF-8 string which is the name of the device.
2043 pub device_name: String,
2044
2045 /// An array of VK_UUID_SIZE `u8` values representing a universally unique identifier for the
2046 /// device.
2047 pub pipeline_cache_uuid: [u8; vk::UUID_SIZE],
2048
2049 /// The [`Vulkan10Limits`] structure specifying device-specific limits of the physical device.
2050 ///
2051 /// See the [limits chapter](https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits)
2052 /// for details.
2053 pub limits: Vulkan10Limits,
2054 // Unsupported (sparse residency):
2055 // pub sparse_properties: vk::PhysicalDeviceSparseProperties,
2056}
2057
2058impl From<vk::PhysicalDeviceProperties> for Vulkan10Properties {
2059 fn from(properties: vk::PhysicalDeviceProperties) -> Self {
2060 Self {
2061 api_version: properties.api_version,
2062 driver_version: properties.driver_version,
2063 vendor_id: properties.vendor_id,
2064 device_id: properties.device_id,
2065 device_type: properties.device_type,
2066 device_name: vk_cstr_to_utf8_string(&properties.device_name),
2067 pipeline_cache_uuid: properties.pipeline_cache_uuid,
2068 limits: properties.limits.into(),
2069 }
2070 }
2071}
2072
2073/// Description of Vulkan 1.1 features.
2074///
2075/// See [`VkPhysicalDeviceVulkan11Features`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceVulkan11Features.html).
2076#[derive(Clone, Copy, Debug)]
2077pub struct Vulkan11Features {
2078 /// Specifies whether objects in the StorageBuffer, ShaderRecordBufferKHR, or
2079 /// PhysicalStorageBuffer storage class with the Block decoration can have 16-bit integer and
2080 /// 16-bit floating-point members.
2081 ///
2082 /// If this feature is not enabled, 16-bit integer or 16-bit floating-point members must not be
2083 /// used in such objects. This also specifies whether shader modules can declare the
2084 /// StorageBuffer16BitAccess capability.
2085 pub storage_buffer16_bit_access: bool,
2086
2087 /// Specifies whether objects in the Uniform storage class with the Block decoration can have
2088 /// 16-bit integer and 16-bit floating-point members.
2089 ///
2090 /// If this feature is not enabled, 16-bit integer or 16-bit floating-point members must not be
2091 /// used in such objects. This also specifies whether shader modules can declare the
2092 /// UniformAndStorageBuffer16BitAccess capability.
2093 pub uniform_and_storage_buffer16_bit_access: bool,
2094
2095 /// Specifies whether objects in the PushConstant storage class can have 16-bit integer and
2096 /// 16-bit floating-point members.
2097 ///
2098 /// If this feature is not enabled, 16-bit integer or floating-point members must not be used
2099 /// in such objects. This also specifies whether shader modules can declare the
2100 /// StoragePushConstant16 capability.
2101 pub storage_push_constant16: bool,
2102
2103 /// Specifies whether objects in the Input and Output storage classes can have 16-bit integer
2104 /// and 16-bit floating-point members.
2105 ///
2106 /// If this feature is not enabled, 16-bit integer or 16-bit floating-point members must not be
2107 /// used in such objects. This also specifies whether shader modules can declare the
2108 /// StorageInputOutput16 capability.
2109 pub storage_input_output16: bool,
2110
2111 /// Specifies whether the implementation supports multiview rendering within a render pass.
2112 ///
2113 /// If this feature is not enabled, the view mask of each subpass must always be zero.
2114 pub multiview: bool,
2115
2116 /// Specifies whether the implementation supports multiview rendering within a render pass,
2117 /// with geometry shaders.
2118 ///
2119 /// If this feature is not enabled, then a pipeline compiled against a subpass with a non-zero
2120 /// view mask must not include a geometry shader.
2121 pub multiview_geometry_shader: bool,
2122
2123 /// Specifies whether the implementation supports multiview rendering within a render pass,
2124 /// with tessellation shaders.
2125 ///
2126 /// If this feature is not enabled, then a pipeline compiled against a subpass with a non-zero
2127 /// view mask must not include any tessellation shaders.
2128 pub multiview_tessellation_shader: bool,
2129
2130 /// Specifies whether the implementation supports the SPIR-V VariablePointersStorageBuffer
2131 /// capability.
2132 ///
2133 /// When this feature is not enabled, shader modules must not declare the
2134 /// SPV_KHR_variable_pointers extension or the VariablePointersStorageBuffer capability.
2135 pub variable_pointers_storage_buffer: bool,
2136
2137 /// Specifies whether the implementation supports the SPIR-V VariablePointers capability.
2138 ///
2139 /// When this feature is not enabled, shader modules must not declare the VariablePointers
2140 /// capability.
2141 pub variable_pointers: bool,
2142
2143 /// Specifies whether protected memory is supported.
2144 pub protected_memory: bool,
2145
2146 /// Specifies whether the implementation supports sampler Y′CBCR conversion.
2147 ///
2148 /// If `sampler_ycbcr_conversion` is `false`, sampler Y′CBCR conversion is not supported, and
2149 /// samplers using sampler Y′CBCR conversion must not be used.
2150 pub sampler_ycbcr_conversion: bool,
2151
2152 /// Specifies whether the implementation supports the SPIR-V DrawParameters capability.
2153 ///
2154 /// When this feature is not enabled, shader modules must not declare the
2155 /// SPV_KHR_shader_draw_parameters extension or the DrawParameters capability.
2156 pub shader_draw_parameters: bool,
2157}
2158
2159impl From<vk::PhysicalDeviceVulkan11Features<'_>> for Vulkan11Features {
2160 fn from(features: vk::PhysicalDeviceVulkan11Features<'_>) -> Self {
2161 Self {
2162 storage_buffer16_bit_access: features.storage_buffer16_bit_access == vk::TRUE,
2163 uniform_and_storage_buffer16_bit_access: features
2164 .uniform_and_storage_buffer16_bit_access
2165 == vk::TRUE,
2166 storage_push_constant16: features.storage_push_constant16 == vk::TRUE,
2167 storage_input_output16: features.storage_input_output16 == vk::TRUE,
2168 multiview: features.multiview == vk::TRUE,
2169 multiview_geometry_shader: features.multiview_geometry_shader == vk::TRUE,
2170 multiview_tessellation_shader: features.multiview_tessellation_shader == vk::TRUE,
2171 variable_pointers_storage_buffer: features.variable_pointers_storage_buffer == vk::TRUE,
2172 variable_pointers: features.variable_pointers == vk::TRUE,
2173 protected_memory: features.protected_memory == vk::TRUE,
2174 sampler_ycbcr_conversion: features.sampler_ycbcr_conversion == vk::TRUE,
2175 shader_draw_parameters: features.shader_draw_parameters == vk::TRUE,
2176 }
2177 }
2178}
2179
2180/// Description of Vulkan 1.1 properties.
2181///
2182/// See [`VkPhysicalDeviceVulkan11Properties`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceVulkan11Properties.html).
2183#[derive(Clone, Copy, Debug)]
2184pub struct Vulkan11Properties {
2185 /// An array of `VK_UUID_SIZE` `u8` values representing a universally unique identifier for
2186 /// the device
2187 pub device_uuid: [u8; vk::UUID_SIZE],
2188
2189 /// An array of `VK_UUID_SIZE` `u8` values representing a universally unique identifier for the
2190 /// driver build in use by the device.
2191 pub driver_uuid: [u8; vk::UUID_SIZE],
2192
2193 /// An array of `VK_LUID_SIZE` `u8` values representing a locally unique identifier for the
2194 /// device
2195 pub device_luid: [u8; vk::LUID_SIZE],
2196
2197 /// A `u32` bitfield identifying the node within a linked device adapter corresponding to the
2198 /// device.
2199 pub device_node_mask: u32,
2200
2201 /// A `bool` value that will be `true` if `device_luid` contains a valid LUID and
2202 /// `device_node_mask` contains a valid node mask, and `false` if they do not.
2203 pub device_luid_valid: bool,
2204
2205 /// The default number of invocations in each subgroup. `subgroup_size` is at least `1` if any
2206 /// of the physical device’s queues support `VK_QUEUE_GRAPHICS_BIT` or `VK_QUEUE_COMPUTE_BIT`.
2207 /// `subgroup_size` is a power-of-two.
2208 pub subgroup_size: u32,
2209
2210 /// A bitfield of `vk::ShaderStageFlagBits` describing the shader stages that group operations
2211 /// with subgroup scope are supported in. `subgroup_supported_stages` will have the
2212 /// `VK_SHADER_STAGE_COMPUTE_BIT` bit set if any of the physical device’s queues support
2213 /// `VK_QUEUE_COMPUTE_BIT`.
2214 pub subgroup_supported_stages: vk::ShaderStageFlags,
2215
2216 /// A bitmask of `vk::SubgroupFeatureFlagBits` specifying the sets of group operations with
2217 /// subgroup scope supported on this device. `subgroup_supported_operations` will have the
2218 /// `VK_SUBGROUP_FEATURE_BASIC_BIT` bit set if any of the physical device’s queues support
2219 /// `VK_QUEUE_GRAPHICS_BIT` or `VK_QUEUE_COMPUTE_BIT`.
2220 pub subgroup_supported_operations: vk::SubgroupFeatureFlags,
2221
2222 /// A `bool` specifying whether quad group operations are available in all stages, or are
2223 /// restricted to fragment and compute stages.
2224 pub subgroup_quad_operations_in_all_stages: bool,
2225
2226 /// A `vk::PointClippingBehavior` value specifying the point clipping behavior supported by the
2227 /// implementation.
2228 pub point_clipping_behavior: vk::PointClippingBehavior,
2229
2230 /// `max_multiview_view_count` is one greater than the maximum view index that can be used in a
2231 /// subpass.
2232 pub max_multiview_view_count: u32,
2233
2234 /// The maximum valid value of instance index allowed to be generated by a drawing command
2235 /// recorded within a subpass of a multiview render pass instance.
2236 pub max_multiview_instance_index: u32,
2237
2238 /// Specifies how an implementation behaves when an application attempts to write to
2239 /// unprotected memory in a protected queue operation, read from protected memory in an
2240 /// unprotected queue operation, or perform a query in a protected queue operation.
2241 ///
2242 /// If this limit is `true`, such writes will be discarded or have undefined values written,
2243 /// reads and queries will return undefined values.
2244 ///
2245 /// If this limit is `false`, applications must not perform these operations.
2246 ///
2247 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html) for
2248 /// more information.
2249 pub protected_no_fault: bool,
2250
2251 /// A maximum number of descriptors (summed over all descriptor types) in a single descriptor
2252 /// set that is guaranteed to satisfy any implementation-dependent constraints on the size of a
2253 /// descriptor set itself.
2254 ///
2255 /// Applications can query whether a descriptor set that goes beyond this limit is supported
2256 /// using `vkGetDescriptorSetLayoutSupport`.
2257 pub max_per_set_descriptors: u32,
2258
2259 /// The maximum size of a memory allocation that can be created, even if there is more space
2260 /// available in the heap.
2261 pub max_memory_allocation_size: vk::DeviceSize,
2262}
2263
2264impl From<vk::PhysicalDeviceVulkan11Properties<'_>> for Vulkan11Properties {
2265 fn from(props: vk::PhysicalDeviceVulkan11Properties<'_>) -> Self {
2266 Self {
2267 device_uuid: props.device_uuid,
2268 driver_uuid: props.driver_uuid,
2269 device_luid: props.device_luid,
2270 device_node_mask: props.device_node_mask,
2271 device_luid_valid: props.device_luid_valid == vk::TRUE,
2272 subgroup_size: props.subgroup_size,
2273 subgroup_supported_stages: props.subgroup_supported_stages,
2274 subgroup_supported_operations: props.subgroup_supported_operations,
2275 subgroup_quad_operations_in_all_stages: props.subgroup_quad_operations_in_all_stages
2276 == vk::TRUE,
2277 point_clipping_behavior: props.point_clipping_behavior,
2278 max_multiview_view_count: props.max_multiview_view_count,
2279 max_multiview_instance_index: props.max_multiview_instance_index,
2280 protected_no_fault: props.protected_no_fault == vk::TRUE,
2281 max_per_set_descriptors: props.max_per_set_descriptors,
2282 max_memory_allocation_size: props.max_memory_allocation_size,
2283 }
2284 }
2285}
2286
2287/// Description of Vulkan 1.2 features.
2288///
2289/// See [`VkPhysicalDeviceVulkan12Features`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceVulkan12Features.html).
2290#[derive(Clone, Copy, Debug)]
2291pub struct Vulkan12Features {
2292 /// Indicates whether the implementation supports the
2293 /// `VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE` sampler address mode.
2294 ///
2295 /// If this feature is not enabled, the `VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE` sampler
2296 /// address mode must not be used.
2297 pub sampler_mirror_clamp_to_edge: bool,
2298
2299 /// Indicates whether the implementation supports the `vkCmdDrawIndirectCount` and
2300 /// `vkCmdDrawIndexedIndirectCount` functions.
2301 ///
2302 /// If this feature is not enabled, these functions must not be used.
2303 pub draw_indirect_count: bool,
2304
2305 /// Indicates whether objects in the StorageBuffer, ShaderRecordBufferKHR, or
2306 /// PhysicalStorageBuffer storage class with the Block decoration can have 8-bit integer
2307 /// members.
2308 ///
2309 /// If this feature is not enabled, 8-bit integer members must not be used in such objects.
2310 /// This also indicates whether shader modules can declare the StorageBuffer8BitAccess
2311 /// capability.
2312 pub storage_buffer8_bit_access: bool,
2313
2314 /// Indicates whether objects in the Uniform storage class with the Block decoration can have
2315 /// 8-bit integer members.
2316 ///
2317 /// If this feature is not enabled, 8-bit integer members must not be used in such objects.
2318 /// This also indicates whether shader modules can declare the
2319 /// UniformAndStorageBuffer8BitAccess capability.
2320 pub uniform_and_storage_buffer8_bit_access: bool,
2321
2322 /// Indicates whether objects in the PushConstant storage class can have 8-bit integer members.
2323 ///
2324 /// If this feature is not enabled, 8-bit integer members must not be used in such objects.
2325 /// This also indicates whether shader modules can declare the StoragePushConstant8
2326 /// capability.
2327 pub storage_push_constant8: bool,
2328
2329 /// Indicates whether shaders can perform 64-bit unsigned and signed integer atomic operations
2330 /// on buffers.
2331 pub shader_buffer_int64_atomics: bool,
2332
2333 /// Indicates whether shaders can perform 64-bit unsigned and signed integer atomic operations
2334 /// on shared and payload memory.
2335 pub shader_shared_int64_atomics: bool,
2336
2337 /// Indicates whether 16-bit floats (halfs) are supported in shader code.
2338 ///
2339 /// This also indicates whether shader modules can declare the Float16 capability. However,
2340 /// this only enables a subset of the storage classes that SPIR-V allows for the Float16
2341 /// SPIR-V capability: Declaring and using 16-bit floats in the Private, Workgroup (for
2342 /// non-Block variables), and Function storage classes is enabled, while declaring them in
2343 /// the interface storage classes (e.g., UniformConstant, Uniform, StorageBuffer, Input,
2344 /// Output, and PushConstant) is not enabled.
2345 pub shader_float16: bool,
2346
2347 /// Indicates whether 8-bit integers (signed and unsigned) are supported in shader code.
2348 ///
2349 /// This also indicates whether shader modules can declare the Int8 capability. However, this
2350 /// only enables a subset of the storage classes that SPIR-V allows for the Int8 SPIR-V
2351 /// capability: Declaring and using 8-bit integers in the Private, Workgroup (for non-Block
2352 /// variables), and Function storage classes is enabled, while declaring them in the interface
2353 /// storage classes (e.g., UniformConstant, Uniform, StorageBuffer, Input, Output, and
2354 /// PushConstant) is not enabled.
2355 pub shader_int8: bool,
2356
2357 /// Indicates whether the implementation supports the minimum set of descriptor indexing
2358 /// features as described in the Vulkan feature requirements. Enabling the
2359 /// `descriptorIndexing` member when `vkCreateDevice` is called does not imply the other
2360 /// minimum descriptor indexing features are also enabled. Those other descriptor indexing
2361 /// features must be enabled individually as needed by the application.
2362 ///
2363 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
2364 pub descriptor_indexing: bool,
2365
2366 /// Indicates whether arrays of input attachments can be indexed by dynamically uniform integer
2367 /// expressions in shader code.
2368 ///
2369 /// If this feature is not enabled, resources with a descriptor type of
2370 /// `VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT` must be indexed only by constant integral expressions
2371 /// when aggregated into arrays in shader code. This also indicates whether shader modules can
2372 /// declare the InputAttachmentArrayDynamicIndexing capability.
2373 pub shader_input_attachment_array_dynamic_indexing: bool,
2374
2375 /// Indicates whether arrays of uniform texel buffers can be indexed by dynamically uniform
2376 /// integer expressions in shader code.
2377 ///
2378 /// If this feature is not enabled, resources with a descriptor type of
2379 /// `VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER` must be indexed only by constant integral
2380 /// expressions when aggregated into arrays in shader code. This also indicates whether shader
2381 /// modules can declare the UniformTexelBufferArrayDynamicIndexing capability.
2382 pub shader_uniform_texel_buffer_array_dynamic_indexing: bool,
2383
2384 /// Indicates whether arrays of storage texel buffers can be indexed by dynamically uniform
2385 /// integer expressions in shader code.
2386 ///
2387 /// If this feature is not enabled, resources with a descriptor type of
2388 /// `VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER` must be indexed only by constant integral
2389 /// expressions when aggregated into arrays in shader code. This also indicates whether shader
2390 /// modules can declare the StorageTexelBufferArrayDynamicIndexing capability.
2391 pub shader_storage_texel_buffer_array_dynamic_indexing: bool,
2392
2393 /// Indicates whether arrays of uniform buffers can be indexed by non-uniform integer
2394 /// expressions in shader code.
2395 ///
2396 /// If this feature is not enabled, resources with a descriptor type of
2397 /// `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER` or `VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC` must not be
2398 /// indexed by non-uniform integer expressions when aggregated into arrays in shader code. This
2399 /// also indicates whether shader modules can declare the UniformBufferArrayNonUniformIndexing
2400 /// capability.
2401 pub shader_uniform_buffer_array_non_uniform_indexing: bool,
2402
2403 /// Indicates whether arrays of samplers or sampled images can be indexed by non-uniform
2404 /// integer expressions in shader code.
2405 ///
2406 /// If this feature is not enabled, resources with a descriptor type of
2407 /// `VK_DESCRIPTOR_TYPE_SAMPLER`, `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER`, or
2408 /// `VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE` must not be indexed by non-uniform integer expressions
2409 /// when aggregated into arrays in shader code. This also indicates whether shader modules
2410 /// can declare the SampledImageArrayNonUniformIndexing capability.
2411 pub shader_sampled_image_array_non_uniform_indexing: bool,
2412
2413 /// Indicates whether arrays of storage buffers can be indexed by non-uniform integer
2414 /// expressions in shader code.
2415 ///
2416 /// If this feature is not enabled, resources with a descriptor type of
2417 /// `VK_DESCRIPTOR_TYPE_STORAGE_BUFFER` or `VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC` must not be
2418 /// indexed by non-uniform integer expressions when aggregated into arrays in shader code. This
2419 /// also indicates whether shader modules can declare the StorageBufferArrayNonUniformIndexing
2420 /// capability.
2421 pub shader_storage_buffer_array_non_uniform_indexing: bool,
2422
2423 /// Indicates whether arrays of storage images can be indexed by non-uniform integer
2424 /// expressions in shader code.
2425 ///
2426 /// If this feature is not enabled, resources with a descriptor type of
2427 /// `VK_DESCRIPTOR_TYPE_STORAGE_IMAGE` must not be indexed by non-uniform integer expressions
2428 /// when aggregated into arrays in shader code. This also indicates whether shader modules
2429 /// can declare the StorageImageArrayNonUniformIndexing capability.
2430 pub shader_storage_image_array_non_uniform_indexing: bool,
2431
2432 /// Indicates whether arrays of input attachments can be indexed by non-uniform integer
2433 /// expressions in shader code.
2434 ///
2435 /// If this feature is not enabled, resources with a descriptor type of
2436 /// `VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT` must not be indexed by non-uniform integer expressions
2437 /// when aggregated into arrays in shader code. This also indicates whether shader modules can
2438 /// declare the InputAttachmentArrayNonUniformIndexing capability.
2439 pub shader_input_attachment_array_non_uniform_indexing: bool,
2440
2441 /// Indicates whether arrays of uniform texel buffers can be indexed by non-uniform integer
2442 /// expressions in shader code.
2443 ///
2444 /// If this feature is not enabled, resources with a descriptor type of
2445 /// `VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER` must not be indexed by non-uniform integer
2446 /// expressions when aggregated into arrays in shader code. This also indicates whether shader
2447 /// modules can declare the UniformTexelBufferArrayNonUniformIndexing capability.
2448 pub shader_uniform_texel_buffer_array_non_uniform_indexing: bool,
2449
2450 /// Indicates whether arrays of storage texel buffers can be indexed by non-uniform integer
2451 /// expressions in shader code.
2452 ///
2453 /// If this feature is not enabled, resources with a descriptor type of
2454 /// `VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER` must not be indexed by non-uniform integer
2455 /// expressions when aggregated into arrays in shader code. This also indicates whether shader
2456 /// modules can declare the StorageTexelBufferArrayNonUniformIndexing capability.
2457 pub shader_storage_texel_buffer_array_non_uniform_indexing: bool,
2458
2459 /// Indicates whether the implementation supports updating uniform buffer descriptors after a
2460 /// set is bound.
2461 ///
2462 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2463 /// used with VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.
2464 pub descriptor_binding_uniform_buffer_update_after_bind: bool,
2465
2466 /// Indicates whether the implementation supports updating sampled image descriptors after a
2467 /// set is bound.
2468 ///
2469 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2470 /// used with VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, or
2471 /// VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE.
2472 pub descriptor_binding_sampled_image_update_after_bind: bool,
2473
2474 /// Indicates whether the implementation supports updating storage image descriptors after a
2475 /// set is bound.
2476 ///
2477 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2478 /// used with VK_DESCRIPTOR_TYPE_STORAGE_IMAGE.
2479 pub descriptor_binding_storage_image_update_after_bind: bool,
2480
2481 /// Indicates whether the implementation supports updating storage buffer descriptors after a
2482 /// set is bound.
2483 ///
2484 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2485 /// used with VK_DESCRIPTOR_TYPE_STORAGE_BUFFER.
2486 pub descriptor_binding_storage_buffer_update_after_bind: bool,
2487
2488 /// Indicates whether the implementation supports updating uniform texel buffer descriptors
2489 /// after a set is bound.
2490 ///
2491 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2492 /// used with VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER.
2493 pub descriptor_binding_uniform_texel_buffer_update_after_bind: bool,
2494
2495 /// Indicates whether the implementation supports updating storage texel buffer descriptors
2496 /// after a set is bound.
2497 ///
2498 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT must not be
2499 /// used with VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER.
2500 pub descriptor_binding_storage_texel_buffer_update_after_bind: bool,
2501
2502 /// Indicates whether the implementation supports updating descriptors while the set is in use.
2503 ///
2504 /// If this feature is not enabled, VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT must
2505 /// not be used.
2506 pub descriptor_binding_update_unused_while_pending: bool,
2507
2508 /// Indicates whether the implementation supports statically using a descriptor set binding in
2509 /// which some descriptors are not valid. If this feature is not enabled,
2510 /// VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT must not be used.
2511 pub descriptor_binding_partially_bound: bool,
2512
2513 /// Indicates whether the implementation supports descriptor sets with a variable-sized last
2514 /// binding. If this feature is not enabled,
2515 /// VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT must not be used.
2516 pub descriptor_binding_variable_descriptor_count: bool,
2517
2518 /// Indicates whether the implementation supports the SPIR-V RuntimeDescriptorArray capability.
2519 ///
2520 /// If this feature is not enabled, descriptors must not be declared in runtime arrays.
2521 pub runtime_descriptor_array: bool,
2522
2523 /// Indicates whether the implementation supports a minimum set of required formats supporting
2524 /// min/max filtering as defined by the filterMinmaxSingleComponentFormats property minimum
2525 /// requirements.
2526 ///
2527 /// If this feature is not enabled, then `VkSamplerReductionModeCreateInfo` must only use
2528 /// `VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE`.
2529 pub sampler_filter_minmax: bool,
2530
2531 /// Indicates that the implementation supports the layout of resource blocks in shaders using
2532 /// scalar alignment.
2533 pub scalar_block_layout: bool,
2534
2535 /// Indicates that the implementation supports specifying the image view for attachments at
2536 /// render pass begin time via `VkRenderPassAttachmentBeginInfo`.
2537 pub imageless_framebuffer: bool,
2538
2539 /// Indicates that the implementation supports the same layouts for uniform buffers as for
2540 /// storage and other kinds of buffers.
2541 ///
2542 /// See [standard buffer layout](https://docs.vulkan.org/spec/latest/chapters/interfaces.html#interfaces-resources-standard-layout).
2543 pub uniform_buffer_standard_layout: bool,
2544
2545 /// A boolean specifying whether subgroup operations can use 8-bit integer, 16-bit integer,
2546 /// 64-bit integer, 16-bit floating-point, and vectors of these types in group operations with
2547 /// subgroup scope, if the implementation supports the types.
2548 pub shader_subgroup_extended_types: bool,
2549
2550 /// Indicates whether the implementation supports a `VkImageMemoryBarrier` for a depth/stencil
2551 /// image with only one of `VK_IMAGE_ASPECT_DEPTH_BIT` or `VK_IMAGE_ASPECT_STENCIL_BIT` set, and
2552 /// whether `VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL`,
2553 /// `VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL`, `VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL`, or
2554 /// `VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL` can be used.
2555 pub separate_depth_stencil_layouts: bool,
2556
2557 /// Indicates that the implementation supports resetting queries from the host with
2558 /// `vkResetQueryPool`.
2559 pub host_query_reset: bool,
2560
2561 /// Indicates whether semaphores created with a `VkSemaphoreType` of
2562 /// `VK_SEMAPHORE_TYPE_TIMELINE` are supported.
2563 pub timeline_semaphore: bool,
2564
2565 /// Indicates that the implementation supports accessing buffer memory in shaders as storage
2566 /// buffers via an address queried from `vkGetBufferDeviceAddress`.
2567 pub buffer_device_address: bool,
2568
2569 /// Indicates that the implementation supports saving and reusing buffer and device addresses,
2570 /// e.g. for trace capture and replay.
2571 pub buffer_device_address_capture_replay: bool,
2572
2573 /// Indicates that the implementation supports the bufferDeviceAddress, rayTracingPipeline and
2574 /// rayQuery features for logical devices created with multiple physical devices.
2575 ///
2576 /// If this feature is not supported, buffer and acceleration structure addresses must not be
2577 /// queried on a logical device created with more than one physical device.
2578 pub buffer_device_address_multi_device: bool,
2579
2580 /// Indicates whether the [Vulkan Memory Model] is supported.
2581 ///
2582 /// This also indicates whether shader modules can declare the `VulkanMemoryModel` capability.
2583 ///
2584 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
2585 ///
2586 /// [Vulkan Memory Model]: https://docs.vulkan.org/spec/latest/chapters/memory.html#memory-model
2587 pub vulkan_memory_model: bool,
2588
2589 /// Indicates whether the [Vulkan Memory Model] can use Device scope synchronization.
2590 ///
2591 /// This also indicates whether shader modules can declare the `VulkanMemoryModelDeviceScope`
2592 /// capability.
2593 ///
2594 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
2595 ///
2596 /// [Vulkan Memory Model]: https://docs.vulkan.org/spec/latest/chapters/memory.html#memory-model
2597 pub vulkan_memory_model_device_scope: bool,
2598
2599 /// Indicates whether the [Vulkan Memory Model] can use availability and visibility chains with
2600 /// more than one element.
2601 ///
2602 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
2603 ///
2604 /// [Vulkan Memory Model]: https://docs.vulkan.org/spec/latest/chapters/memory.html#memory-model
2605 pub vulkan_memory_model_availability_visibility_chains: bool,
2606
2607 /// Indicates whether the implementation supports the ShaderViewportIndex SPIR-V capability
2608 /// enabling variables decorated with the ViewportIndex built-in to be exported from mesh,
2609 /// vertex or tessellation evaluation shaders.
2610 ///
2611 /// If this feature is not enabled, the ViewportIndex built-in decoration must not be used on
2612 /// outputs in mesh, vertex or tessellation evaluation shaders.
2613 pub shader_output_viewport_index: bool,
2614
2615 /// Indicates whether the implementation supports the ShaderLayer SPIR-V capability enabling
2616 /// variables decorated with the Layer built-in to be exported from mesh, vertex or
2617 /// tessellation evaluation shaders.
2618 ///
2619 /// If this feature is not enabled, the Layer built-in decoration must not be used on outputs
2620 /// in mesh, vertex or tessellation evaluation shaders.
2621 pub shader_output_layer: bool,
2622
2623 /// If `true`, the “Id” operand of OpGroupNonUniformBroadcast can be dynamically uniform within
2624 /// a subgroup, and the “Index” operand of OpGroupNonUniformQuadBroadcast can be dynamically
2625 /// uniform within the derivative group.
2626 ///
2627 /// If `false`, these operands must be constants.
2628 pub subgroup_broadcast_dynamic_id: bool,
2629}
2630
2631impl From<vk::PhysicalDeviceVulkan12Features<'_>> for Vulkan12Features {
2632 fn from(features: vk::PhysicalDeviceVulkan12Features<'_>) -> Self {
2633 Self {
2634 sampler_mirror_clamp_to_edge: features.sampler_mirror_clamp_to_edge == vk::TRUE,
2635 draw_indirect_count: features.draw_indirect_count == vk::TRUE,
2636 storage_buffer8_bit_access: features.storage_buffer8_bit_access == vk::TRUE,
2637 uniform_and_storage_buffer8_bit_access: features.uniform_and_storage_buffer8_bit_access
2638 == vk::TRUE,
2639 storage_push_constant8: features.storage_push_constant8 == vk::TRUE,
2640 shader_buffer_int64_atomics: features.shader_buffer_int64_atomics == vk::TRUE,
2641 shader_shared_int64_atomics: features.shader_shared_int64_atomics == vk::TRUE,
2642 shader_float16: features.shader_float16 == vk::TRUE,
2643 shader_int8: features.shader_int8 == vk::TRUE,
2644 descriptor_indexing: features.descriptor_indexing == vk::TRUE,
2645 shader_input_attachment_array_dynamic_indexing: features
2646 .shader_input_attachment_array_dynamic_indexing
2647 == vk::TRUE,
2648 shader_uniform_texel_buffer_array_dynamic_indexing: features
2649 .shader_uniform_texel_buffer_array_dynamic_indexing
2650 == vk::TRUE,
2651 shader_storage_texel_buffer_array_dynamic_indexing: features
2652 .shader_storage_texel_buffer_array_dynamic_indexing
2653 == vk::TRUE,
2654 shader_uniform_buffer_array_non_uniform_indexing: features
2655 .shader_uniform_buffer_array_non_uniform_indexing
2656 == vk::TRUE,
2657 shader_sampled_image_array_non_uniform_indexing: features
2658 .shader_sampled_image_array_non_uniform_indexing
2659 == vk::TRUE,
2660 shader_storage_buffer_array_non_uniform_indexing: features
2661 .shader_storage_buffer_array_non_uniform_indexing
2662 == vk::TRUE,
2663 shader_storage_image_array_non_uniform_indexing: features
2664 .shader_storage_image_array_non_uniform_indexing
2665 == vk::TRUE,
2666 shader_input_attachment_array_non_uniform_indexing: features
2667 .shader_input_attachment_array_non_uniform_indexing
2668 == vk::TRUE,
2669 shader_uniform_texel_buffer_array_non_uniform_indexing: features
2670 .shader_uniform_texel_buffer_array_non_uniform_indexing
2671 == vk::TRUE,
2672 shader_storage_texel_buffer_array_non_uniform_indexing: features
2673 .shader_storage_texel_buffer_array_non_uniform_indexing
2674 == vk::TRUE,
2675 descriptor_binding_uniform_buffer_update_after_bind: features
2676 .descriptor_binding_uniform_buffer_update_after_bind
2677 == vk::TRUE,
2678 descriptor_binding_sampled_image_update_after_bind: features
2679 .descriptor_binding_sampled_image_update_after_bind
2680 == vk::TRUE,
2681 descriptor_binding_storage_image_update_after_bind: features
2682 .descriptor_binding_storage_image_update_after_bind
2683 == vk::TRUE,
2684 descriptor_binding_storage_buffer_update_after_bind: features
2685 .descriptor_binding_storage_buffer_update_after_bind
2686 == vk::TRUE,
2687 descriptor_binding_uniform_texel_buffer_update_after_bind: features
2688 .descriptor_binding_uniform_texel_buffer_update_after_bind
2689 == vk::TRUE,
2690 descriptor_binding_storage_texel_buffer_update_after_bind: features
2691 .descriptor_binding_storage_texel_buffer_update_after_bind
2692 == vk::TRUE,
2693 descriptor_binding_update_unused_while_pending: features
2694 .descriptor_binding_update_unused_while_pending
2695 == vk::TRUE,
2696 descriptor_binding_partially_bound: features.descriptor_binding_partially_bound
2697 == vk::TRUE,
2698 descriptor_binding_variable_descriptor_count: features
2699 .descriptor_binding_variable_descriptor_count
2700 == vk::TRUE,
2701 runtime_descriptor_array: features.runtime_descriptor_array == vk::TRUE,
2702 sampler_filter_minmax: features.sampler_filter_minmax == vk::TRUE,
2703 scalar_block_layout: features.scalar_block_layout == vk::TRUE,
2704 imageless_framebuffer: features.imageless_framebuffer == vk::TRUE,
2705 uniform_buffer_standard_layout: features.uniform_buffer_standard_layout == vk::TRUE,
2706 shader_subgroup_extended_types: features.shader_subgroup_extended_types == vk::TRUE,
2707 separate_depth_stencil_layouts: features.separate_depth_stencil_layouts == vk::TRUE,
2708 host_query_reset: features.host_query_reset == vk::TRUE,
2709 timeline_semaphore: features.timeline_semaphore == vk::TRUE,
2710 buffer_device_address: features.buffer_device_address == vk::TRUE,
2711 buffer_device_address_capture_replay: features.buffer_device_address_capture_replay
2712 == vk::TRUE,
2713 buffer_device_address_multi_device: features.buffer_device_address_multi_device
2714 == vk::TRUE,
2715 vulkan_memory_model: features.vulkan_memory_model == vk::TRUE,
2716 vulkan_memory_model_device_scope: features.vulkan_memory_model_device_scope == vk::TRUE,
2717 vulkan_memory_model_availability_visibility_chains: features
2718 .vulkan_memory_model_availability_visibility_chains
2719 == vk::TRUE,
2720 shader_output_viewport_index: features.shader_output_viewport_index == vk::TRUE,
2721 shader_output_layer: features.shader_output_layer == vk::TRUE,
2722 subgroup_broadcast_dynamic_id: features.subgroup_broadcast_dynamic_id == vk::TRUE,
2723 }
2724 }
2725}
2726
2727/// Description of Vulkan 1.2 properties.
2728///
2729/// See [`VkPhysicalDeviceVulkan12Properties`](https://registry.khronos.org/vulkan/specs/latest/man/html/VkPhysicalDeviceVulkan12Properties.html).
2730#[derive(Clone, Debug)]
2731pub struct Vulkan12Properties {
2732 /// A unique identifier for the driver of the physical device.
2733 pub driver_id: vk::DriverId,
2734
2735 /// An array of `VK_MAX_DRIVER_NAME_SIZE` char containing a null-terminated UTF-8 string which
2736 /// is the name of the driver.
2737 pub driver_name: String,
2738
2739 /// An array of `VK_MAX_DRIVER_INFO_SIZE` char containing a null-terminated UTF-8 string with
2740 /// additional information about the driver.
2741 pub driver_info: String,
2742
2743 /// The version of the Vulkan conformance test suite this driver is conformant against.
2744 pub conformance_version: vk::ConformanceVersion,
2745
2746 /// A `vk::ShaderFloatControlsIndependence` value indicating whether, and how, denorm behavior
2747 /// can be set independently for different bit widths.
2748 pub denorm_behavior_independence: vk::ShaderFloatControlsIndependence,
2749
2750 /// A `vk::ShaderFloatControlsIndependence` value indicating whether, and how, rounding modes
2751 /// can be set independently for different bit widths.
2752 pub rounding_mode_independence: vk::ShaderFloatControlsIndependence,
2753
2754 /// A `bool` value indicating whether sign of a zero, NaNs and ±∞ can be preserved in 16-bit
2755 /// floating-point computations.
2756 ///
2757 /// It also indicates whether the SignedZeroInfNanPreserve execution mode can be used for
2758 /// 16-bit floating-point types.
2759 pub shader_signed_zero_inf_nan_preserve_float16: bool,
2760
2761 /// A `bool` value indicating whether sign of a zero, NaNs and ±∞ can be preserved in 32-bit
2762 /// floating-point computations.
2763 ///
2764 /// It also indicates whether the SignedZeroInfNanPreserve execution mode can be used for
2765 /// 32-bit floating-point types.
2766 pub shader_signed_zero_inf_nan_preserve_float32: bool,
2767
2768 /// A `bool` value indicating whether sign of a zero, NaNs and ±∞ can be preserved in 64-bit
2769 /// floating-point computations.
2770 ///
2771 /// It also indicates whether the SignedZeroInfNanPreserve execution mode can be used for
2772 /// 64-bit floating-point types.
2773 pub shader_signed_zero_inf_nan_preserve_float64: bool,
2774
2775 /// A `bool` value indicating whether denormals can be preserved in 16-bit floating-point
2776 /// computations.
2777 ///
2778 /// It also indicates whether the DenormPreserve execution mode can be used for 16-bit
2779 /// floating-point types.
2780 pub shader_denorm_preserve_float16: bool,
2781
2782 /// A `bool` value indicating whether denormals can be preserved in 32-bit floating-point
2783 /// computations.
2784 ///
2785 /// It also indicates whether the DenormPreserve execution mode can be used for 32-bit
2786 /// floating-point types.
2787 pub shader_denorm_preserve_float32: bool,
2788
2789 /// A `bool` value indicating whether denormals can be preserved in 64-bit floating-point
2790 /// computations.
2791 ///
2792 /// It also indicates whether the DenormPreserve execution mode can be used for 64-bit
2793 /// floating-point types.
2794 pub shader_denorm_preserve_float64: bool,
2795
2796 /// A `bool` value indicating whether denormals can be flushed to zero in 16-bit floating-point
2797 /// computations.
2798 ///
2799 /// It also indicates whether the DenormFlushToZero execution mode can be used for 16-bit
2800 /// floating-point types.
2801 pub shader_denorm_flush_to_zero_float16: bool,
2802
2803 /// A `bool` value indicating whether denormals can be flushed to zero in 32-bit floating-point
2804 /// computations.
2805 ///
2806 /// It also indicates whether the DenormFlushToZero execution mode can be used for 32-bit
2807 /// floating-point types.
2808 pub shader_denorm_flush_to_zero_float32: bool,
2809
2810 /// A `bool` value indicating whether denormals can be flushed to zero in 64-bit floating-point
2811 /// computations.
2812 ///
2813 /// It also indicates whether the DenormFlushToZero execution mode can be used for 64-bit
2814 /// floating-point types.
2815 pub shader_denorm_flush_to_zero_float64: bool,
2816
2817 /// A `bool` value indicating whether an implementation supports the round-to-nearest-even
2818 /// rounding mode for 16-bit floating-point arithmetic and conversion instructions.
2819 ///
2820 /// It also indicates whether the RoundingModeRTE execution mode can be used for 16-bit
2821 /// floating-point types.
2822 pub shader_rounding_mode_rte_float16: bool,
2823
2824 /// A `bool` value indicating whether an implementation supports the round-to-nearest-even
2825 /// rounding mode for 32-bit floating-point arithmetic and conversion instructions.
2826 ///
2827 /// It also indicates whether the RoundingModeRTE execution mode can be used for 32-bit
2828 /// floating-point types.
2829 pub shader_rounding_mode_rte_float32: bool,
2830
2831 /// A `bool` value indicating whether an implementation supports the round-to-nearest-even
2832 /// rounding mode for 64-bit floating-point arithmetic and conversion instructions.
2833 ///
2834 /// It also indicates whether the RoundingModeRTE execution mode can be used for 64-bit
2835 /// floating-point types.
2836 pub shader_rounding_mode_rte_float64: bool,
2837
2838 /// A `bool` value indicating whether an implementation supports the round-towards-zero
2839 /// rounding mode for 16-bit floating-point arithmetic and conversion instructions.
2840 ///
2841 /// It also indicates whether the RoundingModeRTZ execution mode can be used for 16-bit
2842 /// floating-point types.
2843 pub shader_rounding_mode_rtz_float16: bool,
2844
2845 /// A `bool` value indicating whether an implementation supports the round-towards-zero
2846 /// rounding mode for 32-bit floating-point arithmetic and conversion instructions.
2847 ///
2848 /// It also indicates whether the RoundingModeRTZ execution mode can be used for 32-bit
2849 /// floating-point types.
2850 pub shader_rounding_mode_rtz_float32: bool,
2851
2852 /// A `bool` value indicating whether an implementation supports the round-towards-zero
2853 /// rounding mode for 64-bit floating-point arithmetic and conversion instructions.
2854 ///
2855 /// It also indicates whether the RoundingModeRTZ execution mode can be used for 64-bit
2856 /// floating-point types.
2857 pub shader_rounding_mode_rtz_float64: bool,
2858
2859 /// The maximum number of descriptors (summed over all descriptor types) that can be created
2860 /// across all pools that are created with the VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT
2861 /// bit set.
2862 ///
2863 /// Pool creation may fail when this limit is exceeded, or when the space this limit represents
2864 /// is unable to satisfy a pool creation due to fragmentation.
2865 pub max_update_after_bind_descriptors_in_all_pools: u32,
2866
2867 /// A `bool` value indicating whether uniform buffer descriptors natively support nonuniform
2868 /// indexing.
2869 ///
2870 /// If this is `false`, then a single dynamic instance of an instruction that nonuniformly
2871 /// indexes an array of uniform buffers may execute multiple times in order to access all the
2872 /// descriptors.
2873 pub shader_uniform_buffer_array_non_uniform_indexing_native: bool,
2874
2875 /// A `bool` value indicating whether sampler and image descriptors natively support nonuniform
2876 /// indexing.
2877 ///
2878 /// If this is `false`, then a single dynamic instance of an instruction that nonuniformly
2879 /// indexes an array of samplers or images may execute multiple times in order to access all
2880 /// the descriptors.
2881 pub shader_sampled_image_array_non_uniform_indexing_native: bool,
2882
2883 /// A `bool` value indicating whether storage buffer descriptors natively support nonuniform
2884 /// indexing.
2885 ///
2886 /// If this is `false`, then a single dynamic instance of an instruction that nonuniformly
2887 /// indexes an array of storage buffers may execute multiple times in order to access all the
2888 /// descriptors.
2889 pub shader_storage_buffer_array_non_uniform_indexing_native: bool,
2890
2891 /// A `bool` value indicating whether storage image descriptors natively support nonuniform
2892 /// indexing.
2893 ///
2894 /// If this is `false`, then a single dynamic instance of an instruction that nonuniformly
2895 /// indexes an array of storage images may execute multiple times in order to access all the
2896 /// descriptors.
2897 pub shader_storage_image_array_non_uniform_indexing_native: bool,
2898
2899 /// A `bool` value indicating whether input attachment descriptors natively support nonuniform
2900 /// indexing.
2901 ///
2902 /// If this is `false`, then a single dynamic instance of an instruction that nonuniformly
2903 /// indexes an array of input attachments may execute multiple times in order to access all the
2904 /// descriptors.
2905 pub shader_input_attachment_array_non_uniform_indexing_native: bool,
2906
2907 /// A `bool` value indicating whether `robustBufferAccess` can be enabled on a device
2908 /// simultaneously with `descriptorBindingUniformBufferUpdateAfterBind`,
2909 /// `descriptorBindingStorageBufferUpdateAfterBind`,
2910 /// `descriptorBindingUniformTexelBufferUpdateAfterBind`, and/or
2911 /// `descriptorBindingStorageTexelBufferUpdateAfterBind`.
2912 ///
2913 /// If this is `false`, then either `robustBufferAccess` must be disabled or all of these
2914 /// update-after-bind features must be disabled.
2915 pub robust_buffer_access_update_after_bind: bool,
2916
2917 /// A `bool` value indicating whether implicit level of detail calculations for image
2918 /// operations have well-defined results when the image and/or sampler objects used for the
2919 /// instruction are not uniform within a quad.
2920 ///
2921 /// See the [features chapter](https://docs.vulkan.org/spec/latest/chapters/features.html).
2922 pub quad_divergent_implicit_lod: bool,
2923
2924 /// Similar to `maxPerStageDescriptorSamplers` but counts descriptors from descriptor sets
2925 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2926 /// bit set.
2927 pub max_per_stage_descriptor_update_after_bind_samplers: u32,
2928
2929 /// Similar to `maxPerStageDescriptorUniformBuffers` but counts descriptors from descriptor
2930 /// sets created with or without the
2931 /// `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2932 pub max_per_stage_descriptor_update_after_bind_uniform_buffers: u32,
2933
2934 /// Similar to `maxPerStageDescriptorStorageBuffers` but counts descriptors from descriptor
2935 /// sets created with or without the
2936 /// `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2937 pub max_per_stage_descriptor_update_after_bind_storage_buffers: u32,
2938
2939 /// Similar to `maxPerStageDescriptorSampledImages` but counts descriptors from descriptor sets
2940 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2941 /// bit set.
2942 pub max_per_stage_descriptor_update_after_bind_sampled_images: u32,
2943
2944 /// Similar to `maxPerStageDescriptorStorageImages` but counts descriptors from descriptor sets
2945 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2946 /// bit set.
2947 pub max_per_stage_descriptor_update_after_bind_storage_images: u32,
2948
2949 /// Similar to `maxPerStageDescriptorInputAttachments` but counts descriptors from descriptor
2950 /// sets created with or without the
2951 /// `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2952 pub max_per_stage_descriptor_update_after_bind_input_attachments: u32,
2953
2954 /// Similar to `maxPerStageResources` but counts descriptors from descriptor sets created with
2955 /// or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2956 pub max_per_stage_update_after_bind_resources: u32,
2957
2958 /// Similar to `maxDescriptorSetSamplers` but counts descriptors from descriptor sets created
2959 /// with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2960 pub max_descriptor_set_update_after_bind_samplers: u32,
2961
2962 /// Similar to `maxDescriptorSetUniformBuffers` but counts descriptors from descriptor sets
2963 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2964 /// bit set.
2965 pub max_descriptor_set_update_after_bind_uniform_buffers: u32,
2966
2967 /// Similar to `maxDescriptorSetUniformBuffersDynamic` but counts descriptors from descriptor
2968 /// sets created with or without the
2969 /// `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2970 ///
2971 /// While an application can allocate dynamic uniform buffer descriptors from a pool created
2972 /// with the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`, bindings for these
2973 /// descriptors must not be present in any descriptor set layout that includes bindings created
2974 /// with `VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT`.
2975 pub max_descriptor_set_update_after_bind_uniform_buffers_dynamic: u32,
2976
2977 /// Similar to `maxDescriptorSetStorageBuffers` but counts descriptors from descriptor sets
2978 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2979 /// bit set.
2980 pub max_descriptor_set_update_after_bind_storage_buffers: u32,
2981
2982 /// Similar to `maxDescriptorSetStorageBuffersDynamic` but counts descriptors from descriptor
2983 /// sets created with or without the
2984 /// `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT` bit set.
2985 ///
2986 /// While an application can allocate dynamic storage buffer descriptors from a pool created
2987 /// with the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`, bindings for these
2988 /// descriptors must not be present in any descriptor set layout that includes bindings created
2989 /// with `VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT`.
2990 pub max_descriptor_set_update_after_bind_storage_buffers_dynamic: u32,
2991
2992 /// Similar to `maxDescriptorSetSampledImages` but counts descriptors from descriptor sets
2993 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2994 /// bit set.
2995 pub max_descriptor_set_update_after_bind_sampled_images: u32,
2996
2997 /// Similar to `maxDescriptorSetStorageImages` but counts descriptors from descriptor sets
2998 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
2999 /// bit set.
3000 pub max_descriptor_set_update_after_bind_storage_images: u32,
3001
3002 /// Similar to `maxDescriptorSetInputAttachments` but counts descriptors from descriptor sets
3003 /// created with or without the `VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT`
3004 /// bit set.
3005 pub max_descriptor_set_update_after_bind_input_attachments: u32,
3006
3007 /// A bitmask of `vk::ResolveModeFlagBits` indicating the set of supported depth resolve modes.
3008 ///
3009 /// `VK_RESOLVE_MODE_SAMPLE_ZERO_BIT` must be included in the set but implementations may
3010 /// support additional modes.
3011 pub supported_depth_resolve_modes: vk::ResolveModeFlags,
3012
3013 /// A bitmask of `vk::ResolveModeFlagBits` indicating the set of supported stencil resolve
3014 /// modes.
3015 ///
3016 /// `VK_RESOLVE_MODE_SAMPLE_ZERO_BIT` must be included in the set but implementations may
3017 /// support additional modes. `VK_RESOLVE_MODE_AVERAGE_BIT` must not be included in the set.
3018 pub supported_stencil_resolve_modes: vk::ResolveModeFlags,
3019
3020 /// `true` if the implementation supports setting the depth and stencil resolve modes to
3021 /// different values when one of those modes is `VK_RESOLVE_MODE_NONE`.
3022 ///
3023 /// Otherwise the implementation only supports setting both modes to the same value.
3024 pub independent_resolve_none: bool,
3025
3026 /// `true` if the implementation supports all combinations of the supported depth and stencil
3027 /// resolve modes, including setting either depth or stencil resolve mode to
3028 /// `VK_RESOLVE_MODE_NONE`.
3029 ///
3030 /// An implementation that supports `independent_resolve` must also support
3031 /// `independent_resolve_none`.
3032 pub independent_resolve: bool,
3033
3034 /// A `bool` value indicating whether a minimum set of required formats support min/max
3035 /// filtering.
3036 pub filter_minmax_single_component_formats: bool,
3037
3038 /// A `bool` value indicating whether the implementation supports non-identity component
3039 /// mapping of the image when doing min/max filtering.
3040 pub filter_minmax_image_component_mapping: bool,
3041
3042 /// Indicates the maximum difference allowed by the implementation between the current value of
3043 /// a timeline semaphore and any pending signal or wait operations.
3044 pub max_timeline_semaphore_value_difference: u64,
3045
3046 /// A bitmask of `vk::SampleCountFlagBits` indicating the color sample counts that are
3047 /// supported for all framebuffer color attachments with integer formats.
3048 pub framebuffer_integer_color_sample_counts: vk::SampleCountFlags,
3049}
3050
3051impl From<vk::PhysicalDeviceVulkan12Properties<'_>> for Vulkan12Properties {
3052 fn from(properties: vk::PhysicalDeviceVulkan12Properties<'_>) -> Self {
3053 Self {
3054 driver_id: properties.driver_id,
3055 driver_name: vk_cstr_to_utf8_string(&properties.driver_name),
3056 driver_info: vk_cstr_to_utf8_string(&properties.driver_info),
3057 conformance_version: properties.conformance_version,
3058 denorm_behavior_independence: properties.denorm_behavior_independence,
3059 rounding_mode_independence: properties.rounding_mode_independence,
3060 shader_signed_zero_inf_nan_preserve_float16: properties
3061 .shader_signed_zero_inf_nan_preserve_float16
3062 == vk::TRUE,
3063 shader_signed_zero_inf_nan_preserve_float32: properties
3064 .shader_signed_zero_inf_nan_preserve_float32
3065 == vk::TRUE,
3066 shader_signed_zero_inf_nan_preserve_float64: properties
3067 .shader_signed_zero_inf_nan_preserve_float64
3068 == vk::TRUE,
3069 shader_denorm_preserve_float16: properties.shader_denorm_preserve_float16 == vk::TRUE,
3070 shader_denorm_preserve_float32: properties.shader_denorm_preserve_float32 == vk::TRUE,
3071 shader_denorm_preserve_float64: properties.shader_denorm_preserve_float64 == vk::TRUE,
3072 shader_denorm_flush_to_zero_float16: properties.shader_denorm_flush_to_zero_float16
3073 == vk::TRUE,
3074 shader_denorm_flush_to_zero_float32: properties.shader_denorm_flush_to_zero_float32
3075 == vk::TRUE,
3076 shader_denorm_flush_to_zero_float64: properties.shader_denorm_flush_to_zero_float64
3077 == vk::TRUE,
3078 shader_rounding_mode_rte_float16: properties.shader_rounding_mode_rte_float16
3079 == vk::TRUE,
3080 shader_rounding_mode_rte_float32: properties.shader_rounding_mode_rte_float32
3081 == vk::TRUE,
3082 shader_rounding_mode_rte_float64: properties.shader_rounding_mode_rte_float64
3083 == vk::TRUE,
3084 shader_rounding_mode_rtz_float16: properties.shader_rounding_mode_rtz_float16
3085 == vk::TRUE,
3086 shader_rounding_mode_rtz_float32: properties.shader_rounding_mode_rtz_float32
3087 == vk::TRUE,
3088 shader_rounding_mode_rtz_float64: properties.shader_rounding_mode_rtz_float64
3089 == vk::TRUE,
3090 max_update_after_bind_descriptors_in_all_pools: properties
3091 .max_update_after_bind_descriptors_in_all_pools,
3092 shader_uniform_buffer_array_non_uniform_indexing_native: properties
3093 .shader_uniform_buffer_array_non_uniform_indexing_native
3094 == vk::TRUE,
3095 shader_sampled_image_array_non_uniform_indexing_native: properties
3096 .shader_sampled_image_array_non_uniform_indexing_native
3097 == vk::TRUE,
3098 shader_storage_buffer_array_non_uniform_indexing_native: properties
3099 .shader_storage_buffer_array_non_uniform_indexing_native
3100 == vk::TRUE,
3101 shader_storage_image_array_non_uniform_indexing_native: properties
3102 .shader_storage_image_array_non_uniform_indexing_native
3103 == vk::TRUE,
3104 shader_input_attachment_array_non_uniform_indexing_native: properties
3105 .shader_input_attachment_array_non_uniform_indexing_native
3106 == vk::TRUE,
3107 robust_buffer_access_update_after_bind: properties
3108 .robust_buffer_access_update_after_bind
3109 == vk::TRUE,
3110 quad_divergent_implicit_lod: properties.quad_divergent_implicit_lod == vk::TRUE,
3111 max_per_stage_descriptor_update_after_bind_samplers: properties
3112 .max_per_stage_descriptor_update_after_bind_samplers,
3113 max_per_stage_descriptor_update_after_bind_uniform_buffers: properties
3114 .max_per_stage_descriptor_update_after_bind_uniform_buffers,
3115 max_per_stage_descriptor_update_after_bind_storage_buffers: properties
3116 .max_per_stage_descriptor_update_after_bind_storage_buffers,
3117 max_per_stage_descriptor_update_after_bind_sampled_images: properties
3118 .max_per_stage_descriptor_update_after_bind_sampled_images,
3119 max_per_stage_descriptor_update_after_bind_storage_images: properties
3120 .max_per_stage_descriptor_update_after_bind_storage_images,
3121 max_per_stage_descriptor_update_after_bind_input_attachments: properties
3122 .max_per_stage_descriptor_update_after_bind_input_attachments,
3123 max_per_stage_update_after_bind_resources: properties
3124 .max_per_stage_update_after_bind_resources,
3125 max_descriptor_set_update_after_bind_samplers: properties
3126 .max_descriptor_set_update_after_bind_samplers,
3127 max_descriptor_set_update_after_bind_uniform_buffers: properties
3128 .max_descriptor_set_update_after_bind_uniform_buffers,
3129 max_descriptor_set_update_after_bind_uniform_buffers_dynamic: properties
3130 .max_descriptor_set_update_after_bind_uniform_buffers_dynamic,
3131 max_descriptor_set_update_after_bind_storage_buffers: properties
3132 .max_descriptor_set_update_after_bind_storage_buffers,
3133 max_descriptor_set_update_after_bind_storage_buffers_dynamic: properties
3134 .max_descriptor_set_update_after_bind_storage_buffers_dynamic,
3135 max_descriptor_set_update_after_bind_sampled_images: properties
3136 .max_descriptor_set_update_after_bind_sampled_images,
3137 max_descriptor_set_update_after_bind_storage_images: properties
3138 .max_descriptor_set_update_after_bind_storage_images,
3139 max_descriptor_set_update_after_bind_input_attachments: properties
3140 .max_descriptor_set_update_after_bind_input_attachments,
3141 supported_depth_resolve_modes: properties.supported_depth_resolve_modes,
3142 supported_stencil_resolve_modes: properties.supported_stencil_resolve_modes,
3143 independent_resolve_none: properties.independent_resolve_none == vk::TRUE,
3144 independent_resolve: properties.independent_resolve == vk::TRUE,
3145 filter_minmax_single_component_formats: properties
3146 .filter_minmax_single_component_formats
3147 == vk::TRUE,
3148 filter_minmax_image_component_mapping: properties.filter_minmax_image_component_mapping
3149 == vk::TRUE,
3150 max_timeline_semaphore_value_difference: properties
3151 .max_timeline_semaphore_value_difference,
3152 framebuffer_integer_color_sample_counts: properties
3153 .framebuffer_integer_color_sample_counts,
3154 }
3155 }
3156}
3157
3158#[cfg(test)]
3159mod tests {
3160 use super::*;
3161
3162 fn c_chars(bytes: &[u8]) -> Vec<c_char> {
3163 bytes.iter().map(|&byte| byte as c_char).collect()
3164 }
3165
3166 #[test]
3167 fn vk_cstr_to_utf8_string_reads_until_nul() {
3168 let value = c_chars(b"hello\0ignored");
3169
3170 assert_eq!(vk_cstr_to_utf8_string(&value), "hello");
3171 }
3172
3173 #[test]
3174 fn vk_cstr_to_utf8_string_accepts_non_ascii_utf8() {
3175 let value = c_chars("Møøse\0".as_bytes());
3176
3177 assert_eq!(vk_cstr_to_utf8_string(&value), "Møøse");
3178 }
3179
3180 #[test]
3181 fn vk_cstr_to_utf8_string_accepts_128_bytes_before_nul() {
3182 let mut value = vec![b'a'; MAX_C_STRING_UTF8_BYTES];
3183 value.push(0);
3184 let value = c_chars(&value);
3185
3186 assert_eq!(
3187 vk_cstr_to_utf8_string(&value),
3188 "a".repeat(MAX_C_STRING_UTF8_BYTES)
3189 );
3190 }
3191
3192 #[test]
3193 fn vk_cstr_to_utf8_string_rejects_missing_nul() {
3194 let value = c_chars(b"unterminated");
3195
3196 assert_eq!(vk_cstr_to_utf8_string(&value), UNKNOWN_C_STRING);
3197 }
3198
3199 #[test]
3200 fn vk_cstr_to_utf8_string_rejects_nul_after_max_len() {
3201 let mut value = vec![b'a'; MAX_C_STRING_UTF8_BYTES + 1];
3202 value.push(0);
3203 let value = c_chars(&value);
3204
3205 assert_eq!(vk_cstr_to_utf8_string(&value), UNKNOWN_C_STRING);
3206 }
3207
3208 #[test]
3209 fn vk_cstr_to_utf8_string_rejects_invalid_utf8() {
3210 let value = c_chars(&[b'o', 0xff, 0]);
3211
3212 assert_eq!(vk_cstr_to_utf8_string(&value), UNKNOWN_C_STRING);
3213 }
3214}