Skip to content

Commit

Permalink
Uppercase all error strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cwfitzgerald committed Mar 1, 2023
1 parent 70399f8 commit 3fb3ec3
Show file tree
Hide file tree
Showing 17 changed files with 275 additions and 273 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436)
- Added `TextureFormatFeatureFlags::MULTISAMPLE_X16`. By @Dinnerbone in [#3454](https://github.com/gfx-rs/wgpu/pull/3454)
- Support stencil-only views and copying to/from combined depth-stencil textures. By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436)
- Added `Features::SHADER_EARLY_DEPTH_TEST`. By @teoxoy in [#3494](https://github.com/gfx-rs/wgpu/pull/3494)
- Improve attachment related errors. By @cwfitzgerald in [#3549](https://github.com/gfx-rs/wgpu/pull/3549)
- Make error descriptions all upper case. By @cwfitzgerald in [#3549](https://github.com/gfx-rs/wgpu/pull/3549)

#### WebGPU

Expand Down
92 changes: 46 additions & 46 deletions wgpu-core/src/binding_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use thiserror::Error;

#[derive(Clone, Debug, Error)]
pub enum BindGroupLayoutEntryError {
#[error("cube dimension is not expected for texture storage")]
#[error("Cube dimension is not expected for texture storage")]
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,
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
Expand All @@ -38,9 +38,9 @@ pub enum BindGroupLayoutEntryError {
pub enum CreateBindGroupLayoutError {
#[error(transparent)]
Device(#[from] DeviceError),
#[error("conflicting binding at index {0}")]
#[error("Conflicting binding at index {0}")]
ConflictBinding(u32),
#[error("binding {binding} entry is invalid")]
#[error("Binding {binding} entry is invalid")]
Entry {
binding: u32,
#[source]
Expand All @@ -60,63 +60,63 @@ pub enum CreateBindGroupLayoutError {
pub enum CreateBindGroupError {
#[error(transparent)]
Device(#[from] DeviceError),
#[error("bind group layout is invalid")]
#[error("Bind group layout is invalid")]
InvalidLayout,
#[error("buffer {0:?} is invalid or destroyed")]
#[error("Buffer {0:?} is invalid or destroyed")]
InvalidBuffer(BufferId),
#[error("texture view {0:?} is invalid")]
#[error("Texture view {0:?} is invalid")]
InvalidTextureView(TextureViewId),
#[error("texture {0:?} is invalid")]
#[error("Texture {0:?} is invalid")]
InvalidTexture(TextureId),
#[error("sampler {0:?} is invalid")]
#[error("Sampler {0:?} is invalid")]
InvalidSampler(SamplerId),
#[error(
"binding count declared with at most {expected} items, but {actual} items were provided"
"Binding count declared with at most {expected} items, but {actual} items were provided"
)]
BindingArrayPartialLengthMismatch { actual: usize, expected: usize },
#[error(
"binding count declared with exactly {expected} items, but {actual} items were provided"
"Binding count declared with exactly {expected} items, but {actual} items were provided"
)]
BindingArrayLengthMismatch { actual: usize, expected: usize },
#[error("array binding provided zero elements")]
#[error("Array binding provided zero elements")]
BindingArrayZeroLength,
#[error("bound buffer range {range:?} does not fit in buffer of size {size}")]
#[error("Bound buffer range {range:?} does not fit in buffer of size {size}")]
BindingRangeTooLarge {
buffer: BufferId,
range: Range<wgt::BufferAddress>,
size: u64,
},
#[error("buffer binding size {actual} is less than minimum {min}")]
#[error("Buffer binding size {actual} is less than minimum {min}")]
BindingSizeTooSmall {
buffer: BufferId,
actual: u64,
min: u64,
},
#[error("buffer binding size is zero")]
#[error("Buffer binding size is zero")]
BindingZeroSize(BufferId),
#[error("number of bindings in bind group descriptor ({actual}) does not match the number of bindings defined in the bind group layout ({expected})")]
#[error("Number of bindings in bind group descriptor ({actual}) does not match the number of bindings defined in the bind group layout ({expected})")]
BindingsNumMismatch { actual: usize, expected: usize },
#[error("binding {0} is used at least twice in the descriptor")]
#[error("Binding {0} is used at least twice in the descriptor")]
DuplicateBinding(u32),
#[error("unable to find a corresponding declaration for the given binding {0}")]
#[error("Unable to find a corresponding declaration for the given binding {0}")]
MissingBindingDeclaration(u32),
#[error(transparent)]
MissingBufferUsage(#[from] MissingBufferUsageError),
#[error(transparent)]
MissingTextureUsage(#[from] MissingTextureUsageError),
#[error("binding declared as a single item, but bind group is using it as an array")]
#[error("Binding declared as a single item, but bind group is using it as an array")]
SingleBindingExpected,
#[error("buffer offset {0} does not respect device's requested `{1}` limit {2}")]
#[error("Buffer offset {0} does not respect device's requested `{1}` limit {2}")]
UnalignedBufferOffset(wgt::BufferAddress, &'static str, u32),
#[error(
"buffer binding {binding} range {given} exceeds `max_*_buffer_binding_size` limit {limit}"
"Buffer binding {binding} range {given} exceeds `max_*_buffer_binding_size` limit {limit}"
)]
BufferRangeTooLarge {
binding: u32,
given: u32,
limit: u32,
},
#[error("binding {binding} has a different type ({actual:?}) than the one in the layout ({expected:?})")]
#[error("Binding {binding} has a different type ({actual:?}) than the one in the layout ({expected:?})")]
WrongBindingType {
// Index of the binding
binding: u32,
Expand All @@ -125,47 +125,47 @@ pub enum CreateBindGroupError {
// Human-readable description of expected types
expected: &'static str,
},
#[error("texture binding {binding} expects multisampled = {layout_multisampled}, but given a view with samples = {view_samples}")]
#[error("Texture binding {binding} expects multisampled = {layout_multisampled}, but given a view with samples = {view_samples}")]
InvalidTextureMultisample {
binding: u32,
layout_multisampled: bool,
view_samples: u32,
},
#[error("texture binding {binding} expects sample type = {layout_sample_type:?}, but given a view with format = {view_format:?}")]
#[error("Texture binding {binding} expects sample type = {layout_sample_type:?}, but given a view with format = {view_format:?}")]
InvalidTextureSampleType {
binding: u32,
layout_sample_type: wgt::TextureSampleType,
view_format: wgt::TextureFormat,
},
#[error("texture binding {binding} expects dimension = {layout_dimension:?}, but given a view with dimension = {view_dimension:?}")]
#[error("Texture binding {binding} expects dimension = {layout_dimension:?}, but given a view with dimension = {view_dimension:?}")]
InvalidTextureDimension {
binding: u32,
layout_dimension: wgt::TextureViewDimension,
view_dimension: wgt::TextureViewDimension,
},
#[error("storage texture binding {binding} expects format = {layout_format:?}, but given a view with format = {view_format:?}")]
#[error("Storage texture binding {binding} expects format = {layout_format:?}, but given a view with format = {view_format:?}")]
InvalidStorageTextureFormat {
binding: u32,
layout_format: wgt::TextureFormat,
view_format: wgt::TextureFormat,
},
#[error("storage texture bindings must have a single mip level, but given a view with mip_level_count = {mip_level_count:?} at binding {binding}")]
#[error("Storage texture bindings must have a single mip level, but given a view with mip_level_count = {mip_level_count:?} at binding {binding}")]
InvalidStorageTextureMipLevelCount { binding: u32, mip_level_count: u32 },
#[error("sampler binding {binding} expects comparison = {layout_cmp}, but given a sampler with comparison = {sampler_cmp}")]
#[error("Sampler binding {binding} expects comparison = {layout_cmp}, but given a sampler with comparison = {sampler_cmp}")]
WrongSamplerComparison {
binding: u32,
layout_cmp: bool,
sampler_cmp: bool,
},
#[error("sampler binding {binding} expects filtering = {layout_flt}, but given a sampler with filtering = {sampler_flt}")]
#[error("Sampler binding {binding} expects filtering = {layout_flt}, but given a sampler with filtering = {sampler_flt}")]
WrongSamplerFiltering {
binding: u32,
layout_flt: bool,
sampler_flt: bool,
},
#[error("bound texture views can not have both depth and stencil aspects enabled")]
#[error("Bound texture views can not have both depth and stencil aspects enabled")]
DepthStencilAspect,
#[error("the adapter does not support read access for storages texture of format {0:?}")]
#[error("The adapter does not support read access for storages texture of format {0:?}")]
StorageReadNotSupported(wgt::TextureFormat),
#[error(transparent)]
ResourceUsageConflict(#[from] UsageConflict),
Expand Down Expand Up @@ -200,14 +200,14 @@ impl PrettyError for CreateBindGroupError {

#[derive(Clone, Debug, Error)]
pub enum BindingZone {
#[error("stage {0:?}")]
#[error("Stage {0:?}")]
Stage(wgt::ShaderStages),
#[error("whole pipeline")]
#[error("Whole pipeline")]
Pipeline,
}

#[derive(Clone, Debug, Error)]
#[error("too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}")]
#[error("Too many bindings of type {kind:?} in {zone}, limit is {limit}, count was {count}")]
pub struct BindingTypeMaxCountError {
pub kind: BindingTypeMaxCountErrorKind,
pub zone: BindingZone,
Expand Down Expand Up @@ -470,30 +470,30 @@ impl<A: hal::Api> Resource for BindGroupLayout<A> {
pub enum CreatePipelineLayoutError {
#[error(transparent)]
Device(#[from] DeviceError),
#[error("bind group layout {0:?} is invalid")]
#[error("Bind group layout {0:?} is invalid")]
InvalidBindGroupLayout(BindGroupLayoutId),
#[error(
"push constant at index {index} has range bound {bound} not aligned to {}",
"Push constant at index {index} has range bound {bound} not aligned to {}",
wgt::PUSH_CONSTANT_ALIGNMENT
)]
MisalignedPushConstantRange { index: usize, bound: u32 },
#[error(transparent)]
MissingFeatures(#[from] MissingFeatures),
#[error("push constant range (index {index}) provides for stage(s) {provided:?} but there exists another range that provides stage(s) {intersected:?}. Each stage may only be provided by one range")]
#[error("Push constant range (index {index}) provides for stage(s) {provided:?} but there exists another range that provides stage(s) {intersected:?}. Each stage may only be provided by one range")]
MoreThanOnePushConstantRangePerStage {
index: usize,
provided: wgt::ShaderStages,
intersected: wgt::ShaderStages,
},
#[error("push constant at index {index} has range {}..{} which exceeds device push constant size limit 0..{max}", range.start, range.end)]
#[error("Push constant at index {index} has range {}..{} which exceeds device push constant size limit 0..{max}", range.start, range.end)]
PushConstantRangeTooLarge {
index: usize,
range: Range<u32>,
max: u32,
},
#[error(transparent)]
TooManyBindings(BindingTypeMaxCountError),
#[error("bind group layout count {actual} exceeds device bind group limit {max}")]
#[error("Bind group layout count {actual} exceeds device bind group limit {max}")]
TooManyGroups { actual: usize, max: usize },
}

Expand All @@ -508,31 +508,31 @@ impl PrettyError for CreatePipelineLayoutError {

#[derive(Clone, Debug, Error)]
pub enum PushConstantUploadError {
#[error("provided push constant with indices {offset}..{end_offset} overruns matching push constant range at index {idx}, with stage(s) {:?} and indices {:?}", range.stages, range.range)]
#[error("Provided push constant with indices {offset}..{end_offset} overruns matching push constant range at index {idx}, with stage(s) {:?} and indices {:?}", range.stages, range.range)]
TooLarge {
offset: u32,
end_offset: u32,
idx: usize,
range: wgt::PushConstantRange,
},
#[error("provided push constant is for stage(s) {actual:?}, stage with a partial match found at index {idx} with stage(s) {matched:?}, however push constants must be complete matches")]
#[error("Provided push constant is for stage(s) {actual:?}, stage with a partial match found at index {idx} with stage(s) {matched:?}, however push constants must be complete matches")]
PartialRangeMatch {
actual: wgt::ShaderStages,
idx: usize,
matched: wgt::ShaderStages,
},
#[error("provided push constant is for stage(s) {actual:?}, but intersects a push constant range (at index {idx}) with stage(s) {missing:?}. Push constants must provide the stages for all ranges they intersect")]
#[error("Provided push constant is for stage(s) {actual:?}, but intersects a push constant range (at index {idx}) with stage(s) {missing:?}. Push constants must provide the stages for all ranges they intersect")]
MissingStages {
actual: wgt::ShaderStages,
idx: usize,
missing: wgt::ShaderStages,
},
#[error("provided push constant is for stage(s) {actual:?}, however the pipeline layout has no push constant range for the stage(s) {unmatched:?}")]
#[error("Provided push constant is for stage(s) {actual:?}, however the pipeline layout has no push constant range for the stage(s) {unmatched:?}")]
UnmatchedStages {
actual: wgt::ShaderStages,
unmatched: wgt::ShaderStages,
},
#[error("provided push constant offset {0} does not respect `PUSH_CONSTANT_ALIGNMENT`")]
#[error("Provided push constant offset {0} does not respect `PUSH_CONSTANT_ALIGNMENT`")]
Unaligned(u32),
}

Expand Down Expand Up @@ -829,9 +829,9 @@ impl<A: HalApi> Resource for BindGroup<A> {

#[derive(Clone, Debug, Error)]
pub enum GetBindGroupLayoutError {
#[error("pipeline is invalid")]
#[error("Pipeline is invalid")]
InvalidPipeline,
#[error("invalid group index {0}")]
#[error("Invalid group index {0}")]
InvalidGroupIndex(u32),
}

Expand Down
8 changes: 4 additions & 4 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,16 @@ impl RenderBundleEncoder {
pub enum CreateRenderBundleError {
#[error(transparent)]
ColorAttachment(#[from] ColorAttachmentError),
#[error("invalid number of samples {0}")]
#[error("Invalid number of samples {0}")]
InvalidSampleCount(u32),
}

/// Error type returned from `RenderBundleEncoder::new` if the sample count is invalid.
#[derive(Clone, Debug, Error)]
pub enum ExecutionError {
#[error("buffer {0:?} is destroyed")]
#[error("Buffer {0:?} is destroyed")]
DestroyedBuffer(id::BufferId),
#[error("using {0} in a render bundle is not implemented")]
#[error("Using {0} in a render bundle is not implemented")]
Unimplemented(&'static str),
}
impl PrettyError for ExecutionError {
Expand Down Expand Up @@ -1377,7 +1377,7 @@ impl<A: HalApi> State<A> {
/// Error encountered when finishing recording a render bundle.
#[derive(Clone, Debug, Error)]
pub(super) enum RenderBundleErrorInner {
#[error("resource is not valid to use with this render bundle because the resource and the bundle come from different devices")]
#[error("Resource is not valid to use with this render bundle because the resource and the bundle come from different devices")]
NotValidToUse,
#[error(transparent)]
Device(#[from] DeviceError),
Expand Down
26 changes: 13 additions & 13 deletions wgpu-core/src/command/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,43 @@ use wgt::{BufferAddress, BufferSize, BufferUsages, ImageSubresourceRange, Textur
/// Error encountered while attempting a clear.
#[derive(Clone, Debug, Error)]
pub enum ClearError {
#[error("to use clear_texture the CLEAR_TEXTURE feature needs to be enabled")]
#[error("To use clear_texture the CLEAR_TEXTURE feature needs to be enabled")]
MissingClearTextureFeature,
#[error("command encoder {0:?} is invalid")]
#[error("Command encoder {0:?} is invalid")]
InvalidCommandEncoder(CommandEncoderId),
#[error("device {0:?} is invalid")]
#[error("Device {0:?} is invalid")]
InvalidDevice(DeviceId),
#[error("buffer {0:?} is invalid or destroyed")]
#[error("Buffer {0:?} is invalid or destroyed")]
InvalidBuffer(BufferId),
#[error("texture {0:?} is invalid or destroyed")]
#[error("Texture {0:?} is invalid or destroyed")]
InvalidTexture(TextureId),
#[error("texture {0:?} can not be cleared")]
#[error("Texture {0:?} can not be cleared")]
NoValidTextureClearMode(TextureId),
#[error("buffer clear size {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
#[error("Buffer clear size {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
UnalignedFillSize(BufferSize),
#[error("buffer offset {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
#[error("Buffer offset {0:?} is not a multiple of `COPY_BUFFER_ALIGNMENT`")]
UnalignedBufferOffset(BufferAddress),
#[error("clear of {start_offset}..{end_offset} would end up overrunning the bounds of the buffer of size {buffer_size}")]
#[error("Clear of {start_offset}..{end_offset} would end up overrunning the bounds of the buffer of size {buffer_size}")]
BufferOverrun {
start_offset: BufferAddress,
end_offset: BufferAddress,
buffer_size: BufferAddress,
},
#[error("destination buffer is missing the `COPY_DST` usage flag")]
#[error("Destination buffer is missing the `COPY_DST` usage flag")]
MissingCopyDstUsageFlag(Option<BufferId>, Option<TextureId>),
#[error("texture lacks the aspects that were specified in the image subresource range. Texture with format {texture_format:?}, specified was {subresource_range_aspects:?}")]
#[error("Texture lacks the aspects that were specified in the image subresource range. Texture with format {texture_format:?}, specified was {subresource_range_aspects:?}")]
MissingTextureAspect {
texture_format: wgt::TextureFormat,
subresource_range_aspects: TextureAspect,
},
#[error("image subresource level range is outside of the texture's level range. texture range is {texture_level_range:?}, \
#[error("Image subresource level range is outside of the texture's level range. texture range is {texture_level_range:?}, \
whereas subesource range specified start {subresource_base_mip_level} and count {subresource_mip_level_count:?}")]
InvalidTextureLevelRange {
texture_level_range: Range<u32>,
subresource_base_mip_level: u32,
subresource_mip_level_count: Option<u32>,
},
#[error("image subresource layer range is outside of the texture's layer range. texture range is {texture_layer_range:?}, \
#[error("Image subresource layer range is outside of the texture's layer range. texture range is {texture_layer_range:?}, \
whereas subesource range specified start {subresource_base_array_layer} and count {subresource_array_layer_count:?}")]
InvalidTextureLayerRange {
texture_layer_range: Range<u32>,
Expand Down
Loading

0 comments on commit 3fb3ec3

Please sign in to comment.