DispSync: Always resync after inactivity
Changes DispSync to enable hardware vsync immediately when new frames
arrive after a period of inactivity.
No matter how hard we try, we can't avoid drifting over time without
being able to detect error based on display retire fences. By enabling
hardware vsync immediately, we avoid having a weird period or phase
offset relative to hardware while we retrain the model. Once the model
has locked, we turn hardware vsync back off to save power (until we
detect drift again).
Bug: 26255070
Change-Id: If4dd17c2d541015c730f47d824359d7cb4b52c3c
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 37110b9..41e42b7 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -407,8 +407,11 @@
* VSync
*/
void enableHardwareVsync();
- void disableHardwareVsync(bool makeUnavailable);
void resyncToHardwareVsync(bool makeAvailable);
+ void disableHardwareVsync(bool makeUnavailable);
+public:
+ void resyncWithRateLimit();
+private:
/* ------------------------------------------------------------------------
* Debugging & dumpsys
@@ -520,7 +523,7 @@
static const size_t NUM_BUCKETS = 8; // < 1-7, 7+
nsecs_t mFrameBuckets[NUM_BUCKETS];
nsecs_t mTotalTime;
- nsecs_t mLastSwapTime;
+ std::atomic<nsecs_t> mLastSwapTime;
};
}; // namespace android