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:
2026-07-03 12:09:18 +00:00
parent 95a08e99c3
commit 01fcb01019
9 changed files with 259 additions and 150 deletions
+2 -2
View File
@@ -9,11 +9,11 @@ Helper scripts for the Windows host box (the RTX `.173` lab box, repo at
powershell -ExecutionPolicy Bypass -File scripts\windows\setup-build-env.ps1
```
Persists (Machine scope) the three vars the NVENC build needs:
Persists (Machine scope) the vars the host build needs (NVENC itself needs none — its entry
points are runtime-loaded from the driver's `nvEncodeAPI64.dll`):
| var | value | why |
| --- | --- | --- |
| `PUNKTFUNK_NVENC_LIB_DIR` | `C:\Users\Public\nvenc` | NVENC import lib (`nvencodeapi.lib`) |
| `LIBCLANG_PATH` | `C:\Program Files\LLVM\bin` | bindgen (`libclang.dll`) |
| `CMAKE_POLICY_VERSION_MINIMUM` | `3.5` | `audiopus_sys` / cmake crates |
+1 -1
View File
@@ -35,7 +35,7 @@ Set-Location $repo
# Load the persisted build env (Machine scope) into THIS process, so the build sees it even
# if this shell was started before setup-build-env.ps1 ran (env is inherited at spawn time).
foreach ($k in 'PUNKTFUNK_NVENC_LIB_DIR','LIBCLANG_PATH','CMAKE_POLICY_VERSION_MINIMUM') {
foreach ($k in 'LIBCLANG_PATH','CMAKE_POLICY_VERSION_MINIMUM') {
$v = [Environment]::GetEnvironmentVariable($k, 'Machine')
if ($v) { [Environment]::SetEnvironmentVariable($k, $v, 'Process'); Write-Host "env : $k=$v" }
else { Write-Warning "env $k not set (run setup-build-env.ps1)" }
+2 -2
View File
@@ -12,9 +12,9 @@ $admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
if (-not $admin) { throw "Run elevated (Machine-scope env requires Administrator)." }
# NVENC import lib (nvencodeapi.lib); libclang for bindgen; cmake policy floor for audiopus_sys.
# libclang for bindgen; cmake policy floor for audiopus_sys. (NVENC needs no build-time env:
# its entry points are runtime-loaded from the driver's nvEncodeAPI64.dll.)
$vars = [ordered]@{
'PUNKTFUNK_NVENC_LIB_DIR' = 'C:\Users\Public\nvenc'
'LIBCLANG_PATH' = 'C:\Program Files\LLVM\bin'
'CMAKE_POLICY_VERSION_MINIMUM' = '3.5'
# FFMPEG_DIR is only needed for the `amf-qsv` feature (libavcodec). The RTX box builds