Improve read-write and read-only texture storage error message (#2745)

* Improve read-write and read-only texture storage error message

* Update wgpu-core/src/binding_model.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
Jinlei Li 2022-06-07 14:21:17 +08:00 committed by GitHub
parent 091e9b1788
commit f0c7fe3a8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,8 @@ use thiserror::Error;
pub enum BindGroupLayoutEntryError { pub enum BindGroupLayoutEntryError {
#[error("cube dimension is not expected for texture storage")] #[error("cube dimension is not expected for texture storage")]
StorageTextureCube, 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")] #[error("arrays of bindings unsupported for this type of binding")]
ArrayUnsupported, ArrayUnsupported,
#[error(transparent)] #[error(transparent)]

View File

@ -1380,6 +1380,20 @@ impl<A: HalApi> Device<A> {
} }
_ => (), _ => (),
} }
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( Some(
wgt::Features::TEXTURE_BINDING_ARRAY wgt::Features::TEXTURE_BINDING_ARRAY