@@ -1042,13 +1042,9 @@ TEST_F(WddmMemoryManagerResidencyTest, compactTrimCandidateListWithNonNullEntrie
10421042
10431043TEST_F (WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllocationsResident) {
10441044 MockWddmAllocation allocation1, allocation2, allocation3, allocation4;
1045+ ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
10451046
1046- memoryManager->pushAllocationForResidency (&allocation1);
1047- memoryManager->pushAllocationForResidency (&allocation2);
1048- memoryManager->pushAllocationForResidency (&allocation3);
1049- memoryManager->pushAllocationForResidency (&allocation4);
1050-
1051- memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1047+ memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
10521048
10531049 EXPECT_TRUE (allocation1.getResidencyData ().resident );
10541050 EXPECT_TRUE (allocation2.getResidencyData ().resident );
@@ -1058,15 +1054,11 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllo
10581054
10591055TEST_F (WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsUpdatesLastFence) {
10601056 MockWddmAllocation allocation1, allocation2, allocation3, allocation4;
1061-
1062- memoryManager->pushAllocationForResidency (&allocation1);
1063- memoryManager->pushAllocationForResidency (&allocation2);
1064- memoryManager->pushAllocationForResidency (&allocation3);
1065- memoryManager->pushAllocationForResidency (&allocation4);
1057+ ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
10661058
10671059 osContext->get ()->getMonitoredFence ().currentFenceValue = 20 ;
10681060
1069- memoryManager->makeResidentResidencyAllocations (&memoryManager-> getResidencyAllocations () , *osContext);
1061+ memoryManager->makeResidentResidencyAllocations (&residencyPack , *osContext);
10701062
10711063 EXPECT_EQ (20u , allocation1.getResidencyData ().getFenceValueForContextId (osContext->getContextId ()));
10721064 EXPECT_EQ (20u , allocation2.getResidencyData ().getFenceValueForContextId (osContext->getContextId ()));
@@ -1079,12 +1071,9 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksTrip
10791071 void *ptr = reinterpret_cast <void *>(wddm->virtualAllocAddress + 0x1500 );
10801072
10811073 WddmAllocation *allocationTriple = (WddmAllocation *)memoryManager->allocateGraphicsMemory (8196 , ptr);
1074+ ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
10821075
1083- memoryManager->pushAllocationForResidency (&allocation1);
1084- memoryManager->pushAllocationForResidency (allocationTriple);
1085- memoryManager->pushAllocationForResidency (&allocation2);
1086-
1087- memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1076+ memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
10881077
10891078 for (uint32_t i = 0 ; i < allocationTriple->fragmentsStorage .fragmentCount ; i++) {
10901079 EXPECT_TRUE (allocationTriple->fragmentsStorage .fragmentStorageData [i].residency ->resident );
@@ -1102,11 +1091,8 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsSetsLastF
11021091
11031092 osContext->get ()->getMonitoredFence ().currentFenceValue = 20 ;
11041093
1105- memoryManager->pushAllocationForResidency (&allocation1);
1106- memoryManager->pushAllocationForResidency (allocationTriple);
1107- memoryManager->pushAllocationForResidency (&allocation2);
1108-
1109- memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1094+ ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
1095+ memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
11101096
11111097 for (uint32_t i = 0 ; i < allocationTriple->fragmentsStorage .fragmentCount ; i++) {
11121098 EXPECT_EQ (20u , allocationTriple->fragmentsStorage .fragmentStorageData [i].residency ->getFenceValueForContextId (0 ));
@@ -1732,12 +1718,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkAlloca
17321718 ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
17331719 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
17341720
1735- memoryManager->pushAllocationForResidency (&allocation1);
1736- memoryManager->pushAllocationForResidency (&allocation2);
1737- memoryManager->pushAllocationForResidency (&allocation3);
1738- memoryManager->pushAllocationForResidency (&allocation4);
1739-
1740- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1721+ ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
1722+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
17411723
17421724 EXPECT_FALSE (result);
17431725
@@ -1758,11 +1740,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkTriple
17581740 ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
17591741 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
17601742
1761- memoryManager->pushAllocationForResidency (&allocation1);
1762- memoryManager->pushAllocationForResidency (allocationTriple);
1763- memoryManager->pushAllocationForResidency (&allocation2);
1764-
1765- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1743+ ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
1744+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
17661745
17671746 EXPECT_FALSE (result);
17681747
@@ -1781,12 +1760,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsFailsWhenMakeResi
17811760 ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
17821761 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
17831762
1784- memoryManager->pushAllocationForResidency (&allocation1);
1785- memoryManager->pushAllocationForResidency (&allocation2);
1786- memoryManager->pushAllocationForResidency (&allocation3);
1787- memoryManager->pushAllocationForResidency (&allocation4);
1788-
1789- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1763+ ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
1764+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
17901765
17911766 EXPECT_FALSE (result);
17921767
@@ -1805,24 +1780,18 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsCallsMakeResident
18051780 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, false , ::testing::_)).Times (1 );
18061781 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, true , ::testing::_)).Times (1 );
18071782
1808- memoryManager->pushAllocationForResidency (&allocation1);
1809-
1810- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1783+ ResidencyContainer residencyPack{&allocation1};
1784+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
18111785
18121786 EXPECT_FALSE (result);
18131787}
18141788
1815- TEST_F (WddmMemoryManagerTest2, givenAllocationPackWhenTheyArePassedToMakeResidentThenTheyAreUsedInsteadOfMemoryManagerMembers ) {
1789+ TEST_F (WddmMemoryManagerTest2, givenAllocationPackPassedWhenCallingMakeResidentResidencyAllocationsThenItIsUsed ) {
18161790 MockWddmAllocation allocation1;
18171791 MockWddmAllocation allocation2;
1818- MockWddmAllocation allocation3;
18191792 allocation1.handle = 1 ;
18201793 allocation2.handle = 2 ;
1821- allocation3.handle = 3 ;
1822-
1823- ResidencyContainer residencyPack;
1824- residencyPack.push_back (&allocation1);
1825- residencyPack.push_back (&allocation2);
1794+ ResidencyContainer residencyPack{&allocation1, &allocation2};
18261795
18271796 auto makeResidentWithOutBytesToTrim = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool {
18281797 EXPECT_EQ (1 , handles[0 ]);
@@ -1832,7 +1801,6 @@ TEST_F(WddmMemoryManagerTest2, givenAllocationPackWhenTheyArePassedToMakeResiden
18321801 ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
18331802 EXPECT_CALL (*wddm, makeResident (::testing::_, 2 , false , ::testing::_)).Times (1 );
18341803
1835- memoryManager->pushAllocationForResidency (&allocation3);
18361804 bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
18371805 EXPECT_TRUE (result);
18381806}
@@ -1851,9 +1819,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR
18511819
18521820 memoryManager->addToTrimCandidateList (&allocationToTrim);
18531821
1854- memoryManager->pushAllocationForResidency (&allocation1);
1855-
1856- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1822+ ResidencyContainer residencyPack{&allocation1};
1823+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
18571824
18581825 EXPECT_TRUE (result);
18591826
@@ -1862,14 +1829,14 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR
18621829
18631830TEST_F (WddmMemoryManagerTest2, givenMemoryManagerWhenMakeResidentFailsThenMemoryBudgetExhaustedIsReturnedAsTrue) {
18641831 MockWddmAllocation allocation1;
1832+ ResidencyContainer residencyPack{&allocation1};
18651833
18661834 auto makeResidentThatFails = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return false ; };
18671835 auto makeResidentThatSucceds = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return true ; };
18681836
18691837 EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 ).WillOnce (::testing::Invoke (makeResidentThatFails)).WillOnce (::testing::Invoke (makeResidentThatSucceds));
18701838
1871- memoryManager->pushAllocationForResidency (&allocation1);
1872- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1839+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
18731840 EXPECT_TRUE (memoryManager->isMemoryBudgetExhausted ());
18741841}
18751842
0 commit comments