Validate that BufferDescriptor::usage is not zero (#3928)

* Validate that BufferDescriptor::usage is not zero.

* Add a changelog entry.
This commit is contained in:
Nicolas Silva 2023-07-14 22:41:34 +02:00 committed by GitHub
parent fe9aa681fe
commit 7198d60f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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();