Do not execute trim callback if there are no registered contexts.

Change-Id: I9a274281a085cdbeb98a1d495ce9ef9ab897d08a
This commit is contained in:
Mrozek, Michal
2018-10-22 17:15:13 +02:00
committed by sys_ocldev
parent 56f67748fd
commit 77b00fa749
2 changed files with 11 additions and 0 deletions

View File

@@ -57,6 +57,10 @@ void APIENTRY WddmMemoryManager::trimCallback(_Inout_ D3DKMT_TRIMNOTIFICATION *t
WddmMemoryManager *wddmMemMngr = (WddmMemoryManager *)trimNotification->Context;
DEBUG_BREAK_IF(wddmMemMngr == nullptr);
if (wddmMemMngr->getOsContextCount() == 0) {
return;
}
wddmMemMngr->getRegisteredOsContext(0)->get()->getResidencyController().acquireTrimCallbackLock();
wddmMemMngr->trimResidency(trimNotification->Flags, trimNotification->NumBytesToTrim);
wddmMemMngr->getRegisteredOsContext(0)->get()->getResidencyController().releaseTrimCallbackLock();