Repository navigation
Closed
Labels
readyMeets the definition of Ready; claimable
Description
Unit
libobs/obs-scene.c.h: the two mix kernels of scene_audio_render(), which add each audible scene item's audio into the scene's mixes every audio tick:
mix_audio_with_buf():out[pos + i] += in[i] * buf[i], for an item whose visibility change falls in the tick (the 0/1 gain buffer ofapply_scene_item_volume());scene_mix_audio():out[pos + i] += in[i], for every other item.
They move to libobs/obs-scene-audio-mix.c.h and are ported to rust/obs-scene (module audio_mix, next to audio_window and audio_actions).
Phase and position
Phase 2 libobs core, scenes (core-scene group). This is the scene half of #3007 under #3009. The decisions around these kernels are already ported: obs-scene-audio-window.c.h (the window and whether an item mixes) and obs-scene-audio-actions.c.h (the gain buffer). The source volume kernels are a separate issue. Tracking: #4.
Dependencies and existing tests
- Depends on nothing open.
- Existing test that runs the kernels through the real libobs:
test_scene_audio_actions(the visibility ramp, sample by sample, over a second audible item). - No characterization of the kernels on their own yet.
test_scene_audio_mix_steps(cmocka, the moved file on its own) lands first. It pins:- both kernels at
pos0 and inside the tick,count0, 1 and 1024; - the gain buffer at 0, 1 and other values;
- NaN, infinities and -0.0 in each operand;
- output samples outside
pos .. pos + countleft alone.
- both kernels at
Notes
- perf: libobs: vectorize scene audio mixing and source volume multiply when ported #3007 applies:
- a benchmark under
audio_mixinport_comparisonfirst, with before and after numbers on a named x86_64 and a named aarch64 machine; - an assembly check that the kernels vectorize;
- a scalar fallback;
- bit-exact Tier 3.
- a benchmark under
- Vectorization: GCC 14 at
-O2(the Linux builds) leaves both loops scalar, because it cannot rule out thatoutandinoverlap. Clang vectorizes them. Rust slices cannot overlap, so plain Rust loops should vectorize with nostd::arch. - Fused multiply-add: on aarch64, clang's default
-ffp-contract=onfusesout += in * bufinto onefmla, and GCC does the same for x86-64-v3. The C oracle is pinned to-ffp-contract=off(rust/obs-c-oracle/build.rs), as for every port, so the port keeps a separate multiply and add. It matches the oracle bit for bit; the shipped aarch64 C can differ in the last bit. scene_audio_render()keeps the item loop, the mix and channel loops,obs_source_get_audio_mix(), the locks and every read of the item and source. Only the two kernels move, as functions on plain pointers and counts, hidden in libobs.
Metadata
Metadata
Assignees
Labels
readyMeets the definition of Ready; claimable
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 30, 2026
Claiming: #3079.
Plan (one PR, in this order):
mix_audio_with_buf()andscene_mix_audio()move tolibobs/obs-scene-audio-mix.c.has hidden functions on plain pointers and counts;scene_audio_render()keeps everything else in its order.test_scene_audio_mix_steps(cmocka, the moved file on its own), with the cases listed in the issue.rust/obs-scenemoduleaudio_mixwith stubs and Tier 1 tests.audio_mixbenchmark against the C and the assembly check (perf: libobs: vectorize scene audio mixing and source volume multiply when ported #3007).Draft PR within 48 h.
obs-scene: Port the scene audio mix kernels (obs-rust#3079) (obs-rust…