Skip to content

Commit

Permalink
Merge gfx-rs#583
Browse files Browse the repository at this point in the history
583: Improve error messages when passing buffers with the wrong usage flags r=kvark a=HalfVoxel

e.g.

```
thread 'main' panicked at 'An invalid setIndexBuffer call has been made. The buffer usage is COPY_DST | VERTEX which does not contain required usage INDEX
```

Co-authored-by: Aron Granberg <[email protected]>
  • Loading branch information
bors[bot] and HalfVoxel authored Apr 15, 2020
2 parents 6de38a7 + 5f6accc commit 2b12001
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.buffers
.use_extend(&*buffer_guard, buffer_id, (), BufferUsage::INDEX)
.unwrap();
assert!(buffer.usage.contains(BufferUsage::INDEX));
assert!(buffer.usage.contains(BufferUsage::INDEX), "An invalid setIndexBuffer call has been made. The buffer usage is {:?} which does not contain required usage INDEX", buffer.usage);

let end = if size != 0 {
offset + size
Expand Down Expand Up @@ -1012,7 +1012,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.buffers
.use_extend(&*buffer_guard, buffer_id, (), BufferUsage::VERTEX)
.unwrap();
assert!(buffer.usage.contains(BufferUsage::VERTEX));
assert!(buffer.usage.contains(BufferUsage::VERTEX), "An invalid setVertexBuffer call has been made. The buffer usage is {:?} which does not contain required usage VERTEX", buffer.usage);
let empty_slots = (1 + slot as usize).saturating_sub(state.vertex.inputs.len());
state
.vertex
Expand Down Expand Up @@ -1136,7 +1136,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.buffers
.use_extend(&*buffer_guard, buffer_id, (), BufferUsage::INDIRECT)
.unwrap();
assert!(buffer.usage.contains(BufferUsage::INDIRECT));
assert!(buffer.usage.contains(BufferUsage::INDIRECT), "An invalid drawIndirect call has been made. The buffer usage is {:?} which does not contain required usage INDIRECT", buffer.usage);

unsafe {
raw.draw_indirect(&buffer.raw, offset, 1, 0);
Expand All @@ -1149,7 +1149,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.buffers
.use_extend(&*buffer_guard, buffer_id, (), BufferUsage::INDIRECT)
.unwrap();
assert!(buffer.usage.contains(BufferUsage::INDIRECT));
assert!(buffer.usage.contains(BufferUsage::INDIRECT), "An invalid drawIndexedIndirect call has been made. The buffer usage is {:?} which does not contain required usage INDIRECT", buffer.usage);

unsafe {
raw.draw_indexed_indirect(&buffer.raw, offset, 1, 0);
Expand Down

0 comments on commit 2b12001

Please sign in to comment.