@@ -451,95 +451,6 @@ uint64_t WddmMemoryManager::getInternalHeapBaseAddress() {
451
451
return this ->wddm ->getGfxPartition ().Heap32 [1 ].Base ;
452
452
}
453
453
454
- bool WddmMemoryManager::makeResidentResidencyAllocations (ResidencyContainer &allocationsForResidency, OsContext &osContext) {
455
- size_t residencyCount = allocationsForResidency.size ();
456
- std::unique_ptr<D3DKMT_HANDLE[]> handlesForResidency (new D3DKMT_HANDLE[residencyCount * maxFragmentsCount]);
457
-
458
- uint32_t totalHandlesCount = 0 ;
459
-
460
- auto lock = osContext.get ()->getResidencyController ().acquireLock ();
461
-
462
- DBG_LOG (ResidencyDebugEnable, " Residency:" , __FUNCTION__, " currentFenceValue =" , osContext.get ()->getResidencyController ().getMonitoredFence ().currentFenceValue );
463
-
464
- for (uint32_t i = 0 ; i < residencyCount; i++) {
465
- WddmAllocation *allocation = reinterpret_cast <WddmAllocation *>(allocationsForResidency[i]);
466
- bool mainResidency = false ;
467
- bool fragmentResidency[3 ] = {false , false , false };
468
-
469
- mainResidency = allocation->getResidencyData ().resident ;
470
-
471
- DBG_LOG (ResidencyDebugEnable, " Residency:" , __FUNCTION__, " allocation =" , allocation, mainResidency ? " resident" : " not resident" );
472
-
473
- if (allocation->getTrimCandidateListPosition (osContext.getContextId ()) != trimListUnusedPosition) {
474
-
475
- DBG_LOG (ResidencyDebugEnable, " Residency:" , __FUNCTION__, " allocation =" , allocation, " on trimCandidateList" );
476
- osContext.get ()->getResidencyController ().removeFromTrimCandidateList (allocation, false );
477
- } else {
478
-
479
- for (uint32_t allocationId = 0 ; allocationId < allocation->fragmentsStorage .fragmentCount ; allocationId++) {
480
- fragmentResidency[allocationId] = allocation->fragmentsStorage .fragmentStorageData [allocationId].residency ->resident ;
481
-
482
- DBG_LOG (ResidencyDebugEnable, " Residency:" , __FUNCTION__, " fragment handle =" ,
483
- allocation->fragmentsStorage .fragmentStorageData [allocationId].osHandleStorage ->handle ,
484
- fragmentResidency[allocationId] ? " resident" : " not resident" );
485
- }
486
- }
487
-
488
- if (allocation->fragmentsStorage .fragmentCount == 0 ) {
489
- if (!mainResidency)
490
- handlesForResidency[totalHandlesCount++] = allocation->handle ;
491
- } else {
492
- for (uint32_t allocationId = 0 ; allocationId < allocation->fragmentsStorage .fragmentCount ; allocationId++) {
493
- if (!fragmentResidency[allocationId])
494
- handlesForResidency[totalHandlesCount++] = allocation->fragmentsStorage .fragmentStorageData [allocationId].osHandleStorage ->handle ;
495
- }
496
- }
497
- }
498
-
499
- bool result = true ;
500
- if (totalHandlesCount) {
501
- uint64_t bytesToTrim = 0 ;
502
- while ((result = wddm->makeResident (handlesForResidency.get (), totalHandlesCount, false , &bytesToTrim)) == false ) {
503
- osContext.get ()->getResidencyController ().setMemoryBudgetExhausted ();
504
- bool trimmingDone = this ->getRegisteredOsContext (0u )->get ()->getResidencyController ().trimResidencyToBudget (bytesToTrim);
505
- bool cantTrimFurther = !trimmingDone;
506
- if (cantTrimFurther) {
507
- result = wddm->makeResident (handlesForResidency.get (), totalHandlesCount, true , &bytesToTrim);
508
- break ;
509
- }
510
- }
511
- }
512
-
513
- if (result == true ) {
514
- for (uint32_t i = 0 ; i < residencyCount; i++) {
515
- WddmAllocation *allocation = reinterpret_cast <WddmAllocation *>(allocationsForResidency[i]);
516
- // Update fence value not to early destroy / evict allocation
517
- auto currentFence = osContext.get ()->getResidencyController ().getMonitoredFence ().currentFenceValue ;
518
- allocation->getResidencyData ().updateCompletionData (currentFence, osContext.getContextId ());
519
- allocation->getResidencyData ().resident = true ;
520
-
521
- for (uint32_t allocationId = 0 ; allocationId < allocation->fragmentsStorage .fragmentCount ; allocationId++) {
522
- auto residencyData = allocation->fragmentsStorage .fragmentStorageData [allocationId].residency ;
523
- // Update fence value not to remove the fragment referenced by different GA in trimming callback
524
- residencyData->updateCompletionData (currentFence, osContext.getContextId ());
525
- residencyData->resident = true ;
526
- }
527
- }
528
- }
529
-
530
- return result;
531
- }
532
-
533
- void WddmMemoryManager::makeNonResidentEvictionAllocations (ResidencyContainer &evictionAllocations, OsContext &osContext) {
534
- auto lock = osContext.get ()->getResidencyController ().acquireLock ();
535
- const size_t residencyCount = evictionAllocations.size ();
536
-
537
- for (uint32_t i = 0 ; i < residencyCount; i++) {
538
- WddmAllocation *allocation = reinterpret_cast <WddmAllocation *>(evictionAllocations[i]);
539
- osContext.get ()->getResidencyController ().addToTrimCandidateList (allocation);
540
- }
541
- }
542
-
543
454
bool WddmMemoryManager::mapAuxGpuVA (GraphicsAllocation *graphicsAllocation) {
544
455
return wddm->updateAuxTable (graphicsAllocation->getGpuAddress (), graphicsAllocation->gmm , true );
545
456
}
0 commit comments