From 7a01232e543c625bc32d682fd2ce74ad2035520d Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 13 Sep 2024 23:05:01 +1000 Subject: [PATCH] GPUDevice: Use suffixed shaderc libname Avoids conflicts with other installations of shaderc, e.g. the Vulkan SDK, which might be in the user's LD_LIBRARY_PATH. --- scripts/appimage/make-appimage.sh | 2 +- scripts/deps/build-dependencies-linux.sh | 4 ++-- scripts/deps/build-dependencies-mac.sh | 4 ++-- scripts/flatpak/modules/22-shaderc.yaml | 2 +- src/util/gpu_device.cpp | 9 ++++++++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/appimage/make-appimage.sh b/scripts/appimage/make-appimage.sh index 99bbb5766..aa43bd184 100755 --- a/scripts/appimage/make-appimage.sh +++ b/scripts/appimage/make-appimage.sh @@ -63,7 +63,7 @@ declare -a MANUAL_LIBS=( "libswresample.so.5" "libdiscord-rpc.so" "libfreetype.so.6" - "libshaderc_shared.so" + "libshaderc_ds.so" "libspirv-cross-c-shared.so.0" ) diff --git a/scripts/deps/build-dependencies-linux.sh b/scripts/deps/build-dependencies-linux.sh index cbf204129..d24953b87 100755 --- a/scripts/deps/build-dependencies-linux.sh +++ b/scripts/deps/build-dependencies-linux.sh @@ -67,7 +67,7 @@ ZSTD=1.5.6 CPUINFO=7524ad504fdcfcf75a18a133da6abd75c5d48053 DISCORD_RPC=144f3a3f1209994d8d9e8a87964a989cb9911c1e LUNASVG=9af1ac7b90658a279b372add52d6f77a4ebb482c -SHADERC=3a655d0f8d3c946efd690edea31e138d4efef417 +SHADERC=3c12f7af773c547973138bee6d6ac70d91729479 SOUNDTOUCH=463ade388f3a51da078dc9ed062bf28e4ba29da7 SPIRV_CROSS=vulkan-sdk-1.3.290.0 @@ -91,7 +91,7 @@ fd6f417fe9e3a071cf1424a5152d926a34c4a3c5070745470be6cf12a404ed79 $LIBBACKTRACE. e1351218d270db49c3dddcba04fb2153b09731ea3fa6830e423f5952f44585be cpuinfo-$CPUINFO.tar.gz 3eea5ccce6670c126282f1ba4d32c19d486db49a1a5cbfb8d6f48774784d310c discord-rpc-$DISCORD_RPC.tar.gz 3998b024b0d442614a9ee270e76e018bb37a17b8c6941212171731123cbbcac7 lunasvg-$LUNASVG.tar.gz -93aa93c087aadd2d1e97db58399d5cc8aaca750fd5d9004520c7426a4eb1fa82 shaderc-$SHADERC.tar.gz +0663bf6dabbb86fc0e697a601ee0030af715c8c1fbfa6e2b2240bde332f479a0 shaderc-$SHADERC.tar.gz fe45c2af99f6102d2704277d392c1c83b55180a70bfd17fb888cc84a54b70573 soundtouch-$SOUNDTOUCH.tar.gz EOF diff --git a/scripts/deps/build-dependencies-mac.sh b/scripts/deps/build-dependencies-mac.sh index b2cfbe71f..a0d680e31 100755 --- a/scripts/deps/build-dependencies-mac.sh +++ b/scripts/deps/build-dependencies-mac.sh @@ -48,7 +48,7 @@ QT=6.7.2 CPUINFO=7524ad504fdcfcf75a18a133da6abd75c5d48053 DISCORD_RPC=144f3a3f1209994d8d9e8a87964a989cb9911c1e LUNASVG=9af1ac7b90658a279b372add52d6f77a4ebb482c -SHADERC=3a655d0f8d3c946efd690edea31e138d4efef417 +SHADERC=3c12f7af773c547973138bee6d6ac70d91729479 SOUNDTOUCH=463ade388f3a51da078dc9ed062bf28e4ba29da7 SPIRV_CROSS=vulkan-sdk-1.3.290.0 @@ -88,7 +88,7 @@ fb0d1286a35be3583fee34aeb5843c94719e07193bdf1d4d8b0dc14009caef01 qtsvg-everywhe e1351218d270db49c3dddcba04fb2153b09731ea3fa6830e423f5952f44585be cpuinfo-$CPUINFO.tar.gz 3eea5ccce6670c126282f1ba4d32c19d486db49a1a5cbfb8d6f48774784d310c discord-rpc-$DISCORD_RPC.tar.gz 3998b024b0d442614a9ee270e76e018bb37a17b8c6941212171731123cbbcac7 lunasvg-$LUNASVG.tar.gz -93aa93c087aadd2d1e97db58399d5cc8aaca750fd5d9004520c7426a4eb1fa82 shaderc-$SHADERC.tar.gz +0663bf6dabbb86fc0e697a601ee0030af715c8c1fbfa6e2b2240bde332f479a0 shaderc-$SHADERC.tar.gz fe45c2af99f6102d2704277d392c1c83b55180a70bfd17fb888cc84a54b70573 soundtouch-$SOUNDTOUCH.tar.gz EOF diff --git a/scripts/flatpak/modules/22-shaderc.yaml b/scripts/flatpak/modules/22-shaderc.yaml index 70476e974..ebe32f520 100644 --- a/scripts/flatpak/modules/22-shaderc.yaml +++ b/scripts/flatpak/modules/22-shaderc.yaml @@ -11,7 +11,7 @@ build-options: sources: - type: git url: "https://github.com/stenzek/shaderc.git" - commit: "3a655d0f8d3c946efd690edea31e138d4efef417" + commit: "3c12f7af773c547973138bee6d6ac70d91729479" cleanup: - /bin - /include diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index 5d74b8e48..a0983788e 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -1210,6 +1210,13 @@ std::unique_ptr GPUDevice::CreateDeviceForAPI(RenderAPI api) } } +#ifndef _WIN32 +// Use a duckstation-suffixed shaderc name to avoid conflicts and loading another shaderc, e.g. from the Vulkan SDK. +#define SHADERC_LIB_NAME "shaderc_ds" +#else +#define SHADERC_LIB_NAME "shaderc_shared" +#endif + #define SHADERC_FUNCTIONS(X) \ X(shaderc_compiler_initialize) \ X(shaderc_compiler_release) \ @@ -1285,7 +1292,7 @@ bool dyn_libs::OpenShaderc(Error* error) if (s_shaderc_library.IsOpen()) return true; - const std::string libname = DynamicLibrary::GetVersionedFilename("shaderc_shared"); + const std::string libname = DynamicLibrary::GetVersionedFilename(SHADERC_LIB_NAME); if (!s_shaderc_library.Open(libname.c_str(), error)) { Error::AddPrefix(error, "Failed to load shaderc: ");