From 59a73817c87ba5ff9d0de6f32f82ccec01244dcf Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 12 Dec 2020 13:59:47 -0600 Subject: [PATCH] Don't use AntiHooking.dll or use D3DX9 on ARM64 --- app/app.pro | 27 ++++++++++++------- app/main.cpp | 5 ++-- .../video/ffmpeg-renderers/dxva2.cpp | 11 ++++++++ app/streaming/video/ffmpeg-renderers/dxva2.h | 7 ++++- moonlight-qt.pro | 7 +++-- scripts/build-arch.bat | 14 +++++----- 6 files changed, 50 insertions(+), 21 deletions(-) diff --git a/app/app.pro b/app/app.pro index 3d078139..ea248c54 100644 --- a/app/app.pro +++ b/app/app.pro @@ -33,17 +33,22 @@ DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 win32 { - INCLUDEPATH += \ - $$PWD/../libs/windows/include \ - $$(DXSDK_DIR)/Include + INCLUDEPATH += $$PWD/../libs/windows/include contains(QT_ARCH, i386) { + INCLUDEPATH += $$(DXSDK_DIR)/Include LIBS += -L$$PWD/../libs/windows/lib/x86 - LIBS += -L$$(DXSDK_DIR)/Lib/x86 + LIBS += -L$$(DXSDK_DIR)/Lib/x86 -ld3dx9 + DEFINES += HAS_D3DX9 } contains(QT_ARCH, x86_64) { + INCLUDEPATH += $$(DXSDK_DIR)/Include LIBS += -L$$PWD/../libs/windows/lib/x64 - LIBS += -L$$(DXSDK_DIR)/Lib/x64 + LIBS += -L$$(DXSDK_DIR)/Lib/x64 -ld3dx9 + DEFINES += HAS_D3DX9 + } + contains(QT_ARCH, arm64) { + LIBS += -L$$PWD/../libs/windows/lib/arm64 } LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib qwave.lib @@ -102,7 +107,7 @@ unix:!macx { } } win32 { - LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus -ld3dx9 + LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus CONFIG += ffmpeg } win32:!winrt { @@ -353,11 +358,13 @@ INCLUDEPATH += $$PWD/../h264bitstream/h264bitstream DEPENDPATH += $$PWD/../h264bitstream/h264bitstream !winrt { - win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking - else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking + contains(QT_ARCH, i386)|contains(QT_ARCH, x86_64) { + win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking + else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking - INCLUDEPATH += $$PWD/../AntiHooking - DEPENDPATH += $$PWD/../AntiHooking + INCLUDEPATH += $$PWD/../AntiHooking + DEPENDPATH += $$PWD/../AntiHooking + } } unix:!macx: { diff --git a/app/main.cpp b/app/main.cpp index 5ef96d8c..892808b2 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -289,9 +289,10 @@ int main(int argc, char *argv[]) SetUnhandledExceptionFilter(UnhandledExceptionHandler); #endif -#if defined(Q_OS_WIN32) +#if defined(Q_OS_WIN32) && defined(Q_PROCESSOR_X86) // Force AntiHooking.dll to be statically imported and loaded - // by ntdll by calling a dummy function. + // by ntdll on x86/x64 platforms by calling a dummy function. + // AntiHooking.dll is not currently built for ARM64. AntiHookingDummyImport(); #elif defined(Q_OS_LINUX) // Force libssl.so to be directly linked to our binary, so diff --git a/app/streaming/video/ffmpeg-renderers/dxva2.cpp b/app/streaming/video/ffmpeg-renderers/dxva2.cpp index 8824dd80..a37b4495 100644 --- a/app/streaming/video/ffmpeg-renderers/dxva2.cpp +++ b/app/streaming/video/ffmpeg-renderers/dxva2.cpp @@ -31,8 +31,10 @@ DXVA2Renderer::DXVA2Renderer() : m_ProcService(nullptr), m_Processor(nullptr), m_FrameIndex(0), +#ifdef HAS_D3DX9 m_DebugOverlayFont(nullptr), m_StatusOverlayFont(nullptr), +#endif m_BlockingPresent(false) { RtlZeroMemory(m_DecSurfaces, sizeof(m_DecSurfaces)); @@ -52,8 +54,11 @@ DXVA2Renderer::~DXVA2Renderer() SAFE_COM_RELEASE(m_RenderTarget); SAFE_COM_RELEASE(m_ProcService); SAFE_COM_RELEASE(m_Processor); + +#ifdef HAS_D3DX9 SAFE_COM_RELEASE(m_DebugOverlayFont); SAFE_COM_RELEASE(m_StatusOverlayFont); +#endif for (int i = 0; i < ARRAYSIZE(m_DecSurfaces); i++) { SAFE_COM_RELEASE(m_DecSurfaces[i]); @@ -744,6 +749,7 @@ bool DXVA2Renderer::initialize(PDECODER_PARAMETERS params) void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type) { +#ifdef HAS_D3DX9 HRESULT hr; switch (type) @@ -798,6 +804,9 @@ void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type) SDL_assert(false); break; } +#else + Q_UNUSED(type); +#endif } int DXVA2Renderer::getDecoderColorspace() @@ -1002,6 +1011,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame) } } +#ifdef HAS_D3DX9 if (m_DebugOverlayFont != nullptr) { if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug)) { SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(Overlay::OverlayDebug); @@ -1025,6 +1035,7 @@ void DXVA2Renderer::renderFrame(AVFrame *frame) D3DCOLOR_ARGB(color.a, color.r, color.g, color.b)); } } +#endif hr = m_Device->EndScene(); if (FAILED(hr)) { diff --git a/app/streaming/video/ffmpeg-renderers/dxva2.h b/app/streaming/video/ffmpeg-renderers/dxva2.h index 7632cbd6..69bce691 100644 --- a/app/streaming/video/ffmpeg-renderers/dxva2.h +++ b/app/streaming/video/ffmpeg-renderers/dxva2.h @@ -4,9 +4,12 @@ #include "pacer/pacer.h" #include -#include #include +#ifdef HAS_D3DX9 +#include +#endif + extern "C" { #include } @@ -63,7 +66,9 @@ private: DXVA2_ValueRange m_SaturationRange; DXVA2_VideoDesc m_Desc; REFERENCE_TIME m_FrameIndex; +#ifdef HAS_D3DX9 LPD3DXFONT m_DebugOverlayFont; LPD3DXFONT m_StatusOverlayFont; +#endif bool m_BlockingPresent; }; diff --git a/moonlight-qt.pro b/moonlight-qt.pro index a13627df..97fc3d20 100644 --- a/moonlight-qt.pro +++ b/moonlight-qt.pro @@ -8,8 +8,11 @@ SUBDIRS = \ # Build the dependencies in parallel before the final app app.depends = qmdnsengine moonlight-common-c h264bitstream win32:!winrt { - SUBDIRS += AntiHooking - app.depends += AntiHooking + contains(QT_ARCH, i386)|contains(QT_ARCH, x86_64) { + # We don't build AntiHooking.dll for ARM64 (yet?) + SUBDIRS += AntiHooking + app.depends += AntiHooking + } } !winrt:win32|macx { SUBDIRS += soundio diff --git a/scripts/build-arch.bat b/scripts/build-arch.bat index bfdd65c8..a795d766 100644 --- a/scripts/build-arch.bat +++ b/scripts/build-arch.bat @@ -136,13 +136,15 @@ echo Copying DLL dependencies copy %SOURCE_ROOT%\libs\windows\lib\%ARCH%\*.dll %DEPLOY_FOLDER% if !ERRORLEVEL! NEQ 0 goto Error -echo Copying AntiHooking.dll -copy %BUILD_FOLDER%\AntiHooking\%BUILD_CONFIG%\AntiHooking.dll %DEPLOY_FOLDER% -if !ERRORLEVEL! NEQ 0 goto Error +if /I "%ARCH%" NEQ "ARM64" ( + echo Copying AntiHooking.dll + copy %BUILD_FOLDER%\AntiHooking\%BUILD_CONFIG%\AntiHooking.dll %DEPLOY_FOLDER% + if !ERRORLEVEL! NEQ 0 goto Error -echo Copying d3dx9_43.dll from DirectX SDK -expand "%DXSDK_DIR%\Redist\Jun2010_d3dx9_43_%ARCH%.cab" -F:d3dx9_43.dll %DEPLOY_FOLDER% -if !ERRORLEVEL! NEQ 0 goto Error + echo Copying d3dx9_43.dll from DirectX SDK + expand "%DXSDK_DIR%\Redist\Jun2010_d3dx9_43_%ARCH%.cab" -F:d3dx9_43.dll %DEPLOY_FOLDER% + if !ERRORLEVEL! NEQ 0 goto Error +) echo Copying GC mapping list copy %SOURCE_ROOT%\app\SDL_GameControllerDB\gamecontrollerdb.txt %DEPLOY_FOLDER%