Skip to content

Commit 1d4c7fc

Browse files
steamcompmgr: throttle overlay frame callbacks to output refresh under VRR
Under VRR, the main loop forces vblank=true every iteration so games can get commit wake-ups at their uncapped rate. Overlays fall through the FPS-limit throttle, so mangoapp receives a frame callback every main loop iteration and renders flat-out, spiking power usage. Throttle overlays on the latch path only, leaving the commit-done path alone so overlay commits are still marked done immediately and the next game-commit scanout picks up the freshest frame.
1 parent f8b33d3 commit 1d4c7fc

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/steamcompmgr.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5682,6 +5682,24 @@ static bool steamcompmgr_should_vblank_window( bool bShouldLimitFPS, uint64_t vb
56825682

56835683
static bool steamcompmgr_should_vblank_window( steamcompmgr_win_t *w, uint64_t vblank_idx, uint64_t now )
56845684
{
5685+
// Overlays skip the FPS-limit throttle, so cap them to the output refresh under VRR.
5686+
if ( w && w->IsAnyOverlay() &&
5687+
GetBackend()->GetCurrentConnector() && GetBackend()->GetCurrentConnector()->IsVRRActive() )
5688+
{
5689+
uint64_t schedule = w->last_commit_first_latch_time + g_SteamCompMgrAppRefreshCycle;
5690+
5691+
static constexpr uint64_t k_ulVRRScheduleFudge = 200'000; // 0.2ms
5692+
if ( now + k_ulVRRScheduleFudge < schedule )
5693+
{
5694+
if ( !s_oLowestFPSLimitScheduleVRR )
5695+
s_oLowestFPSLimitScheduleVRR = schedule;
5696+
else
5697+
s_oLowestFPSLimitScheduleVRR = std::min( *s_oLowestFPSLimitScheduleVRR, schedule );
5698+
5699+
return false;
5700+
}
5701+
}
5702+
56855703
return steamcompmgr_should_vblank_window( steamcompmgr_window_should_limit_fps( w ), vblank_idx, w, now );
56865704
}
56875705

0 commit comments

Comments
 (0)