Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows ARM64 Support #4771

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:
if: always()
strategy:
matrix:
arch: [x64, x86]
arch: [x64, x86, ARM64]
env:
CMAKE_GENERATOR: 'Visual Studio 17 2022'
CMAKE_SYSTEM_VERSION: '10.0.18363.657'
Expand Down Expand Up @@ -324,6 +324,7 @@ jobs:

- name: 'Restore VLC dependency from cache'
id: vlc-cache
if: matrix.arch != 'ARM64'
uses: actions/cache@v3
env:
CACHE_NAME: 'vlc-cache'
Expand All @@ -333,6 +334,7 @@ jobs:

- name: 'Restore Chromium Embedded Framework from cache'
id: cef-cache
if: matrix.arch != 'ARM64'
uses: actions/cache@v3
env:
CACHE_NAME: 'cef-cache'
Expand Down
26 changes: 22 additions & 4 deletions CI/windows/01_install_dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Param(
[Switch]$Help = $(if (Test-Path variable:Help) { $Help }),
[Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
[Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
[ValidateSet('x86', 'x64')]
[ValidateSet('x86', 'x64', 'ARM64')]
[String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { ('x86', 'x64')[[System.Environment]::Is64BitOperatingSystem] })
)

Expand All @@ -26,7 +26,7 @@ Function Install-obs-deps {
Write-Status "Setup for pre-built Windows OBS dependencies v${Version}"
Ensure-Directory $DepsBuildDir

$ArchSuffix = $BuildArch
$ArchSuffix = $BuildArch.ToLower()

if (!(Test-Path "${DepsBuildDir}/windows-deps-${Version}-${ArchSuffix}")) {

Expand All @@ -52,17 +52,26 @@ function Install-qt-deps {
Write-Status "Setup for pre-built dependency Qt v${Version}"
Ensure-Directory $DepsBuildDir

$ArchSuffix = $BuildArch
$ArchSuffix = $BuildArch.ToLower()

if (!(Test-Path "${DepsBuildDir}/windows-deps-${Version}-${ArchSuffix}/mkspecs")) {

if (${BuildArch} -eq "arm64") {
Write-Step "Download x64 qt..."
$ProgressPreference = $(if ($Quiet.isPresent) { 'SilentlyContinue' } else { 'Continue' })
Invoke-WebRequest -Uri "https://github.com/obsproject/obs-deps/releases/download/${Version}/windows-deps-qt6-${Version}-${ArchSuffix}.zip" -UseBasicParsing -OutFile "windows-deps-qt6-${Version}-${ArchSuffix}.zip"
$ProgressPreference = "Continue"

Write-Step "Unpack x64 qt..."
Expand-Archive -Path "windows-deps-qt6-${Version}-${ArchSuffix}.zip" -DestinationPath "${DepsBuildDir}/qt_host" -Force
}

Write-Step "Download..."
$ProgressPreference = $(if ($Quiet.isPresent) { 'SilentlyContinue' } else { 'Continue' })
Invoke-WebRequest -Uri "https://github.com/obsproject/obs-deps/releases/download/${Version}/windows-deps-qt6-${Version}-${ArchSuffix}.zip" -UseBasicParsing -OutFile "windows-deps-qt6-${Version}-${ArchSuffix}.zip"
$ProgressPreference = "Continue"

Write-Step "Unpack..."

Expand-Archive -Path "windows-deps-qt6-${Version}-${ArchSuffix}.zip" -DestinationPath "${DepsBuildDir}/windows-deps-${Version}-${ArchSuffix}" -Force
} else {
Write-Step "Found existing pre-built Qt..."
Expand All @@ -75,6 +84,10 @@ function Install-vlc {
[String]$Version
)

if (${BuildArch} -eq "arm64") {
Write-Status "Skip VLC for Winodws ARM64"
}

Write-Status "Setup for dependency VLC v${Version}"
Ensure-Directory $DepsBuildDir

Expand All @@ -98,6 +111,11 @@ function Install-cef {
[Parameter(Mandatory=$true)]
[String]$Version
)

if (${BuildArch} -eq "arm64") {
Write-Status "Skip VLC for Winodws ARM64"
}

Write-Status "Setup for dependency CEF v${Version} - ${BuildArch}"

Ensure-Directory $DepsBuildDir
Expand Down
12 changes: 10 additions & 2 deletions CI/windows/02_build_obs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Param(
[Switch]$Quiet = $(if (Test-Path variable:Quiet) { $Quiet }),
[Switch]$Verbose = $(if (Test-Path variable:Verbose) { $Verbose }),
[String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" } else { "build" }),
[ValidateSet('x86', 'x64')]
[ValidateSet('x86', 'x64', 'ARM64')]
[String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { ('x86', 'x64')[[System.Environment]::Is64BitOperatingSystem] }),
[ValidateSet("Release", "RelWithDebInfo", "MinSizeRel", "Debug")]
[String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" } else { "RelWithDebInfo" })
Expand Down Expand Up @@ -61,14 +61,20 @@ function Configure-OBS {
$CmakePrefixPath = Resolve-Path -Path "${CheckoutDir}/../obs-build-dependencies/windows-deps-${WindowsDepsVersion}-${BuildArch}"
$CefDirectory = Resolve-Path -Path "${CheckoutDir}/../obs-build-dependencies/cef_binary_${WindowsCefVersion}_windows_${BuildArch}"
$BuildDirectoryActual = "${BuildDirectory}$(if (${BuildArch} -eq "x64") { "64" } else { "32" })"
$GeneratorPlatform = "$(if (${BuildArch} -eq "x64") { "x64" } else { "Win32" })"

$GeneratorPlatform = "$(if (${BuildArch} -eq "x86") { "Win32" } else { ${BuildArch} })"
if (${BuildArch} -eq "arm64") {
$Qt_Host_Path = Resolve-Path -Path "${CmakePrefixPath}/../qt_host"
}

if ( $PSVersionTable.PSVersion -ge '7.3.0' ) {
$CmakeCommand = @(
"-G", ${CmakeGenerator}
"-DCMAKE_GENERATOR_PLATFORM=${GeneratorPlatform}",
"-DCMAKE_SYSTEM_VERSION=${CmakeSystemVersion}",
"-DCMAKE_PREFIX_PATH:PATH=${CmakePrefixPath}",
"-DCMAKE_TOOLCHAIN_FILE=${CmakePrefixPath}/lib/cmake/Qt6/qt.toolchain.cmake",
"$(if (${BuildArch} -eq "arm64") { "QT_HOST_PATH=${Qt_Host_Path}" })",
"-DCEF_ROOT_DIR:PATH=${CefDirectory}",
"-DENABLE_BROWSER=ON",
"-DVLC_PATH:PATH=${CheckoutDir}/../obs-build-dependencies/vlc-${WindowsVlcVersion}",
Expand All @@ -95,6 +101,8 @@ function Configure-OBS {
"-DCMAKE_GENERATOR_PLATFORM=`"${GeneratorPlatform}`"",
"-DCMAKE_SYSTEM_VERSION=`"${CmakeSystemVersion}`"",
"-DCMAKE_PREFIX_PATH:PATH=`"${CmakePrefixPath}`"",
"-DCMAKE_TOOLCHAIN_FILE=`"${CmakePrefixPath}\lib\cmake\Qt6\qt.toolchain.cmake`"",
"$(if (${BuildArch} -eq "arm64") { "QT_HOST_PATH=${Qt_Host_Path}" })",
"-DCEF_ROOT_DIR:PATH=`"${CefDirectory}`"",
"-DENABLE_BROWSER=ON",
"-DVLC_PATH:PATH=`"${CheckoutDir}/../obs-build-dependencies/vlc-${WindowsVlcVersion}`"",
Expand Down
18 changes: 17 additions & 1 deletion CI/windows/03_package_obs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Param(
[Switch]$BuildInstaller = $(if ($BuildInstaller.isPresent) { $BuildInstaller }),
[Switch]$CombinedArchs = $(if ($CombinedArchs.isPresent) { $CombinedArchs }),
[String]$BuildDirectory = $(if (Test-Path variable:BuildDirectory) { "${BuildDirectory}" } else { "build" }),
[ValidateSet('x86', 'x64')]
[ValidateSet('x86', 'x64', 'ARM64')]
[String]$BuildArch = $(if (Test-Path variable:BuildArch) { "${BuildArch}" } else { ('x86', 'x64')[[System.Environment]::Is64BitOperatingSystem] }),
[ValidateSet("Release", "RelWithDebInfo", "MinSizeRel", "Debug")]
[String]$BuildConfiguration = $(if (Test-Path variable:BuildConfiguration) { "${BuildConfiguration}" } else { "RelWithDebInfo" })
Expand Down Expand Up @@ -82,6 +82,22 @@ function Package-OBS {
Compress-Archive -Force @CompressVars
$ProgressPreference = 'Continue'

} elseif ($BuildArch -eq "ARM64") {
Write-Step "Install 64-bit OBS..."
Invoke-Expression "cmake --build `"${BuildDirectory}64`" --config ${BuildConfiguration} -t install"

$CompressVars = @{
Path = "${CheckoutDir}/build64/install/bin", "${CheckoutDir}/build64/install/data", "${CheckoutDir}/build64/install/obs-plugins"
CompressionLevel = "Optimal"
DestinationPath = "${FileName}-Win-ARM64.zip"
}

Write-Step "Creating zip archive..."

$ProgressPreference = $(if ($Quiet.isPresent) { 'SilentlyContinue' } else { 'Continue' })
Compress-Archive -Force @CompressVars
$ProgressPreference = 'Continue'

} elseif ($BuildArch -eq "x86") {
Write-Step "Install 32-bit OBS..."
Invoke-Expression "cmake --build `"${BuildDirectory}32`" --config ${BuildConfiguration} -t install"
Expand Down
2 changes: 2 additions & 0 deletions UI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ if(OS_WINDOWS)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}../deps/libff/libff/ff-util.c
PROPERTIES COMPILE_FLAGS -Dinline=__inline)

add_definitions(-DNOMINMAX)
endif()

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
Expand Down
4 changes: 4 additions & 0 deletions UI/frontend-plugins/aja-output-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
project(aja-output-ui)

if(OS_WINDOWS AND ARCH_ARM64)
set(ENABLE_AJA OFF)
endif()

if(NOT ENABLE_AJA)
return()
endif()
Expand Down
7 changes: 7 additions & 0 deletions UI/win-update/updater/updater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
"processorArchitecture='amd64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#elif defined _M_ARM64
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
"version='6.0.0.0' " \
"processorArchitecture='arm64' " \
"publicKeyToken='6595b64144ccf1df' " \
"language='*'\"")
#else
#pragma comment(linker, "/manifestdependency:\"type='win32' " \
"name='Microsoft.Windows.Common-Controls' " \
Expand Down
3 changes: 2 additions & 1 deletion UI/window-basic-filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#include <QVariant>

#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#endif #include < Windows.h>
#endif

using namespace std;
Expand Down
3 changes: 2 additions & 1 deletion UI/window-basic-interaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#include <QWindow>

#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#endif #include < Windows.h>
#endif

using namespace std;
Expand Down
3 changes: 2 additions & 1 deletion UI/window-basic-properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
#include <util/c99defs.h>

#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#include <Windows.h>
#endif #include < Windows.h>
#endif

using namespace std;
Expand Down
8 changes: 7 additions & 1 deletion cmake/Modules/CopyMSVCBins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ file(
"${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/libbz2*.dll"
"${FFMPEG_avcodec_INCLUDE_DIR}/../bin${_bin_suffix}/zlib*.dll"
"${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/libbz2*.dll"
"${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/zlib*.dll")
"${FFMPEG_avcodec_INCLUDE_DIR}/bin${_bin_suffix}/zlib*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/../bin/avfilter-*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/../bin${_bin_suffix}/avfilter-*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/bin${_bin_suffix}/avfilter-*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/../bin/avresample-*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/../bin${_bin_suffix}/avresample-*.dll"
"${FFMPEG_avfilter_INCLUDE_DIR}/bin${_bin_suffix}/avresample-*.dll")

file(
GLOB
Expand Down
4 changes: 4 additions & 0 deletions cmake/Modules/ObsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(ObsDefaults_Windows)
set(OS_WINDOWS ON)
set(OS_POSIX OFF)

if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
set(ARCH_ARM64 ON)
endif()
endif()

# Create global property to hold list of activated modules
Expand Down
4 changes: 4 additions & 0 deletions cmake/external/ObsPluginHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|OpenBSD")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(OS_WINDOWS ON)
set(OS_POSIX OFF)

if(CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
set(ARCH_ARM64 ON)
endif()
endif()

# Old-Style plugin detected, find "modern" libobs variant instead and set global
Expand Down
4 changes: 4 additions & 0 deletions deps/obs-scripting/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
option(ENABLE_SCRIPTING_LUA "Enable Lua scripting support" ON)
option(ENABLE_SCRIPTING_PYTHON "Enable Python scripting support" ON)

if(OS_WINDOWS AND ARCH_ARM64)
set(ENABLE_SCRIPTING_LUA OFF)
endif()

if(NOT ENABLE_SCRIPTING)
obs_status(DISABLED "obs-scripting")
return()
Expand Down
2 changes: 1 addition & 1 deletion deps/w32-pthreads/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#define PTW32_PROGCTR(Context) ((Context).Rip)
#endif

#if defined(_ARM_) || defined(ARM)
#if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64)
#define PTW32_PROGCTR(Context) ((Context).Pc)
#endif

Expand Down
8 changes: 7 additions & 1 deletion libobs/obs-win-crash-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ static inline bool get_dbghelp_imports(struct exception_handler_data *data)

static inline void init_instruction_data(struct stack_trace *trace)
{
#ifdef _WIN64
#if defined(_M_ARM64)
trace->instruction_ptr = trace->context.Pc;
trace->frame.AddrPC.Offset = trace->instruction_ptr;
trace->frame.AddrFrame.Offset = trace->context.Fp;
trace->frame.AddrStack.Offset = trace->context.Sp;
trace->image_type = IMAGE_FILE_MACHINE_ARM64;
#elif defined(_WIN64)
trace->instruction_ptr = trace->context.Rip;
trace->frame.AddrPC.Offset = trace->instruction_ptr;
trace->frame.AddrFrame.Offset = trace->context.Rbp;
Expand Down
2 changes: 1 addition & 1 deletion libobs/util/threading-windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <string.h>

#if !defined(_M_IX86) && !defined(_M_X64) && !defined(_M_ARM) && \
!defined(_M_ARM64)
!defined(_M_ARM64) && !defined(_M_ARM64EC)
#error Processor not supported
#endif

Expand Down
4 changes: 2 additions & 2 deletions libobs/util/util_uint64.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

#pragma once

#if defined(_MSC_VER) && defined(_M_X64)
#if defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC)
#include <intrin.h>
#endif

static inline uint64_t util_mul_div64(uint64_t num, uint64_t mul, uint64_t div)
{
#if defined(_MSC_VER) && defined(_M_X64)
#if defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC)
unsigned __int64 high;
const unsigned __int64 low = _umul128(num, mul, &high);
unsigned __int64 rem;
Expand Down
4 changes: 3 additions & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ if(OS_WINDOWS)
add_subdirectory(vlc-video)
add_subdirectory(obs-vst)

if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/enc-amf/CMakeLists.txt")
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/enc-amf/CMakeLists.txt" AND NOT DEFINED
ARCH_ARM64)
add_subdirectory(enc-amf)
else()
obs_status(WARNING "enc-amf plugin not found.")
endif()
if(MSVC)
add_subdirectory(win-ivcam)
add_definitions(-DNOMINMAX)
endif()

check_obs_browser()
Expand Down
5 changes: 5 additions & 0 deletions plugins/aja/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
project(aja)

option(ENABLE_AJA "Build OBS with aja support" ON)

if(OS_WINDOWS AND ARCH_ARM64)
set(ENABLE_AJA OFF)
endif()

if(NOT ENABLE_AJA)
obs_status(DISABLED "aja")
return()
Expand Down
2 changes: 1 addition & 1 deletion plugins/enc-amf
2 changes: 1 addition & 1 deletion plugins/obs-filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ option(ENABLE_SPEEXDSP
"Enable building with SpeexDSP-based noise suppression filter" ON)
option(ENABLE_RNNOISE "Enable building with RNNoise noise supression filter" ON)

if(OS_WINDOWS)
if(OS_WINDOWS AND NOT DEFINED ARCH_ARM64)
option(
ENABLE_NVAFX
"Enable building with NVIDIA Audio Effects SDK (requires redistributable to be installed)"
Expand Down
Loading