Files
benilla-octo/third_party/kira/BENILLA.md
T
gromandClaude Opus 5 81d96af35d Everwood: the HD/OctoWoW line of benilla, imported onto upstream
This checkout had no git history at all, so this one commit carries the whole
of the Everwood work as a single import on top of chairmanpow/benilla-octo's
`main` (706cd71). The two trees have genuinely diverged — each has files the
other does not — so this is a fork point, not a catch-up.

Today's work, which is the reason a baseline exists at all:

- Booth previews no longer cast world shadows (`NO_BOOTH_SHADOW`). Portrait
  characters were entering the sun's shadow cascades, so every skinned-rig
  shadow specialization compiled live mid-frame; the hitch detector logged
  "main thread blocked 1316 ms" beside a `compiled LIVE` warning. This was
  the Fashion/Tmog stutter.
- Per-pane dress-up: each `DressUpModel` pane assembles and stages its own
  tried-on look instead of every pane mirroring the live player.
- Item template cache is append-only JSONL written on the IO pool, replacing
  an 11.6 MB whole-map JSON rewrite on the main thread every 10 s.
- `WOW_SYSTEM_TIMING` rebuilt per-thread: it took 2 mutexes per system enter
  and 4 per exit, costing 15 ms a frame (590 fps -> 60) and corrupting the
  measurements it was taken to produce.
- The visibility-churn sweep moved to its own `WOW_FLASH_CHURN` switch, so a
  frame-cost reading no longer pays 2.7 ms a frame for it.

Local state (`benilla-config/`, `logs/`, `target/`) is excluded by the
existing .gitignore; the account credential it holds is not in this commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
2026-10-15 15:01:14 -06:00

40 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# benilla's `kira` fork — what differs from upstream, and how to check
Upstream: [`tesselode/kira`](https://github.com/tesselode/kira), MIT OR Apache-2.0, version
`0.12.1` — the version the workspace lock resolves to. Wired in through `[patch.crates-io]` in
the workspace root, the way `lua-src` is. The crate is copied from the cargo registry as
published (`src/`, `Cargo.toml`, `README.md`) plus the two licence files from the repository;
upstream files are CRLF and are left so, except the one file patched.
## Why a fork exists at all
The mixer runs on benilla's own audio render thread (`sound/output`), and with a raid buffing
itself — a dozen live voices, most of them spatial — that thread cost **~1.5 ms of every 60 Hz
frame** on an M2 Air (a sampled profile with a dozen spatial voices playing, `Track::process`
two thirds of it). Upstream's sub-track `process` spatializes **every
frame**: two vector normalizes, a length, the attenuation curve and a dB→amplitude `powf` per
frame per spatial track, then two more `powf`s per frame for the volume tween and the fade. At
48 kHz × 12 tracks that is ~1.7 M `powf`s a second plus the vector math, for gains that change
imperceptibly across a 10 ms chunk. FMOD 3 — the mixer the real client delegates to — updates
pan and attenuation per mixer update, not per sample.
## The one patch — `src/track/sub.rs`
`Track::process` evaluates the spatial gains (attenuation, left/right ear gain, the mono fold)
and the volume × fade amplitude at the chunk's two ends and interpolates them linearly across
the chunk. `SpatialData::spatial_gains` is `spatialize` factored into a value; `spatialize`
itself is kept, unused, so the factoring can be diffed against it. A chunk is the output
device's buffer — 512 frames, ~10.7 ms, `sound/output::DEVICE_BUFFER_FRAMES`.
What changes audibly: nothing a listener can name. A source crossing an ear's axis within one
chunk pans linearly in gain over 10 ms instead of following the dot product per sample; a
volume tween ramps linearly in amplitude across each chunk instead of in decibels. Both are
below the granularity the reference itself updates at.
## How to check
`git diff --no-index <registry>/kira-0.12.1/src/track/sub.rs third_party/kira/src/track/sub.rs`
(after `sed 's/\r$//'` on the upstream copy) shows the patch and nothing else; every other file
is byte-identical to the registry crate. The mixer's own tests (`cargo test -p benilla-app
sound::`) run against the fork.