From 5adecbe837d27cf4e0a554ae13a0338743a8cb4b Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Sat, 29 Apr 2023 11:32:53 +0800 Subject: vkd3d and dxvk integration (#2823) * Add d3d sources for linux builds * Return NOT_IMPLEMENTED for shared handle support on Linux * Enable DirectX api on Linux * Do not report DX11 support without FXC * Initial version of SynchAPI emulation * Neaten dx library name handling * Neaten and use posix-synchapi * Add premake option for DirectX on Vulkan * s/SLANG_ENABLE_VKD3D_PROTON/SLANG_ENABLE_VKD3D * Skip failing tests on vkd3d * Regenerate vs projects * Silence unused var warning --- tools/gfx/d3d/d3d-util.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'tools/gfx/d3d/d3d-util.cpp') diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index aff610796..0257ede1b 100644 --- a/tools/gfx/d3d/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp @@ -431,15 +431,20 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) static pD3DCompile compileFunc = nullptr; if (!compileFunc) { + // On Linux, vkd3d-utils isn't suitable as a unix replacement for fxc + // due to at least the following missing feature: + // https://bugs.winehq.org/show_bug.cgi?id=54872 + // TODO(tfoley): maybe want to search for one of a few versions of the DLL - HMODULE compilerModule = LoadLibraryA("d3dcompiler_47.dll"); - if (!compilerModule) + const char* const libName = "d3dcompiler_47"; + SharedLibrary::Handle compilerModule; + if (SLANG_FAILED(SharedLibrary::load(libName, compilerModule))) { - fprintf(stderr, "error: failed load 'd3dcompiler_47.dll'\n"); + fprintf(stderr, "error: failed to load '%s'\n", libName); return SLANG_FAIL; } - compileFunc = (pD3DCompile)GetProcAddress(compilerModule, "D3DCompile"); + compileFunc = (pD3DCompile)SharedLibrary::findSymbolAddressByName(compilerModule, "D3DCompile"); if (!compileFunc) { fprintf(stderr, "error: failed load symbol 'D3DCompile'\n"); @@ -488,17 +493,14 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) /* static */SharedLibrary::Handle D3DUtil::getDxgiModule() { -#if SLANG_ENABLE_DXVK - const char* const libPath = "dxvk_dxgi"; -#else - const char* const libPath = "dxgi"; -#endif + const char* const libName = SLANG_ENABLE_DXVK ? "dxvk_dxgi" : "dxgi"; + static SharedLibrary::Handle s_dxgiModule = [&](){ SharedLibrary::Handle h = nullptr; - SharedLibrary::load(libPath, h); + SharedLibrary::load(libName, h); if (!h) { - fprintf(stderr, "error: failed to load dll '%s'\n", libPath); + fprintf(stderr, "error: failed to load dll '%s'\n", libName); } return h; }(); -- cgit v1.2.3