@@ -1042,13 +1042,9 @@ TEST_F(WddmMemoryManagerResidencyTest, compactTrimCandidateListWithNonNullEntrie
1042
1042
1043
1043
TEST_F (WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllocationsResident) {
1044
1044
MockWddmAllocation allocation1, allocation2, allocation3, allocation4;
1045
+ ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
1045
1046
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);
1052
1048
1053
1049
EXPECT_TRUE (allocation1.getResidencyData ().resident );
1054
1050
EXPECT_TRUE (allocation2.getResidencyData ().resident );
@@ -1058,15 +1054,11 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllo
1058
1054
1059
1055
TEST_F (WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsUpdatesLastFence) {
1060
1056
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};
1066
1058
1067
1059
osContext->get ()->getMonitoredFence ().currentFenceValue = 20 ;
1068
1060
1069
- memoryManager->makeResidentResidencyAllocations (&memoryManager-> getResidencyAllocations () , *osContext);
1061
+ memoryManager->makeResidentResidencyAllocations (&residencyPack , *osContext);
1070
1062
1071
1063
EXPECT_EQ (20u , allocation1.getResidencyData ().getFenceValueForContextId (osContext->getContextId ()));
1072
1064
EXPECT_EQ (20u , allocation2.getResidencyData ().getFenceValueForContextId (osContext->getContextId ()));
@@ -1079,12 +1071,9 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksTrip
1079
1071
void *ptr = reinterpret_cast <void *>(wddm->virtualAllocAddress + 0x1500 );
1080
1072
1081
1073
WddmAllocation *allocationTriple = (WddmAllocation *)memoryManager->allocateGraphicsMemory (8196 , ptr);
1074
+ ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
1082
1075
1083
- memoryManager->pushAllocationForResidency (&allocation1);
1084
- memoryManager->pushAllocationForResidency (allocationTriple);
1085
- memoryManager->pushAllocationForResidency (&allocation2);
1086
-
1087
- memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1076
+ memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
1088
1077
1089
1078
for (uint32_t i = 0 ; i < allocationTriple->fragmentsStorage .fragmentCount ; i++) {
1090
1079
EXPECT_TRUE (allocationTriple->fragmentsStorage .fragmentStorageData [i].residency ->resident );
@@ -1102,11 +1091,8 @@ TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsSetsLastF
1102
1091
1103
1092
osContext->get ()->getMonitoredFence ().currentFenceValue = 20 ;
1104
1093
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);
1110
1096
1111
1097
for (uint32_t i = 0 ; i < allocationTriple->fragmentsStorage .fragmentCount ; i++) {
1112
1098
EXPECT_EQ (20u , allocationTriple->fragmentsStorage .fragmentStorageData [i].residency ->getFenceValueForContextId (0 ));
@@ -1732,12 +1718,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkAlloca
1732
1718
ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
1733
1719
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
1734
1720
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);
1741
1723
1742
1724
EXPECT_FALSE (result);
1743
1725
@@ -1758,11 +1740,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsDoesNotMarkTriple
1758
1740
ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
1759
1741
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
1760
1742
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);
1766
1745
1767
1746
EXPECT_FALSE (result);
1768
1747
@@ -1781,12 +1760,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsFailsWhenMakeResi
1781
1760
ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
1782
1761
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 );
1783
1762
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);
1790
1765
1791
1766
EXPECT_FALSE (result);
1792
1767
@@ -1805,24 +1780,18 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsCallsMakeResident
1805
1780
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, false , ::testing::_)).Times (1 );
1806
1781
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, true , ::testing::_)).Times (1 );
1807
1782
1808
- memoryManager->pushAllocationForResidency (&allocation1);
1809
-
1810
- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1783
+ ResidencyContainer residencyPack{&allocation1};
1784
+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
1811
1785
1812
1786
EXPECT_FALSE (result);
1813
1787
}
1814
1788
1815
- TEST_F (WddmMemoryManagerTest2, givenAllocationPackWhenTheyArePassedToMakeResidentThenTheyAreUsedInsteadOfMemoryManagerMembers ) {
1789
+ TEST_F (WddmMemoryManagerTest2, givenAllocationPackPassedWhenCallingMakeResidentResidencyAllocationsThenItIsUsed ) {
1816
1790
MockWddmAllocation allocation1;
1817
1791
MockWddmAllocation allocation2;
1818
- MockWddmAllocation allocation3;
1819
1792
allocation1.handle = 1 ;
1820
1793
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};
1826
1795
1827
1796
auto makeResidentWithOutBytesToTrim = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool {
1828
1797
EXPECT_EQ (1 , handles[0 ]);
@@ -1832,7 +1801,6 @@ TEST_F(WddmMemoryManagerTest2, givenAllocationPackWhenTheyArePassedToMakeResiden
1832
1801
ON_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault (::testing::Invoke (makeResidentWithOutBytesToTrim));
1833
1802
EXPECT_CALL (*wddm, makeResident (::testing::_, 2 , false , ::testing::_)).Times (1 );
1834
1803
1835
- memoryManager->pushAllocationForResidency (&allocation3);
1836
1804
bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
1837
1805
EXPECT_TRUE (result);
1838
1806
}
@@ -1851,9 +1819,8 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR
1851
1819
1852
1820
memoryManager->addToTrimCandidateList (&allocationToTrim);
1853
1821
1854
- memoryManager->pushAllocationForResidency (&allocation1);
1855
-
1856
- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1822
+ ResidencyContainer residencyPack{&allocation1};
1823
+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
1857
1824
1858
1825
EXPECT_TRUE (result);
1859
1826
@@ -1862,14 +1829,14 @@ TEST_F(WddmMemoryManagerTest2, makeResidentResidencyAllocationsSucceedsWhenMakeR
1862
1829
1863
1830
TEST_F (WddmMemoryManagerTest2, givenMemoryManagerWhenMakeResidentFailsThenMemoryBudgetExhaustedIsReturnedAsTrue) {
1864
1831
MockWddmAllocation allocation1;
1832
+ ResidencyContainer residencyPack{&allocation1};
1865
1833
1866
1834
auto makeResidentThatFails = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return false ; };
1867
1835
auto makeResidentThatSucceds = [](D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return true ; };
1868
1836
1869
1837
EXPECT_CALL (*wddm, makeResident (::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times (2 ).WillOnce (::testing::Invoke (makeResidentThatFails)).WillOnce (::testing::Invoke (makeResidentThatSucceds));
1870
1838
1871
- memoryManager->pushAllocationForResidency (&allocation1);
1872
- bool result = memoryManager->makeResidentResidencyAllocations (&memoryManager->getResidencyAllocations (), *osContext);
1839
+ bool result = memoryManager->makeResidentResidencyAllocations (&residencyPack, *osContext);
1873
1840
EXPECT_TRUE (memoryManager->isMemoryBudgetExhausted ());
1874
1841
}
1875
1842
0 commit comments