core: don't request vblank events when we are not rendering

Previously everytime we receive a vblank event, we always request a new
one. This made the logic somewhat simpler. But this generated many
useless vblank events, and wasted power. We only need vblank events for
two things:

1. after we rendered a frame, we need to know when it has been displayed
   on the screen.
2. estimating the refresh rate.

This commit makes sure we only request vblank events when it's actually
needed.

Fixes #1079

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2023-07-05 05:53:21 +01:00
parent 580889488f
commit 2bc180c2a7
5 changed files with 94 additions and 35 deletions

View File

@@ -30,4 +30,6 @@ void render_statistics_add_render_time_sample(struct render_statistics *rs, int
unsigned int
render_statistics_get_budget(struct render_statistics *rs, unsigned int *divisor);
/// Return the measured vblank interval in microseconds. Returns 0 if not enough
/// samples have been collected yet.
unsigned int render_statistics_get_vblank_time(struct render_statistics *rs);