@@ -24,20 +24,20 @@ DrmMemoryOperationsHandlerBind::~DrmMemoryOperationsHandlerBind() = default;
2424MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident (Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
2525 auto engines = device->getEngines ();
2626 for (const auto &engine : engines) {
27- this ->makeResidentWithinOsContext (engine.osContext , gfxAllocations);
27+ this ->makeResidentWithinOsContext (engine.osContext , gfxAllocations, false );
2828 }
2929 return MemoryOperationsStatus::SUCCESS;
3030}
3131
32- MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext (OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) {
32+ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext (OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable ) {
3333 std::lock_guard<std::mutex> lock (mutex);
3434 for (auto gfxAllocation = gfxAllocations.begin (); gfxAllocation != gfxAllocations.end (); gfxAllocation++) {
35- if (!( *gfxAllocation)-> isAlwaysResident (osContext-> getContextId ())) {
36- auto drmAllocation = static_cast <DrmAllocation *>(*gfxAllocation );
37- auto &drmContextIds = static_cast < const OsContextLinux *>(osContext)-> getDrmContextIds ();
38- for ( uint32_t drmIterator = 0u ; drmIterator < drmContextIds. size (); drmIterator++) {
39- drmAllocation-> makeBOsResident (osContext, drmIterator, nullptr , true );
40- }
35+ auto drmAllocation = static_cast <DrmAllocation *>( *gfxAllocation);
36+ auto &drmContextIds = static_cast <const OsContextLinux *>(osContext)-> getDrmContextIds ( );
37+ for ( uint32_t drmIterator = 0u ; drmIterator < drmContextIds. size (); drmIterator++) {
38+ drmAllocation-> makeBOsResident (osContext, drmIterator, nullptr , true );
39+ }
40+ if (!evictable) {
4141 drmAllocation->updateResidencyTaskCount (GraphicsAllocation::objectAlwaysResident, osContext->getContextId ());
4242 }
4343 }
@@ -58,14 +58,12 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evict(Device *device, Gra
5858
5959MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evictWithinOsContext (OsContext *osContext, GraphicsAllocation &gfxAllocation) {
6060 std::lock_guard<std::mutex> lock (mutex);
61- if (gfxAllocation.isAlwaysResident (osContext->getContextId ())) {
62- auto drmAllocation = static_cast <DrmAllocation *>(&gfxAllocation);
63- auto &drmContextIds = static_cast <const OsContextLinux *>(osContext)->getDrmContextIds ();
64- for (uint32_t drmIterator = 0u ; drmIterator < drmContextIds.size (); drmIterator++) {
65- drmAllocation->makeBOsResident (osContext, drmIterator, nullptr , false );
66- }
67- drmAllocation->updateResidencyTaskCount (GraphicsAllocation::objectNotResident, osContext->getContextId ());
61+ auto drmAllocation = static_cast <DrmAllocation *>(&gfxAllocation);
62+ auto &drmContextIds = static_cast <const OsContextLinux *>(osContext)->getDrmContextIds ();
63+ for (uint32_t drmIterator = 0u ; drmIterator < drmContextIds.size (); drmIterator++) {
64+ drmAllocation->makeBOsResident (osContext, drmIterator, nullptr , false );
6865 }
66+ drmAllocation->updateResidencyTaskCount (GraphicsAllocation::objectNotResident, osContext->getContextId ());
6967 return MemoryOperationsStatus::SUCCESS;
7068}
7169
@@ -84,7 +82,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::isResident(Device *device
8482}
8583
8684void DrmMemoryOperationsHandlerBind::mergeWithResidencyContainer (OsContext *osContext, ResidencyContainer &residencyContainer) {
87- this ->makeResidentWithinOsContext (osContext, ArrayRef<GraphicsAllocation *>(residencyContainer));
85+ this ->makeResidentWithinOsContext (osContext, ArrayRef<GraphicsAllocation *>(residencyContainer), true );
8886 residencyContainer.clear ();
8987}
9088
0 commit comments