Skip to content

Commit

Permalink
fix: vulkan only uses robust_*_access2 if the driver supports it (#3962)
Browse files Browse the repository at this point in the history
  • Loading branch information
schell authored Jul 23, 2023
1 parent 9b10afd commit 8417eff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 13 additions & 3 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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| {
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down

0 comments on commit 8417eff

Please sign in to comment.