diff --git a/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp b/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp index eec7160abc..053a1690fd 100644 --- a/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp +++ b/src/dawn_native/d3d12/ResidencyManagerD3D12.cpp @@ -333,7 +333,10 @@ namespace dawn_native { namespace d3d12 { } // Inserts a heap at the bottom of the LRU. The passed heap must be resident or scheduled to - // become resident within the current serial. + // become resident within the current serial. Failing to call this function when an allocation + // is implicitly made resident will cause the residency manager to view the allocation as + // non-resident and call MakeResident - which will make D3D12's internal residency refcount on + // the allocation out of sync with Dawn. void ResidencyManager::TrackResidentAllocation(Pageable* pageable) { if (!mResidencyManagementEnabled) { return; diff --git a/src/dawn_native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp b/src/dawn_native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp index 258d5c3ea0..9039d8ab9d 100644 --- a/src/dawn_native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp +++ b/src/dawn_native/d3d12/ShaderVisibleDescriptorAllocatorD3D12.cpp @@ -152,6 +152,9 @@ namespace dawn_native { namespace d3d12 { "ID3D12Device::CreateDescriptorHeap")); descriptorHeap = std::make_unique( std::move(d3d12DescriptorHeap), kSize); + // We must track the allocation in the LRU when it is created, otherwise the residency + // manager will see the allocation as non-resident in the later call to LockAllocation. + mDevice->GetResidencyManager()->TrackResidentAllocation(descriptorHeap.get()); } DAWN_TRY(mDevice->GetResidencyManager()->LockAllocation(descriptorHeap.get()));