euv_core/game/pacing/struct.rs
1use super::*;
2
3/// Result returned by `FramePacingController::evaluate` for a single scheduling trigger.
4#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
5pub struct PacingDecision {
6 /// Selected pacing action.
7 #[get(type(copy))]
8 pub(crate) action: PacingAction,
9 /// Monotonic simulation delta time in seconds (`0.0` for deferred, capped, or lifecycle-only frames).
10 #[get(type(copy))]
11 pub(crate) sim_dt_secs: f32,
12 /// Monotonic VSync timestamp in nanoseconds associated with this decision.
13 #[get(type(copy))]
14 pub(crate) timestamp_ns: u64,
15 /// Age of the oldest unpresented pending input event in milliseconds (`0.0` when none pending).
16 #[get(type(copy))]
17 pub(crate) input_age_ms: f32,
18 /// Whether the caller should submit a rendered frame for this trigger.
19 #[get(type(copy))]
20 pub(crate) should_render: bool,
21 /// Whether simulation clocks should advance on this trigger.
22 #[get(type(copy))]
23 pub(crate) should_step_sim: bool,
24}
25
26/// Telemetry counters summarizing VSync pacing health, double-gate avoidance, and spurious-step prevention.
27#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
28pub struct FramePacingStats {
29 /// Total VSync opportunities processed.
30 #[get(type(copy))]
31 pub(crate) vsync_signals: u64,
32 /// Total complete frames submitted.
33 #[get(type(copy))]
34 pub(crate) frames_submitted: u64,
35 /// Total input/safe-area/fullscreen events cleanly deferred instead of spuriously advancing simulation.
36 #[get(type(copy))]
37 pub(crate) deferred_non_vsync_events: u64,
38 /// Total VSyncs skipped solely due to an explicit user FPS cap below display refresh rate.
39 #[get(type(copy))]
40 pub(crate) user_cap_skips: u64,
41 /// Total VSyncs deferred due to bounded in-flight frame backpressure.
42 #[get(type(copy))]
43 pub(crate) in_flight_waits: u64,
44 /// Estimated missed VSync intervals where consecutive timestamps exceeded `1.5x` the nominal period.
45 #[get(type(copy))]
46 pub(crate) missed_vsync_intervals: u64,
47 /// Number of clock time-base rebases (resume or display refresh mode switches).
48 #[get(type(copy))]
49 pub(crate) timebase_rebases: u64,
50}
51
52/// Unified single-source frame pacing controller eliminating double-gating and preventing non-VSync events from advancing game time.
53#[derive(Clone, Copy, Data, Debug, PartialEq)]
54pub struct FramePacingController {
55 /// Active hardware display refresh rate in Hertz (e.g. `60.0`, `120.0`, `144.0`, `240.0`).
56 #[get(type(copy))]
57 pub(crate) display_hz: f32,
58 /// Whether the platform present/VSync loop already paces frames natively (disables redundant software sleep/skip gates).
59 #[get(type(copy))]
60 pub(crate) native_vsync_active: bool,
61 /// Optional explicit user FPS cap (`None` = run at full display refresh rate).
62 #[get(skip)]
63 pub(crate) user_fps_cap: Option<u32>,
64 /// Maximum allowed concurrent in-flight frames (`1..=4`).
65 #[get(type(copy))]
66 pub(crate) max_in_flight_frames: u32,
67 /// Currently submitted frames awaiting present/fence completion.
68 #[get(type(copy))]
69 pub(crate) in_flight_frames: u32,
70 /// Last VSync monotonic timestamp in nanoseconds (`0` before first VSync or after rebase).
71 #[get(type(copy))]
72 pub(crate) last_vsync_ns: u64,
73 /// Last presented frame monotonic timestamp in nanoseconds for explicit user cap pacing.
74 #[get(type(copy))]
75 pub(crate) last_present_ns: u64,
76 /// Monotonic timestamp of the earliest unpresented input event (`0` when no input is pending).
77 #[get(type(copy))]
78 pub(crate) oldest_pending_input_ns: u64,
79 /// Whether a non-VSync input event marked the viewport dirty for the next VSync.
80 #[get(type(copy))]
81 pub(crate) pending_input_dirty: bool,
82 /// Whether a safe-area or fullscreen transition marked layout dirty for the next VSync.
83 #[get(type(copy))]
84 pub(crate) pending_layout_dirty: bool,
85 /// Cumulative pacing telemetry counters.
86 #[get(type(copy))]
87 pub(crate) stats: FramePacingStats,
88}