feat(graphics): migrate native target to 640x360
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
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.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
//! 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(())
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
//! GPU readback qualification of the actual host blit, not a software geometry mirror.
|
||||
#[path = "../src/presentation_blit.rs"]
|
||||
mod presentation_blit;
|
||||
#[path = "../src/viewport.rs"]
|
||||
mod viewport;
|
||||
use pixels::{PixelsBuilder, SurfaceTexture, wgpu};
|
||||
use winit::{
|
||||
application::ApplicationHandler,
|
||||
event_loop::{ActiveEventLoop, EventLoop},
|
||||
window::Window,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
struct Probe;
|
||||
impl ApplicationHandler for Probe {
|
||||
fn resumed(&mut self, events: &ActiveEventLoop) {
|
||||
let window = Box::leak(Box::new(
|
||||
events
|
||||
.create_window(
|
||||
Window::default_attributes()
|
||||
.with_title("PROMETEU graphics qualification")
|
||||
.with_inner_size(winit::dpi::PhysicalSize::new(640, 360)),
|
||||
)
|
||||
.unwrap(),
|
||||
));
|
||||
let size = window.inner_size();
|
||||
let mut pixels =
|
||||
PixelsBuilder::new(640, 360, SurfaceTexture::new(size.width, size.height, &*window))
|
||||
.build()
|
||||
.unwrap();
|
||||
for (i, p) in pixels.frame_mut().as_chunks_mut::<4>().0.iter_mut().enumerate() {
|
||||
let (x, y) = (i % 640, i / 640);
|
||||
// Single-pixel checkerboard detects smoothing; all channels equal avoid channel-order ambiguity.
|
||||
let value = if (x + y) % 2 == 0 { 255 } else { 0 };
|
||||
p.copy_from_slice(&[value, value, value, 255]);
|
||||
}
|
||||
// Exercise real surface acquisition/upload/shader validation too.
|
||||
let blit = presentation_blit::PresentationBlit::new(&pixels);
|
||||
pixels
|
||||
.render_with(|e, t, _| {
|
||||
blit.render(
|
||||
e,
|
||||
t,
|
||||
viewport::Viewport::new((size.width, size.height), (640, 360)).unwrap(),
|
||||
);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let ctx = pixels.context();
|
||||
// A newly created macOS surface may be occluded: render_with then returns
|
||||
// without uploading. Offscreen verification must establish its own input.
|
||||
ctx.queue.write_texture(
|
||||
wgpu::TexelCopyTextureInfo {
|
||||
texture: &ctx.texture,
|
||||
mip_level: 0,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
pixels.frame(),
|
||||
wgpu::TexelCopyBufferLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(640 * 4),
|
||||
rows_per_image: Some(360),
|
||||
},
|
||||
ctx.texture_extent,
|
||||
);
|
||||
for (w, h) in [(1280u32, 720u32), (1000, 700), (320, 240), (641, 361)] {
|
||||
let view = viewport::Viewport::new((w, h), (640, 360)).unwrap();
|
||||
let texture = ctx.device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("blit-readback"),
|
||||
size: wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 },
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: pixels.render_texture_format(),
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_SRC,
|
||||
view_formats: &[],
|
||||
});
|
||||
let stride = (w * 4).div_ceil(256) * 256;
|
||||
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("readback"),
|
||||
size: u64::from(stride) * u64::from(h),
|
||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::MAP_READ,
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
let mut encoder = ctx.device.create_command_encoder(&Default::default());
|
||||
blit.render(&mut encoder, &texture.create_view(&Default::default()), view);
|
||||
encoder.copy_texture_to_buffer(
|
||||
wgpu::TexelCopyTextureInfo {
|
||||
texture: &texture,
|
||||
mip_level: 0,
|
||||
origin: wgpu::Origin3d::ZERO,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
},
|
||||
wgpu::TexelCopyBufferInfo {
|
||||
buffer: &buffer,
|
||||
layout: wgpu::TexelCopyBufferLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(stride),
|
||||
rows_per_image: Some(h),
|
||||
},
|
||||
},
|
||||
wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 },
|
||||
);
|
||||
ctx.queue.submit([encoder.finish()]);
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
buffer.slice(..).map_async(wgpu::MapMode::Read, move |result| tx.send(result).unwrap());
|
||||
ctx.device.poll(wgpu::PollType::wait_indefinitely()).unwrap();
|
||||
rx.recv().unwrap().unwrap();
|
||||
let data = buffer.slice(..).get_mapped_range();
|
||||
let mut checked = 0;
|
||||
for y in 0..h {
|
||||
for x in 0..w {
|
||||
let offset = (y * stride + x * 4) as usize;
|
||||
let rgb = &data[offset..offset + 3];
|
||||
// Every output pixel is black or white: any intermediate value means smoothing.
|
||||
assert!(
|
||||
rgb == [0, 0, 0] || rgb == [255, 255, 255],
|
||||
"filtered pixel at {w}x{h}:({x},{y})={rgb:?}"
|
||||
);
|
||||
if let Some((nx, ny)) = view.inverse(x as f64 + 0.5, y as f64 + 0.5) {
|
||||
let expected = if (nx + ny) % 2 == 0 { 255 } else { 0 };
|
||||
assert_eq!(
|
||||
rgb, [expected; 3],
|
||||
"GPU/input transform mismatch at {w}x{h}:({x},{y})"
|
||||
);
|
||||
checked += 1;
|
||||
} else {
|
||||
assert_eq!(rgb, [0, 0, 0], "bar");
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(checked > 0);
|
||||
println!("GPU_NEAREST_PASS={w}x{h} checked={checked}");
|
||||
}
|
||||
events.exit();
|
||||
}
|
||||
fn window_event(
|
||||
&mut self,
|
||||
_: &ActiveEventLoop,
|
||||
_: winit::window::WindowId,
|
||||
_: winit::event::WindowEvent,
|
||||
) {
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
EventLoop::new().unwrap().run_app(&mut Probe).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user