feat(windows): AMD (AMF) + Intel (QSV) hardware encode on the Windows host
The Windows host was NVIDIA-only (NVENC) with an openh264 software fallback. Add
AMD AMF and Intel QSV via libavcodec — the Windows analogue of the Linux VAAPI
backend — so one installer serves all three GPU vendors.
- encode/ffmpeg_win.rs: new WinVendor{Amf,Qsv} encoder. System-memory NV12/P010
readback (default, robust) + opt-in zero-copy D3D11 (PUNKTFUNK_ZEROCOPY: shares
the capturer's ID3D11Device; AMF takes AV_PIX_FMT_D3D11, QSV derives a QSV frames
ctx and maps) with a system fallback for the format-group mismatch the capturer's
video-processor fallback can produce. HDR Main10 (P010 + BT.2020/PQ VUI; an
Rgb10a2->P010 swscale covers the shader fallback).
- encode.rs: Codec::amf_name/qsv_name; open_video + windows_resolved_backend()
resolve PUNKTFUNK_ENCODER=auto|nvenc|amf|qsv|sw via a DXGI adapter VendorId probe.
- capture/dxgi.rs: gpu_mode mirrors the resolved backend (D3D11 NV12/P010 for AMF/QSV).
- gamestream/serverinfo.rs: GPU-aware codec advertisement (windows_codec_support;
AV1 gated to RDNA3+/Arc, like the VAAPI path).
- Cargo.toml: amf-qsv feature (optional ffmpeg-next in the windows target block).
- CI/installer: windows-host.yml sets FFMPEG_DIR + builds --features nvenc,amf-qsv;
the Inno installer bundles the FFmpeg DLLs; host.env default nvenc -> auto.
CI-green target; AMF/QSV not yet on-glass validated (no AMD/Intel Windows box in the
lab) — NVENC stays live-validated. An adversarial-review pass caught + fixed real
FFI bugs (AV_PIX_FMT_P010 is a macro -> P010LE; windows-rs 0.62 GetImmediateContext/
GetDesc1 return Result; AV_HWFRAME_MAP_* is a bindgen enum with no BitOr).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -50,29 +50,41 @@ pub fn serverinfo_xml(host: &Host, https: bool, paired: bool) -> String {
|
||||
fn codec_mode_support() -> u32 {
|
||||
#[cfg(target_os = "linux")]
|
||||
if crate::encode::linux_zero_copy_is_vaapi() {
|
||||
use super::{SCM_AV1_MAIN8, SCM_H264, SCM_HEVC};
|
||||
let caps = crate::encode::vaapi_codec_support();
|
||||
let mut m = 0;
|
||||
if caps.h264 {
|
||||
m |= SCM_H264;
|
||||
if let Some(m) = probed_mask(crate::encode::vaapi_codec_support()) {
|
||||
return m;
|
||||
}
|
||||
if caps.h265 {
|
||||
m |= SCM_HEVC;
|
||||
}
|
||||
if caps.av1 {
|
||||
m |= SCM_AV1_MAIN8;
|
||||
}
|
||||
// Only trust a probe that actually found an encoder. An empty result means VAAPI wasn't
|
||||
// usable at probe time (no VA display — a GPU-less CI box, or a misconfigured host), NOT
|
||||
// that the GPU encodes nothing; advertise the static superset (pre-probe behaviour) rather
|
||||
// than claiming zero codecs.
|
||||
if m != 0 {
|
||||
}
|
||||
// Windows AMD/Intel (AMF/QSV): advertise only what the GPU actually encodes (AV1 is narrow, an
|
||||
// old iGPU might lack HEVC). NVENC and the GPU-less software path keep the static superset.
|
||||
#[cfg(all(target_os = "windows", feature = "amf-qsv"))]
|
||||
if crate::encode::windows_backend_is_ffmpeg() {
|
||||
if let Some(m) = probed_mask(crate::encode::windows_codec_support()) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
SERVER_CODEC_MODE_SUPPORT
|
||||
}
|
||||
|
||||
/// Turn a probed [`CodecSupport`](crate::encode::CodecSupport) into a `ServerCodecModeSupport` mask,
|
||||
/// or `None` if the probe found nothing — meaning the GPU wasn't usable at probe time (GPU-less CI,
|
||||
/// a misconfigured/wrong-vendor host), NOT that it encodes zero codecs; the caller then advertises
|
||||
/// the static superset (pre-probe behaviour) rather than claiming nothing.
|
||||
#[cfg(any(target_os = "linux", all(target_os = "windows", feature = "amf-qsv")))]
|
||||
fn probed_mask(caps: crate::encode::CodecSupport) -> Option<u32> {
|
||||
use super::{SCM_AV1_MAIN8, SCM_H264, SCM_HEVC};
|
||||
let mut m = 0;
|
||||
if caps.h264 {
|
||||
m |= SCM_H264;
|
||||
}
|
||||
if caps.h265 {
|
||||
m |= SCM_HEVC;
|
||||
}
|
||||
if caps.av1 {
|
||||
m |= SCM_AV1_MAIN8;
|
||||
}
|
||||
(m != 0).then_some(m)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user