Files
prometeu-runtime/crates/host/prometeu-host-desktop-winit/examples/desktop_measure.rs
T
bquarkz a32f834b2b
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
feat(graphics): migrate native target to 640x360
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.
2026-11-20 10:34:45 +00:00

90 lines
3.3 KiB
Rust

//! Bounded run of the production desktop host, with normal teardown for metrics.
//! No machine timing or rendering loop is replaced by this measurement harness.
use prometeu_host_desktop_winit::{audio, fs_backend, log_sink, stats, utilities, wall_clock};
#[allow(dead_code)]
#[path = "../src/debugger.rs"]
mod debugger;
#[path = "../src/input.rs"]
mod input;
#[path = "../src/presentation_blit.rs"]
mod presentation_blit;
#[allow(dead_code)]
#[path = "../src/studio/mod.rs"]
mod studio;
#[path = "../src/viewport.rs"]
mod viewport;
// Compile the actual host implementation; its non-desktop entry points are unused
// by this executable. Keep measurement access out of the product's public API.
#[allow(dead_code)]
mod runner {
include!("../src/runner.rs");
impl HostRunner {
pub(super) fn measured_state(&mut self) -> serde_json::Value {
serde_json::json!({
"host_vm_ticks": self.firmware.os.vm().tick_index(),
"completed_vm_frames": self.firmware.os.vm().completed_logical_frames(),
"logical_frame_index": self.firmware.os.vm().logical_frame_index(),
"synchronous_publications": self.firmware.os.vm().telemetry_snapshot().presented_frames,
"front_buffer_publications": self.hardware.gfx.publication_count(),
"physical_display_hz": null,
})
}
}
}
use std::time::{Duration, Instant};
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{ActiveEventLoop, EventLoop},
window::WindowId,
};
struct Measure {
runner: runner::HostRunner,
started: Option<Instant>,
duration: Duration,
}
impl ApplicationHandler for Measure {
fn resumed(&mut self, events: &ActiveEventLoop) {
self.runner.resumed(events);
self.started = Some(Instant::now());
}
fn window_event(&mut self, events: &ActiveEventLoop, id: WindowId, event: WindowEvent) {
self.runner.window_event(events, id, event);
}
fn about_to_wait(&mut self, events: &ActiveEventLoop) {
if self.started.is_some_and(|start| start.elapsed() >= self.duration) {
events.exit();
} else {
self.runner.about_to_wait(events);
}
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = std::env::args().nth(1).expect("cartridge directory");
let seconds: u64 = std::env::args().nth(2).map(|s| s.parse().expect("seconds")).unwrap_or(10);
assert!(seconds > 0);
let mut runner = runner::HostRunner::new(None, None);
runner.set_boot_target(prometeu_firmware::BootTarget::Cartridge {
path,
debug: false,
debug_port: 0,
});
let mut app = Measure { runner, started: None, duration: Duration::from_secs(seconds) };
let mut events = EventLoop::builder();
#[cfg(target_os = "macos")]
{
use winit::platform::macos::EventLoopBuilderExtMacOS;
events.with_activate_ignoring_other_apps(true);
}
events.build()?.run_app(&mut app)?;
println!(
"{}",
serde_json::json!({"schema":1,"source":"production_desktop_host",
"elapsed_seconds":app.started.map(|s|s.elapsed().as_secs_f64()),
"state":app.runner.measured_state(),
"limitation":"includes boot, no discarded warmup; host/API submission is not physical scanout"})
);
Ok(())
}