diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs index ef97af6d91..458723a3bf 100644 --- a/wgpu-core/src/binding_model.rs +++ b/wgpu-core/src/binding_model.rs @@ -24,6 +24,8 @@ use thiserror::Error; pub enum BindGroupLayoutEntryError { #[error("cube dimension is not expected for texture storage")] StorageTextureCube, + #[error("Read-write and read-only storage textures are not allowed by webgpu, they require the native only feature TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES")] + StorageTextureReadWrite, #[error("arrays of bindings unsupported for this type of binding")] ArrayUnsupported, #[error(transparent)] diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index a590903bbb..016232e51f 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -1380,6 +1380,20 @@ impl Device { } _ => (), } + match access { + wgt::StorageTextureAccess::ReadOnly + | wgt::StorageTextureAccess::ReadWrite + if !self.features.contains( + wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES, + ) => + { + return Err(binding_model::CreateBindGroupLayoutError::Entry { + binding: entry.binding, + error: binding_model::BindGroupLayoutEntryError::StorageTextureReadWrite, + }); + } + _ => (), + } ( Some( wgt::Features::TEXTURE_BINDING_ARRAY