fix: Move evict after unlock to wddm layer

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2025-05-27 07:41:23 +00:00
committed by Compute-Runtime-Automation
parent 0306b77297
commit a0f683e42b
8 changed files with 18 additions and 16 deletions

View File

@@ -979,13 +979,18 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio
return lock2.pData;
}
void Wddm::unlockResource(const D3DKMT_HANDLE &handle) {
void Wddm::unlockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock) {
D3DKMT_UNLOCK2 unlock2 = {};
unlock2.hAllocation = handle;
unlock2.hDevice = this->device;
NTSTATUS status = getGdi()->unlock2(&unlock2);
if (applyMakeResidentPriorToLock) {
this->temporaryResources->evictResource(handle);
}
if (status != STATUS_SUCCESS) {
return;
}

View File

@@ -82,7 +82,7 @@ class Wddm : public DriverModel {
MOCKABLE_VIRTUAL bool verifyNTHandle(HANDLE handle);
bool openNTHandle(const MemoryManager::OsHandleData &osHandleData, WddmAllocation *alloc);
MOCKABLE_VIRTUAL void *lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock, size_t size);
MOCKABLE_VIRTUAL void unlockResource(const D3DKMT_HANDLE &handle);
MOCKABLE_VIRTUAL void unlockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPriorToLock);
MOCKABLE_VIRTUAL void kmDafLock(D3DKMT_HANDLE handle);
MOCKABLE_VIRTUAL bool isKmDafEnabled() const;

View File

@@ -689,11 +689,7 @@ void *WddmMemoryManager::lockResourceImpl(GraphicsAllocation &graphicsAllocation
}
void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
getWddm(graphicsAllocation.getRootDeviceIndex()).unlockResource(wddmAllocation.getDefaultHandle());
if (wddmAllocation.needsMakeResidentBeforeLock()) {
[[maybe_unused]] auto evictionStatus = getWddm(graphicsAllocation.getRootDeviceIndex()).getTemporaryResourcesContainer()->evictResource(wddmAllocation.getDefaultHandle());
DEBUG_BREAK_IF(evictionStatus == MemoryOperationsStatus::failed);
}
getWddm(graphicsAllocation.getRootDeviceIndex()).unlockResource(wddmAllocation.getDefaultHandle(), wddmAllocation.needsMakeResidentBeforeLock());
}
void WddmMemoryManager::freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
@@ -1243,7 +1239,7 @@ bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphics
return false;
}
memcpy_s(ptrOffset(ptr, destinationOffset), graphicsAllocation->getUnderlyingBufferSize() - destinationOffset, memoryToCopy, sizeToCopy);
wddm.unlockResource(wddmAllocation->getHandles()[handleId]);
wddm.unlockResource(wddmAllocation->getHandles()[handleId], wddmAllocation->needsMakeResidentBeforeLock());
}
wddmAllocation->setExplicitlyMadeResident(wddmAllocation->needsMakeResidentBeforeLock());
return true;