mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Unregister trim callback
Change-Id: Ia6592d259a573cbc7161443945d03f6a83e88181 Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a8163f46b2
commit
9399215931
@@ -46,6 +46,11 @@ class MockGdi : public Gdi {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall unregisterTrimNotificationMock(IN D3DKMT_UNREGISTERTRIMNOTIFICATION *arg) {
|
||||
getUnregisterTrimNotificationArg() = *arg;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static NTSTATUS __stdcall destroyAllocation2Mock(IN D3DKMT_DESTROYALLOCATION2 *arg) {
|
||||
getDestroyArg() = *arg;
|
||||
return 0;
|
||||
@@ -87,6 +92,7 @@ class MockGdi : public Gdi {
|
||||
evict = reinterpret_cast<PFND3DKMT_EVICT>(evictMock);
|
||||
}
|
||||
registerTrimNotification = reinterpret_cast<PFND3DKMT_REGISTERTRIMNOTIFICATION>(registerTimNotificationMock);
|
||||
unregisterTrimNotification = reinterpret_cast<PFND3DKMT_UNREGISTERTRIMNOTIFICATION>(unregisterTrimNotificationMock);
|
||||
destroyAllocation2 = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION2>(destroyAllocation2Mock);
|
||||
waitForSynchronizationObjectFromCpu = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU>(waitFromCpuMock);
|
||||
queryResourceInfo = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFO>(queryResourceInfoMock);
|
||||
@@ -109,6 +115,11 @@ class MockGdi : public Gdi {
|
||||
return registerTrimArg;
|
||||
}
|
||||
|
||||
static D3DKMT_UNREGISTERTRIMNOTIFICATION &getUnregisterTrimNotificationArg() {
|
||||
static D3DKMT_UNREGISTERTRIMNOTIFICATION unregisterTrimArg;
|
||||
return unregisterTrimArg;
|
||||
}
|
||||
|
||||
static D3DKMT_DESTROYALLOCATION2 &getDestroyArg() {
|
||||
static D3DKMT_DESTROYALLOCATION2 destroyArg;
|
||||
return destroyArg;
|
||||
|
||||
@@ -874,7 +874,6 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe
|
||||
memoryManager->freeGraphicsMemory(wddmAllocation);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(WddmMemoryManagerResidencyTest, makeResidentResidencyAllocationsMarksAllocationsResident) {
|
||||
MockWddmAllocation allocation1, allocation2, allocation3, allocation4;
|
||||
ResidencyContainer residencyPack{&allocation1, &allocation2, &allocation3, &allocation4};
|
||||
@@ -942,6 +941,16 @@ TEST_F(WddmMemoryManagerResidencyTest, trimCallbackIsRegisteredInWddmMemoryManag
|
||||
EXPECT_EQ(wddm->getDevice(), gdi->getRegisterTrimNotificationArg().hDevice);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerResidencyTest, givenWddmMemoryManagerWhenCallingDestructorThenUnregisterTrimCallback) {
|
||||
auto trimCallbackHandle = wddm->trimCallbackHandle;
|
||||
auto trimCallbackAddress = reinterpret_cast<PFND3DKMT_TRIMNOTIFICATIONCALLBACK>(memoryManager->trimCallback);
|
||||
memoryManager.reset();
|
||||
|
||||
auto &unregisterNotification = gdi->getUnregisterTrimNotificationArg();
|
||||
EXPECT_EQ(trimCallbackAddress, unregisterNotification.Callback);
|
||||
EXPECT_EQ(trimCallbackHandle, unregisterNotification.Handle);
|
||||
}
|
||||
|
||||
TEST(WddmDebugModesTests, givenDebugModeWhenItIsActiveThenTrimCallbackIsNotRegistred) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
DebugManager.flags.DoNotRegisterTrimCallback.set(true);
|
||||
@@ -1642,15 +1651,16 @@ TEST_F(WddmMemoryManagerTest2, givenMemoryManagerWhenMakeResidentFailsThenMemory
|
||||
struct WddmMemoryManagerWithAsyncDeleterTest : ::testing::Test {
|
||||
void SetUp() {
|
||||
wddm = std::make_unique<WddmMock>();
|
||||
wddm->gdi.reset(new MockGdi());
|
||||
wddm->callBaseDestroyAllocations = false;
|
||||
deleter = new MockDeferredDeleter;
|
||||
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm.get(), executionEnvironment);
|
||||
memoryManager->setDeferredDeleter(deleter);
|
||||
}
|
||||
MockDeferredDeleter *deleter = nullptr;
|
||||
std::unique_ptr<WddmMock> wddm;
|
||||
std::unique_ptr<MockWddmMemoryManager> memoryManager;
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<WddmMock> wddm;
|
||||
};
|
||||
|
||||
TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenWddmWhenAsyncDeleterIsEnabledThenCanDeferDeletions) {
|
||||
|
||||
Reference in New Issue
Block a user