commit d1799123515c1cc4098b85084dfd01981ac354cb
parent 4ba93efba2b6b1b8f0c4f7659c18357b8dc08258
Author: Ashley Hale <ahale@mozilla.com>
Date: Sun, 7 Dec 2025 00:59:40 +0000
Bug 1959878 - add markers to WindowsVsyncThread for profiling r=gfx-reviewers,profiler-reviewers,canaltinova,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D240288
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -20,6 +20,7 @@
#include "mozilla/Preferences.h"
#include "mozilla/ProfilerLabels.h"
+#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ProfilerThreadSleep.h"
#include "mozilla/Components.h"
#include "mozilla/Sprintf.h"
@@ -1658,6 +1659,7 @@ class D3DVsyncSource final : public VsyncSource {
const TimeStamp vblank_begin_wait = TimeStamp::Now();
{
AUTO_PROFILER_THREAD_SLEEP;
+ AUTO_PROFILER_MARKER_UNTYPED("WaitForVBlank", GRAPHICS_VSync, {});
hr = mWaitVBlankOutput->WaitForVBlank();
}
if (SUCCEEDED(hr)) {
@@ -1675,10 +1677,12 @@ class D3DVsyncSource final : public VsyncSource {
// To mitigate bug 1924932 we only want to use DwmFlush if WaitForVBlank
// is disabled, WaitForVBlank is the standard since Vista so we should
// probably remove this option entirely.
+ AUTO_PROFILER_MARKER_UNTYPED("DwmFlush", GRAPHICS_VSync, {});
hr = DwmFlush();
}
if (!SUCCEEDED(hr)) {
// DWMFlush isn't working, fallback to software vsync.
+ AUTO_PROFILER_MARKER_UNTYPED("SoftwareVsync", GRAPHICS_VSync, {});
ScheduleSoftwareVsync(TimeStamp::Now());
return;
}
@@ -1688,6 +1692,7 @@ class D3DVsyncSource final : public VsyncSource {
flushTime = now;
if ((flushDiff > longVBlank) || mPrevVsync.IsNull()) {
// Our vblank took longer than 2 intervals, readjust our timestamps
+ PROFILER_MARKER_UNTYPED("LongVBlank", GRAPHICS_VSync);
vsync = GetVBlankTime();
mPrevVsync = vsync;
} else {
@@ -1699,16 +1704,19 @@ class D3DVsyncSource final : public VsyncSource {
vsync = mPrevVsync + mVsyncRate;
if (vsync > now) {
// DWMFlush woke up very early, so readjust our times again
+ PROFILER_MARKER_UNTYPED("EarlyWake", GRAPHICS_VSync);
vsync = GetVBlankTime();
}
if (vsync <= mPrevVsync) {
+ PROFILER_MARKER_UNTYPED("TimeSteppedBack", GRAPHICS_VSync);
vsync = TimeStamp::Now();
}
if ((now - vsync).ToMilliseconds() > 2.0) {
// Account for time drift here where vsync never quite catches up to
// Now and we'd fall ever so slightly further behind Now().
+ PROFILER_MARKER_UNTYPED("TimeFellBehind2ms", GRAPHICS_VSync);
vsync = GetVBlankTime();
}
diff --git a/mozglue/baseprofiler/build/profiling_categories.yaml b/mozglue/baseprofiler/build/profiling_categories.yaml
@@ -213,6 +213,8 @@
label: Image decoding
- name: GRAPHICS_WebGPU
label: WebGPU
+ - name: GRAPHICS_VSync
+ label: VSync triggered animation
- name: DOM
label: DOM