Skip to content

Commit

Permalink
Validate that BufferDescriptor::usage is not zero (#3928)
Browse files Browse the repository at this point in the history
* Validate that BufferDescriptor::usage is not zero.

* Add a changelog entry.
  • Loading branch information
nical authored Jul 14, 2023
1 parent fe9aa68 commit 7198d60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Bottom level categories:
- Flesh out docs. for `AdapterInfo::{device,vendor}` by @ErichDonGubler in [#3763](https://github.com/gfx-rs/wgpu/pull/3763).
- Spell out which sizes are in bytes. By @jimblandy in [#3773](https://github.com/gfx-rs/wgpu/pull/3773).
- On Web, types don't implement `Send` or `Sync` anymore. By @daxpedda in [#3691](https://github.com/gfx-rs/wgpu/pull/3691)
- Validate that `descriptor.usage` is not empty in `create_buffer` by @nical in [https://github.com/gfx-rs/wgpu/pull/#3928](3928)

### Bug Fixes

Expand Down
6 changes: 6 additions & 0 deletions wgpu-core/src/device/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Ok(device) => device,
Err(_) => break DeviceError::Invalid.into(),
};

if desc.usage.is_empty() {
// Per spec, `usage` must not be zero.
break resource::CreateBufferError::InvalidUsage(desc.usage);
}

#[cfg(feature = "trace")]
if let Some(ref trace) = device.trace {
let mut desc = desc.clone();
Expand Down

0 comments on commit 7198d60

Please sign in to comment.