From 355ad949dac86f1234458d97fa4d0a16bbfcd54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 13 Apr 2023 08:51:49 +0200 Subject: [PATCH 1/3] reject binding type multisampled when on a float filterable sample type --- wgpu-core/src/binding_model.rs | 2 ++ wgpu-core/src/device/mod.rs | 25 ++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 252bb46d2d..378643a730 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -29,6 +29,8 @@ pub enum BindGroupLayoutEntryError { StorageTextureReadWrite, #[error("Arrays of bindings unsupported for this type of binding")] ArrayUnsupported, + #[error("Binding of TextureSampleType::Float can't be filterable when multisampled")] + SampleTypeFloatFilterableBindingMultisampled, #[error(transparent)] MissingFeatures(#[from] MissingFeatures), #[error(transparent)] diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 9e311d1019..db156aee5b 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -22,7 +22,7 @@ use hal::{CommandEncoder as _, Device as _}; use parking_lot::{Mutex, MutexGuard}; use smallvec::SmallVec; use thiserror::Error; -use wgt::{BufferAddress, TextureFormat, TextureViewDimension}; +use wgt::{BufferAddress, TextureFormat, TextureSampleType, TextureViewDimension}; use std::{borrow::Cow, iter, mem, num::NonZeroU32, ops::Range, ptr}; @@ -1694,10 +1694,25 @@ impl Device { Some(wgt::Features::TEXTURE_BINDING_ARRAY), WritableStorage::No, ), - Bt::Texture { .. } => ( - Some(wgt::Features::TEXTURE_BINDING_ARRAY), - WritableStorage::No, - ), + Bt::Texture { + multisampled, + sample_type, + .. + } => { + if multisampled + && matches!(sample_type, TextureSampleType::Float { filterable: true }) + { + return Err(binding_model::CreateBindGroupLayoutError::Entry { + binding: entry.binding, + error: binding_model::BindGroupLayoutEntryError::SampleTypeFloatFilterableBindingMultisampled, + }); + } else { + ( + Some(wgt::Features::TEXTURE_BINDING_ARRAY), + WritableStorage::No, + ) + } + } Bt::StorageTexture { access, view_dimension, From e966295a5df3023d06b05105b8f6934b6e80f8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 13 Apr 2023 09:19:01 +0200 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 587e1bd219..a0d421e50f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,6 +143,7 @@ By @cwfitzgerald in [#3671](https://github.com/gfx-rs/wgpu/pull/3671). - Make error descriptions all upper case. By @cwfitzgerald in [#3549](https://github.com/gfx-rs/wgpu/pull/3549) - Don't include ANSI terminal color escape sequences in shader module validation error messages. By @jimblandy in [#3591](https://github.com/gfx-rs/wgpu/pull/3591) - Report error messages from DXC compile. By @Davidster in [#3632](https://github.com/gfx-rs/wgpu/pull/3632) +- Error in native when using a filterable `TextureSampleType::Float` on a multisample `BindingType::Texture`. By @mockersf in [#3686](https://github.com/gfx-rs/wgpu/pull/3686) #### WebGPU From bdaaf1f6dd67ded1a172162d55c20ca9728ec49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Thu, 13 Apr 2023 19:12:53 +0200 Subject: [PATCH 3/3] review --- wgpu-core/src/binding_model.rs | 2 +- wgpu-core/src/device/mod.rs | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index 378643a730..5c63ac43ff 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -29,7 +29,7 @@ pub enum BindGroupLayoutEntryError { StorageTextureReadWrite, #[error("Arrays of bindings unsupported for this type of binding")] ArrayUnsupported, - #[error("Binding of TextureSampleType::Float can't be filterable when multisampled")] + #[error("Multisampled binding with sample type `TextureSampleType::Float` must have filterable set to false.")] SampleTypeFloatFilterableBindingMultisampled, #[error(transparent)] MissingFeatures(#[from] MissingFeatures), diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index db156aee5b..c8ef8632ad 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -1695,24 +1695,19 @@ impl Device { WritableStorage::No, ), Bt::Texture { - multisampled, - sample_type, + multisampled: true, + sample_type: TextureSampleType::Float { filterable: true }, .. } => { - if multisampled - && matches!(sample_type, TextureSampleType::Float { filterable: true }) - { - return Err(binding_model::CreateBindGroupLayoutError::Entry { - binding: entry.binding, - error: binding_model::BindGroupLayoutEntryError::SampleTypeFloatFilterableBindingMultisampled, - }); - } else { - ( - Some(wgt::Features::TEXTURE_BINDING_ARRAY), - WritableStorage::No, - ) - } + return Err(binding_model::CreateBindGroupLayoutError::Entry { + binding: entry.binding, + error: binding_model::BindGroupLayoutEntryError::SampleTypeFloatFilterableBindingMultisampled, + }); } + Bt::Texture { .. } => ( + Some(wgt::Features::TEXTURE_BINDING_ARRAY), + WritableStorage::No, + ), Bt::StorageTexture { access, view_dimension,