Improve drawing error messages

This commit is contained in:
Aron Granberg 2020-04-15 02:27:30 +02:00 committed by Dzmitry Malyshau
parent b51162c2c6
commit 78b4ccfb97

View File

@ -29,7 +29,7 @@ use wgt::{
TextureUsage, BIND_BUFFER_ALIGNMENT, 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 = pub type RenderPassColorAttachmentDescriptor =
RenderPassColorAttachmentDescriptorBase<id::TextureViewId>; RenderPassColorAttachmentDescriptorBase<id::TextureViewId>;
@ -174,7 +174,7 @@ impl OptionalState {
} }
} }
#[derive(Debug, PartialEq)] #[derive(PartialEq)]
enum DrawError { enum DrawError {
MissingBlendColor, MissingBlendColor,
MissingStencilReference, 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)] #[derive(Debug)]
pub struct IndexState { pub struct IndexState {
bound_buffer_view: Option<(id::BufferId, Range<BufferAddress>)>, bound_buffer_view: Option<(id::BufferId, Range<BufferAddress>)>,