diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index 7a45d076d4..6b90c0a475 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -567,6 +567,11 @@ namespace dawn_native { namespace d3d12 { device->DeallocateMemory(mResourceAllocation); + // Now that we've deallocated the memory, the texture is no longer a swap chain texture. + // We can set mSwapChainTexture to false to avoid passing a nullptr to + // ID3D12SharingContract::Present. + mSwapChainTexture = false; + if (mDxgiKeyedMutex != nullptr) { mDxgiKeyedMutex->ReleaseSync(uint64_t(mAcquireMutexKey) + 1); device->ReleaseKeyedMutexForTexture(std::move(mDxgiKeyedMutex));