mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1791881 - Don't crash in buffer_destroy if the buffer is in an invalid state. r=jgilbert
Once https://github.com/gfx-rs/wgpu/pull/3094 is merged, unallocated and freed handles will panic in wgpu-core so we don't have to do it here. In the mean time it will produce the wrong error but still fail safely. DestroyError::Invalid means the handle exists but is not is in an invalid state, for example if the buffer was created with invalid parameter like in this bug's test case. Differential Revision: https://phabricator.services.mozilla.com/D159054
This commit is contained in:
parent
e492626823
commit
f8a2ef4614
@ -419,17 +419,10 @@ pub extern "C" fn wgpu_server_buffer_unmap(
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_server_buffer_destroy(global: &Global, self_id: id::BufferId) {
|
||||
use wgc::resource::DestroyError;
|
||||
match gfx_select!(self_id => global.buffer_destroy(self_id)) {
|
||||
Err(DestroyError::Invalid) => {
|
||||
// This indicates an error on our side.
|
||||
panic!("Buffer already dropped.");
|
||||
}
|
||||
_ => {
|
||||
// Other error need to be reported but are not fatal, since users
|
||||
// can, for example, ask for a buffer to be destroyed multiple times.
|
||||
}
|
||||
}
|
||||
// Per spec, there is no need for the buffer or even device to be in a valid state,
|
||||
// even calling calling destroy multiple times is fine, so no error to push into
|
||||
// an error scope.
|
||||
let _ = gfx_select!(self_id => global.buffer_destroy(self_id));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
Loading…
Reference in New Issue
Block a user