@@ -252,13 +252,16 @@ impl Global {
252252 Ok ( ( ) )
253253 }
254254
255- pub fn buffer_destroy ( & self , buffer_id : id:: BufferId ) -> Result < ( ) , resource :: DestroyError > {
255+ pub fn buffer_destroy ( & self , buffer_id : id:: BufferId ) {
256256 profiling:: scope!( "Buffer::destroy" ) ;
257257 api_log ! ( "Buffer::destroy {buffer_id:?}" ) ;
258258
259259 let hub = & self . hub ;
260260
261- let buffer = hub. buffers . get ( buffer_id) . get ( ) ?;
261+ let Ok ( buffer) = hub. buffers . get ( buffer_id) . get ( ) else {
262+ // If the buffer is already invalid, there's nothing to do.
263+ return ;
264+ } ;
262265
263266 #[ cfg( feature = "trace" ) ]
264267 if let Some ( trace) = buffer. device . trace . lock ( ) . as_mut ( ) {
@@ -270,7 +273,7 @@ impl Global {
270273 buffer_id,
271274 ) ;
272275
273- buffer. destroy ( )
276+ buffer. destroy ( ) ;
274277 }
275278
276279 pub fn buffer_drop ( & self , buffer_id : id:: BufferId ) {
@@ -409,20 +412,23 @@ impl Global {
409412 ( id, err)
410413 }
411414
412- pub fn texture_destroy ( & self , texture_id : id:: TextureId ) -> Result < ( ) , resource :: DestroyError > {
415+ pub fn texture_destroy ( & self , texture_id : id:: TextureId ) {
413416 profiling:: scope!( "Texture::destroy" ) ;
414417 api_log ! ( "Texture::destroy {texture_id:?}" ) ;
415418
416419 let hub = & self . hub ;
417420
418- let texture = hub. textures . get ( texture_id) . get ( ) ?;
421+ let Ok ( texture) = hub. textures . get ( texture_id) . get ( ) else {
422+ // If the texture is already invalid, there's nothing to do.
423+ return ;
424+ } ;
419425
420426 #[ cfg( feature = "trace" ) ]
421427 if let Some ( trace) = texture. device . trace . lock ( ) . as_mut ( ) {
422428 trace. add ( trace:: Action :: FreeTexture ( texture_id) ) ;
423429 }
424430
425- texture. destroy ( )
431+ texture. destroy ( ) ;
426432 }
427433
428434 pub fn texture_drop ( & self , texture_id : id:: TextureId ) {
0 commit comments