Skip to content

obs-ffmpeg: Probe each VAAPI device once and skip decode-only drivers - #1175

Merged
zackees merged 2 commits into
masterfrom
fix/vaapi-startup-probe
Oct 17, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/vaapi-startup-probe

Conversation

@zackees

@zackees zackees commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #1168

RED (first commit): test_vaapi_probe_policy against stubs fails nvidia_kernel_driver_is_decode_only, each_device_is_probed_once, added_answers_are_used_and_kept.
GREEN: 5/5. ./unittest Tier 2: 271/272, the one failure test_deinterlace_2x_field_order is the known load-sensitive test (#456), unrelated.

  • vaapi-probe-policy.c (libva-free, tested): one probe per device for all three codecs; nodes driven by the nvidia kernel driver are not opened (nvidia-vaapi-driver is decode-only) unless LIBVA_DRIVER_NAME picks another VA driver.
  • vaapi-utils.c: render nodes probed in parallel; cache freed on unload (0 leaks).

Measured, launch → main window mapped, median of interleaved runs (2× NVIDIA, KDE Wayland): 4.32 s → 1.43 s; RSS 327 → 298 MiB (no CUDA contexts in-process). Tiers: Tier 2 (cmocka) only; no Rust port involved.

…e (RED, Refs #1168)

test_vaapi_probe_policy (tests.d) checks the decisions behind the obs-ffmpeg
VAAPI encoder probe against stubs in vaapi-probe-policy.c.h, its own unity
group (BUILD.md) so the test builds it without libva: the nvidia kernel
driver (nvidia-vaapi-driver, decode only) is not opened unless
LIBVA_DRIVER_NAME picks another VA driver, and a device answers all three
codec queries from one probe. Fails: nvidia_kernel_driver_is_decode_only,
each_device_is_probed_once, added_answers_are_used_and_kept.
… (GREEN, Fixes #1168)

Every codec query (H.264, AV1, HEVC) opened every render node again, and for
the nvidia kernel driver each vaInitialize loads nvidia-vaapi-driver, which
initialises CUDA (0.45-0.8 s) only to report that it cannot encode. On a
machine with two NVIDIA GPUs that was 2.7 s of a 4 s start.

- vaapi-probe-policy.c.h: a device's answer for all three codecs is probed
  once and kept; a node whose kernel driver is nvidia is not opened unless
  LIBVA_DRIVER_NAME picks another VA driver.
- vaapi-utils.c.h: the render nodes are opened in parallel, one thread each.
- The cache is freed on unload (no bmem leak).

Launch to main window, median of interleaved runs (2x NVIDIA, KDE Wayland):
4.28 s -> 1.42 s; RSS 327 -> 298 MiB (no CUDA contexts in the process).
test_vaapi_probe_policy: 5/5.
@zackees
zackees force-pushed the fix/vaapi-startup-probe branch from 5374201 to b4df4e2 Compare October 17, 2026 06:39
@zackees

zackees commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Rebuilt on master after the BUILD.md unity-group conversion of this plugin (and #1184's Fast Gate fix): the policy/cache code is now .c.h files in their own small groups (so the cmocka test builds them without libva/CUDA), new includes are in the group precompiled headers, and the test is a test/cmocka/tests.d fragment. Same RED → GREEN commits and behavior; re-measured on this build.

@zackees
zackees merged commit ee120df into master Oct 17, 2026
29 checks passed
@zackees
zackees deleted the fix/vaapi-startup-probe branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

obs-ffmpeg: VAAPI encoder probe takes 2.7 s of startup on NVIDIA machines

1 participant