diff --git a/wgpu-core/src/command/render.rs b/wgpu-core/src/command/render.rs index b1d4c809e4..4f08bfffd9 100644 --- a/wgpu-core/src/command/render.rs +++ b/wgpu-core/src/command/render.rs @@ -29,7 +29,7 @@ use wgt::{ TextureUsage, BIND_BUFFER_ALIGNMENT, }; -use std::{borrow::Borrow, collections::hash_map::Entry, iter, mem, ops::Range, slice}; +use std::{borrow::Borrow, collections::hash_map::Entry, fmt, iter, mem, ops::Range, slice}; pub type RenderPassColorAttachmentDescriptor = RenderPassColorAttachmentDescriptorBase; @@ -174,7 +174,7 @@ impl OptionalState { } } -#[derive(Debug, PartialEq)] +#[derive(PartialEq)] enum DrawError { MissingBlendColor, MissingStencilReference, @@ -186,6 +186,17 @@ enum DrawError { }, } +impl fmt::Debug for DrawError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + DrawError::MissingBlendColor => write!(f, "MissingBlendColor. A blend color is required to be set using RenderPass::set_blend_color."), + DrawError::MissingStencilReference => write!(f, "MissingStencilReference. A stencil reference is required to be set using RenderPass::set_stencil_reference."), + DrawError::MissingPipeline => write!(f, "MissingPipeline. You must first set the render pipeline using RenderPass::set_pipeline."), + DrawError::IncompatibleBindGroup { index } => write!(f, "IncompatibleBindGroup. The current render pipeline has a layout which is incompatible with a currently set bind group. They first differ at entry index {}.", index), + } + } +} + #[derive(Debug)] pub struct IndexState { bound_buffer_view: Option<(id::BufferId, Range)>,