diff options
author | Ady Abraham <adyabr@google.com> | 2022-01-13 21:58:32 -0800 |
---|---|---|
committer | Ady Abraham <adyabr@google.com> | 2022-01-20 20:35:59 -0800 |
commit | 3ef084b180f7d1449d9aebec0402a1fc1887ebde (patch) | |
tree | f2639eab9bfbd81590befae74169237207c65748 | |
parent | b351245a4d39de4d0cb02dd21f1ccaf4773eeb93 (diff) | |
download | native-3ef084b180f7d1449d9aebec0402a1fc1887ebde.tar.gz |
SF: adjust kNonExactMatchingPenalty
Give a higher score to frame rates which exact matches by lowering
the scores for other refresh rates, to favor exact (or multiple)
matches when there are multiple refresh rate with a close value.
Bug: b/190578904
Test: SF unit tests
Change-Id: Ia14551e000ee1651a04ab580c4df2afcb2f8edeb
Merged-In: Ia14551e000ee1651a04ab580c4df2afcb2f8edeb
-rw-r--r-- | services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp | 2 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp | 33 |
2 files changed, 34 insertions, 1 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 661b6c8d43..a56827e8f1 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -236,7 +236,7 @@ float RefreshRateConfigs::calculateLayerScoreLocked(const LayerRequirement& laye // The layer frame rate is not a divider of the refresh rate, // there is a small penalty attached to the score to favor the frame rates // the exactly matches the display refresh rate or a multiple. - constexpr float kNonExactMatchingPenalty = 0.99f; + constexpr float kNonExactMatchingPenalty = 0.95f; return calculateNonExactMatchingLayerScoreLocked(layer, refreshRate) * seamlessness * kNonExactMatchingPenalty; } diff --git a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp index d8c9babac3..77b75ab767 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -2207,6 +2207,39 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_deviceWithCloseRefreshRates) { } } +// b/190578904 +TEST_F(RefreshRateConfigsTest, getBestRefreshRate_conflictingVotes) { + const DisplayModes displayModes = { + createDisplayMode(DisplayModeId(0), 0, Fps(43.0f).getPeriodNsecs()), + createDisplayMode(DisplayModeId(1), 0, Fps(53.0f).getPeriodNsecs()), + createDisplayMode(DisplayModeId(2), 0, Fps(55.0f).getPeriodNsecs()), + createDisplayMode(DisplayModeId(3), 0, Fps(60.0f).getPeriodNsecs()), + }; + + const RefreshRateConfigs::GlobalSignals globalSignals = {.touch = false, .idle = false}; + auto refreshRateConfigs = + std::make_unique<RefreshRateConfigs>(displayModes, + /*currentConfigId=*/displayModes[0]->getId()); + + const auto layers = std::vector<LayerRequirement>{ + LayerRequirement{ + .vote = LayerVoteType::ExplicitDefault, + .desiredRefreshRate = Fps(43.0f), + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + LayerRequirement{ + .vote = LayerVoteType::ExplicitExactOrMultiple, + .desiredRefreshRate = Fps(53.0f), + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + }; + + EXPECT_EQ(53, + refreshRateConfigs->getBestRefreshRate(layers, globalSignals).getFps().getIntValue()); +} + TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); |