Files
dhkatzandClaude Opus 5.5 399d934a08
CI / build (push) Successful in 32s
Pace all frames to the frame rate, at best effort
The pacer counted only its own frames, so the client's 30 came on top (60 gave
about 80), and it added no frames at all when the rate was out of reach. It now
asks for a window's next frame once the interval since its last frame began has
passed, and the client has had a third of a frame's time idle: all frames
within the rate, and as many as the client can draw when it can't reach it.

The engine's stats also break a frame's time down: sending to the renderer
process, bytes sent, buffer updates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 21:16:22 -07:00

26 lines
1.4 KiB
C++

#pragma once
// Extra frames between the client's 30-per-second ticks. The client draws a 3D window's frame when the window gets
// WM_PAINT, and steps its scene on its own timer (SceneWindow.dll's runApp: a step, then the window is invalidated);
// its message loop also wakes for WM_PAINT between steps. So asking the windows to repaint more often makes the client
// draw more frames, without stepping the scene. The rate is the user's (T5DE's settings, Graphics: HKCU\Software\T5DE\
// Graphics, FrameRate): 30, the client's own and the default, adds nothing; 60, 120, 240 or 360 add frames between
// ticks; 0 is uncapped.
//
// The rate counts all of a window's frames, the client's own included: a window is asked for one once its last frame
// is drawn and the interval since it began has passed. Drawing runs on the client's main thread, with its input and
// interface, so the client is also always left idle a third of a frame's time between frames: when the rate can't be
// reached, the client draws as many frames as that allows.
#include <windows.h>
namespace t5de::frame_pacer {
// A 3D window an engine draws into: repainted at the user's frame rate while added.
void add(HWND window);
void remove(HWND window);
// A frame drawn into window, taking the client this long (beginRendering to endRendering).
void frameDrawn(HWND window, double seconds);
} // namespace t5de::frame_pacer