From bd1d49c97f7475b60871878d7e4c2e396d94267a Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 05:10:00 +0000 Subject: [PATCH 1/9] fix(build): Enable minhook only on x86_64 MinHook does not support arm64, add conditional check Signed-off-by: Coia Prant Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- cmake/compile_definitions/windows.cmake | 7 ++++++- cmake/dependencies/windows.cmake | 14 ++++++++------ src/platform/windows/display_base.cpp | 10 +++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/cmake/compile_definitions/windows.cmake b/cmake/compile_definitions/windows.cmake index 60ee905b773..cb2cd1ac8c8 100644 --- a/cmake/compile_definitions/windows.cmake +++ b/cmake/compile_definitions/windows.cmake @@ -82,7 +82,6 @@ list(PREPEND PLATFORM_LIBRARIES libssp.a libstdc++.a libwinpthread.a - minhook::minhook ntdll setupapi shlwapi @@ -92,6 +91,12 @@ list(PREPEND PLATFORM_LIBRARIES wsock32 ) +if(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") + list(APPEND PLATFORM_LIBRARIES + minhook::minhook + ) +endif() + if(SUNSHINE_ENABLE_TRAY) list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/third-party/tray/src/tray_windows.c") diff --git a/cmake/dependencies/windows.cmake b/cmake/dependencies/windows.cmake index 3faad7dfd41..3527418bd17 100644 --- a/cmake/dependencies/windows.cmake +++ b/cmake/dependencies/windows.cmake @@ -1,9 +1,11 @@ # windows specific dependencies -# Make sure MinHook is installed -find_library(MINHOOK_LIBRARY libMinHook.a REQUIRED) -find_path(MINHOOK_INCLUDE_DIR MinHook.h PATH_SUFFIXES include REQUIRED) +if(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64") + # Make sure MinHook is installed + find_library(MINHOOK_LIBRARY libMinHook.a REQUIRED) + find_path(MINHOOK_INCLUDE_DIR MinHook.h PATH_SUFFIXES include REQUIRED) -add_library(minhook::minhook STATIC IMPORTED) -set_property(TARGET minhook::minhook PROPERTY IMPORTED_LOCATION ${MINHOOK_LIBRARY}) -target_include_directories(minhook::minhook INTERFACE ${MINHOOK_INCLUDE_DIR}) + add_library(minhook::minhook STATIC IMPORTED) + set_property(TARGET minhook::minhook PROPERTY IMPORTED_LOCATION ${MINHOOK_LIBRARY}) + target_include_directories(minhook::minhook INTERFACE ${MINHOOK_INCLUDE_DIR}) +endif() diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index 6698566207f..ab92aaa29d4 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -12,7 +12,11 @@ // lib includes #include #include -#include + +// conditional includes +#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) + #include +#endif // We have to include boost/process/v1.hpp before display.h due to WinSock.h, // but that prevents the definition of NTSTATUS so we must define it ourself. @@ -407,6 +411,7 @@ namespace platf::dxgi { return false; } +#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) /** * @brief Hook for NtGdiDdDDIGetCachedHybridQueryValue() from win32u.dll. * @param gpuPreference A pointer to the location where the preference will be written. @@ -425,6 +430,7 @@ namespace platf::dxgi { return STATUS_INVALID_PARAMETER; } } +#endif int display_base_t::init(const ::video::config_t &config, const std::string &display_name) { std::once_flag windows_cpp_once_flag; @@ -444,12 +450,14 @@ namespace platf::dxgi { FreeLibrary(user32); } + #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) { // We aren't calling MH_Uninitialize(), but that's okay because this hook lasts for the life of the process MH_Initialize(); MH_CreateHookApi(L"win32u.dll", "NtGdiDdDDIGetCachedHybridQueryValue", (void *) NtGdiDdDDIGetCachedHybridQueryValueHook, nullptr); MH_EnableHook(MH_ALL_HOOKS); } + #endif }); // Get rectangle of full desktop for absolute mouse coordinates From 8d0d9e6fc0f001251e33c6f65900b3ba5227613d Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 08:14:01 +0000 Subject: [PATCH 2/9] fix(build): add check for Steam Audio Driver Steam Audio Driver unavailable on Windows Arm64, add check Signed-off-by: Coia Prant --- src/platform/windows/audio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/windows/audio.cpp b/src/platform/windows/audio.cpp index 20e600acaa9..ea5746b51c8 100644 --- a/src/platform/windows/audio.cpp +++ b/src/platform/windows/audio.cpp @@ -36,7 +36,9 @@ DEFINE_PROPERTYKEY(PKEY_DeviceInterface_FriendlyName, 0x026e516e, 0xb814, 0x414b namespace { constexpr auto SAMPLE_RATE = 48000; +#ifdef STEAM_DRIVER_SUBDIR constexpr auto STEAM_AUDIO_DRIVER_PATH = L"%CommonProgramFiles(x86)%\\Steam\\drivers\\Windows10\\" STEAM_DRIVER_SUBDIR L"\\SteamStreamingSpeakers.inf"; +#endif constexpr auto waveformat_mask_stereo = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; From e8c62fc89e9bd599bf7cf4a3830ed3e48c05a09f Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Mon, 2 Jun 2025 20:08:47 +0000 Subject: [PATCH 3/9] fix(build): add compatibility for clang For AMF `#include`, clang will resolve `std` to `config::amd::std` Use `::std` to force resolution to the global namespace Signed-off-by: Coia Prant Co-authored-by: Ricky8955555 --- src/config.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index c1dba388ef1..5025016fd32 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -187,7 +187,7 @@ namespace config { }; template - std::optional quality_from_view(const std::string_view &quality_type, const std::optional(&original)) { + ::std::optional quality_from_view(const ::std::string_view &quality_type, const ::std::optional(&original)) { #define _CONVERT_(x) \ if (quality_type == #x##sv) \ return (int) T::x @@ -199,7 +199,7 @@ namespace config { } template - std::optional rc_from_view(const std::string_view &rc, const std::optional(&original)) { + ::std::optional rc_from_view(const ::std::string_view &rc, const ::std::optional(&original)) { #define _CONVERT_(x) \ if (rc == #x##sv) \ return (int) T::x @@ -212,7 +212,7 @@ namespace config { } template - std::optional usage_from_view(const std::string_view &usage, const std::optional(&original)) { + ::std::optional usage_from_view(const ::std::string_view &usage, const ::std::optional(&original)) { #define _CONVERT_(x) \ if (usage == #x##sv) \ return (int) T::x @@ -225,7 +225,7 @@ namespace config { return original; } - int coder_from_view(const std::string_view &coder) { + int coder_from_view(const ::std::string_view &coder) { if (coder == "auto"sv) { return _auto; } From c299f9aed4434cca11f52e0ef803a4cf025fad89 Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 05:16:14 +0000 Subject: [PATCH 4/9] fix(build): Declare SyntheticPointerDevice only on x86_64 SyntheticPointerDevice does not support arm64, add conditional check Signed-off-by: Coia Prant --- src/platform/windows/input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index 50f8aab8b04..55d0eab0968 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -22,7 +22,7 @@ #include "src/logging.h" #include "src/platform/common.h" -#ifdef __MINGW32__ +#if defined(__MINGW32__) && (defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64)) DECLARE_HANDLE(HSYNTHETICPOINTERDEVICE); WINUSERAPI HSYNTHETICPOINTERDEVICE WINAPI CreateSyntheticPointerDevice(POINTER_INPUT_TYPE pointerType, ULONG maxCount, POINTER_FEEDBACK_MODE mode); WINUSERAPI BOOL WINAPI InjectSyntheticPointerInput(HSYNTHETICPOINTERDEVICE device, CONST POINTER_TYPE_INFO *pointerInfo, UINT32 count); From ea61996854a973492fdd20b72f13b51bd46ddfcb Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 06:19:57 +0000 Subject: [PATCH 5/9] fix(build): Disable test for windows arm64 CLANGARM64 does not have libatomic which used by googletest, disable it Signed-off-by: Coia Prant --- cmake/prep/options.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index cc2e1e1f59b..f3a820a2174 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -9,6 +9,12 @@ set(SUNSHINE_PUBLISHER_ISSUE_URL "https://app.lizardbyte.dev/support" option(BUILD_DOCS "Build documentation" ON) option(BUILD_TESTS "Build tests" ON) + +# CLANGARM64 does not have libatomic which used by googletest, disable it +if(MINGW AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64") + set(BUILD_TESTS ON CACHE BOOL "Build tests" FORCE) +endif() + option(NPM_OFFLINE "Use offline npm packages. You must ensure packages are in your npm cache." OFF) option(BUILD_WERROR "Enable -Werror flag." OFF) From ba9b25cd98bbef0156e93d7d0e756734921414fa Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 06:36:42 +0000 Subject: [PATCH 6/9] fix(build): replace boost with backports Boost v1.87.0 is not currently compatible with WoA, backport the following context: Support building assembly files for mingw-w64 on arm64 with CMake Link: https://github.com/boostorg/context/commit/f82483d343c6452c62ec89a48d22a3a7e565373d uuid: Do not link to libatomic under any Clang/Windows Link: https://github.com/boostorg/uuid/commit/434329f8dc7fcfb69cd7565ab0318d86772cea39 Signed-off-by: Coia Prant --- cmake/dependencies/Boost_Sunshine.cmake | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cmake/dependencies/Boost_Sunshine.cmake b/cmake/dependencies/Boost_Sunshine.cmake index eb2ac4095fd..ba6d3ebae14 100644 --- a/cmake/dependencies/Boost_Sunshine.cmake +++ b/cmake/dependencies/Boost_Sunshine.cmake @@ -54,8 +54,19 @@ if(NOT Boost_FOUND) # Limit boost to the required libraries only set(BOOST_INCLUDE_LIBRARIES ${BOOST_COMPONENTS}) - set(BOOST_URL "https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz") # cmake-lint: disable=C0301 - set(BOOST_HASH "SHA256=7da75f171837577a52bbf217e17f8ea576c7c246e4594d617bfde7fafd408be5") + # set(BOOST_URL "https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz") # cmake-lint: disable=C0301 + # set(BOOST_HASH "SHA256=7da75f171837577a52bbf217e17f8ea576c7c246e4594d617bfde7fafd408be5") + + # Build Windows Arm64 must backport following: + # + # context: Support building assembly files for mingw-w64 on arm64 with CMake + # Link: https://github.com/boostorg/context/commit/f82483d343c6452c62ec89a48d22a3a7e565373d + # + # uuid: Do not link to libatomic under any Clang/Windows + # Link: https://github.com/boostorg/uuid/commit/434329f8dc7fcfb69cd7565ab0318d86772cea39 + # + set(BOOST_URL "https://github.com/rbqvq/Sunshine/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz") # cmake-lint: disable=C0301 + set(BOOST_HASH "SHA256=7238ae092c7e8aa97fe47321bee4cf6ef059c8001fbde30e3611a856543d605f") if(CMAKE_VERSION VERSION_LESS "3.24.0") FetchContent_Declare( From 9c6fedc4d5481951ccbf97ac6cd59c37fd01a8b8 Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 07:12:40 +0000 Subject: [PATCH 7/9] docs(windows): add documents for arm64 Add windows arm64 documents. Signed-off-by: Coia Prant Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- docs/building.md | 52 +++++++++++++++++++++++++++-------------- docs/getting_started.md | 20 ++++++++++++---- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/docs/building.md b/docs/building.md index b7f5d402601..e11b4a928b2 100644 --- a/docs/building.md +++ b/docs/building.md @@ -72,33 +72,51 @@ sudo port install "${dependencies[@]}" ``` #### Windows -First you need to install [MSYS2](https://www.msys2.org), then startup "MSYS2 UCRT64" and execute the following -commands. + +@warning{Cross-compilation is not supported on Windows. You must build on the target architecture.} + +First you need to install [MSYS2](https://www.msys2.org). + +For AMD64 startup "MSYS2 UCRT64", or for ARM64 startup "MSYS2 CLANGARM64", then execute the following commands. ##### Update all packages ```bash pacman -Syu ``` +##### Set toolchain variable +For UCRT64: +```bash +export TOOLCHAIN="ucrt-x86_64" +``` + +For CLANGARM64: +```bash +export TOOLCHAIN="clang-aarch64" +``` + ##### Install dependencies ```bash dependencies=( "git" - "mingw-w64-ucrt-x86_64-boost" # Optional - "mingw-w64-ucrt-x86_64-cmake" - "mingw-w64-ucrt-x86_64-cppwinrt" - "mingw-w64-ucrt-x86_64-curl-winssl" - "mingw-w64-ucrt-x86_64-doxygen" # Optional, for docs... better to install official Doxygen - "mingw-w64-ucrt-x86_64-graphviz" # Optional, for docs - "mingw-w64-ucrt-x86_64-MinHook" - "mingw-w64-ucrt-x86_64-miniupnpc" - "mingw-w64-ucrt-x86_64-nodejs" - "mingw-w64-ucrt-x86_64-nsis" - "mingw-w64-ucrt-x86_64-onevpl" - "mingw-w64-ucrt-x86_64-openssl" - "mingw-w64-ucrt-x86_64-opus" - "mingw-w64-ucrt-x86_64-toolchain" + "mingw-w64-${TOOLCHAIN}-boost" # Optional + "mingw-w64-${TOOLCHAIN}-cmake" + "mingw-w64-${TOOLCHAIN}-cppwinrt" + "mingw-w64-${TOOLCHAIN}-curl-winssl" + "mingw-w64-${TOOLCHAIN}-graphviz" # Optional, for docs + "mingw-w64-${TOOLCHAIN}-miniupnpc" + "mingw-w64-${TOOLCHAIN}-nodejs" + "mingw-w64-${TOOLCHAIN}-onevpl" + "mingw-w64-${TOOLCHAIN}-openssl" + "mingw-w64-${TOOLCHAIN}-opus" + "mingw-w64-${TOOLCHAIN}-toolchain" ) +if [[ ${MSYSTEM} == "ucrt64" ]]; then + dependencies+=( + "mingw-w64-${TOOLCHAIN}-MinHook" + "mingw-w64-${TOOLCHAIN}-nsis" # TODO: how to create an arm64 installer? + ) +fi pacman -S "${dependencies[@]}" ``` @@ -139,7 +157,7 @@ ninja -C build }} @tab{Windows | @tabs{ @tab{Installer | ```bash - cpack -G NSIS --config ./build/CPackConfig.cmake + cpack -G NSIS --config ./build/CPackConfig.cmake # Not working on CLANGARM64 ```} @tab{Portable | ```bash cpack -G ZIP --config ./build/CPackConfig.cmake diff --git a/docs/getting_started.md b/docs/getting_started.md index f30362390c5..69eaa33045e 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -281,10 +281,17 @@ brew uninstall sunshine ### Windows +Sunshine now supports ARM64 on Windows; however this should be considered experimental. This version does not properly +support GPU scheduling and any hardware acceleration. + #### Installer (recommended) -1. Download and install - [Sunshine-Windows-AMD64-installer.exe](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-installer.exe) +1. Download and install based on your architecture: + + | Architecture | Installer | + |-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------| + | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-installer.exe](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-installer.exe) | + | ARM64 | [Sunshine-Windows-ARM64-installer.exe](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-ARM64-installer.exe) | @attention{You should carefully select or unselect the options you want to install. Do not blindly install or enable features.} @@ -297,8 +304,13 @@ overflow menu. Different versions of Windows may provide slightly different step @warning{By using this package instead of the installer, performance will be reduced. This package is not recommended for most users. No support will be provided!} -1. Download and extract - [Sunshine-Windows-AMD64-portable.zip](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-portable.zip) +1. Download and extract based on your architecture: + + | Architecture | Installer | + |-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------| + | AMD64/x64 (Intel/AMD) | [Sunshine-Windows-AMD64-portable.exe](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-AMD64-portable.zip) | + | ARM64 | [Sunshine-Windows-ARM64-portable.exe](https://github.com/LizardByte/Sunshine/releases/latest/download/Sunshine-Windows-ARM64-portable.zip) | + 2. Open command prompt as administrator 3. Firewall rules From de22b2709ebc40bad469a0ded3e5ae1b71d731d9 Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Sun, 25 May 2025 06:48:49 +0000 Subject: [PATCH 8/9] ci(build/windows): add support for arm64 nsis does not support arm64, so we cannot create an installer at this time Signed-off-by: Coia Prant Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> --- .github/workflows/ci-windows.yml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index e66f52dac99..c84f13fa67a 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -32,6 +32,11 @@ jobs: arch: x86_64 msystem: ucrt64 toolchain: ucrt-x86_64 + - name: Windows-ARM64 + os: windows-11-arm + arch: aarch64 + msystem: clangarm64 + toolchain: clang-aarch64 steps: - name: Checkout uses: actions/checkout@v4 @@ -169,17 +174,22 @@ jobs: "mingw-w64-${TOOLCHAIN}-curl-winssl" "mingw-w64-${TOOLCHAIN}-gcc" "mingw-w64-${TOOLCHAIN}-graphviz" - "mingw-w64-${TOOLCHAIN}-MinHook" "mingw-w64-${TOOLCHAIN}-miniupnpc" "mingw-w64-${TOOLCHAIN}-nlohmann-json" "mingw-w64-${TOOLCHAIN}-nodejs" - "mingw-w64-${TOOLCHAIN}-nsis" "mingw-w64-${TOOLCHAIN}-onevpl" "mingw-w64-${TOOLCHAIN}-openssl" "mingw-w64-${TOOLCHAIN}-opus" "mingw-w64-${TOOLCHAIN}-toolchain" ) + if [[ ${MSYSTEM} == "ucrt64" ]]; then + dependencies+=( + "mingw-w64-${TOOLCHAIN}-MinHook" + "mingw-w64-${TOOLCHAIN}-nsis" # TODO: how to create an arm64 installer? + ) + fi + # do not modify below this line ignore_packages=() @@ -266,7 +276,6 @@ jobs: -B build \ -G Ninja \ -S . \ - -DBUILD_WERROR=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DSUNSHINE_ASSETS_DIR=assets \ -DSUNSHINE_PUBLISHER_NAME='${{ github.repository_owner }}' \ @@ -274,7 +283,8 @@ jobs: -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' ninja -C build - - name: Package Windows + - name: Package Windows Installer + if: runner.arch == 'X86' || runner.arch == 'X64' shell: msys2 {0} run: | mkdir -p artifacts @@ -282,10 +292,20 @@ jobs: # package cpack -G NSIS - cpack -G ZIP # move mv ./cpack_artifacts/Sunshine.exe ../artifacts/Sunshine-${{ matrix.name }}-installer.exe + + - name: Package Windows Portable + shell: msys2 {0} + run: | + mkdir -p artifacts + cd build + + # package + cpack -G ZIP + + # move mv ./cpack_artifacts/Sunshine.zip ../artifacts/Sunshine-${{ matrix.name }}-portable.zip - name: Run tests @@ -298,7 +318,7 @@ jobs: - name: Generate gcov report id: test_report # any except canceled or skipped - if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure') + if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && runner.arch == 'X86' || runner.arch == 'X64' shell: msys2 {0} working-directory: build run: | From 885acc7426d31c858cf8f3132ab9c8265340807d Mon Sep 17 00:00:00 2001 From: Coia Prant Date: Tue, 22 Jul 2025 19:42:08 +0000 Subject: [PATCH 9/9] fix: clang llvm parse error Add missing TOSTRING for ICON Signed-off-by: Coia Prant --- src/platform/windows/windows.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/windows/windows.rc b/src/platform/windows/windows.rc index 7de76b9301c..af6adc05654 100644 --- a/src/platform/windows/windows.rc +++ b/src/platform/windows/windows.rc @@ -41,4 +41,4 @@ BEGIN END END -SuperDuperAmazing ICON DISCARDABLE PROJECT_ICON_PATH +SuperDuperAmazing ICON DISCARDABLE TOSTRING(PROJECT_ICON_PATH)