diff options
| author | 2022-01-13 21:58:32 -0800 | |
|---|---|---|
| committer | 2022-01-19 11:16:48 -0800 | |
| commit | 1c595501f628bffc2bc1acaba4d10deb1c749b8d (patch) | |
| tree | 94ed27726443a643dc1aba533261ea95d443f051 | |
| parent | 6e60b14066a4d16652353a2ff7a18dc8e11d0d04 (diff) | |
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
| -rw-r--r-- | services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp | 2 | ||||
| -rw-r--r-- | services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp | 32 |
2 files changed, 33 insertions, 1 deletions
diff --git a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp index 71d563130e..3331185caa 100644 --- a/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp +++ b/services/surfaceflinger/Scheduler/RefreshRateConfigs.cpp @@ -225,7 +225,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 98746bcd21..2bafabddf3 100644 --- a/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp +++ b/services/surfaceflinger/tests/unittests/RefreshRateConfigsTest.cpp @@ -1986,6 +1986,38 @@ TEST_F(RefreshRateConfigsTest, getBestRefreshRate_deviceWithCloseRefreshRates) { } } +// b/190578904 +TEST_F(RefreshRateConfigsTest, getBestRefreshRate_conflictingVotes) { + const DisplayModes displayModes = { + createDisplayMode(DisplayModeId(0), 0, (43_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(1), 0, (53_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(2), 0, (55_Hz).getPeriodNsecs()), + createDisplayMode(DisplayModeId(3), 0, (60_Hz).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 = 43_Hz, + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + LayerRequirement{ + .vote = LayerVoteType::ExplicitExactOrMultiple, + .desiredRefreshRate = 53_Hz, + .seamlessness = Seamlessness::SeamedAndSeamless, + .weight = 0.41f, + }, + }; + + EXPECT_EQ(53_Hz, refreshRateConfigs->getBestRefreshRate(layers, globalSignals).getFps()); +} + TEST_F(RefreshRateConfigsTest, testComparisonOperator) { EXPECT_TRUE(mExpected60Config < mExpected90Config); EXPECT_FALSE(mExpected60Config < mExpected60Config); |