OSDN Git Service

HWC2: Add properties to revert latching changes
authorDan Stoza <stoza@google.com>
Wed, 20 Jul 2016 22:38:12 +0000 (15:38 -0700)
committerSteve Pfetsch <spfetsch@google.com>
Thu, 21 Jul 2016 02:19:42 +0000 (19:19 -0700)
Adds two properties:

debug.sf.latch_unsignaled - This causes SurfaceFlinger to latch
  buffers even if their fences haven't signaled
debug.sf.disable_backpressure - This causes SurfaceFlinger to skip
  propagating backpressure back to apps by not running when it
  detects that a prior composition missed hardware vsync

Bug: 30216498
Change-Id: Idd70f472ec567a4bc03352f30f201f434cf5d660

services/surfaceflinger/Layer.cpp
services/surfaceflinger/Layer.h
services/surfaceflinger/SurfaceFlinger.cpp
services/surfaceflinger/SurfaceFlinger.h

index 548b048..30a4d79 100644 (file)
@@ -51,6 +51,8 @@
 
 #include "RenderEngine/RenderEngine.h"
 
+#include <mutex>
+
 #define DEBUG_RESIZE    0
 
 namespace android {
@@ -1091,6 +1093,20 @@ uint32_t Layer::getProducerStickyTransform() const {
     return static_cast<uint32_t>(producerStickyTransform);
 }
 
+bool Layer::latchUnsignaledBuffers() {
+    static bool propertyLoaded = false;
+    static bool latch = false;
+    static std::mutex mutex;
+    std::lock_guard<std::mutex> lock(mutex);
+    if (!propertyLoaded) {
+        char value[PROPERTY_VALUE_MAX] = {};
+        property_get("debug.sf.latch_unsignaled", value, "0");
+        latch = atoi(value);
+        propertyLoaded = true;
+    }
+    return latch;
+}
+
 uint64_t Layer::getHeadFrameNumber() const {
     Mutex::Autolock lock(mQueueItemLock);
     if (!mQueueItems.empty()) {
@@ -1102,6 +1118,10 @@ uint64_t Layer::getHeadFrameNumber() const {
 
 bool Layer::headFenceHasSignaled() const {
 #ifdef USE_HWC2
+    if (latchUnsignaledBuffers()) {
+        return true;
+    }
+
     Mutex::Autolock lock(mQueueItemLock);
     if (mQueueItems.empty()) {
         return true;
index 78a8427..c070539 100644 (file)
@@ -465,6 +465,9 @@ private:
     // Temporary - Used only for LEGACY camera mode.
     uint32_t getProducerStickyTransform() const;
 
+    // Loads the corresponding system property once per process
+    static bool latchUnsignaledBuffers();
+
     // -----------------------------------------------------------------------
 
     class SyncPoint
index f298399..8baf28c 100644 (file)
@@ -179,6 +179,10 @@ SurfaceFlinger::SurfaceFlinger()
     }
     ALOGI_IF(mDebugRegion, "showupdates enabled");
     ALOGI_IF(mDebugDDMS, "DDMS debugging enabled");
+
+    property_get("debug.sf.disable_backpressure", value, "0");
+    mPropagateBackpressure = !atoi(value);
+    ALOGI_IF(!mPropagateBackpressure, "Disabling backpressure propagation");
 }
 
 void SurfaceFlinger::onFirstRef()
@@ -924,7 +928,7 @@ void SurfaceFlinger::onMessageReceived(int32_t what) {
                     mPreviousPresentFence != Fence::NO_FENCE &&
                     mPreviousPresentFence->getSignalTime() == INT64_MAX;
             ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
-            if (frameMissed) {
+            if (mPropagateBackpressure && frameMissed) {
                 signalLayerUpdate();
                 break;
             }
index f063aaf..ad2e895 100644 (file)
@@ -507,6 +507,9 @@ private:
     bool mBootFinished;
     bool mForceFullDamage;
     FenceTracker mFenceTracker;
+#ifdef USE_HWC2
+    bool mPropagateBackpressure = true;
+#endif
 
     // these are thread safe
     mutable MessageQueue mEventQueue;