Dont unlock/evict wddm allocations during releasing memory

Change-Id: Ib934867886a883a22fde2f0c03e16338dc215e65
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2019-03-11 10:19:02 +01:00
parent 4386d10e40
commit 3f690e1758
9 changed files with 30 additions and 4 deletions

View File

@@ -1002,7 +1002,15 @@ void Wddm::applyBlockingMakeResident(const D3DKMT_HANDLE &handle) {
while (currentPagingFenceValue > *getPagingFenceAddress())
;
}
void Wddm::removeTemporaryResource(const D3DKMT_HANDLE &handle) {
auto lock = acquireLock(temporaryResourcesLock);
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), handle);
if (position == temporaryResources.end()) {
return;
}
*position = temporaryResources.back();
temporaryResources.pop_back();
}
std::unique_lock<SpinLock> Wddm::acquireLock(SpinLock &lock) {
return std::unique_lock<SpinLock>{lock};
}

View File

@@ -150,6 +150,7 @@ class Wddm {
MOCKABLE_VIRTUAL EvictionStatus evictTemporaryResource(const D3DKMT_HANDLE &handle);
MOCKABLE_VIRTUAL void applyBlockingMakeResident(const D3DKMT_HANDLE &handle);
MOCKABLE_VIRTUAL std::unique_lock<SpinLock> acquireLock(SpinLock &lock);
MOCKABLE_VIRTUAL void removeTemporaryResource(const D3DKMT_HANDLE &handle);
protected:
bool initialized = false;

View File

@@ -286,6 +286,14 @@ void WddmMemoryManager::unlockResourceImpl(GraphicsAllocation &graphicsAllocatio
DEBUG_BREAK_IF(evictionStatus == EvictionStatus::FAILED);
}
}
void WddmMemoryManager::freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) {
auto &wddmAllocation = static_cast<WddmAllocation &>(graphicsAllocation);
if (wddmAllocation.needsMakeResidentBeforeLock) {
for (auto i = 0u; i < wddmAllocation.getNumHandles(); i++) {
wddm->removeTemporaryResource(wddmAllocation.getHandles()[i]);
}
}
}
void WddmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
WddmAllocation *input = static_cast<WddmAllocation *>(gfxAllocation);

View File

@@ -70,6 +70,7 @@ class WddmMemoryManager : public MemoryManager {
void *lockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
void unlockResourceImpl(GraphicsAllocation &graphicsAllocation) override;
void freeAssociatedResourceImpl(GraphicsAllocation &graphicsAllocation) override;
GraphicsAllocation *allocate32BitGraphicsMemoryImpl(const AllocationData &allocationData) override;
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;