Repository navigation
rust: obs-nvenc CUDA/NVENC driver loader (phase 1 of #520) - #529
Merged
Merged
Conversation
Adds the rust/obs-nvenc crate skeleton (candidate lists, typed LoadError, DynLoader seam, libloading-backed SystemLoader in src/platform/) with the safe core stubbed. tests/loader.rs: 17 of 18 tests fail on todo!(). Refs #520
…nctions table (#520) Candidate lists per host (env override, soname, unversioned, distro and NixOS paths, WSL; System32-only DLL names on Windows; none on macOS), first-success walk with GLIBC_x.y dlerror parsing, the cuda_functions[] symbol table with the same _v2 names, and cuDriverGetVersion. All 18 Tier 1 tests pass; the ignored real_gpu_loads smoke test loads /run/opengl-driver/lib/libcuda.so.1 (driver 13.2) on a NixOS host. Refs #520
…520) obs-c-oracle copies the original load_cuda_lib(), cuda_functions[] and load_nvenc_lib() lines verbatim (build.rs, with #line markers; the whole files need nv-codec-headers) and compiles them in oracle/obs_nvenc_loader.c with a recording os_dlopen. tests/loader_parity.rs asserts the Rust search starts with the exact name C opens and the required symbol table equals cuda_functions[]. plugins/obs-nvenc is added to the oracle input hash. Mutation check: swapping libcuda.so.1/libcuda.so, renaming libnvidia-encode.so.1, and dropping _v2 from cuCtxCreate_v2 in the Rust core fails all 3 parity tests; restored, all pass. Refs #520 Local-Gate: v1 tree=90fb0d918bf242fda6c272f0ee9474a10ab0994c secs=383 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791884124,"gate":"rust/all/fmt","host":"linux-x86_64","key":"4b595d4bbc8d0053b8c6d79981e88a05922e6fb837c89c86fb0c51ff44980b35","lane":"lint","parents":["3d1ad78ab12b745a0365d929adc2f2a39ef502eb"],"secs":75,"stamp":"e8ada8ff64e0d0ac90c01fba944124df","tree":"90fb0d918bf242fda6c272f0ee9474a10ab0994c","v":1,"via":"run"} Ci-Attestation: {"at":1791884124,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"4b595d4bbc8d0053b8c6d79981e88a05922e6fb837c89c86fb0c51ff44980b35","lane":"lint","parents":["3d1ad78ab12b745a0365d929adc2f2a39ef502eb"],"secs":75,"stamp":"7ded1fd86ed52d37e898b17e9d7da2ff","tree":"90fb0d918bf242fda6c272f0ee9474a10ab0994c","v":1,"via":"run"} Ci-Attestation: {"at":1791884124,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"524bbd5e1ff902058fa4fc8401353c3b6e525d7de595cb86cae9e44b4e1003b2","lane":"rust-test","parents":["3d1ad78ab12b745a0365d929adc2f2a39ef502eb"],"secs":244,"stamp":"2d88f4d341c584035621aba83af50117","tree":"90fb0d918bf242fda6c272f0ee9474a10ab0994c","v":1,"via":"run"} Ci-Attestation: {"at":1791884124,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"853c9ee0cf8c5dc5a8615d5249672bae6d9cca8ee383c655cb0b6b9b371d88dc","lane":"tier2-linux","parents":["3d1ad78ab12b745a0365d929adc2f2a39ef502eb"],"secs":64,"stamp":"48fafb2cd8b882e7cbe55d985be254f1","tree":"90fb0d918bf242fda6c272f0ee9474a10ab0994c","v":1,"via":"run"}
Keep extract_c next to the #516 strict flags, and declare the nvenc oracle's exported functions for -Wmissing-prototypes. Local-Gate: v1 tree=214f4ee974d1d87f94467b841d6483610ef5c98d secs=506 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1791903015,"gate":"rust/all/fmt","host":"linux-x86_64","key":"093b0888e99ed353c649d6231c7b8971b38f0498abe897ef86cb93292cb51e09","lane":"lint","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":137,"stamp":"24a9802a0ee7205a89b030a32cfb703a","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"093b0888e99ed353c649d6231c7b8971b38f0498abe897ef86cb93292cb51e09","lane":"lint","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":137,"stamp":"d18b79eed5103ad9b6c7ef0caf14d07c","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"b13a3e4e8d44fe75aca42552a99cc2eaa911ca71a18b8d7fd9d20874814a178f","lane":"rust-test","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":122,"stamp":"6f8ba9153dc09b2aef5b7e50bdad8ed2","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"97ea6da0224fe8ef77e08efe6fbc2505","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"413af48c100cac15ebd4f0742e91974c","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"b7654c81b4f0a5e86b81522bc4559a52","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"c67261876c92d68f25be28acbaa61c78","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"4af16c91d7443888ada96f552fd0aa0a","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"fb9a549b6c4ef65f9f0f4b3cf8a0d30709759bdedded7c00c95d24576e528e04","lane":"cross","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":130,"stamp":"97a8a45b954567a11634f446fe988e6c","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"} Ci-Attestation: {"at":1791903015,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"0a00f5f9df6fa38cb1320f1c0291da542d71aec3ae8d3268b5c9949f67506d89","lane":"tier2-linux","parents":["6911ceaadd9b67b7d38878599d29348e840f8daa","56ae6bcb8f54443ccc06eaec470cd89b7a8e525a"],"secs":117,"stamp":"9bc9a8428c7d53445bd659e5f7b4d2eb","tree":"214f4ee974d1d87f94467b841d6483610ef5c98d","v":1,"via":"run"}
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #520 (phase 1 only; phase 2 is #525, the C shim swap is #524).
What
New crate
rust/obs-nvenc(rlib, not yet linked into libobs-rust):candidates():OBS_{CUDA,NVENC,NVML}_LIBRARYoverride, then the C soname (libcuda.so.1), the unversioned symlink, distro/multiarch/NixOS paths, then WSL. Windows: bare DLL names loaded only from System32 (LOAD_LIBRARY_SEARCH_SYSTEM32), with the ARM64nvEncodeAPI.dllorder from nvenc-helpers.c. macOS: empty.CudaDriver::load/load_from: first success wins; typedLoadError(NotFoundwith every dlerror,GlibcMismatchparsed fromversion 'GLIBC_x.y' not found,MissingSymbol,DriverTooOld).Displaykeeps the[NVENC] Test process failed: cuda_libprefix.cuda_functions[](same_v2names, GL entries off on Windows);cuDriverGetVersionoptional.unsafeonly insrc/platform/{unix,windows}.rs(libloading), onecfg_select!inplatform/mod.rs, no Dylint allowlist.libloading = "=0.8.9"as a workspace dependency.Commits
b30c2c55e:tests/loader.rsagainsttodo!()stubs: 17 failed, 1 passed (cuda_version_parts), 1 ignored.3d1ad78ab: 18 passed, 1 ignored.6911ceaad(stamped).Tests
tests/loader.rs, 18 tests): everyLoadErrorvariant, Linux/Windows (x64 + ARM64)/macOS lists on every OS, env override, first-fails-second-succeeds, success-beats-glibc-mismatch, optional symbol, symbol table.real_gpu_loads(#[ignore]): on a NixOS host it loaded/run/opengl-driver/lib/libcuda.so.1(DistroPath) and reported driver 13.2. The C plugin's singlelibcuda.so.1lookup would rely on the loader search path there.tests/loader_parity.rs, 3 tests): the Rust search starts with the exact name C'sload_cuda_lib/load_nvenc_libopen, andrequired_cuda_symbolsequalscuda_functions[].obs-c-oracle/build.rscopies the original lines of those three items verbatim (with#line, panics if the markers move) andoracle/obs_nvenc_loader.ccompiles them with a recordingos_dlopenand a stuboffsetof.plugins/obs-nvencis added to the oracle input hash.libcuda.so.1/libcuda.so, renaminglibnvidia-encode.so.1, andcuCtxCreate_v2tocuCtxCreatein the Rust core made all 3 parity tests fail. With the changes reverted, they pass.Gate
./lintok,./unittestok (rust-test incl. windows-gnu cross build, tier2-linux), local-gate stamped on 6911cea.No C headers, C tests, plugin C files or workflow files are changed.
Still open on #520: the decision comment on phase 2, which needs the #427 CI-minutes data.