From 1f49837cb0ea8e8e17aecf454029feb15c6c35b2 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 12 Nov 2024 23:51:07 +0100 Subject: [PATCH] Fix Vulkan surface capabilities being advertised when its query failed. (#6510) Leaves out portions of #6510 that changed the interface --- CHANGELOG.md | 4 ++++ wgpu-hal/src/vulkan/adapter.rs | 6 ++++-- wgpu/src/backend/wgpu_core.rs | 5 +---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df3b470e5..d0104b363c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ Bottom level categories: - Fix surface creation crashing on iOS. By @mockersf in [#6535](https://github.com/gfx-rs/wgpu/pull/6535) +#### Vulkan + +- Fix surface capabilities being advertised when its query failed. By @wumpf in [#6510](https://github.com/gfx-rs/wgpu/pull/6510) + ## 23.0.0 (2024-10-25) ### Themes of this release diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 6d15492f4c..14fd86a5da 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -2254,7 +2254,8 @@ impl crate::Adapter for super::Adapter { Ok(present_modes) => present_modes, Err(e) => { log::error!("get_physical_device_surface_present_modes: {}", e); - Vec::new() + // Per definition of `SurfaceCapabilities`, there must be at least one present mode. + return None; } } }; @@ -2269,7 +2270,8 @@ impl crate::Adapter for super::Adapter { Ok(formats) => formats, Err(e) => { log::error!("get_physical_device_surface_formats: {}", e); - Vec::new() + // Per definition of `SurfaceCapabilities`, there must be at least one present format. + return None; } } }; diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 652df388ff..ff84b5b683 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -702,10 +702,7 @@ impl crate::Context for ContextWgpuCore { .surface_get_capabilities(surface_data.id, *adapter_data) { Ok(caps) => caps, - Err(wgc::instance::GetSurfaceSupportError::Unsupported) => { - wgt::SurfaceCapabilities::default() - } - Err(err) => self.handle_error_fatal(err, "Surface::get_supported_formats"), + Err(_) => wgt::SurfaceCapabilities::default(), } }