mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Remove GMock from MockAubCsr, GmockAubFileStream, AsyncEventsHandlerTests...
GMock Removed from: - MockAubCsr - GmockAubFileStream - AsyncEventsHandlerTests - AsyncEventsHandlerTests::MyEvent - MockGmmPageTableMngr - GmockWddm Additionally: - GmockAubFileStream body moved to MockAubFileStream class - Deleted unused GmockAubFileStream class - Deleted NiceMocks from AsyncEventsHandlerTests - Renamed GmockWddm to MockWddm Related-To: NEO-4914 Signed-off-by: Fabian Zwolinski <fabian.zwolinski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
f8c1fe53db
commit
1d48e97649
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -928,62 +928,71 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(2u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(3u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(3u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.makeResidentResults = {false, true};
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::testing::Return(true));
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(2u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesThenStoreTemporaryResource) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
allocation.handle = 0x2;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
mockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
EXPECT_EQ(allocation.handle, mockWddm.makeResidentParamsPassed[0].handles[0]);
|
||||
EXPECT_EQ(1u, mockWddm.makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingAllTemporaryResourcesThenEvictionIsNotApplied) {
|
||||
@ -999,37 +1008,38 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesThenAcqui
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingAllTemporaryResourcesAndAllEvictionsSucceedThenReturnSuccess) {
|
||||
MockWddmAllocation allocation(rootDeviceEnvironment->getGmmClientContext());
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
EXPECT_EQ(MemoryOperationsStatus::SUCCESS, mockTemporaryResources->evictAllResourcesResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesThenCallEvictForEachAllocationAndCleanList) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillRepeatedly(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenThreeAllocationsWhenEvictingAllTemporaryResourcesAndOneOfThemFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
mockWddm.evictResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
constexpr uint32_t numAllocations = 3u;
|
||||
for (auto i = 0u; i < numAllocations; i++) {
|
||||
mockTemporaryResources->resourceHandles.push_back(i);
|
||||
}
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
mockWddm.getTemporaryResourcesContainer()->evictAllResources();
|
||||
EXPECT_EQ(MemoryOperationsStatus::FAILED, mockTemporaryResources->evictAllResourcesResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenNoTemporaryResourcesWhenEvictingTemporaryResourceThenEvictionIsNotApplied) {
|
||||
@ -1052,23 +1062,24 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingNonExistingTemporaryResourceTh
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictFailsThenReturnFail) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
mockWddm.evictResult = false;
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(false));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
mockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(MemoryOperationsStatus::FAILED, mockTemporaryResources->evictResourceResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceAndEvictSucceedThenReturnSuccess) {
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
MockWddm mockWddm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
auto mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(mockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(ALLOCATION_HANDLE);
|
||||
EXPECT_CALL(gmockWddm, evict(::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
mockWddm.getTemporaryResourcesContainer()->evictResource(ALLOCATION_HANDLE);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(MemoryOperationsStatus::SUCCESS, mockTemporaryResources->evictResourceResult.operationSuccess);
|
||||
EXPECT_EQ(1u, mockWddm.evictCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherResourcesRemainOnTheList) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -1841,14 +1841,13 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen
|
||||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(AllocationProperties(1, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY, mockDeviceBitfield));
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = allocation->getGpuAddress();
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = allocation->getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo();
|
||||
@ -1856,12 +1855,12 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen
|
||||
expectedDdiUpdateAuxTable.Map = true;
|
||||
|
||||
auto expectedCallCount = static_cast<int>(regularEngines.size());
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
|
||||
auto result = memoryManager.mapAuxGpuVA(allocation);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
memoryManager.freeGraphicsMemory(allocation);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPageTableNotSupportedThenMapAuxVa) {
|
||||
@ -1882,19 +1881,18 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
||||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto hwInfoMock = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
|
||||
ASSERT_NE(nullptr, hwInfoMock);
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPageTableSupportedThenMapAuxVa) {
|
||||
@ -1915,12 +1913,11 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
||||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = GmmHelper::canonize(wddm.getGfxPartition().Standard.Base);
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = gmm->gmmResourceInfo->peekGmmResourceInfo();
|
||||
@ -1929,15 +1926,14 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
|
||||
|
||||
auto expectedCallCount = executionEnvironment->memoryManager.get()->getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
|
||||
auto hwInfoMock = hardwareInfoTable[wddm.getGfxPlatform()->eProductFamily];
|
||||
ASSERT_NE(nullptr, hwInfoMock);
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
|
||||
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupportedWhenReleaseingThenUnmapAuxVa) {
|
||||
@ -1956,7 +1952,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
||||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
@ -1965,7 +1961,6 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
||||
wddmAlloc->setGpuAddress(gpuVa);
|
||||
wddmAlloc->getDefaultGmm()->isCompressionEnabled = true;
|
||||
|
||||
GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {};
|
||||
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
|
||||
expectedDdiUpdateAuxTable.BaseGpuVA = gpuVa;
|
||||
expectedDdiUpdateAuxTable.BaseResInfo = wddmAlloc->getDefaultGmm()->gmmResourceInfo->peekGmmResourceInfo();
|
||||
@ -1974,10 +1969,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationAndPageTableSupported
|
||||
|
||||
auto expectedCallCount = memoryManager.getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount).WillOnce(Invoke([&](const GMM_DDI_UPDATEAUXTABLE *arg) {givenDdiUpdateAuxTable = *arg; return GMM_SUCCESS; }));
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &givenDdiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThenDontUnmapAuxVa) {
|
||||
@ -1992,7 +1987,7 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen
|
||||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
@ -2000,9 +1995,8 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenReleaseingThen
|
||||
auto wddmAlloc = static_cast<WddmAllocation *>(memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{rootDeviceIndex, MemoryConstants::pageSize}));
|
||||
wddmAlloc->getDefaultGmm()->isCompressionEnabled = false;
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) {
|
||||
@ -2021,15 +2015,14 @@ TEST_F(MockWddmMemoryManagerTest, givenNonCompressedAllocationWhenMappedGpuVaThe
|
||||
executionEnvironment->memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
for (auto engine : executionEnvironment->memoryManager.get()->getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
}
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
ASSERT_TRUE(result);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) {
|
||||
@ -2057,7 +2050,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD
|
||||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
engine.commandStreamReceiver->pageTableManager.reset(mockMngr);
|
||||
@ -2071,11 +2064,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsUnsetThenD
|
||||
delete wddmAlloc->getDefaultGmm();
|
||||
wddmAlloc->setDefaultGmm(myGmm);
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0);
|
||||
|
||||
auto result = wddm->mapGpuVirtualAddress(myGmm, ALLOCATION_HANDLE, wddm->getGfxPartition().Standard.Base, wddm->getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
EXPECT_TRUE(result);
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpdateAuxTable) {
|
||||
@ -2094,7 +2086,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpd
|
||||
memoryManager.createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(regularEngines[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(hwInfo)));
|
||||
|
||||
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
|
||||
auto mockMngr = new MockGmmPageTableMngr();
|
||||
auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get();
|
||||
rootDeviceEnvironment->executionEnvironment.initializeMemoryManager();
|
||||
for (auto engine : memoryManager.getRegisteredEngines()) {
|
||||
@ -2111,11 +2103,10 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedFlagSetWhenInternalIsSetThenUpd
|
||||
|
||||
auto expectedCallCount = memoryManager.getRegisteredEnginesCount();
|
||||
|
||||
EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(expectedCallCount);
|
||||
|
||||
auto result = wddm->mapGpuVirtualAddress(myGmm, ALLOCATION_HANDLE, wddm->getGfxPartition().Standard.Base, wddm->getGfxPartition().Standard.Limit, 0u, gpuVa);
|
||||
EXPECT_TRUE(result);
|
||||
memoryManager.freeGraphicsMemory(wddmAlloc);
|
||||
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryWhenCreateAllocationFailsThenPopulateOsHandlesReturnsInvalidPointer) {
|
||||
@ -2125,7 +2116,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryWhenCreateAllocationFailsThenP
|
||||
handleStorage.fragmentStorageData[0].fragmentSize = 0x1000;
|
||||
handleStorage.fragmentStorageData[0].freeTheFragment = false;
|
||||
|
||||
EXPECT_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillOnce(::testing::Return(STATUS_GRAPHICS_NO_VIDEO_MEMORY));
|
||||
wddm->createAllocationsAndMapGpuVaResult = STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
|
||||
auto result = memoryManager->populateOsHandles(handleStorage, 0);
|
||||
|
||||
@ -2145,7 +2136,7 @@ TEST_F(WddmMemoryManagerTest2, givenReadOnlyMemoryPassedToPopulateOsHandlesWhenC
|
||||
handleStorage.fragmentStorageData[1].cpuPtr = reinterpret_cast<void *>(0x2000);
|
||||
handleStorage.fragmentStorageData[1].fragmentSize = 0x6000;
|
||||
|
||||
EXPECT_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillOnce(::testing::Return(STATUS_GRAPHICS_NO_VIDEO_MEMORY));
|
||||
wddm->createAllocationsAndMapGpuVaResult = STATUS_GRAPHICS_NO_VIDEO_MEMORY;
|
||||
|
||||
auto result = memoryManager->populateOsHandles(handleStorage, mockRootDeviceIndex);
|
||||
auto hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <type_traits>
|
||||
@ -108,7 +107,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
|
||||
void SetUp() override {
|
||||
// wddm is deleted by memory manager
|
||||
|
||||
wddm = new NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm = new MockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
ASSERT_NE(nullptr, wddm);
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddm->init();
|
||||
@ -122,17 +121,14 @@ class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture
|
||||
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
osContext = memoryManager->createAndRegisterOsContext(csr.get(), EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
preemptionMode));
|
||||
|
||||
osContext->incRefInternal();
|
||||
|
||||
ON_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillByDefault(::testing::Invoke(wddm, &GmockWddm::baseCreateAllocationAndMapGpuVa));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
osContext->decRefInternal();
|
||||
}
|
||||
|
||||
NiceMock<GmockWddm> *wddm = nullptr;
|
||||
MockWddm *wddm = nullptr;
|
||||
std::unique_ptr<CommandStreamReceiver> csr;
|
||||
OSInterface *osInterface;
|
||||
OsContext *osContext;
|
||||
|
@ -119,7 +119,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
|
||||
void SetUp() {
|
||||
executionEnvironment = platform()->peekExecutionEnvironment();
|
||||
|
||||
wddm = new ::testing::NiceMock<GmockWddm>(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm = new MockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
wddm->resetGdi(new MockGdi());
|
||||
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*defaultHwInfo);
|
||||
wddm->init();
|
||||
@ -147,7 +147,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
|
||||
ExecutionEnvironment *executionEnvironment;
|
||||
std::unique_ptr<MockWddmMemoryManager> memoryManager;
|
||||
std::unique_ptr<CommandStreamReceiver> csr;
|
||||
::testing::NiceMock<GmockWddm> *wddm = nullptr;
|
||||
MockWddm *wddm = nullptr;
|
||||
OsContext *osContext;
|
||||
WddmResidencyController *residencyController;
|
||||
GmmClientContext *gmmClientContext = nullptr;
|
||||
@ -1012,10 +1012,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
MockWddmAllocation allocation3(gmmClientContext);
|
||||
MockWddmAllocation allocation4(gmmClientContext);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
@ -1026,19 +1024,19 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
EXPECT_FALSE(allocation2.getResidencyData().resident[osContextId]);
|
||||
EXPECT_FALSE(allocation3.getResidencyData().resident[osContextId]);
|
||||
EXPECT_FALSE(allocation4.getResidencyData().resident[osContextId]);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenDontMarkTripleAllocationsAsResident) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
MockWddmAllocation allocation2(gmmClientContext);
|
||||
wddm->callBaseCreateAllocationAndMapGpuVa = true;
|
||||
void *ptr = reinterpret_cast<void *>(wddm->getWddmMinAddress() + 0x1500);
|
||||
WddmAllocation *allocationTriple = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{csr->getRootDeviceIndex(), false, 2 * MemoryConstants::pageSize}, ptr));
|
||||
ASSERT_NE(nullptr, allocationTriple);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
@ -1050,21 +1048,21 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocationTriple);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenCallItAgainWithCantTrimFurtherSetToTrue) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, false, ::testing::_, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, true, ::testing::_, ::testing::_)).Times(1);
|
||||
wddm->makeResidentNumberOfBytesToTrim = 4 * 4096;
|
||||
wddm->makeResidentResult = false;
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_NE(wddm->makeResidentParamsPassed[0].cantTrimFurther, wddm->makeResidentParamsPassed[1].cantTrimFurther);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCallingMakeResidentResidencyAllocationsThenItIsUsed) {
|
||||
@ -1074,16 +1072,13 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenAllocationPackPassedWhenCal
|
||||
allocation2.handle = 2;
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2};
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool {
|
||||
EXPECT_EQ(1, handles[0 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(2, handles[1 * EngineLimits::maxHandleCount]);
|
||||
return true;
|
||||
};
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, 2 * EngineLimits::maxHandleCount, false, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(2 * EngineLimits::maxHandleCount, wddm->makeResidentParamsPassed[0].handles.size());
|
||||
EXPECT_EQ(false, wddm->makeResidentParamsPassed[0].cantTrimFurther);
|
||||
EXPECT_EQ(1, wddm->makeResidentParamsPassed[0].handles[0 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(2, wddm->makeResidentParamsPassed[0].handles[1 * EngineLimits::maxHandleCount]);
|
||||
EXPECT_EQ(1u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToBudgetSuceedsWhenCallingMakeResidentResidencyAllocationsThenSucceed) {
|
||||
@ -1094,9 +1089,8 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB
|
||||
|
||||
allocationToTrim.getResidencyData().updateCompletionData(residencyController->getMonitoredFence().lastSubmittedFence, osContext->getContextId());
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [allocationSize](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { *numberOfBytesToTrim = allocationSize; return false; };
|
||||
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentWithOutBytesToTrim)).WillOnce(::testing::Return(true));
|
||||
wddm->makeResidentNumberOfBytesToTrim = allocationSize;
|
||||
wddm->makeResidentResults = {false, true};
|
||||
|
||||
residencyController->addToTrimCandidateList(&allocationToTrim);
|
||||
|
||||
@ -1106,17 +1100,16 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB
|
||||
EXPECT_TRUE(result);
|
||||
|
||||
EXPECT_TRUE(allocation1.getResidencyData().resident[osContextId]);
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenMemoryBudgetExhaustedIsSetToTrue) {
|
||||
MockWddmAllocation allocation1(gmmClientContext);
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
|
||||
auto makeResidentThatFails = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { return false; };
|
||||
auto makeResidentThatSucceds = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool { return true; };
|
||||
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentThatFails)).WillOnce(::testing::Invoke(makeResidentThatSucceds));
|
||||
wddm->makeResidentResults = {false, true};
|
||||
|
||||
residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(residencyController->isMemoryBudgetExhausted());
|
||||
EXPECT_EQ(2u, wddm->makeResidentCalled);
|
||||
}
|
||||
|
Reference in New Issue
Block a user