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
@@ -2,6 +2,7 @@
#include "client/palette.h"
#include "client/video.h"
#include "clock.h"
#include "fps.h"
#include "skele.h"
#include <SDL3/SDL.h>
#include <stdint.h>
@@ -58,7 +59,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;
}
@@ -72,8 +75,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)
@@ -243,6 +247,7 @@ uint8_t skele_video_init(skele_video_config_t cfg)
memset(palette, 0, sizeof(palette));
SDL_ShowWindow(window);
skele_fps_init();
return SKELE_INIT_SUCCESS;
}
@@ -282,7 +287,11 @@ void skele_video_blit(uint8_t *pixels)
SDL_RenderTexture(renderer, texture, NULL, NULL);
}
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)