From 361fe343929ee3db19defd8498c544ebfce6f075 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Wed, 2 Jul 2025 19:01:01 -0700 Subject: [PATCH] Check the parent texture in `TextureView::try_raw` --- wgpu-core/src/resource.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index b6fdadaf1..022b1ba59 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -458,9 +458,9 @@ impl Buffer { .ok_or_else(|| DestroyedResourceError(self.error_ident())) } - pub(crate) fn check_destroyed<'a>( - &'a self, - guard: &'a SnatchGuard, + pub(crate) fn check_destroyed( + &self, + guard: &SnatchGuard, ) -> Result<(), DestroyedResourceError> { self.raw .get(guard) @@ -1217,6 +1217,16 @@ impl Texture { .ok_or_else(|| DestroyedResourceError(self.error_ident())) } + pub(crate) fn check_destroyed( + &self, + guard: &SnatchGuard, + ) -> Result<(), DestroyedResourceError> { + self.inner + .get(guard) + .map(|_| ()) + .ok_or_else(|| DestroyedResourceError(self.error_ident())) + } + pub(crate) fn get_clear_view<'a>( clear_mode: &'a TextureClearMode, desc: &'a wgt::TextureDescriptor<(), Vec>, @@ -1810,6 +1820,7 @@ impl TextureView { &'a self, guard: &'a SnatchGuard, ) -> Result<&'a dyn hal::DynTextureView, DestroyedResourceError> { + self.parent.check_destroyed(guard)?; self.raw .get(guard) .map(|it| it.as_ref())