From f84d951684f2293bb7285f132a433f505e2b4ffe Mon Sep 17 00:00:00 2001 From: Tommy Vercetti <7903172+tommyvct@users.noreply.github.com> Date: Sat, 22 May 2021 15:34:41 -0500 Subject: [PATCH] Windows ARM64: Initial support CI: Add GitHub Action Windows ARM64 CI This mega commit also includes the changes from the following PR: cmake: Add DISABLE_QSV11 option to disable QSV encoder #4748 libobs: Restrict emmintrin.h to x86(_64) platform #4746 Resolve potential symbol clash on MSVC #4743 obs-filters: Add preprocessor guard to method #4730 Windows ARM64: Initial support CI: Add GitHub Action Windows ARM64 CI This mega commit also includes the changes from the following PR: cmake: Add DISABLE_QSV11 option to disable QSV encoder #4748 libobs: Restrict emmintrin.h to x86(_64) platform #4746 Resolve potential symbol clash on MSVC #4743 obs-filters: Add preprocessor guard to method #4730 obs-qsv11: Add ENABLE_QSV11 option obs-qsv11: Add ENABLE_QSV11 option UI: Remove Qt Windows Extras for Qt 6 and later UI: Remove Qt Windows Extras for Qt 6 and later UI: Remove Qt Windows Extras for Qt 6 and later Co-Authored-By: Matt Gajownik --- .github/workflows/main.yml | 66 ++++++++++++++++++++++++++++++- UI/CMakeLists.txt | 9 +++-- UI/win-update/updater/updater.hpp | 7 ++++ UI/window-basic-main.cpp | 14 +++---- UI/window-basic-main.hpp | 4 +- cmake/Modules/CopyMSVCBins.cmake | 4 ++ deps/w32-pthreads/context.h | 2 +- libobs/obs-win-crash-handler.c | 8 +++- libobs/util/threading-windows.h | 2 +- libobs/util/util_uint64.h | 4 +- 10 files changed, 101 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5885a2ccfdddd2..9a89fcc49b9fef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,14 +5,16 @@ on: paths-ignore: - '**.md' branches: - - master + - '**' + - '*' tags: - '*' pull_request: paths-ignore: - '**.md' branches: - - master + - '**' + - '*' env: MACOS_CEF_BUILD_VERSION: '4183' @@ -709,3 +711,63 @@ jobs: with: name: '${{ env.FILE_NAME }}' path: build/* + winarm64: + name: 'Windows on ARM64' + runs-on: [windows-latest] + env: + QT_VERSION: '5.15.2' + CMAKE_GENERATOR: "Visual Studio 16 2019" + CMAKE_SYSTEM_VERSION: "10.0.18363.657" + VIRTUALCAM-GUID: "A3FCE0F5-3493-419F-958A-ABA1250EC20B" + steps: + - name: 'Add msbuild to PATH' + uses: microsoft/setup-msbuild@v1.0.2 + - name: 'Checkout' + uses: actions/checkout@v2.3.3 + with: + submodules: 'recursive' + - name: 'Fetch Git Tags' + shell: bash + run: | + git fetch --prune --unshallow + echo "OBS_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV + echo "OBS_GIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + echo "OBS_GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + - name: 'Check for Github Labels' + if: github.event_name == 'pull_request' + shell: bash + run: | + LABELS_URL="$(echo ${{ github.event.pull_request.url }} | sed s'/pulls/issues/')" + LABEL_FOUND="$(curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "${LABELS_URL}/labels" | sed -n 's/.*"name": "\(.*\)",/\1/p' | grep 'Seeking Testers' || true)" + if [ "${LABEL_FOUND}" = "Seeking Testers" ]; then + echo "SEEKING_TESTERS=1" >> $GITHUB_ENV + else + echo "SEEKING_TESTERS=0" >> $GITHUB_ENV + fi + - name: 'Install prerequisite: Pre-built dependencies' + run: | + curl -kL https://github.com/tommyvct/obs-deps/releases/latest/download/DepsARM64.zip -f --retry 5 -o DepsARM64.zip + 7z x DepsARM64.zip -o"${{ github.workspace }}/cmbuild/" + - name: "Configure" + run: | + mkdir ./build64 + cd ./build64 + cmake -G"${{ env.CMAKE_GENERATOR }}" -A"ARM64" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=true -DCOMPILE_D3D12_HOOK=true -DDepsPath="${{ github.workspace }}/cmbuild/DepsARM64" -DQTDIR="${{ github.workspace }}/cmbuild/DepsARM64/qt/" -DCEF_ROOT_DIR="${{ github.workspace }}/cmbuild/DepsARM64/cef" -DPYTHON_LIB="${{ github.workspace }}/cmbuild/DepsARM64/bin/python39.lib" -DTWITCH_CLIENTID='${{ env.TWITCH_CLIENTID }}' -DTWITCH_HASH='${{ env.TWITCH_HASH }}' -DRESTREAM_CLIENTID='${{ env.RESTREAM_CLIENTID }}' -DRESTREAM_HASH='${{ env.RESTREAM_HASH }}' -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE -DVIRTUALCAM_GUID=${{ env.VIRTUALCAM-GUID }} -DBUILD_AMD_ENCODER=OFF -DENABLE_SCRIPTING=ON -DCOMPILE_PYTHON=ON -DENABLE_QSV11=OFF -DVULKAN_INCLUDE_DIR="${{ github.workspace }}/cmbuild/DepsARM64/VulkanSDK/include" -DVULKAN_LIB="${{ github.workspace }}/cmbuild/DepsARM64/VulkanSDK/vulkan-1.lib" .. + - name: 'Build' + run: msbuild /m /p:Configuration=RelWithDebInfo .\build64\obs-studio.sln + - name: 'Package' + if: success() && (github.event_name != 'pull_request' || env.SEEKING_TESTERS == '1') + run: | + $env:FILE_DATE=(Get-Date -UFormat "%F") + $env:FILE_NAME="${env:FILE_DATE}-${{ env.OBS_GIT_HASH }}-${{ env.OBS_GIT_TAG }}-windows_arm64" + echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV} + robocopy .\build64\rundir\RelWithDebInfo .\build\ /E /XF .gitignore + 7z + - name: 'Publish' + if: success() && (github.event_name != 'pull_request' || env.SEEKING_TESTERS == '1') + uses: actions/upload-artifact@v2.2.0 + with: + name: '${{ env.FILE_NAME }}' + path: build/* + + diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index 375faffae582ba..9028501798ae2b 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -73,7 +73,7 @@ find_package(Threads REQUIRED) find_package(Qt5Network ${FIND_MODE}) find_package(Qt5Widgets ${FIND_MODE}) find_package(Qt5Svg ${FIND_MODE}) -if(WIN32) +if(WIN32 AND (Qt5Widgets_VERSION VERSION_LESS 6.0.0)) find_package(Qt5WinExtras ${FIND_MODE}) endif() find_package(Qt5Xml ${FIND_MODE}) @@ -452,8 +452,11 @@ if(WIN32) set_target_properties(obs PROPERTIES OUTPUT_NAME "obs${_output_suffix}") - target_link_libraries(obs - Qt5::WinExtras) + + if(Qt5Widgets_VERSION VERSION_LESS 6.0.0) + target_link_libraries(obs + Qt5::WinExtras) + endif() endif() target_link_libraries(obs diff --git a/UI/win-update/updater/updater.hpp b/UI/win-update/updater/updater.hpp index 812d1da7a7fa07..7f7031f8689918 100644 --- a/UI/win-update/updater/updater.hpp +++ b/UI/win-update/updater/updater.hpp @@ -65,6 +65,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' " \ diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index fe53cf70b4ebf1..564b55f828d534 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -2015,7 +2015,7 @@ void OBSBasic::OBSInit() SystemTray(true); #endif -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setWindow(windowHandle()); #endif @@ -6650,7 +6650,7 @@ inline void OBSBasic::OnActivate(bool force) App()->IncrementSleepInhibition(); UpdateProcessPriority(); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setOverlayIcon(QIcon::fromTheme( "obs-active", QIcon(":/res/images/active.png"))); #endif @@ -6681,7 +6681,7 @@ inline void OBSBasic::OnDeactivate() App()->DecrementSleepInhibition(); ClearProcessPriority(); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->clearOverlayIcon(); #endif if (trayIcon && trayIcon->isVisible()) { @@ -6708,7 +6708,7 @@ inline void OBSBasic::OnDeactivate() #endif trayIcon->setIcon(QIcon::fromTheme("obs-tray-paused", trayIconFile)); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setOverlayIcon(QIcon::fromTheme( "obs-paused", QIcon(":/res/images/paused.png"))); @@ -6724,7 +6724,7 @@ inline void OBSBasic::OnDeactivate() #endif trayIcon->setIcon(QIcon::fromTheme("obs-tray-active", trayIconFile)); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setOverlayIcon(QIcon::fromTheme( "obs-active", QIcon(":/res/images/active.png"))); @@ -9697,7 +9697,7 @@ void OBSBasic::PauseRecording() ui->statusbar->RecordingPaused(); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setOverlayIcon(QIcon::fromTheme( "obs-paused", QIcon(":/res/images/paused.png"))); #endif @@ -9741,7 +9741,7 @@ void OBSBasic::UnpauseRecording() ui->statusbar->RecordingUnpaused(); -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) taskBtn->setOverlayIcon(QIcon::fromTheme( "obs-active", QIcon(":/res/images/active.png"))); #endif diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 5e26a1bb0990b9..e52bd705689b16 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -22,7 +22,7 @@ #include #include #include -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif #include @@ -317,7 +317,7 @@ class OBSBasic : public OBSMainWindow { QPointer renameScene; QPointer renameSource; -#ifdef _WIN32 +#if defined(_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWinTaskbarButton *taskBtn = new QWinTaskbarButton(this); #endif diff --git a/cmake/Modules/CopyMSVCBins.cmake b/cmake/Modules/CopyMSVCBins.cmake index aee9296dd85163..2b46f9785a4260 100644 --- a/cmake/Modules/CopyMSVCBins.cmake +++ b/cmake/Modules/CopyMSVCBins.cmake @@ -39,6 +39,10 @@ file(GLOB FFMPEG_BIN_FILES "${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" + "${FFMPEG_postproc_INCLUDE_DIR}/../bin/postproc-*.dll" "${FFMPEG_postproc_INCLUDE_DIR}/../bin${_bin_suffix}/postproc-*.dll" diff --git a/deps/w32-pthreads/context.h b/deps/w32-pthreads/context.h index f55dd73e944929..72e1c1812a9b14 100644 --- a/deps/w32-pthreads/context.h +++ b/deps/w32-pthreads/context.h @@ -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 diff --git a/libobs/obs-win-crash-handler.c b/libobs/obs-win-crash-handler.c index d4551b56482139..9e27e3b9b93cd1 100644 --- a/libobs/obs-win-crash-handler.c +++ b/libobs/obs-win-crash-handler.c @@ -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; diff --git a/libobs/util/threading-windows.h b/libobs/util/threading-windows.h index ce083d4af6c848..0f03bffe738875 100644 --- a/libobs/util/threading-windows.h +++ b/libobs/util/threading-windows.h @@ -20,7 +20,7 @@ #include #if !defined(_M_IX86) && !defined(_M_X64) && !defined(_M_ARM) && \ - !defined(_M_ARM64) + !defined(_M_ARM64) && !defined(_M_ARM64EC) #error Processor not supported #endif diff --git a/libobs/util/util_uint64.h b/libobs/util/util_uint64.h index 654436b7a99d08..f40cc961c54166 100644 --- a/libobs/util/util_uint64.h +++ b/libobs/util/util_uint64.h @@ -16,13 +16,13 @@ #pragma once -#if defined(_MSC_VER) && defined(_M_X64) +#if defined(_MSC_VER) && defined(_M_X64) && !defined(_M_ARM64EC) #include #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;