mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add tests for locking in trimResidency()
Change-Id: Iddbecedae9cf21a4e5232dcac5d145962623e7d6 Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
53b32bc6ba
commit
ef02827cd9
@@ -28,6 +28,13 @@ class MockWddmResidencyController : public WddmResidencyController {
|
||||
using WddmResidencyController::trimResidency;
|
||||
using WddmResidencyController::trimResidencyToBudget;
|
||||
using WddmResidencyController::WddmResidencyController;
|
||||
|
||||
uint32_t acquireLockCallCount = 0u;
|
||||
|
||||
std::unique_lock<SpinLock> acquireLock() override {
|
||||
acquireLockCallCount++;
|
||||
return WddmResidencyController::acquireLock();
|
||||
}
|
||||
};
|
||||
|
||||
struct WddmResidencyControllerTest : ::testing::Test {
|
||||
@@ -690,3 +697,33 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenThreeAllocationsAlignedSizeBigge
|
||||
EXPECT_FALSE(allocation2.getResidencyData().resident);
|
||||
EXPECT_TRUE(allocation3.getResidencyData().resident);
|
||||
}
|
||||
|
||||
using WddmResidencyControllerLockTest = WddmResidencyControllerWithGdiTest;
|
||||
|
||||
TEST_F(WddmResidencyControllerLockTest, givenPeriodicTrimWhenTrimmingResidencyThenLockOnce) {
|
||||
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
|
||||
trimNotification.Flags.PeriodicTrim = 1;
|
||||
trimNotification.NumBytesToTrim = 0;
|
||||
|
||||
residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim);
|
||||
EXPECT_EQ(1, residencyController->acquireLockCallCount);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerLockTest, givenTrimToBudgetWhenTrimmingResidencyThenLockOnce) {
|
||||
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
|
||||
trimNotification.Flags.TrimToBudget = 1;
|
||||
trimNotification.NumBytesToTrim = 0;
|
||||
|
||||
residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim);
|
||||
EXPECT_EQ(1, residencyController->acquireLockCallCount);
|
||||
}
|
||||
|
||||
TEST_F(WddmResidencyControllerLockTest, givenPeriodicTrimAndTrimToBudgetWhenTrimmingResidencyThenLockTwice) {
|
||||
D3DKMT_TRIMNOTIFICATION trimNotification = {0};
|
||||
trimNotification.Flags.PeriodicTrim = 1;
|
||||
trimNotification.Flags.TrimToBudget = 1;
|
||||
trimNotification.NumBytesToTrim = 0;
|
||||
|
||||
residencyController->trimResidency(trimNotification.Flags, trimNotification.NumBytesToTrim);
|
||||
EXPECT_EQ(2, residencyController->acquireLockCallCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user