d3d11: Drop D3D11 native resources in DestroyImpl

d3d11::TextureView was keeping the associated D3D11 texture alive after
Destroy() via its SRV, DSV, etc. Ensure these are cleaned up correctly,
and also handle a similar leak in d3d11::Buffer.

With these a massive Chrome Graphite memory regression is fixed.

Bug: 336318604
Change-Id: Idfa344fb9d899cc2cd7654eb725dfd1080d8d50d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/188480
Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: Peng Huang <penghuang@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
diff --git a/src/dawn/native/d3d11/BufferD3D11.cpp b/src/dawn/native/d3d11/BufferD3D11.cpp
index 2262d2a..2bc1a86 100644
--- a/src/dawn/native/d3d11/BufferD3D11.cpp
+++ b/src/dawn/native/d3d11/BufferD3D11.cpp
@@ -395,6 +395,7 @@
     if (mMappedData) {
         UnmapImpl();
     }
+    mD3d11ConstantBuffer = nullptr;
     mD3d11NonConstantBuffer = nullptr;
 }
 
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp
index d052901..a1e6a37 100644
--- a/src/dawn/native/d3d11/TextureD3D11.cpp
+++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -369,6 +369,8 @@
     //   other threads using the texture since there are no other live refs.
     TextureBase::DestroyImpl();
     mD3d11Resource = nullptr;
+    mKeyedMutex = nullptr;
+    mTextureForStencilSampling = nullptr;
 }
 
 ID3D11Resource* Texture::GetD3D11Resource() const {
@@ -1203,7 +1205,10 @@
 
 void TextureView::DestroyImpl() {
     TextureViewBase::DestroyImpl();
+    mD3d11SharedResourceView = nullptr;
     mD3d11RenderTargetViews.clear();
+    mD3d11DepthStencilView = nullptr;
+    mD3d11UnorderedAccessView = nullptr;
 }
 
 ResultOrError<ID3D11ShaderResourceView*> TextureView::GetOrCreateD3D11ShaderResourceView() {