From 25dfd6420aeca9763129331b72021714b5ddbee8 Mon Sep 17 00:00:00 2001 From: Seamus Mulholland-Patterson Date: Fri, 15 Jul 2022 17:18:11 +0800 Subject: [PATCH 1/2] added downlevel restriction error message for InvalidFormatUsages error --- wgpu-core/src/device/mod.rs | 8 ++++++++ wgpu-core/src/resource.rs | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index e832b27ddb..bee775e0d9 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -800,9 +800,17 @@ impl Device { let missing_allowed_usages = desc.usage - format_features.allowed_usages; if !missing_allowed_usages.is_empty() { + // detect downlevel incompatibilities + let wgpu_allowed_usages = desc + .format + .describe() + .guaranteed_format_features + .allowed_usages; + let wgpu_missing_usages = desc.usage - wgpu_allowed_usages; return Err(CreateTextureError::InvalidFormatUsages( missing_allowed_usages, desc.format, + wgpu_missing_usages.is_empty(), )); } diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index bc7f865f39..07a7086ff1 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -423,8 +423,11 @@ pub enum CreateTextureError { "Texture descriptor mip level count {requested} is invalid, maximum allowed is {maximum}" )] InvalidMipLevelCount { requested: u32, maximum: u32 }, - #[error("Texture usages {0:?} are not allowed on a texture of type {1:?}")] - InvalidFormatUsages(wgt::TextureUsages, wgt::TextureFormat), + #[error( + "Texture usages {0:?} are not allowed on a texture of type {1:?}{}", + if *.2 { " due to downlevel restrictions" } else { "" } + )] + InvalidFormatUsages(wgt::TextureUsages, wgt::TextureFormat, bool), #[error("Texture usages {0:?} are not allowed on a texture of dimensions {1:?}")] InvalidDimensionUsages(wgt::TextureUsages, wgt::TextureDimension), #[error("Texture usage STORAGE_BINDING is not allowed for multisampled textures")] From f77cbe500d4364d7f5a559579cc1f1cd8e34f6a0 Mon Sep 17 00:00:00 2001 From: Seamus Mulholland-Patterson Date: Sat, 16 Jul 2022 00:12:59 +0800 Subject: [PATCH 2/2] added changelog entry for #2886 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a84f455fbf..18b305d0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,9 @@ Bottom level categories: #### Metal - Extract the generic code into `get_metal_layer` by @jinleili in [#2826](https://github.com/gfx-rs/wgpu/pull/2826) +#### General +- Added downlevel restriction error message for `InvalidFormatUsages` error by @Seamooo in [#2886](https://github.com/gfx-rs/wgpu/pull/2886) + ## wgpu-0.13.2 (2022-07-13) ### Bug Fixes