diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index bf29520674..d45b6145c8 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -1431,11 +1431,10 @@ impl Device { }); } - if desc.size.depth_or_array_layers != 1 { - return Err(CreateTextureError::InvalidDimension( - TextureDimensionError::MultisampledDepthOrArrayLayer( - desc.size.depth_or_array_layers, - ), + if desc.dimension != wgt::TextureDimension::D2 { + return Err(CreateTextureError::InvalidMultisampledDimension( + desc.dimension, + desc.sample_count, )); } diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index b5290f2605..2546c46892 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -1551,8 +1551,6 @@ pub enum TextureDimensionError { multiple: u32, format: wgt::TextureFormat, }, - #[error("Multisampled texture depth or array layers must be 1, got {0}")] - MultisampledDepthOrArrayLayer(u32), } impl WebGpuError for TextureDimensionError { @@ -1597,6 +1595,10 @@ pub enum CreateTextureError { InvalidMultisampledFormat(wgt::TextureFormat), #[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarantees {2:?} samples are supported by this format. With the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature your device supports {3:?}.")] InvalidSampleCount(u32, wgt::TextureFormat, Vec, Vec), + #[error( + "Textures of dimension {0:?} cannot be multisampled, but the multisample count is {1}" + )] + InvalidMultisampledDimension(wgt::TextureDimension, u32), #[error("Multisampled textures must have RENDER_ATTACHMENT usage")] MultisampledNotRenderAttachment, #[error("Texture format {0:?} can't be used due to missing features")] @@ -1637,7 +1639,8 @@ impl WebGpuError for CreateTextureError { | Self::InvalidMultisampledStorageBinding | Self::InvalidMultisampledFormat(_) | Self::InvalidSampleCount(..) - | Self::MultisampledNotRenderAttachment => return ErrorType::Validation, + | Self::MultisampledNotRenderAttachment + | Self::InvalidMultisampledDimension(..) => return ErrorType::Validation, }; e.webgpu_error_type() }