From 4bef545a46ebbd4aee6273e1d49a4773ece23b79 Mon Sep 17 00:00:00 2001 From: DevJac Date: Wed, 25 Oct 2023 09:07:53 -0600 Subject: [PATCH] Include supported sample counts in InvalidSampleCount errors --- wgpu-core/src/device/resource.rs | 24 ++++++++++++++++++++++++ wgpu-core/src/pipeline.rs | 8 ++++---- wgpu-core/src/resource.rs | 4 ++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index b448383ecd..a2160b9ee5 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -662,6 +662,14 @@ impl Device { return Err(CreateTextureError::InvalidSampleCount( desc.sample_count, desc.format, + desc.format + .guaranteed_format_features(self.features) + .flags + .supported_sample_counts(), + adapter + .get_texture_format_features(desc.format) + .flags + .supported_sample_counts(), )); }; } @@ -2818,6 +2826,14 @@ impl Device { break Some(pipeline::ColorStateError::InvalidSampleCount( desc.multisample.count, cs.format, + cs.format + .guaranteed_format_features(self.features) + .flags + .supported_sample_counts(), + adapter + .get_texture_format_features(cs.format) + .flags + .supported_sample_counts(), )); } if let Some(blend_mode) = cs.blend { @@ -2876,6 +2892,14 @@ impl Device { break Some(pipeline::DepthStencilStateError::InvalidSampleCount( desc.multisample.count, ds.format, + ds.format + .guaranteed_format_features(self.features) + .flags + .supported_sample_counts(), + adapter + .get_texture_format_features(ds.format) + .flags + .supported_sample_counts(), )); } diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index a3ec3f3a30..bfab15b2f5 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -299,8 +299,8 @@ pub enum ColorStateError { FormatNotBlendable(wgt::TextureFormat), #[error("Format {0:?} does not have a color aspect")] FormatNotColor(wgt::TextureFormat), - #[error("Sample count {0} is not supported by format {1:?} on this device. It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")] - InvalidSampleCount(u32, wgt::TextureFormat), + #[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees {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("Output format {pipeline} is incompatible with the shader {shader}")] IncompatibleFormat { pipeline: validation::NumericType, @@ -321,8 +321,8 @@ pub enum DepthStencilStateError { FormatNotDepth(wgt::TextureFormat), #[error("Format {0:?} does not have a stencil aspect, but stencil test/write is enabled")] FormatNotStencil(wgt::TextureFormat), - #[error("Sample count {0} is not supported by format {1:?} on this device. It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")] - InvalidSampleCount(u32, wgt::TextureFormat), + #[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees {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), } #[derive(Clone, Debug, Error)] diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index c0977b80ef..4ff8f539a8 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -579,8 +579,8 @@ pub enum CreateTextureError { InvalidMultisampledStorageBinding, #[error("Format {0:?} does not support multisampling")] InvalidMultisampledFormat(wgt::TextureFormat), - #[error("Sample count {0} is not supported by format {1:?} on this device. It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")] - InvalidSampleCount(u32, wgt::TextureFormat), + #[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees {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("Multisampled textures must have RENDER_ATTACHMENT usage")] MultisampledNotRenderAttachment, #[error("Texture format {0:?} can't be used due to missing features")]