Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Centralize the fixed 640x360 RGBA8888/60 Hz contract in the existing HAL. Preserve 8/16/32 tiles and composition, cover partial edges and mixed-size camera movement, and adapt firmware, fixtures, hosts and native tests. Share nearest-neighbor presentation geometry with pointer input. Measure actual framebuffer publications and successful host presentations separately from VM ticks, with bounded opt-in diagnostics and release harnesses. Validated with the complete tooling verify gate, native rendering tests, GPU readback, headless/process integration, formatting and strict clippy. The existing synchronous session path is documented; no worker/session architecture replacement or format compatibility layer is introduced. Work: WRK-0016 / DEC-0001 / PLN-0001 Commit and push explicitly authorized by the user after completion.
57 lines
2.5 KiB
Rust
57 lines
2.5 KiB
Rust
//! Unpaced logical-frame and capture timing through the real headless host.
|
|
use prometeu_host_headless::{AdvanceFrameOutcome, HeadlessHost};
|
|
use std::time::Instant;
|
|
|
|
fn stats(mut times: Vec<u64>) -> serde_json::Value {
|
|
times.sort_unstable();
|
|
let n = times.len();
|
|
serde_json::json!({"mean_us":times.iter().sum::<u64>() as f64/n as f64/1000.0,
|
|
"p95_us":times[(n*95).div_ceil(100)-1] as f64/1000.0,
|
|
"p99_us":times[(n*99).div_ceil(100)-1] as f64/1000.0,
|
|
"max_us":times[n-1] as f64/1000.0,
|
|
"over_60hz_budget":times.iter().filter(|&&t|t>1_000_000_000/60).count()})
|
|
}
|
|
fn main() {
|
|
let mut args = std::env::args().skip(1);
|
|
let cartridge = args.next().expect("cartridge directory");
|
|
let count: usize = args.next().map(|s| s.parse().expect("frame count")).unwrap_or(600);
|
|
assert!(count > 0);
|
|
let mut host = HeadlessHost::new();
|
|
host.boot(cartridge).expect("boot");
|
|
let mut advance = Vec::with_capacity(count);
|
|
let mut capture = Vec::with_capacity(count);
|
|
let mut previous = None;
|
|
let mut published = 0;
|
|
let mut checksum = 0;
|
|
for i in 0..count + 120 {
|
|
let start = Instant::now();
|
|
assert!(matches!(
|
|
host.advance_frame().expect("advance"),
|
|
AdvanceFrameOutcome::FrameCompleted { .. }
|
|
));
|
|
let elapsed = start.elapsed().as_nanos() as u64;
|
|
let start = Instant::now();
|
|
let frame = host.capture_frame().expect("published frame").frame;
|
|
let capture_ns = start.elapsed().as_nanos() as u64;
|
|
assert_eq!((frame.width, frame.height, frame.stride_pixels), (640, 360, 640));
|
|
assert_ne!(previous, Some((frame.ownership, frame.frame_id)));
|
|
previous = Some((frame.ownership, frame.frame_id));
|
|
checksum ^= frame.pixels[(i * 173) % frame.pixels.len()];
|
|
if i >= 120 {
|
|
advance.push(elapsed);
|
|
capture.push(capture_ns);
|
|
published += 1;
|
|
}
|
|
}
|
|
let state = host.get_state();
|
|
println!(
|
|
"{}",
|
|
serde_json::json!({"schema":1,"width":640,"height":360,"frames":count,"warmup_frames":120,
|
|
"completed_logical_frames_total":state.frame_index,"host_ticks_total":state.tick_index,
|
|
"published_frames_measured":published,"repeated_publications_measured":0,
|
|
"advance_including_vm_render_publish":stats(advance),"owned_capture":stats(capture),"checksum":checksum,
|
|
"vm_hz":null,"physical_display_hz":null,
|
|
"limitations":"unpaced real VM/headless; capture copies owned pixels; no GPU, realtime cadence or physical display"})
|
|
);
|
|
}
|