Skip to content

Commit

Permalink
Sample count error includes info about supported counts and features
Browse files Browse the repository at this point in the history
  • Loading branch information
DevJac committed Oct 25, 2023
1 parent b813856 commit 7f02609
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
27 changes: 24 additions & 3 deletions wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,14 @@ impl<A: HalApi> Device<A> {
return Err(CreateTextureError::InvalidSampleCount(
desc.sample_count,
desc.format,
format_features.flags.supported_sample_counts(),
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 @@ -2819,7 +2826,14 @@ impl<A: HalApi> Device<A> {
break Some(pipeline::ColorStateError::InvalidSampleCount(
desc.multisample.count,
cs.format,
format_features.flags.supported_sample_counts(),
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 @@ -2878,7 +2892,14 @@ impl<A: HalApi> Device<A> {
break Some(pipeline::DepthStencilStateError::InvalidSampleCount(
desc.multisample.count,
ds.format,
format_features.flags.supported_sample_counts(),
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 (supported sample counts are: {2:?}). It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")]
InvalidSampleCount(u32, wgt::TextureFormat, Vec<u32>),
#[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees sample counts {2:?}. 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 (supported sample counts are: {2:?}). It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")]
InvalidSampleCount(u32, wgt::TextureFormat, Vec<u32>),
#[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees sample counts {2:?}. 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 (supported sample counts are: {2:?}). It may be supported by your adapter through the TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES feature.")]
InvalidSampleCount(u32, wgt::TextureFormat, Vec<u32>),
#[error("Sample count {0} is not supported by format {1:?} on this device. The WebGPU spec guarentees sample counts {2:?}. 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 7f02609

Please sign in to comment.