Skip to content

Commit 46e6ac2

Browse files
authored
Add Run-Ahead data to on-screen statistics (libretro#14838)
1 parent d33c2ff commit 46e6ac2

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

gfx/video_driver.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,10 @@ void video_driver_build_info(video_frame_info_t *video_info)
27162716
video_info->black_frame_insertion = settings->uints.video_black_frame_insertion;
27172717
video_info->hard_sync = settings->bools.video_hard_sync;
27182718
video_info->hard_sync_frames = settings->uints.video_hard_sync_frames;
2719+
video_info->runahead = settings->bools.run_ahead_enabled;
2720+
video_info->runahead_second_instance = settings->bools.run_ahead_secondary_instance;
2721+
video_info->preemptive_frames = settings->bools.preemptive_frames_enable;
2722+
video_info->runahead_frames = settings->uints.run_ahead_frames;
27192723
video_info->fps_show = settings->bools.video_fps_show;
27202724
video_info->memory_show = settings->bools.video_memory_show;
27212725
video_info->statistics_show = settings->bools.video_statistics_show;
@@ -3999,6 +4003,7 @@ void video_driver_frame(const void *data, unsigned width,
39994003
if (render_frame && video_info.statistics_show)
40004004
{
40014005
audio_statistics_t audio_stats;
4006+
char runahead_stats[128];
40024007
double stddev = 0.0;
40034008
struct retro_system_av_info *av_info = &video_st->av_info;
40044009
unsigned red = 255;
@@ -4027,18 +4032,34 @@ void video_driver_frame(const void *data, unsigned width,
40274032

40284033
audio_compute_buffer_statistics(&audio_stats);
40294034

4035+
runahead_stats[0] = '\0';
4036+
4037+
if (video_info.runahead && !video_info.runahead_second_instance)
4038+
snprintf(runahead_stats, sizeof(runahead_stats),
4039+
" -Run-Ahead Mode: Single Instance\n -Latency frames removed: %u\n",
4040+
video_info.runahead_frames);
4041+
else if (video_info.runahead && video_info.runahead_second_instance)
4042+
snprintf(runahead_stats, sizeof(runahead_stats),
4043+
" -Run-Ahead Mode: Second Instance\n -Latency frames removed: %u\n",
4044+
video_info.runahead_frames);
4045+
else if (video_info.preemptive_frames)
4046+
snprintf(runahead_stats, sizeof(runahead_stats),
4047+
" -Run-Ahead Mode: Preemptive Frames\n -Latency frames removed: %u\n",
4048+
video_info.runahead_frames);
4049+
40304050
snprintf(video_info.stat_text,
40314051
sizeof(video_info.stat_text),
40324052
"Video Statistics:\n -Frame rate: %6.2f fps\n -Frame time: %6.2f ms\n -Frame time deviation: %.3f %%\n"
4033-
" -Frame delay (target/effective): %u/%u ms\n -Frame count: %" PRIu64"\n -Viewport: %d x %d x %3.2f\n"
4053+
" -Frame count: %" PRIu64"\n -Frame delay (target/effective): %u/%u ms\n%s -Viewport: %d x %d x %3.2f\n"
40344054
"Audio Statistics:\n -Average buffer saturation: %.2f %%\n -Standard deviation: %.2f %%\n -Time spent close to underrun: %.2f %%\n -Time spent close to blocking: %.2f %%\n -Sample count: %d\n"
40354055
"Core Geometry:\n -Size: %u x %u\n -Max Size: %u x %u\n -Aspect: %3.2f\nCore Timing:\n -FPS: %3.2f\n -Sample Rate: %6.2f\n",
40364056
last_fps,
40374057
frame_time / 1000.0f,
40384058
100.0f * stddev,
4059+
video_st->frame_count,
40394060
video_st->frame_delay_target,
40404061
video_st->frame_delay_effective,
4041-
video_st->frame_count,
4062+
runahead_stats,
40424063
video_info.width,
40434064
video_info.height,
40444065
video_info.refresh_rate,

gfx/video_driver.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ typedef struct video_frame_info
402402
int crt_switch_porch_adjust;
403403

404404
unsigned hard_sync_frames;
405+
unsigned runahead_frames;
405406
unsigned aspect_ratio_idx;
406407
unsigned max_swapchain_images;
407408
unsigned monitor_index;
@@ -454,7 +455,7 @@ typedef struct video_frame_info
454455
bool full_screen;
455456
} osd_stat_params;
456457

457-
char stat_text[512];
458+
char stat_text[1024];
458459

459460
bool widgets_active;
460461
bool notifications_hidden;
@@ -466,6 +467,9 @@ typedef struct video_frame_info
466467
bool input_driver_nonblock_state;
467468
bool input_driver_grab_mouse_state;
468469
bool hard_sync;
470+
bool runahead;
471+
bool runahead_second_instance;
472+
bool preemptive_frames;
469473
bool fps_show;
470474
bool memory_show;
471475
bool statistics_show;

0 commit comments

Comments
 (0)