Frame interval and refresh overrides, live key input for test drives
VICTORY_FRAME_INTERVAL_US paces frames at another interval than the title asks (it asks 33.333 ms); VICTORY_DISPLAY_REFRESH adds a refresh rate above 60 Hz to the display mode list. VICTORY_KEYS_FILE lets a driver script press the stand-in pad's buttons while the title runs. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
1 parent
545f89019e
commit
2f0fbe147a
3 files changed
+189
-42
No files matched your search
@@ -39,6 +39,25 @@ fn clock() -> std::sync::MutexGuard<'static, Option<Clock>> {
|
||||
CLOCK.lock().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
/// `VICTORY_FRAME_INTERVAL_US=<n>`: frames begin every `n` microseconds
|
||||
/// whatever interval the title sets (16667: 60 a second, 8333: 120, 1000:
|
||||
/// as fast as frames are made). The title sets 33,333 us (30 a second)
|
||||
/// against the 60 Hz mode it is offered; it times its own frames with the
|
||||
/// performance counter, so a shorter interval is a higher frame rate, not a
|
||||
/// faster game. Values outside 1,000..=1,000,000 are ignored.
|
||||
fn interval_override() -> Option<Duration> {
|
||||
static OVERRIDE: std::sync::OnceLock<Option<Duration>> = std::sync::OnceLock::new();
|
||||
*OVERRIDE.get_or_init(|| {
|
||||
let us = std::env::var("VICTORY_FRAME_INTERVAL_US").ok()?.trim().parse::<u64>().ok()?;
|
||||
let interval = (1_000..=1_000_000).contains(&us).then(|| Duration::from_micros(us));
|
||||
match interval {
|
||||
Some(interval) => tracing::info!(?interval, "VICTORY_FRAME_INTERVAL_US: frame interval overridden"),
|
||||
None => tracing::warn!(us, "VICTORY_FRAME_INTERVAL_US outside 1000..=1000000: ignored"),
|
||||
}
|
||||
interval
|
||||
})
|
||||
}
|
||||
|
||||
/// Device method: a frame every `length` microseconds. The period is how
|
||||
/// many intervals a frame may take to reach the display (pipeline depth),
|
||||
/// not part of the rate.
|
||||
@@ -46,14 +65,15 @@ pub(crate) extern "system" fn set_interval(
|
||||
_: This,
|
||||
_output: This,
|
||||
length: u32,
|
||||
_period: u32,
|
||||
_flags: u32,
|
||||
period: u32,
|
||||
flags: u32,
|
||||
) -> HRESULT {
|
||||
let interval = match length {
|
||||
let asked = match length {
|
||||
0 => SIXTIETH,
|
||||
us => Duration::from_micros(u64::from(us)),
|
||||
};
|
||||
tracing::info!(?interval, "frame interval");
|
||||
let interval = interval_override().unwrap_or(asked);
|
||||
tracing::info!(?asked, ?interval, period, flags, "frame interval");
|
||||
// A new interval starts from now, after the last tick handed out.
|
||||
let first = LAST
|
||||
.iter()
|
||||
@@ -105,7 +125,7 @@ fn next_tick(kind: u32) -> (u64, Duration) {
|
||||
let mut clock = clock();
|
||||
let c = clock.get_or_insert_with(|| Clock {
|
||||
start: Instant::now(),
|
||||
interval: SIXTIETH,
|
||||
interval: interval_override().unwrap_or(SIXTIETH),
|
||||
first: 0,
|
||||
});
|
||||
let elapsed = c.start.elapsed().as_nanos();
|
||||
|
||||
Reference in new issue
Block a user