From 7cedc1f7a50b8ef5e26437a440c8ea268e6ac407 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 30 Jun 2021 13:44:28 +0300 Subject: [PATCH] Add dynamic DirectX loading helper. --- .../SourceFiles/platform/win/windows_dlls.cpp | 63 +------------------ cmake | 2 +- docs/building-msvc.md | 2 +- 3 files changed, 3 insertions(+), 64 deletions(-) diff --git a/Telegram/SourceFiles/platform/win/windows_dlls.cpp b/Telegram/SourceFiles/platform/win/windows_dlls.cpp index ce84175f5..c4a51ffa7 100644 --- a/Telegram/SourceFiles/platform/win/windows_dlls.cpp +++ b/Telegram/SourceFiles/platform/win/windows_dlls.cpp @@ -12,8 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include -#include - #define LOAD_SYMBOL(lib, name) ::base::Platform::LoadMethod(lib, #name, name) namespace Platform { @@ -46,6 +44,7 @@ void init() { u"rstrtmgr.dll"_q, u"psapi.dll"_q, u"user32.dll"_q, + u"d3d9.dll"_q, u"d3d11.dll"_q, u"dxgi.dll"_q, }; @@ -54,26 +53,6 @@ void init() { } } -// D3D11.DLL - -HRESULT (__stdcall *D3D11CreateDevice)( - _In_opt_ IDXGIAdapter* pAdapter, - D3D_DRIVER_TYPE DriverType, - HMODULE Software, - UINT Flags, - _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, - UINT FeatureLevels, - UINT SDKVersion, - _COM_Outptr_opt_ ID3D11Device** ppDevice, - _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, - _COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext); - -// DXGI.DLL - -HRESULT (__stdcall *CreateDXGIFactory1)( - REFIID riid, - _COM_Outptr_ void **ppFactory); - void start() { init(); @@ -123,47 +102,7 @@ void start() { const auto LibUser32 = SafeLoadLibrary(u"user32.dll"_q); LOAD_SYMBOL(LibUser32, SetWindowCompositionAttribute); - - const auto LibD3D11 = SafeLoadLibrary(u"d3d11.dll"_q); - LOAD_SYMBOL(LibD3D11, D3D11CreateDevice); - - const auto LibDXGI = SafeLoadLibrary(u"dxgi.dll"_q); - LOAD_SYMBOL(LibDXGI, CreateDXGIFactory1); } } // namespace Dlls } // namespace Platform - -HRESULT WINAPI D3D11CreateDevice( - _In_opt_ IDXGIAdapter* pAdapter, - D3D_DRIVER_TYPE DriverType, - HMODULE Software, - UINT Flags, - _In_reads_opt_(FeatureLevels) CONST D3D_FEATURE_LEVEL* pFeatureLevels, - UINT FeatureLevels, - UINT SDKVersion, - _COM_Outptr_opt_ ID3D11Device** ppDevice, - _Out_opt_ D3D_FEATURE_LEVEL* pFeatureLevel, - _COM_Outptr_opt_ ID3D11DeviceContext** ppImmediateContext) { - return Platform::Dlls::D3D11CreateDevice - ? Platform::Dlls::D3D11CreateDevice( - pAdapter, - DriverType, - Software, - Flags, - pFeatureLevels, - FeatureLevels, - SDKVersion, - ppDevice, - pFeatureLevel, - ppImmediateContext) - : S_FALSE; -} - -HRESULT WINAPI CreateDXGIFactory1( - REFIID riid, - _COM_Outptr_ void **ppFactory) { - return Platform::Dlls::CreateDXGIFactory1 - ? Platform::Dlls::CreateDXGIFactory1(riid, ppFactory) - : S_FALSE; -} diff --git a/cmake b/cmake index 8d7772ab3..e2455f319 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 8d7772ab33f2b04efde728decd8ae265a461b185 +Subproject commit e2455f3194b3591d5046d0d38b8e5921c1149302 diff --git a/docs/building-msvc.md b/docs/building-msvc.md index 4ee4a2641..485083f49 100644 --- a/docs/building-msvc.md +++ b/docs/building-msvc.md @@ -198,7 +198,6 @@ Open **x86 Native Tools Command Prompt for VS 2019.bat**, go to ***BuildPath*** configure ^ -prefix "%LibrariesPath%\Al-5.15.2" ^ - -recheck ^ -debug-and-release ^ -force-debug-info ^ -opensource ^ @@ -212,6 +211,7 @@ Open **x86 Native Tools Command Prompt for VS 2019.bat**, go to ***BuildPath*** QMAKE_LIBS_OPENGL_ES2_RELEASE="%LibrariesPath%\angle\out\Release\obj\libGLESv2_static.lib %LibrariesPath%\angle\out\Release\obj\libANGLE_static.lib d3d11.lib d3d9.lib dxgi.lib dxguid.lib" ^ -egl ^ -D "EGLAPI=" ^ + -D "DESKTOP_APP_QT_STATIC_ANGLE=" ^ QMAKE_LIBS_EGL_DEBUG="%LibrariesPath%\angle\out\Debug\obj\libEGL_static.lib %LibrariesPath%\angle\out\Debug\obj\libGLESv2_static.lib %LibrariesPath%\angle\out\Debug\obj\libANGLE_static.lib d3d11.lib d3d9.lib dxgi.lib dxguid.lib Gdi32.lib User32.lib" ^ QMAKE_LIBS_EGL_RELEASE="%LibrariesPath%\angle\out\Release\obj\libEGL_static.lib %LibrariesPath%\angle\out\Release\obj\libGLESv2_static.lib %LibrariesPath%\angle\out\Release\obj\libANGLE_static.lib d3d11.lib d3d9.lib dxgi.lib dxguid.lib Gdi32.lib User32.lib" ^ -openssl-linked ^