feat(host/windows): NVENC D3D11 hardware encoder (--features nvenc)

Zero-copy capture->encode on the GPU via the raw NVENC API (nvidia_video_codec_sdk sys + ENCODE_API; the safe wrapper is CUDA-only). Opens an NV_ENC_DEVICE_TYPE_DIRECTX session on the SAME ID3D11Device as the DXGI capturer (carried on the new FramePayload::D3d11), registers a pool of BGRA textures once, CopyResources each captured texture in and encode_picture; CBR/ULL, infinite GOP, P-only, forced-IDR for RFI. The DXGI capturer gains a D3D11 zero-copy output (selected, like the encoder, by PUNKTFUNK_ENCODER=nvenc) so capture+encode share textures.

OFF by default (the nvenc feature pulls the NVENC SDK + cudarc): the default Windows host links without it (openh264 path). cudarc builds toolkit-less via the SDK ci-check feature (dynamic-loading). At link time --features nvenc needs nvencodeapi.lib (NVENC SDK, or an import lib generated from the driver's nvEncodeAPI64.dll) on PUNKTFUNK_NVENC_LIB_DIR. Both default and --features nvenc builds validated to compile+link GPU-less on the VM (import lib generated from the driver DLL). Runtime needs a real NVIDIA GPU.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-15 01:39:46 +00:00
parent 0aff2a8d5e
commit 3d3b9e8a5f
6 changed files with 498 additions and 9 deletions
Generated
+20
View File
@@ -806,6 +806,15 @@ dependencies = [
"cipher",
]
[[package]]
name = "cudarc"
version = "0.16.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17200eb07e7d85a243aa1bf4569a7aa998385ba98d14833973a817a63cc86e92"
dependencies = [
"libloading",
]
[[package]]
name = "curve25519-dalek"
version = "4.1.3"
@@ -2222,6 +2231,16 @@ dependencies = [
"syn",
]
[[package]]
name = "nvidia-video-codec-sdk"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b150dfc88653e761947906dfc0ea14af16ae366cfc55122caab94381761605a"
dependencies = [
"cudarc",
"lazy_static",
]
[[package]]
name = "oid-registry"
version = "0.7.1"
@@ -2615,6 +2634,7 @@ dependencies = [
"khronos-egl",
"libc",
"mdns-sd",
"nvidia-video-codec-sdk",
"openh264",
"opus",
"pipewire",