diff --git a/crates/victory-gpu/src/ambient.rs b/crates/victory-gpu/src/ambient.rs index 06884c6..40c5586 100644 --- a/crates/victory-gpu/src/ambient.rs +++ b/crates/victory-gpu/src/ambient.rs @@ -128,7 +128,7 @@ fn title_names() -> &'static Names { if shape_on() { tracing::info!( profile = victory_profile::get().is_some(), - "the stand-in for indirect light: the title profile names none of its programs; they are looked for by the places their tables bind (the reflections' stand-in stays off; VICTORY_AMBIENT_SHAPE=0: none)" + "the stand-in for indirect light: the title profile names none of its programs; they are looked for by the places their tables bind (VICTORY_AMBIENT_SHAPE=1; the reflections' stand-in stays off)" ); } else { crate::title::without("the stand-in for indirect light and reflections"); @@ -227,10 +227,14 @@ fn weak(role: Role) -> bool { static BY_SHAPE: Mutex<[Vec<[u8; 32]>; 4]> = Mutex::new([Vec::new(), Vec::new(), Vec::new(), Vec::new()]); /// Whether programs are looked for by the places their tables bind -/// (`VICTORY_AMBIENT_SHAPE=0`: not; the stand-in then needs the profile). +/// (`VICTORY_AMBIENT_SHAPE=1`; off by default, so the stand-in needs the +/// profile). Off since a run with the profile compared the rule with the +/// profile's names: it gave the radiance and air parts to programs the +/// profile does not name in every one of 48 checks, and found none of the +/// named ones. fn shape_on() -> bool { static ON: OnceLock = OnceLock::new(); - *ON.get_or_init(|| std::env::var_os("VICTORY_AMBIENT_SHAPE").is_none_or(|v| v != "0")) + *ON.get_or_init(|| std::env::var_os("VICTORY_AMBIENT_SHAPE").is_some_and(|v| v == "1")) } /// A compute program's part by the places its tables bind, those the hooks @@ -688,6 +692,15 @@ struct Said { last_frame: AtomicU64, /// Bit 0 opaque surfaces, 1 alpha, 2 water, 3 others. layers: AtomicU64, + /// Of the dispatches followed: those that read the depth kept, and those that did not because + /// the kept one is of another size (the last pair of sizes, as width << 32 | height), was kept + /// more than two frames before, or the depth kept is off (`VICTORY_AMBIENT_MISS_DEPTH=usual`). + kept: AtomicU64, + kept_size: AtomicU64, + kept_stale: AtomicU64, + kept_off: AtomicU64, + size_held: AtomicU64, + size_asked: AtomicU64, } static SAID_MISS: Said = Said { @@ -697,6 +710,12 @@ static SAID_MISS: Said = Said { not_ready: AtomicU64::new(0), last_frame: AtomicU64::new(u64::MAX), layers: AtomicU64::new(0), + kept: AtomicU64::new(0), + kept_size: AtomicU64::new(0), + kept_stale: AtomicU64::new(0), + kept_off: AtomicU64::new(0), + size_held: AtomicU64::new(0), + size_asked: AtomicU64::new(0), }; /// What came of a dispatch of the miss program, counted for the line. @@ -828,7 +847,8 @@ pub(crate) fn note_miss(note: MissNote) { "a stand-in for reflections (VICTORY_AMBIENT_SPECULAR={share},{sky}) in the last {:.0} s: \ {} frames, {} dispatches of the miss program followed (surfaces: {}), each by an estimate along \ the reflected direction put in right after it (before the screen-space resolve); {} of layers it does not \ - follow ({}) and {} before a frame's light was kept left as the title had them", + follow ({}) and {} before a frame's light was kept left as the title had them; the depth kept read by {} \ + of those followed (not by {} where it is of another size: kept {}, asked {}; {} kept too long ago; {} with it off)", now.duration_since(since).as_secs_f32(), s.frames.swap(0, Relaxed), s.ran.swap(0, Relaxed), @@ -836,9 +856,20 @@ pub(crate) fn note_miss(note: MissNote) { s.left.swap(0, Relaxed), if by_layer.is_empty() { "-".to_owned() } else { by_layer.join(", ") }, s.not_ready.swap(0, Relaxed), + s.kept.swap(0, Relaxed), + s.kept_size.swap(0, Relaxed), + size_text(s.size_held.load(Relaxed)), + size_text(s.size_asked.load(Relaxed)), + s.kept_stale.swap(0, Relaxed), + s.kept_off.swap(0, Relaxed), ); } +/// A size word (width << 32 | height) as `x`; `-` for none. +fn size_text(word: u64) -> String { + if word == 0 { "-".to_owned() } else { format!("{}x{}", word >> 32, word & 0xffff_ffff) } +} + /// By the title's program followed (resolve, radiance, air, miss): how often /// the stand-in recorded its passes after it, how often it left the title's /// output as it was because no frame's light had been kept yet, and the frame @@ -940,10 +971,25 @@ pub(crate) fn after(list: &HostList, role: Role, views: &Views) -> bool { let size_word = u64::from(views.depth_size[0]) << 32 | u64::from(views.depth_size[1]); let frame = crate::frame::current(); // The depth kept, if it is of this size and of this frame or the two before. - let kept = role == Role::Miss - && kept_depth() - && DEPTH_KEPT.load(Ordering::Relaxed) == size_word - && frame.wrapping_sub(DEPTH_KEPT_IN.load(Ordering::Relaxed)) <= 2; + let kept = role == Role::Miss && { + let said = &SAID_MISS; + let held = DEPTH_KEPT.load(Ordering::Relaxed); + if !kept_depth() { + said.kept_off.fetch_add(1, Ordering::Relaxed); + false + } else if held != size_word { + said.kept_size.fetch_add(1, Ordering::Relaxed); + said.size_held.store(held, Ordering::Relaxed); + said.size_asked.store(size_word, Ordering::Relaxed); + false + } else if frame.wrapping_sub(DEPTH_KEPT_IN.load(Ordering::Relaxed)) > 2 { + said.kept_stale.fetch_add(1, Ordering::Relaxed); + false + } else { + said.kept.fetch_add(1, Ordering::Relaxed); + true + } + }; let [strength, radius] = shade(); let floats = [level, constant, strength, radius, 0.1, 0.45]; let mut words = [0u32; 16]; diff --git a/docs/commands.md b/docs/commands.md index 9b0ac97..b0d46fd 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -161,7 +161,7 @@ such switch, so changing one translates again (a few minutes, once). | `VICTORY_TYPED_STORE_BASE` | on | a full-width typed store at a scalar or built offset runs where that offset is 0 at run time; `0`: refused, as in 0.8.3 (translation) | | `VICTORY_AMD_DIMS_APART`, `VICTORY_AMD_FOLD_BITS` | on, AMD cards only | size queries kept apart, and no folding of bit counts and reversals of constants: AMD's compiler mishandled both; tested on no AMD card (translation) | | `VICTORY_RT_WALKS` | off | `1`: compute programs whose code tests structure nodes run even while no structure builder runs and the profile names no hit-resolve programs (left out by default then: their walks find nothing) | -| `VICTORY_AMBIENT_SHAPE` | on | without the profile's names, the light estimate finds its passes by the places their tables bind; `0`: off | +| `VICTORY_AMBIENT_SHAPE` | off | `1`: without the profile's names, the light estimate looks for its passes by the places their tables bind (untrusted: checked against the profile's names it found other programs) | | `VICTORY_AMBIENT_FILTER` | `1` | the probe filter of the light estimate (magenta and deep blue); `2`: also neon green, 0.8.3's default | | `VICTORY_BCPACK_NEUTRAL` | on | without a BCPack table file, packed textures are filled with flat blocks of their kind; `0`: the requests fail, as before | | `VICTORY_PROFILE_ANY_EXE` | on | a title profile made for another copy of the executable keeps its roles and tables and drops its patch groups; `0`: refused | diff --git a/docs/fork-ray-tracing.md b/docs/fork-ray-tracing.md index e09d416..200f188 100644 --- a/docs/fork-ray-tracing.md +++ b/docs/fork-ray-tracing.md @@ -192,7 +192,7 @@ fork's constant. | `VICTORY_AMBIENT_AIR=` | what the air scatters is bounded by a multiple of the light around (off: a brown veil can stay in lit interiors) | | `VICTORY_AMBIENT_FLOOR=` | a floor under the estimate in close views; the view's distance is measured from the scene's depth in the resolve pass (off) | | `VICTORY_AMBIENT_FILTER=1\|2` | probe light of the colours the program's leftovers have is dropped: `1` (the default) magenta and deep blue, `2` also neon green | -| `VICTORY_AMBIENT_SHAPE=0` | without a title profile, the passes are not looked for by shape | +| `VICTORY_AMBIENT_SHAPE=1` | without a title profile, the passes are looked for by shape (off by default: the rule found other programs than the profile names) | It is off while the builder runs.