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:
@@ -1,5 +1,6 @@
|
|||||||
#include "client/video.h"
|
#include "client/video.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
#include "fps.h"
|
||||||
#include "skele.h"
|
#include "skele.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <stk/stk_log.h>
|
#include <stk/stk_log.h>
|
||||||
@@ -49,7 +50,9 @@ static void apply_present_mode(void)
|
|||||||
|
|
||||||
cap = configured_max_fps;
|
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;
|
present_fn = present;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -63,8 +66,9 @@ static void apply_present_mode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
frame_budget_ns = 1000000000ULL / cap;
|
frame_budget_ns = 1000000000ULL / cap;
|
||||||
|
skele_frame_budget_ms = frame_budget_ns / 1e6f;
|
||||||
last_present_ns = skele_time_ns();
|
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)
|
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();
|
apply_present_mode();
|
||||||
|
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
|
skele_fps_init();
|
||||||
return SKELE_INIT_SUCCESS;
|
return SKELE_INIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +242,11 @@ void skele_video_shutdown(void)
|
|||||||
is_fullscreen = 0;
|
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; }
|
uint8_t skele_video_using_vsync(void) { return vsync_active; }
|
||||||
|
|
||||||
void skele_video_set_vsync(uint8_t enabled)
|
void skele_video_set_vsync(uint8_t enabled)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "client/palette.h"
|
#include "client/palette.h"
|
||||||
#include "client/video.h"
|
#include "client/video.h"
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
#include "fps.h"
|
||||||
#include "skele.h"
|
#include "skele.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -58,7 +59,9 @@ static void apply_present_mode(void)
|
|||||||
|
|
||||||
cap = configured_max_fps;
|
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;
|
present_fn = present;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -72,8 +75,9 @@ static void apply_present_mode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
frame_budget_ns = 1000000000ULL / cap;
|
frame_budget_ns = 1000000000ULL / cap;
|
||||||
|
skele_frame_budget_ms = frame_budget_ns / 1e6f;
|
||||||
last_present_ns = skele_time_ns();
|
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)
|
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));
|
memset(palette, 0, sizeof(palette));
|
||||||
SDL_ShowWindow(window);
|
SDL_ShowWindow(window);
|
||||||
|
skele_fps_init();
|
||||||
return SKELE_INIT_SUCCESS;
|
return SKELE_INIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +287,11 @@ void skele_video_blit(uint8_t *pixels)
|
|||||||
SDL_RenderTexture(renderer, texture, NULL, NULL);
|
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; }
|
uint8_t skele_video_using_vsync(void) { return vsync_active; }
|
||||||
|
|
||||||
void skele_video_set_vsync(uint8_t enabled)
|
void skele_video_set_vsync(uint8_t enabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user