Skip to content

Commit

Permalink
Improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
scoopr committed Dec 17, 2023
1 parent 526148d commit 88dfad7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
22 changes: 20 additions & 2 deletions wgpu-core/src/command/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,21 @@ mod compat {
self.expected.is_none() || !self.is_valid()
}

// Describe how bind group layouts are incompatible, for validation
// error message.
fn bgl_diff(&self) -> Vec<String> {
let mut diff = Vec::new();

if let Some(expected_bgl) = self.expected.as_ref() {
diff.push(format!(
"Should be compatible with bind group layout with label = `{}`",
expected_bgl.label()
));
if let Some(assigned_bgl) = self.assigned.as_ref() {
diff.push(format!(
"Assigned bind group layout with label = `{}`",
assigned_bgl.label()
));
for (id, e_entry) in &expected_bgl.entries {
if let Some(a_entry) = assigned_bgl.entries.get(id) {
if a_entry.binding != e_entry.binding {
Expand Down Expand Up @@ -100,12 +110,20 @@ mod compat {
"Assigned bindgroup layout is implicit, expected explicit".to_owned(),
);
}
} else if let Some(_assigned_bgl) = self.assigned.as_ref() {
} else if let Some(assigned_bgl) = self.assigned.as_ref() {
diff.push(format!(
"Assigned bind group layout = `{}`",
assigned_bgl.label()
));
diff.push(
"Assigned bindgroup layout is not implicit, expected implicit".to_owned(),
);
}

if diff.is_empty() {
diff.push("But no differences found? (internal error)".to_owned())
}

diff
}
}
Expand Down Expand Up @@ -183,7 +201,7 @@ mod compat {
return e.bgl_diff();
}
}
vec![String::from("No differences detected?")]
vec![String::from("No differences detected? (internal error)")]
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions wgpu-core/src/command/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ pub enum DrawError {
MissingVertexBuffer { index: u32 },
#[error("Index buffer must be set")]
MissingIndexBuffer,
#[error("The pipeline layout, associated with the current render pipeline, contains a incompatible bind group layout at index {index}")]
IncompatibleBindGroup {
index: u32,
diff: Vec<String>, //expected: BindGroupLayoutId,
//provided: Option<(BindGroupLayoutId, BindGroupId)>,
},
#[error("Incompatible bind group at index {index} in the current render pipeline")]
IncompatibleBindGroup { index: u32, diff: Vec<String> },
#[error("Vertex {last_vertex} extends beyond limit {vertex_limit} imposed by the buffer in slot {slot}. Did you bind the correct `Vertex` step-rate vertex buffer?")]
VertexBeyondLimit {
last_vertex: u32,
Expand Down

0 comments on commit 88dfad7

Please sign in to comment.