mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 08:13:27 +00:00
rename error variants that contain IDs
This commit is contained in:
parent
6fe041d544
commit
a4bb5dff2b
@ -78,10 +78,10 @@ pub enum CreateBindGroupError {
|
||||
InvalidLayout,
|
||||
#[error("BufferId {0:?} is invalid")]
|
||||
InvalidBufferId(BufferId),
|
||||
#[error("Texture view Id {0:?} is invalid")]
|
||||
#[error("TextureViewId {0:?} is invalid")]
|
||||
InvalidTextureViewId(TextureViewId),
|
||||
#[error("Sampler {0:?} is invalid")]
|
||||
InvalidSampler(SamplerId),
|
||||
#[error("SamplerId {0:?} is invalid")]
|
||||
InvalidSamplerId(SamplerId),
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error(
|
||||
@ -198,12 +198,6 @@ impl PrettyError for CreateBindGroupError {
|
||||
Self::BindingSizeTooSmall { buffer, .. } => {
|
||||
fmt.buffer_label(&buffer);
|
||||
}
|
||||
Self::InvalidTextureViewId(id) => {
|
||||
fmt.texture_view_label(&id);
|
||||
}
|
||||
Self::InvalidSampler(id) => {
|
||||
fmt.sampler_label(&id);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
@ -511,8 +505,8 @@ impl<A: HalApi> BindGroupLayout<A> {
|
||||
pub enum CreatePipelineLayoutError {
|
||||
#[error(transparent)]
|
||||
Device(#[from] DeviceError),
|
||||
#[error("Bind group layout {0:?} is invalid")]
|
||||
InvalidBindGroupLayout(BindGroupLayoutId),
|
||||
#[error("BindGroupLayoutId {0:?} is invalid")]
|
||||
InvalidBindGroupLayoutId(BindGroupLayoutId),
|
||||
#[error(
|
||||
"Push constant at index {index} has range bound {bound} not aligned to {}",
|
||||
wgt::PUSH_CONSTANT_ALIGNMENT
|
||||
@ -538,14 +532,7 @@ pub enum CreatePipelineLayoutError {
|
||||
TooManyGroups { actual: usize, max: usize },
|
||||
}
|
||||
|
||||
impl PrettyError for CreatePipelineLayoutError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
if let Self::InvalidBindGroupLayout(id) = *self {
|
||||
fmt.bind_group_layout_label(&id);
|
||||
};
|
||||
}
|
||||
}
|
||||
impl PrettyError for CreatePipelineLayoutError {}
|
||||
|
||||
#[derive(Clone, Debug, Error)]
|
||||
#[non_exhaustive]
|
||||
|
@ -661,7 +661,7 @@ fn set_pipeline<A: HalApi>(
|
||||
) -> Result<(), RenderBundleErrorInner> {
|
||||
let pipeline = pipeline_guard
|
||||
.get(pipeline_id)
|
||||
.map_err(|_| RenderCommandError::InvalidPipeline(pipeline_id))?;
|
||||
.map_err(|_| RenderCommandError::InvalidPipelineId(pipeline_id))?;
|
||||
|
||||
state.trackers.render_pipelines.write().add_single(pipeline);
|
||||
|
||||
@ -948,11 +948,7 @@ pub enum ExecutionError {
|
||||
#[error("Using {0} in a render bundle is not implemented")]
|
||||
Unimplemented(&'static str),
|
||||
}
|
||||
impl PrettyError for ExecutionError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
}
|
||||
}
|
||||
impl PrettyError for ExecutionError {}
|
||||
|
||||
pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
|
||||
|
||||
|
@ -144,8 +144,8 @@ pub enum ComputePassErrorInner {
|
||||
InvalidBindGroupId(id::BindGroupId),
|
||||
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
||||
BindGroupIndexOutOfRange { index: u32, max: u32 },
|
||||
#[error("Compute pipeline {0:?} is invalid")]
|
||||
InvalidPipeline(id::ComputePipelineId),
|
||||
#[error("ComputePipelineId {0:?} is invalid")]
|
||||
InvalidPipelineId(id::ComputePipelineId),
|
||||
#[error("QuerySet {0:?} is invalid")]
|
||||
InvalidQuerySet(id::QuerySetId),
|
||||
#[error(transparent)]
|
||||
@ -189,17 +189,11 @@ pub enum ComputePassErrorInner {
|
||||
impl PrettyError for ComputePassErrorInner {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
match *self {
|
||||
Self::InvalidPipeline(id) => {
|
||||
fmt.compute_pipeline_label(&id);
|
||||
if let Self::Dispatch(DispatchError::IncompatibleBindGroup { ref diff, .. }) = *self {
|
||||
for d in diff {
|
||||
fmt.note(&d);
|
||||
}
|
||||
Self::Dispatch(DispatchError::IncompatibleBindGroup { ref diff, .. }) => {
|
||||
for d in diff {
|
||||
fmt.note(&d);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,7 +1067,7 @@ impl Global {
|
||||
.compute_pipelines
|
||||
.read()
|
||||
.get_owned(pipeline_id)
|
||||
.map_err(|_| ComputePassErrorInner::InvalidPipeline(pipeline_id))
|
||||
.map_err(|_| ComputePassErrorInner::InvalidPipelineId(pipeline_id))
|
||||
.map_pass_err(scope)?;
|
||||
|
||||
base.commands.push(ArcComputeCommand::SetPipeline(pipeline));
|
||||
|
@ -106,7 +106,7 @@ impl ComputeCommand {
|
||||
.get_owned(pipeline_id)
|
||||
.map_err(|_| ComputePassError {
|
||||
scope: PassErrorScope::SetPipelineCompute,
|
||||
inner: ComputePassErrorInner::InvalidPipeline(pipeline_id),
|
||||
inner: ComputePassErrorInner::InvalidPipelineId(pipeline_id),
|
||||
})?,
|
||||
),
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
binding_model::{LateMinBufferBindingSizeMismatch, PushConstantUploadError},
|
||||
error::ErrorFormatter,
|
||||
id,
|
||||
resource::{
|
||||
DestroyedResourceError, MissingBufferUsageError, MissingTextureUsageError,
|
||||
@ -83,8 +82,8 @@ pub enum RenderCommandError {
|
||||
VertexBufferIndexOutOfRange { index: u32, max: u32 },
|
||||
#[error("Dynamic buffer offset {0} does not respect device's requested `{1}` limit {2}")]
|
||||
UnalignedBufferOffset(u64, &'static str, u32),
|
||||
#[error("Render pipeline {0:?} is invalid")]
|
||||
InvalidPipeline(id::RenderPipelineId),
|
||||
#[error("RenderPipelineId {0:?} is invalid")]
|
||||
InvalidPipelineId(id::RenderPipelineId),
|
||||
#[error("QuerySet {0:?} is invalid")]
|
||||
InvalidQuerySet(id::QuerySetId),
|
||||
#[error("Render pipeline targets are incompatible with render pass")]
|
||||
@ -112,20 +111,7 @@ pub enum RenderCommandError {
|
||||
#[error("Support for {0} is not implemented yet")]
|
||||
Unimplemented(&'static str),
|
||||
}
|
||||
impl crate::error::PrettyError for RenderCommandError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
match *self {
|
||||
Self::InvalidBindGroupId(id) => {
|
||||
fmt.bind_group_label(&id);
|
||||
}
|
||||
Self::InvalidPipeline(id) => {
|
||||
fmt.render_pipeline_label(&id);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
}
|
||||
impl crate::error::PrettyError for RenderCommandError {}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
|
@ -30,7 +30,7 @@ pub use timestamp_writes::PassTimestampWrites;
|
||||
use self::memory_init::CommandBufferTextureMemoryActions;
|
||||
|
||||
use crate::device::{Device, DeviceError};
|
||||
use crate::error::{ErrorFormatter, PrettyError};
|
||||
use crate::error::PrettyError;
|
||||
use crate::hub::Hub;
|
||||
use crate::lock::{rank, Mutex};
|
||||
use crate::snatch::SnatchGuard;
|
||||
@ -598,26 +598,17 @@ pub enum CommandEncoderError {
|
||||
|
||||
#[error("QuerySet {0:?} for pass timestamp writes is invalid.")]
|
||||
InvalidTimestampWritesQuerySetId(id::QuerySetId),
|
||||
#[error("Attachment texture view {0:?} is invalid")]
|
||||
InvalidAttachment(id::TextureViewId),
|
||||
#[error("Attachment texture view {0:?} for resolve is invalid")]
|
||||
InvalidResolveTarget(id::TextureViewId),
|
||||
#[error("Depth stencil attachment view {0:?} is invalid")]
|
||||
InvalidDepthStencilAttachment(id::TextureViewId),
|
||||
#[error("Occlusion query set {0:?} is invalid")]
|
||||
#[error("Attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidAttachmentId(id::TextureViewId),
|
||||
#[error("Resolve attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidResolveTargetId(id::TextureViewId),
|
||||
#[error("Depth stencil attachment TextureViewId {0:?} is invalid")]
|
||||
InvalidDepthStencilAttachmentId(id::TextureViewId),
|
||||
#[error("Occlusion QuerySetId {0:?} is invalid")]
|
||||
InvalidOcclusionQuerySetId(id::QuerySetId),
|
||||
}
|
||||
|
||||
impl PrettyError for CommandEncoderError {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
if let Self::InvalidAttachment(id) = *self {
|
||||
fmt.texture_view_label_with_key(&id, "attachment");
|
||||
} else if let Self::InvalidResolveTarget(id) = *self {
|
||||
fmt.texture_view_label_with_key(&id, "resolve target");
|
||||
};
|
||||
}
|
||||
}
|
||||
impl PrettyError for CommandEncoderError {}
|
||||
|
||||
impl Global {
|
||||
pub fn command_encoder_finish<A: HalApi>(
|
||||
|
@ -107,18 +107,11 @@ pub enum QueryError {
|
||||
InvalidBufferId(id::BufferId),
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error("QuerySet {0:?} is invalid or destroyed")]
|
||||
InvalidQuerySet(id::QuerySetId),
|
||||
#[error("QuerySetId {0:?} is invalid or destroyed")]
|
||||
InvalidQuerySetId(id::QuerySetId),
|
||||
}
|
||||
|
||||
impl crate::error::PrettyError for QueryError {
|
||||
fn fmt_pretty(&self, fmt: &mut crate::error::ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
if let Self::InvalidQuerySet(id) = *self {
|
||||
fmt.query_set_label(&id)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl crate::error::PrettyError for QueryError {}
|
||||
|
||||
/// Error encountered while trying to use queries
|
||||
#[derive(Clone, Debug, Error)]
|
||||
@ -356,7 +349,7 @@ impl Global {
|
||||
let query_set_guard = hub.query_sets.read();
|
||||
let query_set = query_set_guard
|
||||
.get(query_set_id)
|
||||
.map_err(|_| QueryError::InvalidQuerySet(query_set_id))?;
|
||||
.map_err(|_| QueryError::InvalidQuerySetId(query_set_id))?;
|
||||
|
||||
tracker.query_sets.add_single(query_set);
|
||||
|
||||
@ -403,7 +396,7 @@ impl Global {
|
||||
let query_set_guard = hub.query_sets.read();
|
||||
let query_set = query_set_guard
|
||||
.get(query_set_id)
|
||||
.map_err(|_| QueryError::InvalidQuerySet(query_set_id))?;
|
||||
.map_err(|_| QueryError::InvalidQuerySetId(query_set_id))?;
|
||||
|
||||
tracker.query_sets.add_single(query_set);
|
||||
|
||||
|
@ -590,10 +590,6 @@ pub enum RenderPassErrorInner {
|
||||
Encoder(#[from] CommandEncoderError),
|
||||
#[error("Parent encoder is invalid")]
|
||||
InvalidParentEncoder,
|
||||
#[error("Attachment texture view {0:?} is invalid")]
|
||||
InvalidAttachmentId(id::TextureViewId),
|
||||
#[error("Attachment texture view {0:?} is invalid")]
|
||||
InvalidResolveTargetId(id::TextureViewId),
|
||||
#[error("The format of the depth-stencil attachment ({0:?}) is not a depth-stencil format")]
|
||||
InvalidDepthStencilAttachmentFormat(wgt::TextureFormat),
|
||||
#[error("Buffer {0:?} is invalid or destroyed")]
|
||||
@ -724,9 +720,6 @@ pub enum RenderPassErrorInner {
|
||||
impl PrettyError for RenderPassErrorInner {
|
||||
fn fmt_pretty(&self, fmt: &mut ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
if let Self::InvalidAttachmentId(id) = *self {
|
||||
fmt.texture_view_label_with_key(&id, "attachment");
|
||||
};
|
||||
if let Self::Draw(DrawError::IncompatibleBindGroup { diff, .. }) = self {
|
||||
for d in diff {
|
||||
fmt.note(&d);
|
||||
@ -1381,12 +1374,12 @@ impl Global {
|
||||
{
|
||||
let view = texture_views
|
||||
.get_owned(*view_id)
|
||||
.map_err(|_| CommandEncoderError::InvalidAttachment(*view_id))?;
|
||||
.map_err(|_| CommandEncoderError::InvalidAttachmentId(*view_id))?;
|
||||
view.same_device(device)?;
|
||||
|
||||
let resolve_target = if let Some(resolve_target_id) = resolve_target {
|
||||
let rt_arc = texture_views.get_owned(*resolve_target_id).map_err(|_| {
|
||||
CommandEncoderError::InvalidResolveTarget(*resolve_target_id)
|
||||
CommandEncoderError::InvalidResolveTargetId(*resolve_target_id)
|
||||
})?;
|
||||
rt_arc.same_device(device)?;
|
||||
|
||||
@ -1412,7 +1405,7 @@ impl Global {
|
||||
let view = texture_views
|
||||
.get_owned(depth_stencil_attachment.view)
|
||||
.map_err(|_| {
|
||||
CommandEncoderError::InvalidDepthStencilAttachment(
|
||||
CommandEncoderError::InvalidDepthStencilAttachmentId(
|
||||
depth_stencil_attachment.view,
|
||||
)
|
||||
})?;
|
||||
|
@ -163,7 +163,7 @@ impl RenderCommand {
|
||||
.get_owned(pipeline_id)
|
||||
.map_err(|_| RenderPassError {
|
||||
scope: PassErrorScope::SetPipelineRender,
|
||||
inner: RenderCommandError::InvalidPipeline(pipeline_id).into(),
|
||||
inner: RenderCommandError::InvalidPipelineId(pipeline_id).into(),
|
||||
})?,
|
||||
),
|
||||
|
||||
|
@ -1994,7 +1994,7 @@ impl<A: HalApi> Device<A> {
|
||||
) -> Result<&'a Sampler<A>, binding_model::CreateBindGroupError> {
|
||||
use crate::binding_model::CreateBindGroupError as Error;
|
||||
|
||||
let sampler = storage.get(id).map_err(|_| Error::InvalidSampler(id))?;
|
||||
let sampler = storage.get(id).map_err(|_| Error::InvalidSamplerId(id))?;
|
||||
used.samplers.add_single(sampler);
|
||||
|
||||
sampler.same_device(self)?;
|
||||
@ -2512,7 +2512,7 @@ impl<A: HalApi> Device<A> {
|
||||
let mut bind_group_layouts = ArrayVec::new();
|
||||
for &id in desc.bind_group_layouts.iter() {
|
||||
let Ok(bgl) = bgl_registry.get(id) else {
|
||||
return Err(Error::InvalidBindGroupLayout(id));
|
||||
return Err(Error::InvalidBindGroupLayoutId(id));
|
||||
};
|
||||
|
||||
bind_group_layouts.push(bgl);
|
||||
|
@ -385,11 +385,7 @@ impl ResourceUsageCompatibilityError {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::error::PrettyError for ResourceUsageCompatibilityError {
|
||||
fn fmt_pretty(&self, fmt: &mut crate::error::ErrorFormatter) {
|
||||
fmt.error(self);
|
||||
}
|
||||
}
|
||||
impl crate::error::PrettyError for ResourceUsageCompatibilityError {}
|
||||
|
||||
/// Pretty print helper that shows helpful descriptions of a conflicting usage.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
Loading…
Reference in New Issue
Block a user