feat: wire fps diagnostics into video present/init

Also fixes frame_budget_ns being left unset when vsync paces
presentation without an explicit sleep (present_fn == present), and
exposes it as skele_frame_budget_ms for reporting alongside the
sleep-based capped path.
This commit is contained in:
2026-08-23 17:44:04 +02:00
parent db05df4227
commit 55fc4958f7
2 changed files with 24 additions and 6 deletions
+12 -3
View File
@@ -1,5 +1,6 @@
#include "client/video.h"
#include "clock.h"
#include "fps.h"
#include "skele.h"
#include <SDL3/SDL.h>
#include <stk/stk_log.h>
@@ -49,7 +50,9 @@ static void apply_present_mode(void)
cap = configured_max_fps;
if (cap == SKELE_VIDEO_FPS_UNCAPPED || (vsync_active && !cap)) {
if (cap == SKELE_VIDEO_FPS_UNCAPPED) {
frame_budget_ns = 0;
skele_frame_budget_ms = 0.0f;
present_fn = present;
return;
}
@@ -63,8 +66,9 @@ static void apply_present_mode(void)
}
frame_budget_ns = 1000000000ULL / cap;
skele_frame_budget_ms = frame_budget_ns / 1e6f;
last_present_ns = skele_time_ns();
present_fn = present_capped;
present_fn = vsync_active ? present : present_capped;
}
static uint8_t max_scale(uint16_t rw, uint16_t rh)
@@ -219,6 +223,7 @@ uint8_t skele_video_init(skele_video_config_t cfg)
apply_present_mode();
SDL_ShowWindow(window);
skele_fps_init();
return SKELE_INIT_SUCCESS;
}
@@ -237,7 +242,11 @@ void skele_video_shutdown(void)
is_fullscreen = 0;
}
void skele_video_present(void) { present_fn(); }
void skele_video_present(void)
{
present_fn();
skele_fps_frame_mark();
}
uint8_t skele_video_using_vsync(void) { return vsync_active; }
void skele_video_set_vsync(uint8_t enabled)