From 025880595d06fe5ab41022555b03983ba2aae9b1 Mon Sep 17 00:00:00 2001 From: Sunny Sachanandani Date: Tue, 4 Oct 2022 00:08:52 +0000 Subject: [PATCH] d3d12: Keep wait fences alive until GPU completion In D3D12, objects need to be kept alive until they're done being used on the GPU. This is particularly important for wait fences imported into Dawn otherwise the waits don't happen sometimes. Bug: dawn:576 Change-Id: Id2d8af59f1530a1e507471cf2e4653ac5cfbae06 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104425 Reviewed-by: Austin Eng Commit-Queue: Sunny Sachanandani Kokoro: Kokoro Auto-Submit: Sunny Sachanandani Commit-Queue: Austin Eng --- src/dawn/native/d3d12/TextureD3D12.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dawn/native/d3d12/TextureD3D12.cpp b/src/dawn/native/d3d12/TextureD3D12.cpp index d7fc90f236..a75482164a 100644 --- a/src/dawn/native/d3d12/TextureD3D12.cpp +++ b/src/dawn/native/d3d12/TextureD3D12.cpp @@ -739,6 +739,8 @@ MaybeError Texture::SynchronizeImportedTextureBeforeUse() { DAWN_TRY(CheckHRESULT(device->GetCommandQueue()->Wait(fence->GetD3D12Fence(), fence->GetFenceValue()), "D3D12 fence wait");); + // Keep D3D12 fence alive since we'll clear the waitFences list below. + device->ReferenceUntilUnused(fence->GetD3D12Fence()); } mWaitFences.clear(); return {};