ac0e73321c
apple / screenshots (push) Successful in 6m18s
ci / web (push) Successful in 1m25s
ci / docs-site (push) Successful in 1m5s
android / android (push) Successful in 13m2s
arch / build-publish (push) Successful in 12m39s
decky / build-publish (push) Successful in 19s
docker / build-push (--build-arg FEDORA_VERSION=44, ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora44-rpm) (push) Successful in 10s
docker / build-push (., web/Dockerfile, punktfunk-web) (push) Successful in 10s
docker / build-push (ci, ci/fedora-rpm.Dockerfile, punktfunk-fedora-rpm) (push) Successful in 8s
docker / build-push (ci, ci/rust-ci-noble.Dockerfile, punktfunk-rust-ci-noble) (push) Successful in 9s
ci / bench (push) Successful in 5m36s
docker / build-push (docs-site, docs-site/Dockerfile, punktfunk-docs) (push) Successful in 10s
windows-host / package (push) Successful in 16m23s
docker / build-push (ci, ci/rust-ci.Dockerfile, punktfunk-rust-ci) (push) Successful in 6m8s
deb / build-publish-host (push) Successful in 10m16s
deb / build-publish (push) Successful in 12m30s
ci / rust (push) Successful in 19m26s
rpm / build-publish (44, fedora-44, punktfunk-fedora44-rpm) (push) Successful in 22m20s
docker / deploy-docs (push) Successful in 23s
rpm / build-publish (43, bazzite, punktfunk-fedora-rpm) (push) Successful in 24m32s
apple / swift (push) Successful in 1m17s
PyroWave's wavelet encode runs on the GPU's compute/shader cores, so a GPU-bound game starves it: submit spikes from ~2 ms to ~15 ms under a 95%+ game load and the stream fps collapses. NVENC is immune (separate encoder ASIC). Two levers to let the encode get scheduled ahead of the game's rendering: - Windows process GPU scheduling: D3DKMTSetProcessSchedulingPriorityClass, env PUNKTFUNK_GPU_PRIORITY = off|above-normal|high (default)|realtime. Best-effort, once per process, non-fatal on refusal (enc/windows/pyrowave.rs). - Global-priority Vulkan encode queue (Granite patch 0005): request a VK_KHR_global_priority queue (PYROWAVE_QUEUE_PRIORITY = off|high|realtime, default realtime), downgrading REALTIME→HIGH→none on NOT_PERMITTED so a refused class never regresses the encoder to HEVC. HONEST STATUS: on an RTX 4090 / Windows / WDDM neither moved the ~15 ms spikes — the graphics-vs-compute preemption granularity is the wall, not the priority level. Kept because both are correct, harmless (graceful fallback), and may help other GPUs/drivers. For a GPU-saturated game the working levers are reducing the encode's GPU cost (4:2:0/8-bit) or H.265; PyroWave holds full rate on the desktop and in games that leave the GPU headroom. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
90 lines
4.5 KiB
TOML
90 lines
4.5 KiB
TOML
# Hardware/software video encode (plan §7 / §W6): the per-vendor backends (NVENC, VAAPI, AMF, QSV,
|
|
# Vulkan-Video, PyroWave, openh264) behind one `Encoder` trait + `open_video` selector, extracted
|
|
# from the host so it depends on the shared frame vocabulary (pf-frame) rather than living inside
|
|
# the orchestrator. Speaks pf-frame (CapturedFrame/PixelFormat/dxgi identity) and pf-zerocopy
|
|
# (CUDA), never pf-capture — the capture→encode edge is one-way (plan §2.4).
|
|
[package]
|
|
name = "pf-encode"
|
|
version.workspace = true
|
|
edition = "2021"
|
|
rust-version.workspace = true
|
|
license = "MIT OR Apache-2.0"
|
|
description = "punktfunk host video encode: NVENC/VAAPI/AMF/QSV/Vulkan-Video/PyroWave/openh264 backends behind one Encoder trait."
|
|
publish = false
|
|
|
|
[dependencies]
|
|
punktfunk-core = { path = "../punktfunk-core", features = ["quic"] }
|
|
pf-frame = { path = "../pf-frame" }
|
|
pf-gpu = { path = "../pf-gpu" }
|
|
pf-host-config = { path = "../pf-host-config" }
|
|
pf-zerocopy = { path = "../pf-zerocopy" }
|
|
anyhow = "1"
|
|
tracing = "0.1"
|
|
|
|
[dev-dependencies]
|
|
# A test writer for the NVENC backend's unit tests (`with_test_writer().try_init()`).
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
|
|
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
|
|
# Software H.264 (openh264, BSD-2) — the GPU-less encode path on both platforms.
|
|
openh264 = "0.9"
|
|
|
|
[target.'cfg(target_os = "linux")'.dependencies]
|
|
# libavcodec (NVENC libav + VAAPI backends). `ffmpeg-sys-next` auto-detects the FFmpeg version.
|
|
ffmpeg-next = "8"
|
|
libc = "0.2"
|
|
# Vulkan bindings for the raw Vulkan-Video encode + PyroWave compute backends (feature-gated below;
|
|
# the dep stays unconditional to mirror the host's Linux target — unused-but-declared is harmless).
|
|
ash = "0.38"
|
|
# `libnvidia-encode.so.1` is dlopen'd at runtime for the direct-SDK NVENC/CUDA backend.
|
|
libloading = "0.8"
|
|
# Direct-SDK NVENC (raw `sys::nvEncodeAPI` types; entry points resolved at runtime). `ci-check` =
|
|
# vendored bindings, no CUDA toolkit at build.
|
|
nvidia-video-codec-sdk = { version = "0.4", features = ["ci-check"], optional = true }
|
|
# PyroWave (opt-in wired-LAN wavelet codec) — vendored codec + bindgen'd C API, only under `pyrowave`.
|
|
pyrowave-sys = { path = "../pyrowave-sys", optional = true }
|
|
|
|
[target.'cfg(target_os = "windows")'.dependencies]
|
|
# NVENC (direct SDK, D3D11 input) + the shared D3D11/DXGI vocabulary via pf-frame.
|
|
nvidia-video-codec-sdk = { version = "0.4", features = ["ci-check"], optional = true }
|
|
# AMD (AMF) + Intel (QSV) hardware encode via libavcodec (behind `amf-qsv`; link-imports FFmpeg).
|
|
ffmpeg-next = { version = "8", optional = true }
|
|
# `libnvidia-encode`/`nvEncodeAPI64.dll` resolved at runtime; the NVENC status→cause table dlopen.
|
|
libloading = "0.8"
|
|
# Native Intel QSV (VPL): vendored static MIT dispatcher + bindgen'd C API, only under `qsv`.
|
|
libvpl-sys = { path = "../libvpl-sys", optional = true }
|
|
# PyroWave (opt-in wired-LAN wavelet codec) — vendored codec + bindgen'd C API, only under
|
|
# `pyrowave`. The Windows backend is the NV12 zero-copy D3D11→Vulkan encoder; same crate as Linux.
|
|
pyrowave-sys = { path = "../pyrowave-sys", optional = true }
|
|
windows = { version = "0.62", features = [
|
|
"Win32_Foundation",
|
|
"Win32_Graphics_Direct3D",
|
|
"Win32_Graphics_Direct3D11",
|
|
"Win32_Graphics_Dxgi",
|
|
"Win32_Graphics_Dxgi_Common",
|
|
# SECURITY_ATTRIBUTES — the PyroWave backend's IDXGIResource1::CreateSharedHandle signature.
|
|
"Win32_Security",
|
|
"Win32_Storage_FileSystem",
|
|
"Win32_System_LibraryLoader",
|
|
"Win32_System_Threading",
|
|
# D3DKMTSetProcessSchedulingPriorityClass — raise the host's WDDM GPU scheduling priority
|
|
# above a running game so PyroWave's compute-shader encode isn't starved (enc/windows/pyrowave.rs).
|
|
"Wdk_Graphics_Direct3D",
|
|
] }
|
|
|
|
[features]
|
|
default = []
|
|
# NVENC hardware encode (Linux CUDA + Windows D3D11); entry points resolved at runtime.
|
|
nvenc = ["dep:nvidia-video-codec-sdk"]
|
|
# AMD (AMF) + Intel (QSV) hardware encode on Windows via libavcodec.
|
|
amf-qsv = ["dep:ffmpeg-next"]
|
|
# Raw Vulkan-Video HEVC/AV1 encode on Linux (reuses the `ash` bindings; no new dep).
|
|
vulkan-encode = []
|
|
# PyroWave — the opt-in wired-LAN intra-only wavelet codec (Linux encode backend).
|
|
pyrowave = ["dep:pyrowave-sys"]
|
|
# Native Intel QSV via the statically linked VPL dispatcher (Windows; runtime GPU
|
|
# libs come from the Intel driver store). Supersedes the ffmpeg `amf-qsv` QSV path
|
|
# (design/native-qsv-encoder.md). ⚠ Like `nvenc`: hand builds need this feature or
|
|
# Intel boxes fall through to the ffmpeg path / software.
|
|
qsv = ["dep:libvpl-sys"]
|