1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

core: check we have both frame time and render time before pacing

We only checked render time. If we don't have frame time estimates, we
would divide by zero and end up with wild scheduling delays.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2023-04-27 04:06:56 +01:00
parent fcb9dc8cfd
commit 336cb0917a
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -230,16 +230,16 @@ void schedule_render(session_t *ps) {
// TODO(yshui): why 1500? // TODO(yshui): why 1500?
const int SLACK = 1500; const int SLACK = 1500;
int render_time_estimate = rolling_max_get_max(ps->render_stats); int render_time_estimate = rolling_max_get_max(ps->render_stats);
if (render_time_estimate < 0) { auto frame_time = (uint64_t)rolling_avg_get_avg(ps->frame_time);
// We don't have render time estimates, maybe there's no frame rendered if (render_time_estimate < 0 || frame_time == 0) {
// yet, or the backend doesn't support render timing information, // We don't have render time, and/or frame time estimates, maybe there's
// schedule render immediately. // no frame rendered yet, or the backend doesn't support render timing
// information, schedule render immediately.
ps->target_msc = ps->last_msc + 1; ps->target_msc = ps->last_msc + 1;
goto schedule; goto schedule;
} }
render_time_estimate += SLACK; render_time_estimate += SLACK;
auto frame_time = (uint64_t)rolling_avg_get_avg(ps->frame_time);
auto minimal_target_us = now_us + (uint64_t)render_time_estimate; auto minimal_target_us = now_us + (uint64_t)render_time_estimate;
auto frame_delay = (uint64_t)ceil( auto frame_delay = (uint64_t)ceil(
(double)(minimal_target_us - ps->last_msc_instant) / (double)frame_time); (double)(minimal_target_us - ps->last_msc_instant) / (double)frame_time);