🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@faratech
Copy link

Summary

This PR adds support for building and running Sunshine on Windows ARM64 devices, specifically targeting Qualcomm Snapdragon X Elite/Plus laptops with Adreno GPUs.

Changes

Build System

  • Fix icon path handling for cross-compilation with llvm-rc
  • Add ARM64 Steam audio driver subdirectory detection
  • Add CMake toolchain file for aarch64-w64-mingw32

Clang/MinGW Compatibility

  • Fix ::std:: namespace qualification for clang template resolution
  • Fix boost::process inline namespace syntax for clang
  • Add wgc_interop_guids.h header for WGC GUID constexpr evaluation

Qualcomm GPU Support

  • Add Qualcomm vendor ID detection (0x4D4F4351, 0x5143)
  • Route Qualcomm GPUs to Media Foundation encoders

Media Foundation Encoder

  • Add mediafoundation encoder with h264_mf, hevc_mf, av1_mf codecs
  • Configure for streaming: CBR rate control, display_remoting scenario
  • Add FIXED_GOP_SIZE flag for encoders without on-demand IDR support
  • Limit to SDR 4:2:0 8-bit (Qualcomm MF encoder limitation)

Documentation

  • Add comprehensive docs/BUILD-ARM64.md build guide

Testing

Tested on:

  • Device: Qualcomm Snapdragon X Elite (Adreno X1-85 GPU)
  • Build: Cross-compiled from WSL2 Ubuntu using llvm-mingw
  • Streaming: Verified with Moonlight client

What Works

  • Desktop capture (WGC and DXGI duplication)
  • Hardware encoding via Media Foundation (HEVC, H.264, AV1)
  • Audio capture
  • Input handling

Known Limitations

  • No HDR support (Qualcomm MF encoder only supports 8-bit)
  • No YUV444 support
  • MF encoder has ~8ms latency overhead vs direct GPU APIs
  • D3D12 Video Encode API not supported by Qualcomm drivers
  • Software encoding may perform better for low-latency use cases

Checklist

  • Code compiles without warnings
  • Changes are backwards compatible (all changes are conditional)
  • Tested on target hardware
  • Documentation included

- Use ::std:: fully qualified namespace in template functions to avoid
  ambiguity with clang's namespace resolution
- Fix boost::process inline namespace declaration for clang compatibility
  (clang doesn't support 'inline v1' syntax the same way as MSVC)

These changes enable cross-compilation with llvm-mingw toolchain for
Windows ARM64 targets.
- Fix icon path handling for cross-compilation with llvm-rc
  (use relative path from build directory)
- Add ARM64 Steam audio driver subdirectory detection

Enables building Sunshine for Windows ARM64 using llvm-mingw toolchain.
Add wgc_interop_guids.h which provides __mingw_uuidof specialization
for IGraphicsCaptureItemInterop interface. This is required for
constexpr GUID evaluation when compiling with clang/llvm-mingw.

The header is conditionally included only when building with clang.
Add vendor ID detection for Qualcomm Adreno GPUs:
- 0x4D4F4351: "QCOM" in ASCII (reversed as little-endian)
- 0x5143: Alternate Qualcomm vendor ID

When a Qualcomm GPU is detected, only Media Foundation encoders
(h264_mf, hevc_mf, av1_mf) are considered compatible, as Qualcomm
doesn't support NVENC, AMF, or QSV encoder APIs.
Add Windows Media Foundation hardware encoder support for platforms
that don't have NVENC, AMF, or QSV (primarily Qualcomm Snapdragon).

Encoders added:
- h264_mf: H.264 via Media Foundation
- hevc_mf: HEVC via Media Foundation
- av1_mf: AV1 via Media Foundation

Configuration:
- Uses D3D11VA hardware device for GPU texture input
- CBR rate control with display_remoting scenario for streaming
- Only supports SDR 4:2:0 8-bit (Qualcomm MF encoder limitation)
- Fixed GOP size of 120 frames since MF doesn't support on-demand IDR

The mediafoundation encoder is probed after quicksync and amdvce,
serving as a fallback for ARM64 Windows devices.
Add comprehensive build guide for cross-compiling Sunshine to Windows
ARM64 from Linux using llvm-mingw toolchain.

Includes:
- Prerequisites and quick start
- Step-by-step dependency building (OpenSSL, curl, miniupnpc, opus)
- Stub libraries for unsupported features (MinHook, VPL)
- CMake toolchain file for aarch64-w64-mingw32
- Hardware encoding notes and limitations
- Troubleshooting section
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher
Copy link
Member

Duplicate of #3905

@ReenigneArcher ReenigneArcher marked this as a duplicate of #3905 Dec 19, 2025
} else if (adapter_desc.VendorId == 0x4D4F4351 || // Qualcomm (QCOM as MOQC reversed)
adapter_desc.VendorId == 0x5143) { // Qualcomm alternate ID
// If it's not a MediaFoundation encoder, it's not compatible with a Qualcomm GPU
if (!boost::algorithm::ends_with(name, "_mf")) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just move this check for _mf into the Unknown GPU Vendor ID section below. MF should be a generic fallback for any unknown GPUs (and should never be allowed for any GPUs where we have native API support).

@ns6089
Copy link
Contributor

ns6089 commented Jan 4, 2026

Add FIXED_GOP_SIZE flag for encoders without on-demand IDR support

Did anyone confirm that eAVEncH264PictureType::eAVEncH264PictureType_IDR doesn't work on Qualcomm, or is it just ffmpeg limitation?

@ns6089
Copy link
Contributor

ns6089 commented Jan 4, 2026

Also it may use IDR on CODECAPI_AVEncVideoForceKeyFrame, which is triggered by ffmpeg on AV_PICTURE_TYPE_I.

@cgutman
Copy link
Collaborator

cgutman commented Jan 5, 2026

Also it may use IDR on CODECAPI_AVEncVideoForceKeyFrame, which is triggered by ffmpeg on AV_PICTURE_TYPE_I.

Yeah, I expect that to work (as it's mandatory for any hardware encoder per MSDN).

If the reason for this was the "Encoder did not produce IDR frame" warning, it's possible that was simply an output delay issue. If the MF encoder is delaying output frames for further input (which is bad for latency), then the warning will be displayed even though the key frame will come after submitting a subsequent frame.

@ns6089
Copy link
Contributor

ns6089 commented Jan 5, 2026

CODECAPI_AVEncVideoMarkLTRFrame
CODECAPI_AVEncVideoUseLTRFrame

👀

I somehow doubt that Qualcomm supports these two though, that would be too nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants