fix(encode/windows): resolve NVENC at runtime — AMD/Intel hosts no longer crash at start
The nvenc build linked nvEncodeAPI64.dll's entry points at load time, so a --features nvenc binary hard-crashed on any box without the NVIDIA driver (AMD/Intel). Entry points now come from a runtime LoadLibrary table (encode/windows/nvenc.rs load_api); a missing DLL just falls through the encoder auto-detect to AMF/QSV/software. The generated import lib and all its plumbing (gen-nvenc-importlib.ps1, nvenc.def, PUNKTFUNK_NVENC_LIB_DIR, setup-build-env wiring) are gone. Live-validated on the RTX 4090 box (NVENC session, 7000+ frames). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
//! Build script. The only thing it does: with the `nvenc` feature (Windows GPU host), tell the
|
||||
//! linker to pull the NVENC import library. The NVENC entry points
|
||||
//! (`NvEncodeAPICreateInstance` / `NvEncodeAPIGetMaxSupportedVersion`) live in `nvEncodeAPI64.dll`
|
||||
//! (shipped with the NVIDIA driver), so the host links against `nvencodeapi.lib`. Point
|
||||
//! `PUNKTFUNK_NVENC_LIB_DIR` at a directory containing `nvencodeapi.lib` — from the NVIDIA Video
|
||||
//! Codec SDK, or an import lib generated from the driver's `nvEncodeAPI64.dll`
|
||||
//! (`lib /def:nvenc.def /machine:x64 /out:nvencodeapi.lib` with the two exports above).
|
||||
//! Build script: stamps the build version. NVENC deliberately needs NOTHING here — the entry
|
||||
//! points (`NvEncodeAPICreateInstance` / `NvEncodeAPIGetMaxSupportedVersion`) live in
|
||||
//! `nvEncodeAPI64.dll`, which only exists where the NVIDIA driver is installed, so
|
||||
//! `encode/windows/nvenc.rs` resolves them at RUNTIME (`LoadLibraryExW`). The former link-time
|
||||
//! import (`cargo:rustc-link-lib=nvencodeapi`) made the Windows loader kill the all-vendor host
|
||||
//! binary on every AMD/Intel-only box before `main` ("nvencodeapi64.dll was not found").
|
||||
fn main() {
|
||||
// Build provenance: stamp the exact package/build version into the binary so a running host
|
||||
// can report what it is (mgmt /health, the startup log, `--version`) and a stale/shadowed
|
||||
@@ -18,12 +17,4 @@ fn main() {
|
||||
.unwrap_or_else(|| std::env::var("CARGO_PKG_VERSION").unwrap_or_else(|_| "unknown".into()));
|
||||
println!("cargo:rustc-env=PUNKTFUNK_VERSION={version}");
|
||||
println!("cargo:rerun-if-env-changed=PUNKTFUNK_BUILD_VERSION");
|
||||
|
||||
if std::env::var_os("CARGO_FEATURE_NVENC").is_some() {
|
||||
if let Some(dir) = std::env::var_os("PUNKTFUNK_NVENC_LIB_DIR") {
|
||||
println!("cargo:rustc-link-search=native={}", dir.to_string_lossy());
|
||||
}
|
||||
println!("cargo:rustc-link-lib=dylib=nvencodeapi");
|
||||
println!("cargo:rerun-if-env-changed=PUNKTFUNK_NVENC_LIB_DIR");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user