Bug 1233576. Ensure vsync timestamps are monotonic on Windows 10. r=kats
authorMason Chang <mchang@mozilla.com>
Fri, 18 Dec 2015 08:32:21 -0800
changeset 276961 4cad80316bc91b8d0249e695e821044109634044
parent 276960 4c71bfbcbaee35f9ee5fb8f1b7554dcbed30c388
child 276962 c32cff3324bac9337a6738e07d5b88430d2edf6b
push id69333
push usermchang@mozilla.com
push dateFri, 18 Dec 2015 16:32:29 +0000
treeherdermozilla-inbound@4cad80316bc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1233576
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1233576. Ensure vsync timestamps are monotonic on Windows 10. r=kats
gfx/thebes/gfxWindowsPlatform.cpp
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -2896,16 +2896,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