Skip to content

Commit

Permalink
Include supported sample counts in InvalidSampleCount errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DevJac committed Oct 26, 2023
1 parent e0e1056 commit 4bef545
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
24 changes: 24 additions & 0 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,14 @@ impl<A: HalApi> Device<A> {
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(),
));
};
}
Expand Down Expand Up @@ -2818,6 +2826,14 @@ impl<A: HalApi> Device<A> {
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 {
Expand Down Expand Up @@ -2876,6 +2892,14 @@ impl<A: HalApi> Device<A> {
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(),
));
}

Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>, Vec<u32>),
#[error("Output format {pipeline} is incompatible with the shader {shader}")]
IncompatibleFormat {
pipeline: validation::NumericType,
Expand All @@ -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<u32>, Vec<u32>),
}

#[derive(Clone, Debug, Error)]
Expand Down
4 changes: 2 additions & 2 deletions wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>, Vec<u32>),
#[error("Multisampled textures must have RENDER_ATTACHMENT usage")]
MultisampledNotRenderAttachment,
#[error("Texture format {0:?} can't be used due to missing features")]
Expand Down

0 comments on commit 4bef545

Please sign in to comment.