From 4d24f55226870055c8dcbb3409efc5355da134d7 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 20 Apr 2023 20:06:37 +0800 Subject: Changes for vkd3d proton (#2813) * Add some caches to .gitignore * Remove appendWideChars Use String::toWString instead * s/Sleep/sleepCurrentThread * formatting * Expand set of shared libraries which have buggy dlclose Work around https://github.com/microsoft/DirectXShaderCompiler/issues/5119 and https://github.com/doitsujin/dxvk/issues/3330 libdxcompiler.so invokes UB on dlclose, the dxvk libs break GDB when closed * Add assert for specialization failure on DX11 As a band aid for https://github.com/shader-slang/slang/issues/2805 * More fine grained selection of directx features --- source/core/slang-platform.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 4f9b0698c..9185559a2 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -173,13 +173,24 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); /* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, Handle& handleOut) { handleOut = nullptr; - const auto dxcName = "libdxcompiler"; - const bool isDXC = strncmp(platformFileName, dxcName, strlen(dxcName)) == 0; + // Work around + // https://github.com/microsoft/DirectXShaderCompiler/issues/5119 and + // https://github.com/doitsujin/dxvk/issues/3330 + // libdxcompiler.so invokes UB on dlclose, the dxvk libs break GDB when + // closed + const auto unclosableLibNames = {"libdxcompiler", "libdxvk_d3d11", "libdxvk_dxgi"}; + bool isUnclosable = false; + for(auto n : unclosableLibNames) + { + if(strncmp(platformFileName, n, strlen(n)) == 0) + { + isUnclosable = true; + break; + } + } if (strlen(platformFileName) == 0) platformFileName = nullptr; - // Work around https://github.com/microsoft/DirectXShaderCompiler/issues/5119 - // libdxcompiler.so invokes UB on dlclose - const auto mode = RTLD_NOW | RTLD_GLOBAL | (isDXC ? RTLD_NODELETE : 0); + const auto mode = RTLD_NOW | RTLD_GLOBAL | (isUnclosable ? RTLD_NODELETE : 0); void *h = dlopen(platformFileName, mode); if (!h) { -- cgit v1.2.3