From 1950abefc9cbed29d2f59407b09e799d833ec185 Mon Sep 17 00:00:00 2001 From: xiaopengli89 Date: Mon, 30 Oct 2023 18:55:16 +0800 Subject: [PATCH] fix hal view formats --- wgpu-core/src/device/resource.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index e09bda77e98..46fb90191e3 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -703,17 +703,18 @@ impl Device { if desc.format == *format { continue; } - if let ( - TextureFormat::NV12, - TextureFormat::R8Unorm - | TextureFormat::R8Uint - | TextureFormat::Rg8Unorm - | TextureFormat::Rg8Uint, - ) = (desc.format, *format) + + if !matches!( + (desc.format, *format), + ( + TextureFormat::NV12, + TextureFormat::R8Unorm + | TextureFormat::R8Uint + | TextureFormat::Rg8Unorm + | TextureFormat::Rg8Uint, + ) + ) && desc.format.remove_srgb_suffix() != format.remove_srgb_suffix() { - continue; - } - if desc.format.remove_srgb_suffix() != format.remove_srgb_suffix() { return Err(CreateTextureError::InvalidViewFormat(*format, desc.format)); } hal_view_formats.push(*format);