From 60d249a9090b4942c371c9c1557684f21b096336 Mon Sep 17 00:00:00 2001 From: sorgts Date: Wed, 12 Aug 2020 20:15:32 +0200 Subject: [PATCH 1/3] Fix Windows/CMake build with Visual Studio --- CMakeLists.txt | 25 +++++++++++++++---------- Windows/InputDevice.cpp | 1 + Windows/WASAPIStream.cpp | 1 + 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0137d06d5a..76e754e72d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -915,6 +915,7 @@ if(WIN32) set(THIN3D_PLATFORMS ${THIN3D_PLATFORMS} ext/native/thin3d/thin3d_d3d9.cpp ext/native/thin3d/thin3d_d3d11.cpp + ext/native/thin3d/d3d9_d3dcompiler_loader.cpp ext/native/thin3d/d3dx9_loader.cpp ext/native/thin3d/d3dx9_loader.h ext/native/thin3d/d3d11_loader.cpp @@ -1848,8 +1849,6 @@ if(USE_MINIUPNPC) if (NOT WIN32) add_definitions (-DMINIUPNPC_SET_SOCKET_TIMEOUT) add_definitions (-D_BSD_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200112L) - else() - add_definitions (-D_WIN32_WINNT=0x0501) # XP or higher for getnameinfo and friends endif() if (MACOSX) add_definitions (-D_DARWIN_C_SOURCE) @@ -1897,25 +1896,31 @@ if(USE_MINIUPNPC) # find_library (RESOLV_LIBRARY NAMES resolv) # set (LDLIBS ${SOCKET_LIBRARY} ${NSL_LIBRARY} ${RESOLV_LIBRARY} ${LDLIBS}) endif() - if (MSVC) - # Suppress noise warnings - target_compile_definitions(miniupnpc _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) - endif() if (UPNPC_BUILD_STATIC) add_library(miniupnpc STATIC ${MINIUPNPC_SOURCES}) target_link_libraries(${CoreLibName} miniupnpc ${LDLIBS}) set(UPNPC_LIBRARY miniupnpc) + if (MSVC) + # Suppress noise warnings + target_compile_definitions(miniupnpc PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) + endif() endif() endif() setup_target_project(${CoreLibName} Core) -# Generate git-version.cpp at build time. -add_custom_target(GitVersion ALL - DEPENDS something_that_never_exists) +# Generate git-version at build time. +add_custom_target(GitVersion DEPENDS something_that_never_exists) + +set(WIN_VERSION_CMD "") +if (WIN32) + set(WIN_VERSION_CMD COMMAND ${CMAKE_SOURCE_DIR}/Windows/git-version-gen.cmd PPSSPPWindows) +endif() + add_custom_command(OUTPUT something_that_never_exists COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} - -P ${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake) + -P ${CMAKE_CURRENT_SOURCE_DIR}/git-version.cmake + ${WIN_VERSION_CMD}) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/git-version.cpp PROPERTIES GENERATED TRUE diff --git a/Windows/InputDevice.cpp b/Windows/InputDevice.cpp index 3c59c8323e..d800c87713 100644 --- a/Windows/InputDevice.cpp +++ b/Windows/InputDevice.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "stdafx.h" #include #include diff --git a/Windows/WASAPIStream.cpp b/Windows/WASAPIStream.cpp index d399781c46..9662bf2891 100644 --- a/Windows/WASAPIStream.cpp +++ b/Windows/WASAPIStream.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "WindowsAudio.h" #include "WASAPIStream.h" #include "Common/Log.h" From 0ae12da3a7c58de41324ad19532e3bc3217d0c85 Mon Sep 17 00:00:00 2001 From: sorgts Date: Thu, 13 Aug 2020 16:48:19 +0200 Subject: [PATCH 2/3] Fix SSE detection with clang-cl clang-cl advertises its SSE support through the macros and expects the program to adhere to them, so check if any macro definition is available before falling back to the latest level as a default --- Common/Common.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Common/Common.h b/Common/Common.h index 9fffa42922..9894771c53 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -70,18 +70,16 @@ #define __forceinline inline __attribute__((always_inline)) #endif -#if !defined(__GNUC__) && (defined(_M_X64) || defined(_M_IX86)) +#if defined __SSE4_2__ +# define _M_SSE 0x402 +#elif defined __SSE4_1__ +# define _M_SSE 0x401 +#elif defined __SSSE3__ +# define _M_SSE 0x301 +#elif defined __SSE3__ +# define _M_SSE 0x300 +#elif defined __SSE2__ +# define _M_SSE 0x200 +#elif !defined(__GNUC__) && (defined(_M_X64) || defined(_M_IX86)) # define _M_SSE 0x402 -#else -# if defined __SSE4_2__ -# define _M_SSE 0x402 -# elif defined __SSE4_1__ -# define _M_SSE 0x401 -# elif defined __SSSE3__ -# define _M_SSE 0x301 -# elif defined __SSE3__ -# define _M_SSE 0x300 -# elif defined __SSE2__ -# define _M_SSE 0x200 -# endif #endif From a8a1c67df0451a7cc8ec98610e3ea30abd1eb23f Mon Sep 17 00:00:00 2001 From: sorgts Date: Thu, 13 Aug 2020 16:48:48 +0200 Subject: [PATCH 3/3] Fix build with clang-cl --- CMakeLists.txt | 4 +++- Core/HLE/sceKernel.h | 2 +- Core/HLE/sceKernelModule.cpp | 2 +- Windows/InputDevice.cpp | 2 +- Windows/aboutbox.rc | Bin 2418 -> 1179 bytes Windows/version.rc | Bin 2486 -> 1214 bytes 6 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76e754e72d..6e51ca995e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,7 +311,9 @@ if(NOT MSVC) else() # Disable warnings about MS-specific _s variants of libc functions add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-MP) + if (NOT CLANG) + add_compile_options(-MP) + endif() set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_NDEBUG") endif() diff --git a/Core/HLE/sceKernel.h b/Core/HLE/sceKernel.h index 9e2a8ff3ac..c9d4e20d4c 100644 --- a/Core/HLE/sceKernel.h +++ b/Core/HLE/sceKernel.h @@ -25,7 +25,7 @@ class PointerWrap; -enum { +enum : u32 { SCE_KERNEL_ERROR_OK = 0, SCE_KERNEL_ERROR_ALREADY = 0x80000020, SCE_KERNEL_ERROR_BUSY = 0x80000021, diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index c049729246..3d096e8a43 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -72,7 +72,7 @@ enum { PSP_THREAD_ATTR_USER = 0x80000000, }; -enum { +enum : u32 { // Function exports. NID_MODULE_START = 0xD632ACDB, NID_MODULE_STOP = 0xCEE8593C, diff --git a/Windows/InputDevice.cpp b/Windows/InputDevice.cpp index d800c87713..70d4a6ff48 100644 --- a/Windows/InputDevice.cpp +++ b/Windows/InputDevice.cpp @@ -27,7 +27,7 @@ static std::atomic_flag threadRunningFlag; static std::thread inputThread; -static std::atomic_bool focused = true; +static std::atomic_bool focused = ATOMIC_VAR_INIT(true); inline static void ExecuteInputPoll() { if (host && (focused.load(std::memory_order_relaxed) || !g_Config.bGamepadOnlyFocused)) { diff --git a/Windows/aboutbox.rc b/Windows/aboutbox.rc index 1e669a134b7b8236aa39c98cced9566a0eafad2e..43e3b7200515c8b1dc71e5bd7e9879a29d2fd615 100644 GIT binary patch literal 1179 zcmaJ=+is&U5Pe7DA4c>gk=ztW)291I0%>WJfMU{3rIjKA4q;2MWuV=x_ILJ6_Q!UB z?4_+*3t^8vbI!~eTUE}^f?Zm`Hq98|oaRwh#Vp1J2vHP5^kf9jX}JUKc&7DKq6ZW9He`bh5B!PHRuxm1ENfiq>bk_C0^;x66B%x+4T=_Q#eVxZb=q(0k_0 zm#Xq-SF<*}Dm7JUXodu|83npySq65NXiZ*qcHeYW89CSPTvY&v?M(b7y%{Zo0HFai z?@lAG?cEXcyibgCoeXrGT4#6M_|$RDaBX+(`;_`VhK$!VumX2X44qsN(;y}?)o#Ff42+J676y%p3- zG%I_r)13dAS%3e$wpaF!ab#buVkU z{@VE){8PRjJXh>SHnstyZ$tJ$M%`|>X`|uF7Fd;?GU)5LzAjwT8YN@I(7b@G27K2p zK{_+6WM|5kfkwXRD_fCqW*fF?hi-J`!v!cr{S(SO;x$f>uXg}esh>TOd!26linN{GeU~6US z^caqqZ!@t#vI2bp`4#k+-Hu5~LAG=sAW!kQPn&_a4nAX0$T-EFH|y?y2HRy{48AR5 z++|(l--cfCnT*<^{a`OWo9Nueq66PW&}kGoExB*8?LebUI!dh8eTMa}%N1@~XDx5b z#6JrT%dTt1|Jq4UD!GhjLLuGXpCzyCv8~`qj13iJ>a^fE9uWscu;7~H(|f+W=RiL3 zDV4bgr7}i{KQ=NhJ=LNprFxFxtD-$1l}$WSoO9?}bFGtJ&DK-^y8#t7qz2j`q^f&M zEzB{8O4|Xop5I?^R)w|+aa&|mW|aLGKh3-3=_$<|=qfVKLH`bnSOmHN`*G;&IHjNn1XzB^~1 zzR`2O5nbX7Yjr=#Y}qAM&_&x7(j+16iD9SiH6|Lm??BOGrCO-5QY6)}q@&B-09lH< z&=|lqdpT|I`p$|V)~ zvb-u#b1@wv;G{S0l1M6>^sWRvBhU?RU0OSOD-PjPy;q;KP&K@kWPY&sxtSj#7SoY- zu`<-|8*Ee#hul(SpS#V}cY}bZs|0+Tna; TAD)c0v@SoAqk4ObUOoQ+k-AYt diff --git a/Windows/version.rc b/Windows/version.rc index dbefa2cef81bddf6eee3566d166fad2fdea2a9c0..1c6d3982b19d71cfa8fbbfaafc438cafe9b154ad 100644 GIT binary patch literal 1214 zcmb7D+is&U5Pgr7e;BbZt<+Gb%665ECucT}^ply!VQtWH~o?nl?d>f=b2ve1wF__iRrk%rJ{IWkV0f zRkfihH^FveF9XMOw~jmYpxNkkw*ymWZZ{F|{UGrD?GML2Rao9)F;Xyp=}p$w>Jvy! zI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