Bug 1233576. Ensure vsync timestamps are monotonic on Windows 10. r=kats a=sylvestre
authorMason Chang <mchang@mozilla.com>
Fri, 18 Dec 2015 08:32:21 -0800
changeset 298023 8e41d75f63faf347ebc0993e64ff3ea1d1686589
parent 298022 cee07fcf667693297d665b08d8517e5f4eb92b97
child 298024 8fffb73940213a6b5b14d2cb9e7f49857eea7d6c
push id8842
push userkwierso@gmail.com
push dateTue, 22 Dec 2015 21:07:53 +0000
treeherdermozilla-aurora@8fffb7394021 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, sylvestre
bugs1233576
milestone45.0a2
Bug 1233576. Ensure vsync timestamps are monotonic on Windows 10. r=kats a=sylvestre
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -2872,16 +2872,21 @@ public:
 
         DWM_TIMING_INFO vblankTime;
         // Make sure to init the cbSize, otherwise GetCompositionTiming will fail
         vblankTime.cbSize = sizeof(DWM_TIMING_INFO);
 
         LARGE_INTEGER frequency;
         QueryPerformanceFrequency(&frequency);
         TimeStamp vsync = TimeStamp::Now();
+        // On Windows 10, DwmGetCompositionInfo returns the upcoming vsync.
+        // See GetAdjustedVsyncTimestamp.
+        // On start, set mPrevVsync to the "next" vsync
+        // So we'll use this timestamp on the 2nd loop iteration.
+        mPrevVsync = vsync + mSoftwareVsyncRate;
 
         for (;;) {
           { // scope lock
             MonitorAutoLock lock(mVsyncEnabledLock);
             if (!mVsyncEnabled) return;
           }
 
           // Large parts of gecko assume that the refresh driver timestamp