Release D3D11on12Resource Cache after Texture::Destroy() has been called

On D3D12 backend, external texture holds mD3D11on12Resource which caches
D3D11on12Resources and guarding by refptr. The texture will released this ref
until destructor works.

This model leaks the gpu memory if client fails to release all the ref to
the texture.

Instead, external texture also provides a method called "Destroy". It is
called more eagerly and means the external texture is in the end of lifecycle.

So thid CL moves the ref reset of D3D11on12Resource into Destroy(). This prevents
unexpected gpu memory leak caused by client missing ref release call.

Bug: 1308405
Change-Id: I253e1eda192256e4bd1c470e26dcc6af3c234447
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
This commit is contained in:
Shaobo 2022-03-29 08:14:53 +00:00 committed by Dawn LUCI CQ
parent e055ae5b52
commit 8e414a140b
1 changed files with 4 additions and 0 deletions

View File

@ -667,6 +667,10 @@ namespace dawn::native::d3d12 {
// We can set mSwapChainTexture to false to avoid passing a nullptr to // We can set mSwapChainTexture to false to avoid passing a nullptr to
// ID3D12SharingContract::Present. // ID3D12SharingContract::Present.
mSwapChainTexture = false; mSwapChainTexture = false;
// Now that the texture has been destroyed. It should release the refptr
// of the d3d11on12 resource.
mD3D11on12Resource = nullptr;
} }
DXGI_FORMAT Texture::GetD3D12Format() const { DXGI_FORMAT Texture::GetD3D12Format() const {