Files
mtgodot-poc/src/host/frame_policy.h
T
shenleiandClaude Opus 5.5 75d2dd8545 host: split src/host/main.cpp into translation units
main.cpp (4.5k lines) -> main.cpp (entry, args, synthetic benchmark) plus
vulkan_window, live_client, frame_policy, native_audio, texture_decode,
render_state, input_keymap, host_util. Bodies are moved verbatim; multi-line
VulkanWindow / NativeAudioEngine / FrameRatePolicy members are defined out of
line; one-line accessors stay inline. Anonymous namespace -> mt_host.

No behavior change: ctest 15/15, port_gate macos+android PASS, desktop
--live-client login screen and synthetic --draws runs unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:30:44 +09:00

51 lines
1.5 KiB
C++

#pragma once
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
#include <string>
namespace mt_host {
// Command-line overrides, defined in frame_policy.cpp.
extern int g_fps_cap;
extern int g_refresh_rate;
extern int g_fps_mode;
extern int g_idle_fps;
extern double g_idle_after_s;
// The frame-rate setting (system option dialog, platform/EterBase/FrameRateMode.h) turned into a frame
// rate, a display refresh rate and the ADPF budget; --fps-cap / --refresh-rate pin those for a test run.
// Frames the player does not watch closely cost the same power as the ones they do, so after a while
// without input (and no auto hunt running) the rate drops to --idle-fps until the next touch. The display
// is asked for 60 Hz unless the setting wants more: a 120 Hz panel scanning out a 60 fps game costs power
// for nothing.
class FrameRatePolicy {
public:
struct Decision {
int mode = -1;
int fps = 0; // frames per second the loop aims at
int display_hz = 0; // the refresh rate asked of the display
bool idle = false;
bool operator==(const Decision&) const = default;
};
bool pinned() const { return g_fps_cap > 0 || g_refresh_rate > 0; }
void load();
Decision decide(double idle_seconds, bool auto_hunt);
int max_hz() const { return max_hz_; }
private:
static std::string settings_path();
void save(int mode);
std::string path_;
int saved_mode_ = -1;
int max_hz_ = 60;
};
} // namespace mt_host
#endif