Skip to content

Performance Research A07 HRTF Indexing and Target Update

github-actions[bot] edited this page Sep 15, 2026 · 1 revision

HRTF addressing, smoothing, and SIMD

A07 — Implementation and validation notes

Field Value
Evidence state 97,309-address model matches; separate channel-update reductions reproduce a defect
Inspected source 322986f4c5502b3fa887a9605ac8cd88e9b2c579
First experiment Separate target-update correctness repair from index walking
Scope Addendum dated September 15, 2026; not a current-main benchmark or implementation status

Unproven performance research · Performance research — common test protocol · Performance research — reproducible checks

Evidence and implementation reasoning

Source and proof. The filter uses 31 taps, a maximum integer delay of 42, and a 73-sample ring. For valid p in [0,72], d in [0,42], and k in [0,30], let t=p-d-k. Then t lies in [-72,72], so the existing ring index equals t+73 when negative and t otherwise. The predecessor index and decrement-with-wrap recurrence also match. All 97,309 position/delay/tap combinations were checked with zero mismatches. This proves addressing equivalence for the stated domain, not complete audio equivalence or a speedup. Filter source.

Practical implementation order. First replace repeated modular indexing with a correctly initialized pointer/index walk. Then investigate independent coefficient-smoothing lanes. Only later change the FIR reduction layout. Preserve per-sample parameter stepping, interpolation, in-place input/output behavior, accumulation order, FMA policy, and saved history.

Production precedent. Arm CMSIS-DSP uses expanded FIR state buffers to avoid circular addressing and describes the resulting performance benefit. That supports contiguous state handling, but xemu's changing coefficients and fractional delay prevent treating a stock fixed-coefficient FIR as an equivalent drop-in. CMSIS FIR.

Concrete correctness defect found. In hrtf_filter_set_target_params(), the normalization loop uses break when the current channel's absolute coefficient sum is zero or one. If that is the left channel, the right target is not copied. The caller is present in the guest HRTF-target assignment method. Two standalone C cases reproduce stale right-channel targets using coefficients encodable by the existing signed-8-bit conversion; a left-sum-two control updates both channels correctly. Isolate this correctness repair from performance work. Target assignment, coefficient conversion.

Gain scale. Each active HRTF voice executes 1,984 tap evaluations per 32-sample frame, approximately 2.976 million/s at 48 kHz. The opportunity is real work removal, but % 73 may already be strength-reduced by the compiler; inspect generated code rather than assuming a hardware integer divide per tap.

First patch boundary

Use separate patches/controls for C1 target update and P1 indexing. Defer changed FIR reduction, FMA use and coefficient SIMD until P1 output is qualified.

C1: update both channel targets independently; P1: same sample stepping and tap order with decrement-and-wrap indices

Locate the inspected seam before editing; names or ownership may have changed since the pinned review:

git grep -n -E 'hrtf_filter_process|hrtf_filter_set_target_params|set_hrir' -- hw/xbox/mcpx/apu

Proposed focused tests

These are implementation gates to add or exercise, not claims that production tests already exist or passed. Retained standalone checks are on the checks page.

Test ID Setup / deliberate control Required oracle
A07.C1 Left coefficient absolute sum 0 and 1, with a nonzero new right target; sum-2 positive control. Old reduction preserves a stale right target in the first two cases; the repair updates both targets independently.
A07.P1 All 73 positions x 43 delays x 31 taps; check predecessor and decrement-with-wrap indices. 97,309 tuples match the original integer addressing.
A07.P2 Replay in-place processing across ring wrap, delay endpoints and fractional delays, with coefficient changes every sample/frame boundary. Sample outputs and saved history match under the declared floating-point/FMA policy.

Counters and rejection criteria

Collect: index_mismatches, channel_target_mismatches, pcm_mismatches, active_hrtf_voices, tap_evaluations, hrtf_cpu_ns. Keep exact counts separate from sampled durations; use an uninstrumented build for performance qualification.

Reject or hold: A passing indexing model does not qualify parameter semantics or changed summation. Inspect generated assembly: do not assume one hardware divide per source-level modulo.

Follow the common protocol for source identities, previous-main/fixed-baseline controls, raw results, confidence and retail/XISO qualification. No gain becomes proven from a model, cache hit, local operation count, or shifted wait label alone.

Clone this wiki locally