Skip to content

Commit 0d69482

Browse files
committed
[hal/vulkan] Don't advertise features without prerequisites present.
Don't advertise features like `STORAGE_RESOURCE_BINDING_ARRAY` unless at least one of the features it extends, like `BUFFER_BINDING_ARRAY` or `TEXTURE_BINDING_ARRAY`, is actually present. Replace the calls to `all_features_supported` with the equivalent inline code, and delete the function.
1 parent 1f67474 commit 0d69482

File tree

1 file changed

+23
-54
lines changed

1 file changed

+23
-54
lines changed

wgpu-hal/src/vulkan/adapter.rs

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -560,21 +560,13 @@ impl PhysicalDeviceFeatures {
560560
self.core.shader_sampled_image_array_dynamic_indexing != 0,
561561
);
562562
features.set(F::SHADER_PRIMITIVE_INDEX, self.core.geometry_shader != 0);
563-
if Self::all_features_supported(
564-
&features,
565-
&[
566-
(
567-
F::BUFFER_BINDING_ARRAY,
568-
self.core.shader_storage_buffer_array_dynamic_indexing,
569-
),
570-
(
571-
F::TEXTURE_BINDING_ARRAY,
572-
self.core.shader_storage_image_array_dynamic_indexing,
573-
),
574-
],
575-
) {
576-
features.insert(F::STORAGE_RESOURCE_BINDING_ARRAY);
577-
}
563+
features.set(
564+
F::STORAGE_RESOURCE_BINDING_ARRAY,
565+
(features.contains(F::BUFFER_BINDING_ARRAY)
566+
&& self.core.shader_storage_buffer_array_dynamic_indexing != 0)
567+
|| (features.contains(F::TEXTURE_BINDING_ARRAY)
568+
&& self.core.shader_storage_image_array_dynamic_indexing != 0),
569+
);
578570
//if self.core.shader_storage_image_array_dynamic_indexing != 0 {
579571
//if self.core.shader_clip_distance != 0 {
580572
//if self.core.shader_cull_distance != 0 {
@@ -605,36 +597,22 @@ impl PhysicalDeviceFeatures {
605597

606598
if let Some(ref descriptor_indexing) = self.descriptor_indexing {
607599
const STORAGE: F = F::STORAGE_RESOURCE_BINDING_ARRAY;
608-
if Self::all_features_supported(
609-
&features,
610-
&[
611-
(
612-
F::TEXTURE_BINDING_ARRAY,
613-
descriptor_indexing.shader_sampled_image_array_non_uniform_indexing,
614-
),
615-
(
616-
F::BUFFER_BINDING_ARRAY | STORAGE,
617-
descriptor_indexing.shader_storage_buffer_array_non_uniform_indexing,
618-
),
619-
],
620-
) {
621-
features.insert(F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING);
622-
}
623-
if Self::all_features_supported(
624-
&features,
625-
&[
626-
(
627-
F::BUFFER_BINDING_ARRAY,
628-
descriptor_indexing.shader_uniform_buffer_array_non_uniform_indexing,
629-
),
630-
(
631-
F::TEXTURE_BINDING_ARRAY | STORAGE,
632-
descriptor_indexing.shader_storage_image_array_non_uniform_indexing,
633-
),
634-
],
635-
) {
636-
features.insert(F::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING);
637-
}
600+
features.set(
601+
F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING,
602+
(features.contains(F::TEXTURE_BINDING_ARRAY)
603+
&& descriptor_indexing.shader_sampled_image_array_non_uniform_indexing != 0)
604+
&& (features.contains(F::BUFFER_BINDING_ARRAY | STORAGE)
605+
&& descriptor_indexing.shader_storage_buffer_array_non_uniform_indexing
606+
!= 0),
607+
);
608+
features.set(
609+
F::UNIFORM_BUFFER_AND_STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING,
610+
(features.contains(F::BUFFER_BINDING_ARRAY)
611+
&& descriptor_indexing.shader_uniform_buffer_array_non_uniform_indexing != 0)
612+
&& (features.contains(F::TEXTURE_BINDING_ARRAY | STORAGE)
613+
&& descriptor_indexing.shader_storage_image_array_non_uniform_indexing
614+
!= 0),
615+
);
638616
if descriptor_indexing.descriptor_binding_partially_bound != 0 && !intel_windows {
639617
features |= F::PARTIALLY_BOUND_BINDING_ARRAY;
640618
}
@@ -783,15 +761,6 @@ impl PhysicalDeviceFeatures {
783761

784762
(features, dl_flags)
785763
}
786-
787-
fn all_features_supported(
788-
features: &wgt::Features,
789-
implications: &[(wgt::Features, vk::Bool32)],
790-
) -> bool {
791-
implications
792-
.iter()
793-
.all(|&(flag, support)| !features.contains(flag) || support != 0)
794-
}
795764
}
796765

797766
/// Vulkan "properties" structures gathered about a physical device.

0 commit comments

Comments
 (0)