diff --git a/bench/at-3d/check.sh b/bench/at-3d/check.sh index ea4aa41c..7fe51770 100755 --- a/bench/at-3d/check.sh +++ b/bench/at-3d/check.sh @@ -2,7 +2,8 @@ # #26: a 3D composition's --at frames step only themselves and their neighbours, and draw as the whole timeline stepped # draws them. scene.tsx (360 frames) is drawn at four frames with --at and must report the sparse stepping ("N of M # frames stepped"); frozen.tsx draws the same four frames as a 4-frame composition (each the scene under , so -# its rows come from stepping every frame), and each pair must be pixel-identical. Exits 1 on a failure. +# its rows come from stepping every frame), and each pair must be pixel-identical; its --manifest must list the four +# frames. Exits 1 on a failure. # bench/at-3d/check.sh (RAEA_BIN: the raea to run, default target/release/raea) cd "$(dirname "$0")/../.." || exit 2 BIN=${RAEA_BIN:-$PWD/target/release/raea} @@ -10,11 +11,14 @@ BIN=${RAEA_BIN:-$PWD/target/release/raea} export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0 OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-at-3d.XXXXXX") trap 'rm -rf "$OUT"' EXIT -RAEA_STARTUP_TRACE=1 "$BIN" render bench/at-3d/scene.tsx --at 30,150,270,330 -o "$OUT/at" > "$OUT/at.log" 2>&1 || { echo "FAIL: the --at render failed"; tail -5 "$OUT/at.log"; exit 1; } +RAEA_STARTUP_TRACE=1 "$BIN" render bench/at-3d/scene.tsx --at 30,150,270,330 -o "$OUT/at" --manifest "$OUT/at.json" > "$OUT/at.log" 2>&1 || { echo "FAIL: the --at render failed"; tail -5 "$OUT/at.log"; exit 1; } "$BIN" render bench/at-3d/frozen.tsx -o "$OUT/frozen" > "$OUT/frozen.log" 2>&1 || { echo "FAIL: the frozen render failed"; tail -5 "$OUT/frozen.log"; exit 1; } status=0 stepped=$(grep -o "[0-9]* of [0-9]* frames stepped" "$OUT/at.log") [ "$stepped" = "12 of 332 frames stepped" ] || { echo "FAIL: the --at render stepped '${stepped:-every frame}', not 12 of 332"; status=1; } +# --manifest: written for 3D frames too, one entry a frame drawn (#28: a 3D still or --at wrote none) +n=$(python3 -c 'import json,sys;print(len(json.load(open(sys.argv[1]))["frames"]))' "$OUT/at.json" 2>/dev/null) +[ "$n" = 4 ] || { echo "FAIL: the --at render's manifest has ${n:-no} frames, not 4"; status=1; } for k in 0 1 2 3; do f=$(printf 'frame-%05d.png' $k) d=$(magick compare -metric AE "$OUT/at/$f" "$OUT/frozen/$f" null: 2>&1 | cut -d' ' -f1) diff --git a/runtime/export/src/fed.rs b/runtime/export/src/fed.rs index c77da7a1..d232e252 100644 --- a/runtime/export/src/fed.rs +++ b/runtime/export/src/fed.rs @@ -306,9 +306,7 @@ pub(crate) fn render_fed(app: &mut App, js: &Path, w: u32, h: u32, fps: f64, tot // 3D parts passing through each other on screen: on stderr, and in the manifest for the legacy app's checks let found = FED_CLIPPING.lock().unwrap().take().and_then(|t| t.join().ok()); let clipping = found.unwrap_or_else(|| scene::told(&frames.borrow(), w, h, fps)); - if let (Some(path), Some(frames_seen)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) { - std::fs::write(&path, json!({"width": w, "height": h, "fps": fps, "frames": frames_seen, "clipping": clipping, "sounds": heard(&frames.borrow(), ¬es.borrow(), &cx, fps)}).to_string()).map_err(|e| format!("{}: {e}", path.display()))?; - } + write_manifest(cx, (w, h, fps), clipping, |cx| heard(&frames.borrow(), ¬es.borrow(), cx, fps))?; let ms = t0.elapsed().as_secs_f64() * 1e3 / n.max(1) as f64; Ok(format!("APPLIED {n} frames rendered to {} ({ms:.1} ms a frame, pages handed to raea-render on the GPU)", out.display())) } diff --git a/runtime/export/src/lib.rs b/runtime/export/src/lib.rs index aaa82f6a..08b3e129 100644 --- a/runtime/export/src/lib.rs +++ b/runtime/export/src/lib.rs @@ -29,7 +29,6 @@ use serde_json::{Map, Value, json}; pub(crate) use raea_runtime_react::scene::*; pub(crate) use raea_runtime_react::{ReactKind, ReactOutbox, ReactPlugin, ReactProps}; -mod scene3d; mod bevy_frame; use bevy_frame::*; mod pages; @@ -67,6 +66,13 @@ pub(crate) struct Sound { /// `render --manifest PATH` (the CLI's; render_bundle keeps its signature for the iPhone): where render.json goes. static MANIFEST: std::sync::Mutex> = std::sync::Mutex::new(None); +/// With --manifest, its file: the frames' boxes as drawn (Ctx.manifest), the 3D's clipping and the sounds heard. +fn write_manifest(cx: &mut Ctx, (w, h, fps): (u32, u32, f64), clipping: Vec, heard: impl FnOnce(&Ctx) -> Value) -> R<()> { + let (Some(path), Some(frames)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) else { return Ok(()) }; + let m = json!({"width": w, "height": h, "fps": fps, "frames": frames, "clipping": clipping, "sounds": heard(cx)}); + std::fs::write(&path, m.to_string()).map_err(|e| format!("{}: {e}", path.display())) +} + /// `render --stage WxH`: a responsive composition (one that lays out from useVideoConfig) laid out at a stage's size, as /// the legacy app's stage plays it (live.rs open), so a game's render can be checked against its frames at its own size. static STAGE: std::sync::Mutex> = std::sync::Mutex::new(None); diff --git a/runtime/export/src/program.rs b/runtime/export/src/program.rs index 878cea1e..52550f39 100644 --- a/runtime/export/src/program.rs +++ b/runtime/export/src/program.rs @@ -36,8 +36,8 @@ pub(crate) fn program(frames: &[(i64, Frame)], w: u32, h: u32, fps: f64) -> raea } } if has3d { - // where it is and looks, frame by frame; its lens, ambient light and post-processing (scene3d) - scene3d::camera(frames, &mut p, &mut cam); + // where it is and looks, frame by frame; its lens, ambient light and post-processing (raea-runtime-scene) + raea_runtime_scene::camera(&scene::all_items(frames), &mut p, &mut cam); } p.spawns.push(("camera".into(), vec![cam])); // the pages: each distinct page shown for the frames in a row it's the same @@ -123,8 +123,8 @@ pub(crate) fn program(frames: &[(i64, Frame)], w: u32, h: u32, fps: f64) -> raea p.spawns.push(("master".into(), vec![row("mix", vec![("lufs", V::N(lufs)), ("ceiling", V::N(ceiling))])])); } if has3d { - // lights, meshes, models and pictures in space, matched across frames by identity (scene3d) - scene3d::rows(frames, &mut p); + // lights, meshes, models and pictures in space, matched across frames by identity (raea-runtime-scene) + raea_runtime_scene::rows(&scene::all_items(frames), &mut p); } p } diff --git a/runtime/export/src/render.rs b/runtime/export/src/render.rs index 1a9368ec..ae6e5af1 100644 --- a/runtime/export/src/render.rs +++ b/runtime/export/src/render.rs @@ -283,9 +283,9 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti write_aov(out, i, cx.scene3d.as_mut())?; } } - if let Some(t) = FED_CLIPPING.lock().unwrap().take() { - let _ = t.join(); - } + // with --manifest, its file as a 2D render writes it (it wrote none, and an older one stayed looking current, #28) + let clipping = FED_CLIPPING.lock().unwrap().take().and_then(|t| t.join().ok()).unwrap_or_default(); + write_manifest(&mut cx, (w, h, fps), clipping, |_| json!([]))?; return Ok(if folder { format!("APPLIED {} frames rendered to {} (bevy_ui, the page over its 3D)", wanted.len(), out.display()) } else { @@ -340,9 +340,7 @@ pub(crate) fn render_bundle_with(js: &Path, dir: &Path, out: &Path, wanted: Opti drop(app); // 3D parts passing through each other on screen: on stderr, and in the manifest for the legacy app's checks let clipping = scene::told(&frames, w, h, fps); - if let (Some(path), Some(frames_seen)) = (MANIFEST.lock().unwrap().clone(), cx.manifest.take()) { - std::fs::write(&path, json!({"width": w, "height": h, "fps": fps, "frames": frames_seen, "clipping": clipping, "sounds": heard(&frames, &tones, &cx, fps)}).to_string()).map_err(|e| format!("{}: {e}", path.display()))?; - } + write_manifest(&mut cx, (w, h, fps), clipping, |cx| heard(&frames, &tones, cx, fps))?; let ext = out_ext(out); // raea-render's IR built directly from the frames and drawn by raea-render (checked equal to the retired rrl's compile of the same diff --git a/runtime/export/src/review.rs b/runtime/export/src/review.rs index 802cab0d..66b75eda 100644 --- a/runtime/export/src/review.rs +++ b/runtime/export/src/review.rs @@ -6,7 +6,7 @@ //! the cameras, each tile's place on the sheets and its exposure, and what the exposure found. use super::*; -use crate::scene3d::items; +use crate::scene::items; use raea_core_review::{TILE_W, VIEWS, boxes_of, cameras, ceiling, inside, parts_box, passed, whole}; pub fn review(args: &[String], dir_out: &Path) -> R { diff --git a/runtime/export/src/scene.rs b/runtime/export/src/scene.rs index 660e8ffe..51a70e13 100644 --- a/runtime/export/src/scene.rs +++ b/runtime/export/src/scene.rs @@ -4,9 +4,18 @@ use serde_json::{Value, json}; -use super::scene3d::{all_items, items}; use super::{Frame, bundle_composition, comp_opts, flag, scene_frames_to}; +/// A frame's 3D walked into its parts (raea-runtime-scene). +pub(crate) fn items(f: &Frame) -> Vec { + raea_runtime_scene::items_of(&f.scene) +} + +/// Each frame's items, walked once (a frame's tree was walked again for each kind of part: 11 times a live frame) +pub(crate) fn all_items(frames: &[(i64, Frame)]) -> Vec> { + frames.iter().map(|(_, f)| items(f)).collect() +} + /// raea_sys_contact::told on a render's frames: the parts that clip where the camera sees them, said on stderr /// (RAEA_CLIP_CHECK=0 skips it). pub(crate) fn told(frames: &[(i64, Frame)], w: u32, h: u32, fps: f64) -> Vec { diff --git a/runtime/export/src/scene3d.rs b/runtime/export/src/scene3d.rs deleted file mode 100644 index ada8434c..00000000 --- a/runtime/export/src/scene3d.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! A composition's frames handed to raea-runtime-scene: each frame's 3D walked into its parts once, and the camera's -//! and parts' rows made from them. - -use std::collections::BTreeMap; - -use raea_core_program::ir::{Program, V}; -use raea_core_scene::Item; -use super::Frame; - -pub(crate) fn items(f: &Frame) -> Vec { - raea_runtime_scene::items_of(&f.scene) -} - -/// Each frame's items, walked once (a frame's tree was walked again for each kind of part: 11 times a live frame) -pub(crate) fn all_items(frames: &[(i64, Frame)]) -> Vec> { - frames.iter().map(|(_, f)| items(f)).collect() -} - -/// The camera row's 3D columns: where it is and looks (keyed), its lens, the ambient light, the post-processing. -pub(crate) fn camera(frames: &[(i64, Frame)], p: &mut Program, row: &mut BTreeMap) { - raea_runtime_scene::camera(&all_items(frames), p, row) -} - -/// The lights, meshes, models and pictures in space, as rows. -pub(crate) fn rows(frames: &[(i64, Frame)], p: &mut Program) { - raea_runtime_scene::rows(&all_items(frames), p) -}