Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

NB2a: debug views as channels with values; messages that told an author to run cargo

shinyobjectze9909de88fa3
diff --git a/Cargo.lock b/Cargo.lock
index 86bae347..0ae92aae 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -15366,6 +15366,7 @@ dependencies = [
"miniz_oxide 0.8.9",
"objc2 0.6.5",
"raea-io-home",
+ "raea-io-trace",
"rquickjs",
]
@@ -15788,6 +15789,7 @@ dependencies = [
"bevy",
"indexmap",
"raea-core-program",
+ "raea-io-trace",
"raea-sys-frame",
"raea-sys-rt",
"serde_json",
@@ -16157,6 +16159,7 @@ name = "raea-sys-lod"
version = "0.1.0"
dependencies = [
"bevy",
+ "raea-io-trace",
"raea-sys-frame",
]
@@ -16192,6 +16195,7 @@ dependencies = [
"raea-core-program",
"raea-core-shape",
"raea-io-net",
+ "raea-io-trace",
"raea-sys-frame",
"raea-sys-mesh",
"raea-sys-sampler",
@@ -16462,6 +16466,7 @@ dependencies = [
"ort",
"raea-io-home",
"raea-io-media",
+ "raea-io-trace",
"raea-sys-vision",
"serde_json",
]
@@ -16596,6 +16601,7 @@ version = "0.1.0"
dependencies = [
"bevy",
"raea-core-program",
+ "raea-io-trace",
"raea-sys-frame",
"serde_json",
]
diff --git a/apps/game/src/export.rs b/apps/game/src/export.rs
index 6e34c362..39e78d64 100644
--- a/apps/game/src/export.rs
+++ b/apps/game/src/export.rs
@@ -74,11 +74,11 @@ pub fn export(args: &[String]) -> R<String> {
}
};
if !player.exists() {
- return Err(format!("no player at {} (build it: cargo build --profile game -p raea-app-game --bin raea-game --features player)", player.display()));
+ return Err(format!("no game player at {}: this raea ships without raea-game, which a game's export is made from; `raea bug \"export-game: no player\"` asks for it (docs/nobuild.feature NB3a)", player.display()));
}
// the release build's player is ~128 MB stripped, the game profile's ~74 MB (fat LTO, one codegen unit; lightspeed
- // R7): say so when the bigger one ships because it's the newer
- if !player.to_string_lossy().contains("/game/") && flag(args, "--player").is_none() {
+ // R7): say so when the bigger one ships because it's the newer, to a checkout's build (an installed raea has only its own)
+ if !player.to_string_lossy().contains("/game/") && player.to_string_lossy().contains("/target/") && flag(args, "--player").is_none() {
let mb = std::fs::metadata(&player).map(|m| m.len() as f64 / 1048576.0).unwrap_or(0.0);
eprintln!("raea export-game: shipping the release build's player ({mb:.0} MB before stripping): `cargo build --profile game -p raea-app-game --bin raea-game --features player` makes the ~74 MB one, which ships when it's the newer");
}
diff --git a/apps/tools/src/song.rs b/apps/tools/src/song.rs
index 91d00659..b2b89a8e 100644
--- a/apps/tools/src/song.rs
+++ b/apps/tools/src/song.rs
@@ -56,7 +56,7 @@ pub fn song(args: &[String]) -> R<String> {
}
let bin = raea_io_assets::perceive_bin();
if !bin.is_file() {
- return Err("song: the map is made by raea-perceive, which isn't installed beside raea. Update raea (`curl -fsSL https://raea.io/install | sh`: releases ship it in ~/.raea/bin), or from a checkout `cargo build --release -p raea-perceive`, or point RAEA_PERCEIVE at one".into());
+ return Err("song: the map is made by raea-perceive, which isn't installed beside raea. Update raea (`curl -fsSL https://raea.io/install | sh`: releases ship it in ~/.raea/bin), or point RAEA_PERCEIVE at one".into());
}
// its beat model (Beat This!, MIT): an install keeps it in share/raea/models; raea-perceive reads it from
// raea_io_home::models() (~/.local/share/raea-models; %LOCALAPPDATA%\raea\models on Windows)
diff --git a/docs/manual/reference/cli/traces.md b/docs/manual/reference/cli/traces.md
index 667cf8ea..d72c2040 100644
--- a/docs/manual/reference/cli/traces.md
+++ b/docs/manual/reference/cli/traces.md
@@ -32,6 +32,13 @@ switches, named without `RAEA_` and in lower case: `bake_trace`, `seedling_trace
itself still works and overrides the composition, and `RAEA_STATS=bevy_passes,trace` chooses channels for a run without
touching the file.
+Debug views are channels too, and a view that takes a value takes it after `=`:
+
+```tsx
+native("stats.on", { channels: ["pass=depth"] }); // the depth pass instead of the picture (or normal, albedo, sun, sky)
+native("stats.on", { channels: ["lod_debug", "fog_debug", "volume_debug"] });
+```
+
While the run goes, `native("stats.read", {})` gives what it has measured so far: each timed pass's runs and its mean
and worst milliseconds, and the counters (`engine/draws`, `engine/updates`; two updates a draw means each frame was
drawn twice). A render works out its frames ahead of the engine, so a frame's code can read the totals from before that
diff --git a/io/assets/src/lib.rs b/io/assets/src/lib.rs
index 7dd3f151..b3adbeb1 100644
--- a/io/assets/src/lib.rs
+++ b/io/assets/src/lib.rs
@@ -310,7 +310,7 @@ impl Store {
cmd.args([format!("--{k}"), params[k].as_f64().unwrap_or(0.0).to_string()]);
}
if let J::Array(b) = &params["subject"] {
- let bin = Some(perceive_bin()).filter(|b| b.exists()).ok_or("matchmove: a subject is tracked by raea-perceive (EdgeTAM), not found: build it with `cargo build --release -p raea-perceive` or set RAEA_PERCEIVE")?;
+ let bin = Some(perceive_bin()).filter(|b| b.exists()).ok_or("matchmove: a subject is tracked by raea-perceive (EdgeTAM), not found beside raea: update raea (`curl -fsSL https://raea.io/install | sh`: releases ship it in ~/.raea/bin), or set RAEA_PERCEIVE")?;
cmd.args(["--subject", &b.iter().map(|v| v.as_f64().unwrap_or(0.0).to_string()).collect::<Vec<_>>().join(",")]).arg("--perceive").arg(bin);
}
// its progress on stderr: stdout is the caller's answer
diff --git a/io/trace/src/lib.rs b/io/trace/src/lib.rs
index c72310a8..55a1f286 100644
--- a/io/trace/src/lib.rs
+++ b/io/trace/src/lib.rs
@@ -30,7 +30,7 @@ mod stats;
use crash::*;
pub use look::{sessions, status, summarize};
-pub use stats::{choose as choose_stats, chosen as chosen_stats, count, pass_ms, stat, stats, table as stats_table};
+pub use stats::{choose as choose_stats, chosen as chosen_stats, count, pass_ms, stat, stat_value, stats, table as stats_table};
struct Session {
dir: PathBuf,
diff --git a/io/trace/src/stats.rs b/io/trace/src/stats.rs
index b0fa6c67..bc5b2280 100644
--- a/io/trace/src/stats.rs
+++ b/io/trace/src/stats.rs
@@ -7,7 +7,8 @@
//! (each of Bevy's render passes timed) `bevy_passes`. It's on when the run's TypeScript chose it
//! (`native("stats.on", { channels: [...] })` at a composition's top level, which runs before the Engine opens), when
//! RAEA_STATS lists it (`RAEA_STATS=bevy_passes,bake_trace`, or `all`), or when its own variable is set (not to 0), the
-//! override.
+//! override. A debug view that takes a value takes it the same way: `pass=depth` chooses RAEA_PASS's depth pass, and a
+//! channel chosen bare carries "1".
use serde_json::{json, Value};
use std::collections::BTreeMap;
@@ -44,20 +45,37 @@ pub fn stat(var: &str) -> bool {
return v != "0";
}
let name = var.trim_start_matches("RAEA_");
- let on = |c: &Vec<String>| c.iter().any(|n| n == "all" || n.eq_ignore_ascii_case(name));
+ let on = |c: &Vec<String>| c.iter().any(|n| n == "all" || n.split('=').next().is_some_and(|n| n.eq_ignore_ascii_case(name)));
match CHOSEN.read().ok().and_then(|c| c.as_ref().map(on)) {
Some(o) => o,
None => on(&chosen()),
}
}
-/// Channels turned on for the rest of this run (`stats.on`); a name is a RAEA_ variable's without RAEA_, or `all`.
+/// The value the channel of the variable `var` carries: the variable's own (the override), else the chosen channel's
+/// (`pass=depth`; chosen bare, or by `all`, "1"). None when it's off.
+pub fn stat_value(var: &str) -> Option<String> {
+ if let Ok(v) = std::env::var(var) {
+ return Some(v);
+ }
+ let name = var.trim_start_matches("RAEA_");
+ let c = chosen();
+ let own = c.iter().find_map(|n| match n.split_once('=') {
+ Some((k, v)) if k.eq_ignore_ascii_case(name) => Some(v.to_string()),
+ None if n.eq_ignore_ascii_case(name) => Some("1".to_string()),
+ _ => None,
+ });
+ own.or_else(|| c.iter().any(|n| n == "all").then(|| "1".to_string()))
+}
+
+/// Channels turned on for the rest of this run (`stats.on`); a name is a RAEA_ variable's without RAEA_, or `all`, and
+/// `name=value` gives a view its value (a channel chosen again takes the later value).
pub fn choose(channels: &[String]) {
let mut c = chosen();
for n in channels.iter().map(|n| n.trim().trim_start_matches("RAEA_").to_ascii_lowercase()).filter(|n| !n.is_empty()) {
- if !c.contains(&n) {
- c.push(n);
- }
+ let key = n.split('=').next().unwrap_or_default().to_string();
+ c.retain(|o| o.split('=').next() != Some(key.as_str()));
+ c.push(n);
}
if let Ok(mut w) = CHOSEN.write() {
*w = Some(c);
diff --git a/runtime/jsengine/Cargo.toml b/runtime/jsengine/Cargo.toml
index 90e5d614..5f199c2d 100644
--- a/runtime/jsengine/Cargo.toml
+++ b/runtime/jsengine/Cargo.toml
@@ -14,6 +14,7 @@ name = "raea_runtime_jsengine"
portable = ["dep:rquickjs", "dep:miniz_oxide", "dep:iana-time-zone"]
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
raea-io-home = { path = "../../io/home" }
rquickjs = { version = "0.14", optional = true, features = ["loader"] }
# QuickJS's Intl (js/intl): its pack's chunks are raw deflate, and the date polyfill's default zone is the system's
diff --git a/runtime/jsengine/src/upkeep.rs b/runtime/jsengine/src/upkeep.rs
index 49a4b7c5..d4c5ea7f 100644
--- a/runtime/jsengine/src/upkeep.rs
+++ b/runtime/jsengine/src/upkeep.rs
@@ -20,7 +20,7 @@ use crate::JsEngine;
/// RAEA_INSPECT is on (set and not "0"): the heap log, and on JavaScriptCore the context listed in Safari's Develop
/// menu for its Web Inspector.
pub fn inspect() -> bool {
- !matches!(std::env::var("RAEA_INSPECT").as_deref(), Err(_) | Ok("" | "0"))
+ !matches!(raea_io_trace::stat_value("RAEA_INSPECT").as_deref(), None | Some("" | "0"))
}
pub struct Upkeep {
diff --git a/runtime/page/src/faces.rs b/runtime/page/src/faces.rs
index 076253ec..e2927d0b 100644
--- a/runtime/page/src/faces.rs
+++ b/runtime/page/src/faces.rs
@@ -113,7 +113,7 @@ fn make(take: &Path) -> Result<Track, String> {
files.push(p);
}
let out = std::process::Command::new(&perceive).arg("eyes").args(&files).output().map_err(|e| {
- format!("framing=\"face\" needs raea-perceive to find the face, and it couldn't be run ({}: {e}). Update raea (releases ship it in ~/.raea/bin), or from a checkout `cargo build --release -p raea-perceive`, or point RAEA_PERCEIVE at one; or frame the Video yourself with objectPosition", perceive.display())
+ format!("framing=\"face\" needs raea-perceive to find the face, and it couldn't be run ({}: {e}). Update raea (`curl -fsSL https://raea.io/install | sh`: releases ship it in ~/.raea/bin), or point RAEA_PERCEIVE at one; or frame the Video yourself with objectPosition", perceive.display())
})?;
if !out.status.success() {
return Err(format!("framing=\"face\": raea-perceive eyes failed (an older raea-perceive has no eyes: update it): {}", String::from_utf8_lossy(&out.stderr).trim()));
diff --git a/systems/compose/Cargo.toml b/systems/compose/Cargo.toml
index d4a1caeb..85a9ac96 100644
--- a/systems/compose/Cargo.toml
+++ b/systems/compose/Cargo.toml
@@ -7,6 +7,7 @@ publish = false
description = "Composition passes (which pass drew each pixel, frame-wide effects held back from some) and a frame's passes in place of its picture (depth, normal, albedo)"
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
raea-sys-frame = { path = "../frame" }
raea-sys-rt = { path = "../rt" }
raea-core-program = { path = "../../core/program" }
diff --git a/systems/compose/src/passes.rs b/systems/compose/src/passes.rs
index 6ef3e3a3..5cae6882 100644
--- a/systems/compose/src/passes.rs
+++ b/systems/compose/src/passes.rs
@@ -41,14 +41,14 @@ pub enum Pass {
Sky,
}
-/// The pass RAEA_PASS asks for, if any.
+/// The pass the channel pass asks for (`pass=depth` from TypeScript's stats.on, or RAEA_PASS), if any.
pub fn wanted() -> Option<Pass> {
- match std::env::var("RAEA_PASS").as_deref() {
- Ok("depth") => Some(Pass::Depth),
- Ok("normal") => Some(Pass::Normal),
- Ok("albedo") => Some(Pass::Albedo),
- Ok("sun") => Some(Pass::Sun),
- Ok("sky") => Some(Pass::Sky),
+ match raea_io_trace::stat_value("RAEA_PASS").as_deref() {
+ Some("depth") => Some(Pass::Depth),
+ Some("normal") => Some(Pass::Normal),
+ Some("albedo") => Some(Pass::Albedo),
+ Some("sun") => Some(Pass::Sun),
+ Some("sky") => Some(Pass::Sky),
_ => None,
}
}
@@ -213,7 +213,7 @@ fn draw(view: ViewQuery<(&ViewTarget, &ExtractedView, &PassView, Option<&ViewPre
let (Some(depth), Some(normal)) = (prepass.depth_only_view(), prepass.normal_view()) else { return };
let device = ctx.render_device().clone();
let world_from_clip = extracted.world_from_view.to_matrix() * extracted.clip_from_view.inverse();
- let rays = std::env::var("RAEA_PASS_RAYS").ok().and_then(|v| v.parse().ok()).unwrap_or(64u32);
+ let rays = raea_io_trace::stat_value("RAEA_PASS_RAYS").and_then(|v| v.parse().ok()).unwrap_or(64u32);
let sun_dir = sun.map(|s| s.0).unwrap_or(Vec3::Y).normalize_or(Vec3::Y);
let mut params = bevy::render::render_resource::UniformBuffer::from(Params {
view_from_clip: extracted.clip_from_view.inverse(),
@@ -221,7 +221,7 @@ fn draw(view: ViewQuery<(&ViewTarget, &ExtractedView, &PassView, Option<&ViewPre
sun: sun_dir.extend(0.267f32.to_radians().cos()),
// the sky pass's reach in millimetres (RAEA_PASS_REACH metres; 50 by default, the room and out of it; half a
// metre or so makes it contact occlusion)
- frame: UVec4::new(frame.0, rays, (std::env::var("RAEA_PASS_REACH").ok().and_then(|v| v.parse::<f32>().ok()).unwrap_or(50.0) * 1000.0) as u32, 0),
+ frame: UVec4::new(frame.0, rays, (raea_io_trace::stat_value("RAEA_PASS_REACH").and_then(|v| v.parse::<f32>().ok()).unwrap_or(50.0) * 1000.0) as u32, 0),
});
params.write_buffer(&device, &queue);
let copy = kept.map(|k| &k.0.default_view).unwrap_or(normal);
diff --git a/systems/fog/src/froxel.rs b/systems/fog/src/froxel.rs
index 4f83b219..6de81a6f 100644
--- a/systems/fog/src/froxel.rs
+++ b/systems/fog/src/froxel.rs
@@ -277,8 +277,8 @@ fn draw(
};
let ms = !matches!(msaa, Msaa::Off);
let device = ctx.render_device().clone();
- // RAEA_FOG_SKIP=pass,...: those passes not drawn (timing their cost)
- let skip = std::env::var("RAEA_FOG_SKIP").unwrap_or_default();
+ // the channel fog_skip=pass,... (stats.on, or RAEA_FOG_SKIP): those passes not drawn (timing their cost)
+ let skip = raea_io_trace::stat_value("RAEA_FOG_SKIP").unwrap_or_default();
let g = grid.params.grid;
ctx.command_encoder().push_debug_group("froxel_fog");
diff --git a/systems/fog/src/froxel/pipelines.rs b/systems/fog/src/froxel/pipelines.rs
index 81120c51..5dd5e46c 100644
--- a/systems/fog/src/froxel/pipelines.rs
+++ b/systems/fog/src/froxel/pipelines.rs
@@ -231,7 +231,7 @@ pub fn hero_descriptor(p: &Pipelines, view_key: MeshPipelineViewLayoutKey, entry
if tricubic {
defs.push("TRICUBIC_TRANSMITTANCE".into());
}
- if std::env::var_os("RAEA_FOG_SHOW_FALLBACK").is_some() {
+ if raea_io_trace::stat("RAEA_FOG_SHOW_FALLBACK") {
defs.push("SHOW_FALLBACK".into());
}
if ms {
diff --git a/systems/fog/src/froxel/views.rs b/systems/fog/src/froxel/views.rs
index 34f5a8a3..66d7d0bc 100644
--- a/systems/fog/src/froxel/views.rs
+++ b/systems/fog/src/froxel/views.rs
@@ -168,7 +168,7 @@ pub fn prepare_views(
let along = (0..4).map(|i| params.hero_along[i]).max().unwrap_or(0).max(4);
params.epi = UVec4::new(lines, along, e.every, n);
params.epi_tol = Vec4::new(e.rel, e.abs, e.depth, spacing);
- if std::env::var_os("RAEA_FOG_DEBUG").is_some() {
+ if raea_io_trace::stat("RAEA_FOG_DEBUG") {
eprintln!("froxel heroes: rects {:?} lines {:?} along {:?} layers {:?}", &params.hero_rect[..slot], params.hero_lines, params.hero_along, (cascades, points));
}
}
diff --git a/systems/lod/Cargo.toml b/systems/lod/Cargo.toml
index 15aa630c..953ccd34 100644
--- a/systems/lod/Cargo.toml
+++ b/systems/lod/Cargo.toml
@@ -7,6 +7,7 @@ publish = false
description = "Detail by distance and size on screen: where each part is drawn, its levels cross-faded, its shadow left to a coarser level, nothing drawn past its last, the sun's shadows faded out at their distance (docs/realism.feature LT21)"
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }
# swapping Bevy's shadows.wesl for the one whose last cascade fades out (shadow.rs)
raea-sys-frame = { path = "../frame" }
diff --git a/systems/lod/src/lib.rs b/systems/lod/src/lib.rs
index 34628990..b7a521e1 100644
--- a/systems/lod/src/lib.rs
+++ b/systems/lod/src/lib.rs
@@ -57,15 +57,15 @@ struct ShadowLeft;
pub fn install(app: &mut App) {
app.register_type::<Detail>().add_systems(PostUpdate, apply.after(VisibilitySystems::CalculateBounds).after(bevy::transform::TransformSystems::Propagate).before(VisibilitySystems::CheckVisibility));
shadow::install(app);
- match std::env::var("RAEA_LOD_DEBUG").as_deref() {
- Ok("time") => {
+ match raea_io_trace::stat_value("RAEA_LOD_DEBUG").as_deref() {
+ Some("time") => {
app.init_resource::<LodTime>();
app.add_systems(PostUpdate, timed.after(apply));
}
- Ok(_) => {
+ Some(_) => {
app.add_systems(PostUpdate, report.after(VisibilitySystems::CheckVisibility));
}
- Err(_) => {}
+ None => {}
}
}
@@ -88,7 +88,7 @@ fn timed(mut t: ResMut<LodTime>, changed: Query<(), Changed<Detail>>, parts: Que
/// name holds it (RAEA_LOD_DEBUG=tile-)
#[allow(clippy::type_complexity)]
fn report(views: Query<(Entity, Option<&Camera>, &GlobalTransform), Or<(With<Camera>, With<bevy::camera::ShadowLodOrigin>)>>, ranged: Query<(Entity, &VisibilityRange, &GlobalTransform, &ViewVisibility, &InheritedVisibility, Option<&Aabb>)>, ranges: Res<bevy::camera::visibility::VisibleEntityRanges>, parents: Query<&ChildOf>, named: Query<&Name, With<Detail>>, frame: Res<bevy::diagnostic::FrameCount>, vis: Query<(Option<&Visibility>, Option<&InheritedVisibility>, Option<&Name>)>) {
- let only = std::env::var("RAEA_LOD_DEBUG").ok().filter(|v| v != "1");
+ let only = raea_io_trace::stat_value("RAEA_LOD_DEBUG").filter(|v| v != "1");
let cams: Vec<_> = views.iter().collect();
eprintln!("raea lod: frame {} {} views ({} active cameras)", frame.0, cams.len(), cams.iter().filter(|(_, c, _)| c.is_some_and(|c| c.is_active)).count());
for (e, r, gt, vv, iv, aabb) in &ranged {
diff --git a/systems/material/Cargo.toml b/systems/material/Cargo.toml
index a174b5f2..22cd145d 100644
--- a/systems/material/Cargo.toml
+++ b/systems/material/Cargo.toml
@@ -15,6 +15,7 @@ native = ["dep:resvg"]
multi-layer = ["bevy/pbr_multi_layer_material_textures"]
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
raea-sys-frame = { path = "../frame" }
raea-sys-sampler = { path = "../sampler" }
raea-core-program = { path = "../../core/program" }
diff --git a/systems/material/src/clay.rs b/systems/material/src/clay.rs
index 2d3200c4..12426a18 100644
--- a/systems/material/src/clay.rs
+++ b/systems/material/src/clay.rs
@@ -14,7 +14,7 @@ const GREY: [f32; 3] = [0.62, 0.62, 0.6];
pub fn on() -> bool {
static ENV: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
- CLAY.load(Ordering::Relaxed) || *ENV.get_or_init(|| std::env::var_os("RAEA_CLAY").is_some_and(|v| v != "0"))
+ CLAY.load(Ordering::Relaxed) || *ENV.get_or_init(|| raea_io_trace::stat("RAEA_CLAY"))
}
fn is_clay(m: &StandardMaterial) -> bool {
diff --git a/systems/song/Cargo.toml b/systems/song/Cargo.toml
index 1dbc9f01..fd9ed731 100644
--- a/systems/song/Cargo.toml
+++ b/systems/song/Cargo.toml
@@ -10,6 +10,7 @@ description = "Sound through ONNX models: a song's beats and energy map, stems,
denoise = ["dep:deep_filter", "dep:ndarray"]
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
# frames come from the media plane (VideoToolbox on Apple, ffmpeg or the software decoders elsewhere)
raea-io-media = { path = "../../io/media", default-features = false, features = ["apple"] }
raea-sys-vision = { path = "../vision" }
diff --git a/systems/song/src/song/analyse.rs b/systems/song/src/song/analyse.rs
index d07a73df..f7741adb 100644
--- a/systems/song/src/song/analyse.rs
+++ b/systems/song/src/song/analyse.rs
@@ -302,7 +302,7 @@ pub fn analyse(x: &[f32], spect: &[[f32; MELS]], beats: &[f64], downs: &[f64], m
}
}
builds.sort_by_key(|b| b.0);
- if std::env::var_os("RAEA_SONG_DEBUG").is_some() {
+ if raea_io_trace::stat("RAEA_SONG_DEBUG") {
for &(p, base, jump, impact) in &drop_base {
eprintln!("drop? {:7.2} base {base:.2} jump {jump:.2} impact {impact:.2} nov {:.2}", beats[p], nov[p] / nmax);
}
@@ -441,7 +441,7 @@ pub fn analyse(x: &[f32], spect: &[[f32; MELS]], beats: &[f64], downs: &[f64], m
}
let _ = std::fs::write(p, csv);
}
- if std::env::var_os("RAEA_SONG_DEBUG").is_some() {
+ if raea_io_trace::stat("RAEA_SONG_DEBUG") {
for (j, bar) in bars.iter().enumerate() {
let (s, e) = (bar.0, bar.1);
eprintln!("bar {j:3} {:7.2}s E {:.2} raw {:.2} loud {:.2} low {:.2} on {:.2} br {:.2} hi {:.2} nov {:.2} rate {}", beats[s],
diff --git a/systems/volume/Cargo.toml b/systems/volume/Cargo.toml
index 546192d1..0042bc53 100644
--- a/systems/volume/Cargo.toml
+++ b/systems/volume/Cargo.toml
@@ -7,6 +7,7 @@ publish = false
description = "Simulated volumes (<Smoke>, <Cloud>, <Contrail>): a fluid on a grid, raymarched, lit and casting shadows, a function of the frame"
[dependencies]
+raea-io-trace = { path = "../../io/trace" }
raea-sys-frame = { path = "../frame" }
raea-core-program = { path = "../../core/program" }
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }
diff --git a/systems/volume/src/lib.rs b/systems/volume/src/lib.rs
index 8b0c0ee7..ea8aba8a 100644
--- a/systems/volume/src/lib.rs
+++ b/systems/volume/src/lib.rs
@@ -393,7 +393,7 @@ pub fn sync_volumes(
let (_, size) = placed(&v);
let t = num(&v, "time", 0.0);
vol.sim.run_to(t, size);
- if std::env::var_os("RAEA_VOLUME_DEBUG").is_some() {
+ if raea_io_trace::stat("RAEA_VOLUME_DEBUG") {
let sim = &vol.sim;
let (mut sum, mut top, mut tmax) = (0.0f32, 0usize, 0.0f32);
for (i, d) in sim.d.iter().enumerate() {
diff --git a/tools/nobuild.sh b/tools/nobuild.sh
index 73481e10..87e92859 100755
--- a/tools/nobuild.sh
+++ b/tools/nobuild.sh
@@ -25,7 +25,8 @@
# tools/nobuild.sh stats NB2a's check: every stat variable decided done is read through raea_io_trace::stat;
# tools/nobuild/stats/stats.tsx chooses bevy_passes and trace from TypeScript and reads
# stats.read back; the run prints each pass and keeps stats.json; RAEA_TRACE=1 and
-# RAEA_STATS give the same trace lines on the scene without stats.on. Exits 1 if one fails
+# RAEA_STATS give the same trace lines on the scene without stats.on; pass=depth chosen
+# from TypeScript draws RAEA_PASS=depth's frame. Exits 1 if one fails
#
# A decision row (tab-separated): kind:name, then its class, the TypeScript form it becomes, its check, its status
# (open, doing, done, stays). Classes: frame (changes what a frame shows or costs: a prop), view (a debug view: NB2),
@@ -260,11 +261,11 @@ stats() {
dir=$(mktemp -d "${TMPDIR:-/tmp}/nobuild-stats.XXXXXX") || exit 1
check() { if [ "$2" = pass ]; then echo " $1: pass ($3)"; else echo " $1: FAIL ($3)"; fails=$((fails + 1)); fi; }
echo "nobuild stats: tools/nobuild/stats/stats.tsx by $bin"
- # each stat variable decided done is read through stat(), so TypeScript and RAEA_STATS reach it, never straight
- for v in $(awk -F'\t' '$2 == "stat" && $5 == "done" && $1 ~ /^env:/ { sub(/^env:/, "", $1); print $1 }' "$RAEA/docs/nobuild/decisions.tsv"); do
+ # each stat or view variable decided done is read through stat() or stat_value(), so TypeScript and RAEA_STATS reach it
+ for v in $(awk -F'\t' '($2 == "stat" || $2 == "view") && $5 == "done" && $1 ~ /^env:/ { sub(/^env:/, "", $1); print $1 }' "$RAEA/docs/nobuild/decisions.tsv"); do
n=$((n + 1)); raw+=$(cd "$RAEA" && git grep -n -E "env::var(_os)?\(\"$v\"\)" -- '*.rs' ':!vendor' ':!io/trace' | head -2)
done
- check "each done stat variable read through stat()" "$([ -z "$raw" ] && echo pass)" "${raw:-$n variables}"
+ check "each done stat or view variable read through stat()" "$([ -z "$raw" ] && echo pass)" "${raw:-$n variables}"
# chosen from TypeScript, no variable set: stats.on at the scene's top level, stats.read on its last frame
(cd "$here" && env -u RAEA_TRACE -u RAEA_BEVY_PASSES -u RAEA_STATS RAEA_TRACE_DIR="$dir/trace" "$bin" render stats.tsx -o "$dir/ts" > "$dir/ts.log" 2>&1)
local read rows kept
@@ -284,6 +285,13 @@ stats() {
(cd "$dir" && env -u RAEA_TRACE RAEA_STATS=trace,bevy_passes "$bin" render plain.tsx -o "$dir/list" > "$dir/list.log" 2>&1)
(cd "$dir" && env -u RAEA_TRACE -u RAEA_BEVY_PASSES -u RAEA_STATS "$bin" render plain.tsx -o "$dir/none" > "$dir/none.log" 2>&1)
check "nothing chosen: no trace lines, no table" "$([ -z "$(traced "$dir/none.log")" ] && ! grep -q '^raea stats' "$dir/none.log" && grep -q '^APPLIED' "$dir/none.log" && echo pass)" "$(traced "$dir/none.log" | wc -l | tr -d ' ') trace lines"
+ # a debug view chosen with its value: pass=depth from TypeScript draws RAEA_PASS=depth's frame, not the beauty
+ sed 's/channels: \["bevy_passes", "trace"\]/channels: ["pass=depth"]/' "$here/stats.tsx" > "$dir/view.tsx"
+ (cd "$dir" && env -u RAEA_PASS -u RAEA_STATS "$bin" render view.tsx -o "$dir/view" > "$dir/view.log" 2>&1)
+ (cd "$dir" && env -u RAEA_STATS RAEA_PASS=depth "$bin" render plain.tsx -o "$dir/penv" > "$dir/penv.log" 2>&1)
+ local pae beauty
+ pae=$(diff_levels PAE "$dir/view/frame-00006.png" "$dir/penv/frame-00006.png"); beauty=$(diff_levels PAE "$dir/view/frame-00006.png" "$dir/none/frame-00006.png")
+ check "pass=depth from TypeScript draws RAEA_PASS=depth's frame" "$([ "$pae" = 0.000 ] && [ -n "$beauty" ] && [ "$beauty" != 0.000 ] && echo pass)" "max ${pae:-no frame} levels apart; ${beauty:-no frame} from the beauty"
check "RAEA_TRACE=1 the same trace lines" "$([ "$(traced "$dir/env.log")" = "$(traced "$dir/ts.log")" ] && ! grep -q '^raea stats' "$dir/env.log" && echo pass)" "$(traced "$dir/env.log" | wc -l | tr -d ' ') lines, no table"
check "RAEA_STATS=trace,bevy_passes the same, with the table" "$([ "$(traced "$dir/list.log")" = "$(traced "$dir/ts.log")" ] && grep -q '^ bevy/' "$dir/list.log" && echo pass)" "$(traced "$dir/list.log" | wc -l | tr -d ' ') lines, $(grep -c '^ bevy/' "$dir/list.log") passes"
echo "nobuild stats: $fails failing"
@@ -297,5 +305,5 @@ case ${1:-} in
props) props ;;
catalog) catalog ;;
stats) stats ;;
- *) sed -n '2,33p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;
+ *) sed -n '2,34p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;
esac