From 8417eff6bc80b0f48b58de42dc811c040cece1bd Mon Sep 17 00:00:00 2001 From: Schell Carl Scivally Date: Sun, 23 Jul 2023 15:52:44 +1200 Subject: [PATCH] fix: vulkan only uses robust_*_access2 if the driver supports it (#3962) --- wgpu-hal/src/vulkan/adapter.rs | 16 +++++++++++++--- wgpu-hal/src/vulkan/mod.rs | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index d23aca76a3..5f16e3a99b 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -234,11 +234,11 @@ impl PhysicalDeviceFeatures { robustness2: if enabled_extensions.contains(&vk::ExtRobustness2Fn::name()) { // Note: enabling `robust_buffer_access2` isn't requires, strictly speaking // since we can enable `robust_buffer_access` all the time. But it improves - // program portability, so we opt into it anyway. + // program portability, so we opt into it if they are supported. Some( vk::PhysicalDeviceRobustness2FeaturesEXT::builder() - .robust_buffer_access2(private_caps.robust_buffer_access) - .robust_image_access2(private_caps.robust_image_access) + .robust_buffer_access2(private_caps.robust_buffer_access2) + .robust_image_access2(private_caps.robust_image_access2) .build(), ) } else { @@ -1063,6 +1063,16 @@ impl super::Instance { .image_robustness .map_or(false, |ext| ext.robust_image_access != 0), }, + robust_buffer_access2: phd_features + .robustness2 + .as_ref() + .map(|r| r.robust_buffer_access2 == 1) + .unwrap_or_default(), + robust_image_access2: phd_features + .robustness2 + .as_ref() + .map(|r| r.robust_image_access2 == 1) + .unwrap_or_default(), zero_initialize_workgroup_memory: phd_features .zero_initialize_workgroup_memory .map_or(false, |ext| { diff --git a/wgpu-hal/src/vulkan/mod.rs b/wgpu-hal/src/vulkan/mod.rs index 6949403265..3a0bfd82b9 100644 --- a/wgpu-hal/src/vulkan/mod.rs +++ b/wgpu-hal/src/vulkan/mod.rs @@ -189,6 +189,8 @@ struct PrivateCapabilities { non_coherent_map_mask: wgt::BufferAddress, robust_buffer_access: bool, robust_image_access: bool, + robust_buffer_access2: bool, + robust_image_access2: bool, zero_initialize_workgroup_memory: bool, }