From 0a636950ae39b99b14b2053ce08726d26a4182d3 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 11 Oct 2022 16:44:36 +0200 Subject: [PATCH] Make some errors non-fatal. --- wgpu-core/src/hub.rs | 3 +-- wgpu/src/backend/direct.rs | 17 +++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/wgpu-core/src/hub.rs b/wgpu-core/src/hub.rs index 8e256e7c32..2c586c930e 100644 --- a/wgpu-core/src/hub.rs +++ b/wgpu-core/src/hub.rs @@ -358,9 +358,8 @@ impl Storage { let (index, epoch, _) = id.unzip(); let (result, storage_epoch) = match self.map.get_mut(index as usize) { Some(&mut Element::Occupied(ref mut v, epoch)) => (Ok(v), epoch), - Some(&mut Element::Vacant) => panic!("{}[{}] does not exist", self.kind, index), + Some(&mut Element::Vacant) | None => panic!("{}[{}] does not exist", self.kind, index), Some(&mut Element::Error(epoch, ..)) => (Err(InvalidId), epoch), - None => return Err(InvalidId), }; assert_eq!( epoch, storage_epoch, diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 93b313205d..3d33e2c768 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1790,22 +1790,18 @@ impl crate::Context for Context { } fn buffer_destroy(&self, buffer: &Self::BufferId) { + // Per spec, no error to report. Even calling destroy multiple times is valid. let global = &self.0; - match wgc::gfx_select!(buffer.id => global.buffer_destroy(buffer.id)) { - Ok(()) => (), - Err(err) => self.handle_error_fatal(err, "Buffer::destroy"), - } + let _ = wgc::gfx_select!(buffer.id => global.buffer_destroy(buffer.id)); } fn buffer_drop(&self, buffer: &Self::BufferId) { let global = &self.0; wgc::gfx_select!(buffer.id => global.buffer_drop(buffer.id, false)) } fn texture_destroy(&self, texture: &Self::TextureId) { + // Per spec, no error to report. Even calling destroy multiple times is valid. let global = &self.0; - match wgc::gfx_select!(texture.id => global.texture_destroy(texture.id)) { - Ok(()) => (), - Err(err) => self.handle_error_fatal(err, "Texture::destroy"), - } + let _ = wgc::gfx_select!(texture.id => global.texture_destroy(texture.id)); } fn texture_drop(&self, texture: &Self::TextureId) { let global = &self.0; @@ -1813,10 +1809,7 @@ impl crate::Context for Context { } fn texture_view_drop(&self, texture_view: &Self::TextureViewId) { let global = &self.0; - match wgc::gfx_select!(*texture_view => global.texture_view_drop(*texture_view, false)) { - Ok(()) => (), - Err(err) => self.handle_error_fatal(err, "TextureView::drop"), - } + let _ = wgc::gfx_select!(*texture_view => global.texture_view_drop(*texture_view, false)); } fn sampler_drop(&self, sampler: &Self::SamplerId) { let global = &self.0;