mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Create Wddm residency logging
Change-Id: I7b469dd42cdedfdde2a9abea8d02bac2046c91cf Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
8f7b18fae2
commit
812dda6761
@ -26,6 +26,7 @@
|
||||
#include "opencl/test/unit_test/mocks/mock_gfx_partition.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_gmm_resource_info.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_wddm_residency_logger.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/wddm_fixture.h"
|
||||
@ -459,7 +460,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) {
|
||||
EXPECT_TRUE(error);
|
||||
EXPECT_TRUE(allocation.getGpuAddress() != 0);
|
||||
|
||||
error = wddm->makeResident(allocation.getHandles().data(), allocation.getNumHandles(), false, nullptr);
|
||||
error = wddm->makeResident(allocation.getHandles().data(), allocation.getNumHandles(), false, nullptr, allocation.getAlignedSize());
|
||||
EXPECT_TRUE(error);
|
||||
|
||||
uint64_t sizeToTrim;
|
||||
@ -666,7 +667,7 @@ TEST_F(Wddm20Tests, makeResidentMultipleHandles) {
|
||||
gdi->getMakeResidentArg().NumAllocations = 0;
|
||||
gdi->getMakeResidentArg().AllocationList = nullptr;
|
||||
|
||||
bool error = wddm->makeResident(handles, 2, false, nullptr);
|
||||
bool error = wddm->makeResident(handles, 2, false, nullptr, 0x1000);
|
||||
EXPECT_TRUE(error);
|
||||
|
||||
EXPECT_EQ(2u, gdi->getMakeResidentArg().NumAllocations);
|
||||
@ -681,7 +682,7 @@ TEST_F(Wddm20Tests, makeResidentMultipleHandlesWithReturnBytesToTrim) {
|
||||
gdi->getMakeResidentArg().NumBytesToTrim = 30;
|
||||
|
||||
uint64_t bytesToTrim = 0;
|
||||
bool success = wddm->makeResident(handles, 2, false, &bytesToTrim);
|
||||
bool success = wddm->makeResident(handles, 2, false, &bytesToTrim, 0x1000);
|
||||
EXPECT_TRUE(success);
|
||||
|
||||
EXPECT_EQ(gdi->getMakeResidentArg().NumBytesToTrim, bytesToTrim);
|
||||
@ -891,29 +892,29 @@ using WddmLockWithMakeResidentTests = Wddm20Tests;
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatDoesntNeedMakeResidentBeforeLockWhenLockThenDontStoreItOrCallMakeResident) {
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||
wddm->lockResource(ALLOCATION_HANDLE, false);
|
||||
wddm->lockResource(ALLOCATION_HANDLE, false, 0x1000);
|
||||
EXPECT_TRUE(mockTemporaryResources->resourceHandles.empty());
|
||||
EXPECT_EQ(0u, wddm->makeResidentResult.called);
|
||||
wddm->unlockResource(ALLOCATION_HANDLE);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationThatNeedsMakeResidentBeforeLockWhenLockThenCallBlockingMakeResident) {
|
||||
wddm->lockResource(ALLOCATION_HANDLE, true);
|
||||
wddm->lockResource(ALLOCATION_HANDLE, true, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->makeResidentResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenAcquireUniqueLock) {
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->acquireLockResult.called);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(&mockTemporaryResources->resourcesLock), mockTemporaryResources->acquireLockResult.uint64ParamPassed);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenCallMakeResidentAndStoreAllocation) {
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE, 0x1000);
|
||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||
EXPECT_EQ(ALLOCATION_HANDLE, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenWaitForCurrentPagingFenceValue) {
|
||||
wddm->mockPagingFence = 0u;
|
||||
wddm->currentPagingFenceValue = 3u;
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE);
|
||||
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE, 0x1000);
|
||||
EXPECT_EQ(1u, wddm->makeResidentResult.called);
|
||||
EXPECT_EQ(3u, wddm->mockPagingFence);
|
||||
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
|
||||
@ -923,8 +924,8 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside
|
||||
allocation.handle = 0x3;
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryResourcesAreEvictedSuccessfullyThenCallMakeResidentOneMoreTime) {
|
||||
@ -934,8 +935,8 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndTemporaryR
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.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::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->evictAllResourcesResult.called);
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentStillFailsThenDontStoreTemporaryResource) {
|
||||
@ -945,9 +946,9 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.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::_)).Times(3).WillRepeatedly(::testing::Return(false));
|
||||
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);
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(0u, mockTemporaryResources->resourceHandles.size());
|
||||
}
|
||||
TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeResidentPassesAfterEvictThenStoreTemporaryResource) {
|
||||
@ -957,9 +958,9 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.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::_)).Times(2).WillOnce(::testing::Return(false)).WillOnce(::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);
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(1u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
@ -969,8 +970,8 @@ TEST_F(WddmLockWithMakeResidentTests, whenApplyBlockingMakeResidentAndMakeReside
|
||||
GmockWddm gmockWddm(*executionEnvironment->rootDeviceEnvironments[0].get());
|
||||
auto mockTemporaryResources = reinterpret_cast<MockWddmResidentAllocationsContainer *>(gmockWddm.temporaryResources.get());
|
||||
mockTemporaryResources->resourceHandles.push_back(0x1);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle);
|
||||
EXPECT_CALL(gmockWddm, makeResident(&allocation.handle, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(1).WillOnce(::testing::Return(true));
|
||||
gmockWddm.temporaryResources->makeResidentResource(allocation.handle, 0x1000);
|
||||
EXPECT_EQ(2u, mockTemporaryResources->resourceHandles.size());
|
||||
EXPECT_EQ(0x2, mockTemporaryResources->resourceHandles.back());
|
||||
}
|
||||
@ -1266,3 +1267,129 @@ TEST(HwDeviceId, whenHwDeviceIdIsDestroyedThenAdapterIsClosed) {
|
||||
EXPECT_EQ(1u, GdiWithMockedCloseFunc::closeAdapterCalled);
|
||||
EXPECT_EQ(adapter, GdiWithMockedCloseFunc::closeAdapterCalledArgPassed);
|
||||
}
|
||||
|
||||
namespace NEO {
|
||||
namespace ResLog {
|
||||
extern uint32_t mockFopenCalled;
|
||||
extern uint32_t mockVfptrinfCalled;
|
||||
extern uint32_t mockFcloseCalled;
|
||||
} // namespace ResLog
|
||||
} // namespace NEO
|
||||
|
||||
TEST_F(WddmTest, WhenResidencyLoggingEnabledThenExpectLoggerCreated) {
|
||||
NEO::ResLog::mockFopenCalled = 0;
|
||||
NEO::ResLog::mockVfptrinfCalled = 0;
|
||||
NEO::ResLog::mockFcloseCalled = 0;
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
wddm->residencyLogger.reset();
|
||||
if (NEO::residencyLoggingAvailable) {
|
||||
EXPECT_EQ(1u, NEO::ResLog::mockFopenCalled);
|
||||
EXPECT_EQ(1u, NEO::ResLog::mockVfptrinfCalled);
|
||||
EXPECT_EQ(1u, NEO::ResLog::mockFcloseCalled);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentSuccessThenExpectSizeRapport) {
|
||||
if (!NEO::residencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::ResLog::mockFopenCalled = 0;
|
||||
NEO::ResLog::mockVfptrinfCalled = 0;
|
||||
NEO::ResLog::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
|
||||
D3DKMT_HANDLE handle = 0x10;
|
||||
uint64_t bytesToTrim = 0;
|
||||
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
|
||||
|
||||
//2 - one for open log, second for allocation size
|
||||
EXPECT_EQ(2u, NEO::ResLog::mockVfptrinfCalled);
|
||||
EXPECT_TRUE(logger->makeResidentCall);
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentFailThenExpectTrimReport) {
|
||||
if (!NEO::residencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::ResLog::mockFopenCalled = 0;
|
||||
NEO::ResLog::mockVfptrinfCalled = 0;
|
||||
NEO::ResLog::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
|
||||
D3DKMT_HANDLE handle = static_cast<D3DKMT_HANDLE>(-1);
|
||||
uint64_t bytesToTrim = 0;
|
||||
|
||||
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
|
||||
|
||||
//3 - one for open log, second for report allocations, 3rd for trim size
|
||||
EXPECT_EQ(3u, NEO::ResLog::mockVfptrinfCalled);
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenEnterWaitCalledThenExpectInternalFlagOn) {
|
||||
if (!NEO::residencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::ResLog::mockFopenCalled = 0;
|
||||
NEO::ResLog::mockVfptrinfCalled = 0;
|
||||
NEO::ResLog::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
logger->enteredWait();
|
||||
EXPECT_TRUE(logger->enterWait);
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenExpectFlagsOff) {
|
||||
if (!NEO::residencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::ResLog::mockFopenCalled = 0;
|
||||
NEO::ResLog::mockVfptrinfCalled = 0;
|
||||
NEO::ResLog::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
|
||||
D3DKMT_HANDLE handle = 0x10;
|
||||
uint64_t bytesToTrim = 0;
|
||||
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
|
||||
|
||||
//2 - one for open log, second for allocation size
|
||||
EXPECT_EQ(2u, NEO::ResLog::mockVfptrinfCalled);
|
||||
EXPECT_TRUE(logger->makeResidentCall);
|
||||
|
||||
logger->enterWait = true;
|
||||
wddm->waitOnPagingFenceFromCpu();
|
||||
EXPECT_EQ(4u, NEO::ResLog::mockVfptrinfCalled);
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
EXPECT_FALSE(logger->enterWait);
|
||||
}
|
||||
|
@ -6,9 +6,20 @@
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_wddm.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_wddm_residency_logger_functions.h"
|
||||
|
||||
namespace NEO {
|
||||
Wddm *Wddm::createWddm(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||
return new WddmMock(rootDeviceEnvironment);
|
||||
}
|
||||
|
||||
namespace ResLog {
|
||||
fopenFuncPtr fopenPtr = &mockFopen;
|
||||
vfprintfFuncPtr vfprintfPtr = &mockVfptrinf;
|
||||
fcloseFuncPtr fclosePtr = &mockFclose;
|
||||
|
||||
uint32_t mockFopenCalled = 0;
|
||||
uint32_t mockVfptrinfCalled = 0;
|
||||
uint32_t mockFcloseCalled = 0;
|
||||
} // namespace ResLog
|
||||
} // namespace NEO
|
||||
|
@ -54,7 +54,7 @@ class WddmKmDafListenerTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
||||
wddmWithKmDafMock->lockResource(ALLOCATION_HANDLE, false);
|
||||
wddmWithKmDafMock->lockResource(ALLOCATION_HANDLE, false, 0x1000);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
|
||||
@ -105,7 +105,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenFreeGpuVirtualAddressIsCalledThenKmDa
|
||||
TEST_F(WddmKmDafListenerTest, givenWddmWhenMakeResidentIsCalledThenKmDafListenerNotifyMakeResidentIsFedWithCorrectParams) {
|
||||
MockWddmAllocation allocation;
|
||||
|
||||
wddmWithKmDafMock->makeResident(&allocation.handle, 1, false, nullptr);
|
||||
wddmWithKmDafMock->makeResident(&allocation.handle, 1, false, nullptr, 0x1000);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->featureTable->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.hAdapter);
|
||||
|
@ -962,10 +962,10 @@ TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, makeResidentResidency
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenDontMarkAllocationsAsResident) {
|
||||
MockWddmAllocation allocation1, allocation2, allocation3, allocation4;
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
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::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
@ -984,10 +984,10 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
WddmAllocation *allocationTriple = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{false, 2 * MemoryConstants::pageSize}, ptr));
|
||||
ASSERT_NE(nullptr, allocationTriple);
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
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::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2);
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1, allocationTriple, &allocation2};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
@ -1004,11 +1004,11 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallingMakeResidentResidencyAllocationsThenCallItAgainWithCantTrimFurtherSetToTrue) {
|
||||
MockWddmAllocation allocation1;
|
||||
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { *numberOfBytesToTrim = 4 * 4096; return false; };
|
||||
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::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, false, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, true, ::testing::_)).Times(1);
|
||||
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);
|
||||
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
@ -1023,13 +1023,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) -> bool {
|
||||
auto makeResidentWithOutBytesToTrim = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim, size_t size) -> bool {
|
||||
EXPECT_EQ(1, handles[0]);
|
||||
EXPECT_EQ(2, handles[1]);
|
||||
return true;
|
||||
};
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, 2, false, ::testing::_)).Times(1);
|
||||
ON_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).WillByDefault(::testing::Invoke(makeResidentWithOutBytesToTrim));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, 2, false, ::testing::_, ::testing::_)).Times(1);
|
||||
|
||||
bool result = residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(result);
|
||||
@ -1043,9 +1043,9 @@ 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) -> bool { *numberOfBytesToTrim = allocationSize; return false; };
|
||||
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::_)).Times(2).WillOnce(::testing::Invoke(makeResidentWithOutBytesToTrim)).WillOnce(::testing::Return(true));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentWithOutBytesToTrim)).WillOnce(::testing::Return(true));
|
||||
|
||||
residencyController->addToTrimCandidateList(&allocationToTrim);
|
||||
|
||||
@ -1061,10 +1061,10 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsWhenCallin
|
||||
MockWddmAllocation allocation1;
|
||||
ResidencyContainer residencyPack{&allocation1};
|
||||
|
||||
auto makeResidentThatFails = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return false; };
|
||||
auto makeResidentThatSucceds = [](const D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim) -> bool { return true; };
|
||||
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::_)).Times(2).WillOnce(::testing::Invoke(makeResidentThatFails)).WillOnce(::testing::Invoke(makeResidentThatSucceds));
|
||||
EXPECT_CALL(*wddm, makeResident(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)).Times(2).WillOnce(::testing::Invoke(makeResidentThatFails)).WillOnce(::testing::Invoke(makeResidentThatSucceds));
|
||||
|
||||
residencyController->makeResidentResidencyAllocations(residencyPack);
|
||||
EXPECT_TRUE(residencyController->isMemoryBudgetExhausted());
|
||||
|
Reference in New Issue
Block a user