From 3ba7334dba52a344d4aca95572743c76cf60ddaf Mon Sep 17 00:00:00 2001 From: ramindani Date: Mon, 1 Apr 2024 11:42:33 -0700 Subject: [PATCH] [Composer-VTS] Check minFrameIntervalNs to check if rate is changing With different VRR modes we may have 2 modes with exactly the same minFrameIntervalNs, and in this case we can't differentiate between 2 modes. Test: atest VtsHalGraphicsComposer3_TargetTest BUG: 328350178 Change-Id: I5cddfee8b789ed6ce1b223ec345175f19a0db091 --- .../composer/aidl/vts/VtsComposerClient.h | 21 ++++++++++++--- .../VtsHalGraphicsComposer3_TargetTest.cpp | 26 +++++++++++-------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/graphics/composer/aidl/vts/VtsComposerClient.h b/graphics/composer/aidl/vts/VtsComposerClient.h index fabc82a7a6..d3842c55c6 100644 --- a/graphics/composer/aidl/vts/VtsComposerClient.h +++ b/graphics/composer/aidl/vts/VtsComposerClient.h @@ -258,13 +258,13 @@ class VtsDisplay { struct DisplayConfig { DisplayConfig(int32_t vsyncPeriod_, int32_t configGroup_, - std::optional vrrConfig_ = {}) + std::optional vrrConfigOpt_ = {}) : vsyncPeriod(vsyncPeriod_), configGroup(configGroup_), - vrrConfig(std::move(vrrConfig_)) {} + vrrConfigOpt(std::move(vrrConfigOpt_)) {} int32_t vsyncPeriod; int32_t configGroup; - std::optional vrrConfig; + std::optional vrrConfigOpt; }; void addDisplayConfig(int32_t config, DisplayConfig displayConfig) { @@ -273,6 +273,21 @@ class VtsDisplay { DisplayConfig getDisplayConfig(int32_t config) { return mDisplayConfigs.find(config)->second; } + bool isRateSameBetweenConfigs(int config1, int config2) { + const auto displayConfig1 = getDisplayConfig(config1); + const auto displayConfig2 = getDisplayConfig(config2); + const auto vrrConfigOpt1 = displayConfig1.vrrConfigOpt; + const auto vrrConfigOpt2 = displayConfig2.vrrConfigOpt; + + if (vrrConfigOpt1 && vrrConfigOpt2 && + vrrConfigOpt1->minFrameIntervalNs == vrrConfigOpt2->minFrameIntervalNs) { + return true; + } else if (displayConfig1.vsyncPeriod == displayConfig2.vsyncPeriod) { + return true; + } + return false; + } + std::unordered_map getDisplayConfigs() { return mDisplayConfigs; } private: diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index f72cf55300..bf073ae99b 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -1603,18 +1603,24 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest { EXPECT_TRUE(mComposerClient->setActiveConfig(&display, config1).isOk()); sendRefreshFrame(display, nullptr); - const auto displayConfigGroup1 = display.getDisplayConfig(config1); - int32_t vsyncPeriod1 = displayConfigGroup1.vsyncPeriod; - int32_t configGroup1 = displayConfigGroup1.configGroup; + const auto displayConfig1 = display.getDisplayConfig(config1); + int32_t vsyncPeriod1 = displayConfig1.vsyncPeriod; + int32_t configGroup1 = displayConfig1.configGroup; - const auto displayConfigGroup2 = display.getDisplayConfig(config2); - int32_t vsyncPeriod2 = displayConfigGroup2.vsyncPeriod; - int32_t configGroup2 = displayConfigGroup2.configGroup; + const auto displayConfig2 = display.getDisplayConfig(config2); + int32_t vsyncPeriod2 = displayConfig2.vsyncPeriod; + int32_t configGroup2 = displayConfig2.configGroup; if (vsyncPeriod1 == vsyncPeriod2) { return; // continue } + if ((!displayConfig1.vrrConfigOpt && displayConfig2.vrrConfigOpt) || + (displayConfig1.vrrConfigOpt && !displayConfig2.vrrConfigOpt)) { + // switching between vrr to non-vrr modes + return; // continue + } + // We don't allow delayed change when changing config groups if (params.delayForChange > 0 && configGroup1 != configGroup2) { return; // continue @@ -2738,7 +2744,7 @@ TEST_P(GraphicsComposerAidlCommandV2Test, SetRefreshRateChangedCallbackDebug_Ena const auto displayFilter = [&](auto refreshRateChangedDebugData) { bool nonVrrRateMatching = true; if (std::optional vrrConfigOpt = - display.getDisplayConfig(configId).vrrConfig; + display.getDisplayConfig(configId).vrrConfigOpt; getInterfaceVersion() >= 3 && !vrrConfigOpt) { nonVrrRateMatching = refreshRateChangedDebugData.refreshPeriodNanos == refreshRateChangedDebugData.vsyncPeriodNanos; @@ -2836,10 +2842,7 @@ TEST_P(GraphicsComposerAidlCommandV2Test, .isOk()); forEachTwoConfigs(displayId, [&](int32_t config1, int32_t config2) { - const int32_t vsyncPeriod1 = display.getDisplayConfig(config1).vsyncPeriod; - const int32_t vsyncPeriod2 = display.getDisplayConfig(config2).vsyncPeriod; - - if (vsyncPeriod1 == vsyncPeriod2) { + if (display.isRateSameBetweenConfigs(config1, config2)) { return; // continue } @@ -2854,6 +2857,7 @@ TEST_P(GraphicsComposerAidlCommandV2Test, sendRefreshFrame(display, &timeline); } + const int32_t vsyncPeriod2 = display.getDisplayConfig(config2).vsyncPeriod; const auto callbackFilter = [displayId, vsyncPeriod2](auto refreshRateChangedDebugData) { constexpr int kVsyncThreshold = 1000;