mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
feat(display): black frame insertion on 100 Hz and faster screens (#2653)
* feat(display): black frame insertion on 100 Hz and faster screens * feat(display): black frame insertion lives in Screen effects * test(compositor): cover black frame insertion in the render-on-commit harness * fix(display): keep HDR and pacing intact around black frame insertion * fix(display): gate black frame insertion on the panel's refresh, not the tick rate BFI checked the 100 Hz minimum against g_refresh_ns, an average of the time between handled vsync ticks. BFI presents on every tick, so under load the ticks run late, the average fell to 95-100 Hz on a 120 Hz panel, and BFI switched off and on again many times a second (3793 times in one session on a Retroid Pocket Duo). That showed as uneven flicker. Use the display mode's refresh (g_output_refresh_mhz) instead, which only changes when the mode does. * fix(display): offer black frame insertion for the bottom screen and while it is on * fix(display): capture a picture, not a black refresh, while black frame insertion strobes * fix(display): hold black frame insertion off until the last capture ends * fix(display): keep the game composed while a capture holds black frame insertion * test(display): a picture hold presents only pictures while black frame insertion runs
This commit is contained in:
1 parent
f65e7a3d43
commit
758e7983fa
46 files changed
+343
-29
No files matched your search
@@ -51,6 +51,19 @@ static int vkp_cardboard_pose_changed(void) { return pose_changes; }
|
||||
static void render_scene(void) { renders++; g_dirty = 0; g_dirty_since_ns = 0; g_rendered_tick_ns = g_tick_vsync_ns; g_tick_held = 0; }
|
||||
static int on_fallback_timer(void *data) { return 0; }
|
||||
static void on_commit_idle(void *data);
|
||||
volatile int g_bfi;
|
||||
volatile int g_bfi_picture_hold;
|
||||
static int g_bfi_running, g_scene_layer_only, cardboard, quest, blacks;
|
||||
static unsigned g_bfi_phase;
|
||||
static const char *g_bfi_blocked;
|
||||
static struct { unsigned lit, dark, failed; } g_bfi_stats;
|
||||
static int g_scene_w, g_scene_h;
|
||||
#define BFI_MIN_REFRESH_MHZ 99000
|
||||
static atomic_int g_output_refresh_mhz = 144000;
|
||||
static int vkp_cardboard_active(void) { return cardboard; }
|
||||
static int vkp_quest_layer_presentation(void) { return quest; }
|
||||
static int vkp_render_plain(int w, int h) { blacks++; return 0; }
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) {}
|
||||
'''
|
||||
|
||||
CHECKS = r'''
|
||||
@@ -186,6 +199,57 @@ int main(void) {
|
||||
assert(renders - r0 == c + 1);
|
||||
}
|
||||
|
||||
/* black frame insertion alternates the scene and black on every tick, and arrivals draw nothing */
|
||||
{
|
||||
const int idles_before = idles_added;
|
||||
const int b0 = blacks;
|
||||
g_bfi = 1;
|
||||
r0 = renders;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
arrive(1 * ms);
|
||||
tick(t += refresh);
|
||||
}
|
||||
assert(g_bfi_running == 1 && idles_added == idles_before);
|
||||
assert(renders - r0 == 5 && blacks - b0 == 5 && g_bfi_stats.lit == 5 && g_bfi_stats.dark == 5);
|
||||
|
||||
/* a capture's picture hold presents only pictures and keeps BFI composing the scene */
|
||||
g_bfi_picture_hold = 1;
|
||||
r0 = renders;
|
||||
const int hb = blacks;
|
||||
for (int i = 0; i < 4; i++) tick(t += refresh);
|
||||
assert(g_bfi_running == 1 && renders - r0 == 4 && blacks == hb);
|
||||
g_bfi_picture_hold = 0;
|
||||
r0 = renders;
|
||||
for (int i = 0; i < 4; i++) tick(t += refresh);
|
||||
assert(renders - r0 == 2 && blacks - hb == 2);
|
||||
|
||||
/* frame generation, a slow screen or a layer-only game make it wait and the tick draws as before */
|
||||
framegen = 1;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 0 && g_bfi_blocked != NULL);
|
||||
framegen = 0;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 1);
|
||||
g_output_refresh_mhz = 60000;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 0);
|
||||
g_output_refresh_mhz = 144000;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 1);
|
||||
/* late ticks under load do not switch it off while the panel runs fast */
|
||||
g_refresh_ns = 16666667;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 1);
|
||||
g_refresh_ns = refresh;
|
||||
g_scene_layer_only = 1;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 0);
|
||||
g_scene_layer_only = 0;
|
||||
g_bfi = 0;
|
||||
tick(t += refresh);
|
||||
assert(g_bfi_running == 0 && g_bfi_blocked == NULL);
|
||||
}
|
||||
|
||||
/* without screen ticks the fallback timer still draws */
|
||||
clock_ns += 200000000LL;
|
||||
schedule_render();
|
||||
@@ -206,7 +270,8 @@ class RenderOnCommitTest(unittest.TestCase):
|
||||
render = extract_function(source, 'render_scene')
|
||||
self.assertIn('g_rendered_tick_ns = g_tick_vsync_ns;', render)
|
||||
self.assertIn('g_tick_held = 0;', render)
|
||||
functions = ('scene_held_for_limit', 'commit_renders_on', 'render_on_commit', 'schedule_render', 'scene_waits_for_game', 'on_commit_idle', 'on_vsync')
|
||||
functions = ('scene_held_for_limit', 'commit_renders_on', 'render_on_commit', 'schedule_render', 'scene_waits_for_game', 'on_commit_idle',
|
||||
'bfi_blocked', 'bfi_update', 'bfi_tick', 'on_vsync')
|
||||
harness = PREAMBLE + '\n'.join(extract_function(source, name) for name in functions) + CHECKS
|
||||
with tempfile.TemporaryDirectory(prefix='droiddeck-render-on-commit-') as folder:
|
||||
path = Path(folder)
|
||||
|
||||
Reference in new issue
Block a user