From a22c634cd4bb952481c3b05568c61c44ac7f3582 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 12 Apr 2022 18:07:19 +1000 Subject: [PATCH] 3rdparty: Add zstd --- .gitmodules | 3 + 3rdparty/libzip/CMakeLists.txt | 8 +- 3rdparty/libzip/libzip.vcxproj | 8 +- 3rdparty/libzip/libzip.vcxproj.filters | 1 + 3rdparty/libzip/private/config.h | 2 +- 3rdparty/zstd/CMakeLists.txt | 37 +++++++++ 3rdparty/zstd/zstd | 1 + 3rdparty/zstd/zstd.vcxproj | 104 +++++++++++++++++++++++++ 3rdparty/zstd/zstd.vcxproj.filters | 67 ++++++++++++++++ PCSX2_qt.sln | 15 ++++ PCSX2_suite.sln | 15 ++++ cmake/SearchForStuff.cmake | 3 + 12 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 3rdparty/zstd/CMakeLists.txt create mode 160000 3rdparty/zstd/zstd create mode 100644 3rdparty/zstd/zstd.vcxproj create mode 100644 3rdparty/zstd/zstd.vcxproj.filters diff --git a/.gitmodules b/.gitmodules index 9fe51b413..f2698eb4f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,3 +36,6 @@ [submodule "3rdparty/libzip/libzip"] path = 3rdparty/libzip/libzip url = https://github.com/nih-at/libzip.git +[submodule "3rdparty/zstd/zstd"] + path = 3rdparty/zstd/zstd + url = https://github.com/facebook/zstd.git diff --git a/3rdparty/libzip/CMakeLists.txt b/3rdparty/libzip/CMakeLists.txt index 4af0b4531..b6a90ef15 100644 --- a/3rdparty/libzip/CMakeLists.txt +++ b/3rdparty/libzip/CMakeLists.txt @@ -7,7 +7,7 @@ set(ENABLE_MBEDTLS OFF CACHE BOOL "") set(ENABLE_WINDOWS_CRYPTO OFF CACHE BOOL "") set(ENABLE_BZIP2 OFF CACHE BOOL "") set(ENABLE_LZMA OFF CACHE BOOL "") -set(ENABLE_ZSTD OFF CACHE BOOL "") +set(ENABLE_ZSTD ON CACHE BOOL "") set(BUILD_TOOLS OFF CACHE BOOL "") set(BUILD_REGRESS OFF CACHE BOOL "") @@ -21,4 +21,10 @@ if(WIN32) set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib") endif() +# Fill in the location of zstd, so find_package() doesn't try to use +# a potentially-old system version. It also picks up Zstd::Zstd. +set(Zstd_FOUND TRUE) +set(Zstd_LIBRARY "$") +set(Zstd_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../zstd/zstd/lib") + add_subdirectory(libzip EXCLUDE_FROM_ALL) diff --git a/3rdparty/libzip/libzip.vcxproj b/3rdparty/libzip/libzip.vcxproj index 5f033c2ff..a7aec03ca 100644 --- a/3rdparty/libzip/libzip.vcxproj +++ b/3rdparty/libzip/libzip.vcxproj @@ -33,6 +33,7 @@ + @@ -161,11 +162,16 @@ + + + {52244028-937a-44e9-a76b-2bea18fd239a} + + ZIP_STATIC;%(PreprocessorDefinitions) TurnOffAllWarnings - $(SolutionDir)3rdparty\zlib;$(ProjectDir)private;$(ProjectDir)libzip\lib;$(ProjectDir);%(AdditionalIncludeDirectories) + $(SolutionDir)3rdparty\zstd\zstd\lib;$(SolutionDir)3rdparty\zlib;$(ProjectDir)private;$(ProjectDir)libzip\lib;$(ProjectDir);%(AdditionalIncludeDirectories) diff --git a/3rdparty/libzip/libzip.vcxproj.filters b/3rdparty/libzip/libzip.vcxproj.filters index 9766d8477..7b7ef9e82 100644 --- a/3rdparty/libzip/libzip.vcxproj.filters +++ b/3rdparty/libzip/libzip.vcxproj.filters @@ -120,6 +120,7 @@ + diff --git a/3rdparty/libzip/private/config.h b/3rdparty/libzip/private/config.h index 5d5b8619f..57faa6724 100644 --- a/3rdparty/libzip/private/config.h +++ b/3rdparty/libzip/private/config.h @@ -30,7 +30,7 @@ /* #undef HAVE_GNUTLS */ /* #undef HAVE_LIBBZ2 */ /* #undef HAVE_LIBLZMA */ -/* #undef HAVE_LIBZSTD */ +#define HAVE_LIBZSTD /* #undef HAVE_LOCALTIME_R */ /* #undef HAVE_MBEDTLS */ /* #undef HAVE_MKSTEMP */ diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt new file mode 100644 index 000000000..b866f1d2b --- /dev/null +++ b/3rdparty/zstd/CMakeLists.txt @@ -0,0 +1,37 @@ +enable_language(C ASM) + +add_library(pcsx2-zstd + zstd/lib/common/debug.c + zstd/lib/common/entropy_common.c + zstd/lib/common/error_private.c + zstd/lib/common/fse_decompress.c + zstd/lib/common/pool.c + zstd/lib/common/threading.c + zstd/lib/common/xxhash.c + zstd/lib/common/zstd_common.c + zstd/lib/compress/fse_compress.c + zstd/lib/compress/hist.c + zstd/lib/compress/huf_compress.c + zstd/lib/compress/zstd_compress.c + zstd/lib/compress/zstd_compress_literals.c + zstd/lib/compress/zstd_compress_sequences.c + zstd/lib/compress/zstd_compress_superblock.c + zstd/lib/compress/zstd_double_fast.c + zstd/lib/compress/zstd_fast.c + zstd/lib/compress/zstd_lazy.c + zstd/lib/compress/zstd_ldm.c + zstd/lib/compress/zstdmt_compress.c + zstd/lib/compress/zstd_opt.c + zstd/lib/decompress/huf_decompress.c + zstd/lib/decompress/zstd_ddict.c + zstd/lib/decompress/zstd_decompress_block.c + zstd/lib/decompress/zstd_decompress.c +) + +if(NOT MSVC AND ${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") + target_sources(pcsx2-zstd PRIVATE zstd/lib/decompress/huf_decompress_amd64.S) +endif() + +target_include_directories(pcsx2-zstd PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/zstd/lib") + +add_library(Zstd::Zstd ALIAS pcsx2-zstd) \ No newline at end of file diff --git a/3rdparty/zstd/zstd b/3rdparty/zstd/zstd new file mode 160000 index 000000000..e47e674cd --- /dev/null +++ b/3rdparty/zstd/zstd @@ -0,0 +1 @@ +Subproject commit e47e674cd09583ff0503f0f6defd6d23d8b718d3 diff --git a/3rdparty/zstd/zstd.vcxproj b/3rdparty/zstd/zstd.vcxproj new file mode 100644 index 000000000..72a8ad698 --- /dev/null +++ b/3rdparty/zstd/zstd.vcxproj @@ -0,0 +1,104 @@ + + + + + + {52244028-937A-44E9-A76B-2BEA18FD239A} + + + + StaticLibrary + $(DefaultPlatformToolset) + MultiByte + true + true + false + + + + + + + + + + + + + + AllRules.ruleset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + %(PreprocessorDefinitions) + TurnOffAllWarnings + $(SolutionDir)3rdparty\zstd\zstd\lib;%(AdditionalIncludeDirectories) + + + + + \ No newline at end of file diff --git a/3rdparty/zstd/zstd.vcxproj.filters b/3rdparty/zstd/zstd.vcxproj.filters new file mode 100644 index 000000000..e5198a3b6 --- /dev/null +++ b/3rdparty/zstd/zstd.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PCSX2_qt.sln b/PCSX2_qt.sln index 78d2a5830..d50e1977e 100644 --- a/PCSX2_qt.sln +++ b/PCSX2_qt.sln @@ -60,6 +60,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "3rdparty\sdl2\SDL.vc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzip", "3rdparty\libzip\libzip.vcxproj", "{20B2E9FE-F020-42A0-B324-956F5B06EA68}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "3rdparty\zstd\zstd.vcxproj", "{52244028-937A-44E9-A76B-2BEA18FD239A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug AVX2|x64 = Debug AVX2|x64 @@ -370,6 +372,18 @@ Global {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release AVX2|x64.Build.0 = Release|x64 {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release|x64.ActiveCfg = Release|x64 {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release|x64.Build.0 = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug AVX2|x64.ActiveCfg = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug AVX2|x64.Build.0 = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug|x64.ActiveCfg = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug|x64.Build.0 = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel AVX2|x64.ActiveCfg = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel AVX2|x64.Build.0 = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel|x64.ActiveCfg = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel|x64.Build.0 = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release AVX2|x64.ActiveCfg = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release AVX2|x64.Build.0 = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release|x64.ActiveCfg = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -397,6 +411,7 @@ Global {EF6834A9-11F3-4331-BC34-21B325ABB180} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} {812B4434-FD6B-4CB2-8865-5FD8EB34B046} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} {20B2E9FE-F020-42A0-B324-956F5B06EA68} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} + {52244028-937A-44E9-A76B-2BEA18FD239A} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0BC474EA-3628-45D3-9DBC-E22D0B7E0F77} diff --git a/PCSX2_suite.sln b/PCSX2_suite.sln index 86bebca86..0691c76a2 100644 --- a/PCSX2_suite.sln +++ b/PCSX2_suite.sln @@ -64,6 +64,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glslang", "3rdparty\glslang EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libzip", "3rdparty\libzip\libzip.vcxproj", "{20B2E9FE-F020-42A0-B324-956F5B06EA68}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "3rdparty\zstd\zstd.vcxproj", "{52244028-937A-44E9-A76B-2BEA18FD239A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug AVX2|x64 = Debug AVX2|x64 @@ -374,6 +376,18 @@ Global {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release AVX2|x64.Build.0 = Release|x64 {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release|x64.ActiveCfg = Release|x64 {20B2E9FE-F020-42A0-B324-956F5B06EA68}.Release|x64.Build.0 = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug AVX2|x64.ActiveCfg = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug AVX2|x64.Build.0 = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug|x64.ActiveCfg = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Debug|x64.Build.0 = Debug|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel AVX2|x64.ActiveCfg = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel AVX2|x64.Build.0 = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel|x64.ActiveCfg = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Devel|x64.Build.0 = Devel|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release AVX2|x64.ActiveCfg = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release AVX2|x64.Build.0 = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release|x64.ActiveCfg = Release|x64 + {52244028-937A-44E9-A76B-2BEA18FD239A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -402,6 +416,7 @@ Global {88FB34EC-845E-4F21-A552-F1573B9ED167} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} {EF6834A9-11F3-4331-BC34-21B325ABB180} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} {20B2E9FE-F020-42A0-B324-956F5B06EA68} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} + {52244028-937A-44E9-A76B-2BEA18FD239A} = {78EBE642-7A4D-4EA7-86BE-5639C6646C38} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0BC474EA-3628-45D3-9DBC-E22D0B7E0F77} diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index b87791af4..91b7a9ab3 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -238,6 +238,9 @@ if(NOT USE_SYSTEM_YAML) endif() endif() +# We could use a system version of zstd, but is it going to be recent enough? +add_subdirectory(3rdparty/zstd EXCLUDE_FROM_ALL) + if(QT_BUILD) # Default to bundled Qt6 for Windows. if(WIN32 AND NOT DEFINED Qt6_DIR)