mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
fix: remove destroyed allocations from eviction lists
mark explicitly made resident allocations Related-To: NEO-13246, GSD-10319 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a61656c2de
commit
db6fe7892c
@@ -725,6 +725,10 @@ void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation
|
||||
WddmAllocation *input = static_cast<WddmAllocation *>(gfxAllocation);
|
||||
DEBUG_BREAK_IF(!validateAllocation(input));
|
||||
|
||||
if (gfxAllocation->isExplicitlyMadeResident()) {
|
||||
freeAssociatedResourceImpl(*gfxAllocation);
|
||||
}
|
||||
|
||||
auto ®isteredEngines = getRegisteredEngines(gfxAllocation->getRootDeviceIndex());
|
||||
for (auto &engine : registeredEngines) {
|
||||
auto &residencyController = static_cast<OsContextWin *>(engine.osContext)->getResidencyController();
|
||||
@@ -1237,6 +1241,7 @@ bool WddmMemoryManager::copyMemoryToAllocationBanks(GraphicsAllocation *graphics
|
||||
memcpy_s(ptrOffset(ptr, destinationOffset), graphicsAllocation->getUnderlyingBufferSize() - destinationOffset, memoryToCopy, sizeToCopy);
|
||||
wddm.unlockResource(wddmAllocation->getHandles()[handleId]);
|
||||
}
|
||||
wddmAllocation->setExplicitlyMadeResident(wddmAllocation->needsMakeResidentBeforeLock());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(Device *device,
|
||||
size_t totalSize = 0;
|
||||
|
||||
for (const auto &allocation : gfxAllocations) {
|
||||
allocation->setExplicitlyMadeResident(true);
|
||||
WddmAllocation *wddmAllocation = reinterpret_cast<WddmAllocation *>(allocation);
|
||||
totalSize += wddmAllocation->getAlignedSize();
|
||||
|
||||
@@ -48,6 +49,7 @@ MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(Device *device,
|
||||
}
|
||||
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::evict(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||
gfxAllocation.setExplicitlyMadeResident(false);
|
||||
constexpr uint32_t stackHandlesCount = NEO::maxFragmentsCount * EngineLimits::maxHandleCount;
|
||||
StackVec<D3DKMT_HANDLE, stackHandlesCount> handlesForEviction;
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
@@ -81,4 +83,25 @@ MemoryOperationsStatus WddmMemoryOperationsHandler::isResident(Device *device, G
|
||||
return residentAllocations->isAllocationResident(defaultHandle);
|
||||
}
|
||||
|
||||
MemoryOperationsStatus WddmMemoryOperationsHandler::free(Device *device, GraphicsAllocation &gfxAllocation) {
|
||||
if (gfxAllocation.isExplicitlyMadeResident()) {
|
||||
|
||||
WddmAllocation &wddmAllocation = reinterpret_cast<WddmAllocation &>(gfxAllocation);
|
||||
|
||||
if (wddmAllocation.fragmentsStorage.fragmentCount > 0) {
|
||||
OsHandleStorage &fragmentStorage = wddmAllocation.fragmentsStorage;
|
||||
|
||||
for (uint32_t allocId = 0; allocId < fragmentStorage.fragmentCount; allocId++) {
|
||||
residentAllocations->removeResource(static_cast<OsHandleWin *>(fragmentStorage.fragmentStorageData[allocId].osHandleStorage)->handle);
|
||||
}
|
||||
} else {
|
||||
const auto &handles = wddmAllocation.getHandles();
|
||||
size_t handleCount = wddmAllocation.getNumGmms();
|
||||
for (uint32_t i = 0; i < handleCount; i++) {
|
||||
residentAllocations->removeResource(handles[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return MemoryOperationsStatus::success;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -36,6 +36,7 @@ class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override {
|
||||
return evict(nullptr, gfxAllocation);
|
||||
}
|
||||
MemoryOperationsStatus free(Device *device, GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
protected:
|
||||
Wddm *wddm;
|
||||
|
||||
Reference in New Issue
Block a user