diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-09-21 23:13:56 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-09-21 23:13:56 +0000 |
commit | 8bbcf7b0a7e802e2bced3532d4a4c98d5c6a1fb6 (patch) | |
tree | 5f4e6e1e97a162958415a0a931f223b3660fff92 | |
parent | 25b089024a262cdf3ccff6460937fbb3b8e5d3e6 (diff) | |
parent | fcf2c201ad8d353f6268a6c6f0363c7751f34a7c (diff) | |
download | native-8bbcf7b0a7e802e2bced3532d4a4c98d5c6a1fb6.tar.gz |
Snap for 5892339 from fcf2c201ad8d353f6268a6c6f0363c7751f34a7c to qt-qpr1-release
Change-Id: I7b1a6b5a1b7fd1709d3f581b68269f63b342d41d
-rw-r--r-- | services/surfaceflinger/Scheduler/LayerInfo.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/Scheduler/SchedulerUtils.h | 6 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 34 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 3 |
4 files changed, 37 insertions, 11 deletions
diff --git a/services/surfaceflinger/Scheduler/LayerInfo.h b/services/surfaceflinger/Scheduler/LayerInfo.h index a7337817e3..17afddac28 100644 --- a/services/surfaceflinger/Scheduler/LayerInfo.h +++ b/services/surfaceflinger/Scheduler/LayerInfo.h @@ -109,7 +109,7 @@ class LayerInfo { bool isLowActivityLayer() const { // We want to make sure that we received more than two frames from the layer // in order to check low activity. - if (mElements.size() < 2) { + if (mElements.size() < scheduler::LOW_ACTIVITY_BUFFERS + 1) { return false; } @@ -118,7 +118,8 @@ class LayerInfo { // Check the frame before last to determine whether there is low activity. // If that frame is older than LOW_ACTIVITY_EPSILON_NS, the layer is sending // infrequent updates. - if (mElements.at(mElements.size() - 2) < obsoleteEpsilon) { + if (mElements.at(mElements.size() - (scheduler::LOW_ACTIVITY_BUFFERS + 1)) < + obsoleteEpsilon) { return true; } diff --git a/services/surfaceflinger/Scheduler/SchedulerUtils.h b/services/surfaceflinger/Scheduler/SchedulerUtils.h index ced1899109..ac10f83ad9 100644 --- a/services/surfaceflinger/Scheduler/SchedulerUtils.h +++ b/services/surfaceflinger/Scheduler/SchedulerUtils.h @@ -42,9 +42,11 @@ static constexpr uint32_t HWC2_SCREEN_OFF_CONFIG_ID = 0xffffffff; // or waiting idle in messaging app, when cursor is blinking. static constexpr std::chrono::nanoseconds OBSOLETE_TIME_EPSILON_NS = 1200ms; -// Layer is considered low activity if the buffers come more than LOW_ACTIVITY_EPSILON_NS -// apart. This is helping SF to vote for lower refresh rates when there is not activity +// Layer is considered low activity if the LOW_ACTIVITY_BUFFERS buffers come more than +// LOW_ACTIVITY_EPSILON_NS apart. +// This is helping SF to vote for lower refresh rates when there is not activity // in screen. +static constexpr int LOW_ACTIVITY_BUFFERS = 2; static constexpr std::chrono::nanoseconds LOW_ACTIVITY_EPSILON_NS = 250ms; // Calculates the statistical mean (average) in the data structure (array, vector). The diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index d91b0e7db7..23b399f838 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -358,6 +358,11 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI mPropagateBackpressure = !atoi(value); ALOGI_IF(!mPropagateBackpressure, "Disabling backpressure propagation"); + property_get("debug.sf.enable_gl_backpressure", value, "0"); + mPropagateBackpressureClientComposition = atoi(value); + ALOGI_IF(mPropagateBackpressureClientComposition, + "Enabling backpressure propagation for Client Composition"); + property_get("debug.sf.enable_hwc_vds", value, "0"); mUseHwcVirtualDisplays = atoi(value); ALOGI_IF(mUseHwcVirtualDisplays, "Enabling HWC virtual displays"); @@ -1676,7 +1681,8 @@ void SurfaceFlinger::updateVrFlinger() { setTransactionFlags(eDisplayTransactionNeeded); } -bool SurfaceFlinger::previousFrameMissed() NO_THREAD_SAFETY_ANALYSIS { +bool SurfaceFlinger::previousFrameMissed(int graceTimeMs) NO_THREAD_SAFETY_ANALYSIS { + ATRACE_CALL(); // We are storing the last 2 present fences. If sf's phase offset is to be // woken up before the actual vsync but targeting the next vsync, we need to check // fence N-2 @@ -1685,7 +1691,15 @@ bool SurfaceFlinger::previousFrameMissed() NO_THREAD_SAFETY_ANALYSIS { ? mPreviousPresentFences[0] : mPreviousPresentFences[1]; - return fence != Fence::NO_FENCE && (fence->getStatus() == Fence::Status::Unsignaled); + if (fence == Fence::NO_FENCE) { + return false; + } + + if (graceTimeMs > 0 && fence->getStatus() == Fence::Status::Unsignaled) { + fence->wait(graceTimeMs); + } + + return (fence->getStatus() == Fence::Status::Unsignaled); } void SurfaceFlinger::populateExpectedPresentTime() NO_THREAD_SAFETY_ANALYSIS { @@ -1708,7 +1722,15 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { // seeing this same value. populateExpectedPresentTime(); - bool frameMissed = previousFrameMissed(); + // When Backpressure propagation is enabled we want to give a small grace period + // for the present fence to fire instead of just giving up on this frame to handle cases + // where present fence is just about to get signaled. + const int graceTimeForPresentFenceMs = + (mPropagateBackpressure && + (mPropagateBackpressureClientComposition || !mHadClientComposition)) + ? 1 + : 0; + bool frameMissed = previousFrameMissed(graceTimeForPresentFenceMs); bool hwcFrameMissed = mHadDeviceComposition && frameMissed; bool gpuFrameMissed = mHadClientComposition && frameMissed; ATRACE_INT("FrameMissed", static_cast<int>(frameMissed)); @@ -1737,9 +1759,9 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { break; } - // For now, only propagate backpressure when missing a hwc frame. - if (hwcFrameMissed && !gpuFrameMissed) { - if (mPropagateBackpressure) { + if (frameMissed && mPropagateBackpressure) { + if ((hwcFrameMissed && !gpuFrameMissed) || + mPropagateBackpressureClientComposition) { signalLayerUpdate(); break; } diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 74882f3909..2718e0e860 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -851,7 +851,7 @@ private: return hwcDisplayId ? getHwComposer().toPhysicalDisplayId(*hwcDisplayId) : std::nullopt; } - bool previousFrameMissed(); + bool previousFrameMissed(int graceTimeMs = 0); void setVsyncEnabledInHWC(DisplayId displayId, HWC2::Vsync enabled); /* @@ -1023,6 +1023,7 @@ private: volatile nsecs_t mDebugInTransaction = 0; bool mForceFullDamage = false; bool mPropagateBackpressure = true; + bool mPropagateBackpressureClientComposition = false; std::unique_ptr<SurfaceInterceptor> mInterceptor; SurfaceTracing mTracing{*this}; bool mTracingEnabled = false; |