From 5cc118bde79d652a1cebab96cd8b8f198be8aaa9 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Mon, 19 Dec 2022 23:36:00 +0000 Subject: [PATCH] Clear reference to MTLTexture on TextureView::DestroyImpl Bug: dawn:1355 Change-Id: I834b02a05d50c39b1a8d272e2d437d7ce1f96fb5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115061 Kokoro: Kokoro Commit-Queue: Austin Eng Reviewed-by: Loko Kung --- src/dawn/native/metal/TextureMTL.h | 2 +- src/dawn/native/metal/TextureMTL.mm | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dawn/native/metal/TextureMTL.h b/src/dawn/native/metal/TextureMTL.h index 0d5a3c8d0c..f4ae94e823 100644 --- a/src/dawn/native/metal/TextureMTL.h +++ b/src/dawn/native/metal/TextureMTL.h @@ -104,8 +104,8 @@ class TextureView final : public TextureViewBase { private: using TextureViewBase::TextureViewBase; MaybeError Initialize(const TextureViewDescriptor* descriptor); + void DestroyImpl() override; - // TODO(crbug.com/dawn/1355): Clear this reference on texture destroy. NSPRef> mMtlTextureView; }; diff --git a/src/dawn/native/metal/TextureMTL.mm b/src/dawn/native/metal/TextureMTL.mm index a26ad65b22..42d752471e 100644 --- a/src/dawn/native/metal/TextureMTL.mm +++ b/src/dawn/native/metal/TextureMTL.mm @@ -1124,6 +1124,10 @@ MaybeError TextureView::Initialize(const TextureViewDescriptor* descriptor) { return {}; } +void TextureView::DestroyImpl() { + mMtlTextureView = nil; +} + id TextureView::GetMTLTexture() const { ASSERT(mMtlTextureView != nullptr); return mMtlTextureView.Get();