From b9135ca0cd5f30abce30d7652b44574c0fdfb512 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Fri, 2 Jul 2021 14:23:27 +0200 Subject: [PATCH] Do not try to load libraries natively under __WINE__ This was only half-implemented (e.g. OpenXR was still calling GetModuleHandle), broke compilation with Vulkan due to mismatched ABI, and wouldn't have worked anyways with winelib builds because we still need access to wine's implementation of the Vulkan win32 winsys integration. Perhaps this is still useful for dxvk-native but if so it should be re-added under a DXVK_NATIVE flag. --- src/d3d11/d3d11_options.cpp | 2 -- src/dxvk/dxvk_openvr.cpp | 32 ++------------------------------ src/dxvk/dxvk_openvr.h | 10 ++-------- src/dxvk/dxvk_openxr.cpp | 4 ++-- src/dxvk/dxvk_openxr.h | 12 +++--------- src/vulkan/vulkan_loader.cpp | 10 ---------- 6 files changed, 9 insertions(+), 61 deletions(-) diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index 15406749..486b078b 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -28,9 +28,7 @@ namespace dxvk { && DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd; bool apitraceAttached = false; - #ifndef __WINE__ apitraceAttached = ::GetModuleHandle("dxgitrace.dll") != nullptr; - #endif this->apitraceMode = config.getOption("d3d11.apitraceMode", apitraceAttached); diff --git a/src/dxvk/dxvk_openvr.cpp b/src/dxvk/dxvk_openvr.cpp index c754173a..fe61e1bc 100644 --- a/src/dxvk/dxvk_openvr.cpp +++ b/src/dxvk/dxvk_openvr.cpp @@ -5,20 +5,8 @@ #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif -#ifdef __WINE__ -#include - -#pragma push_macro("_WIN32") -//request UNIX ABI from openvr.hpp -#undef _WIN32 -#endif - #include -#ifdef __WINE__ -#pragma pop_macro("_WIN32") -#endif - using VR_InitInternalProc = vr::IVRSystem* (VR_CALLTYPE *)(vr::EVRInitError*, vr::EVRApplicationType); using VR_ShutdownInternalProc = void (VR_CALLTYPE *)(); using VR_GetGenericInterfaceProc = void* (VR_CALLTYPE *)(const char*, vr::EVRInitError*); @@ -316,40 +304,24 @@ namespace dxvk { } - SoHandle VrInstance::loadLibrary() { - SoHandle handle = nullptr; - #ifdef __WINE__ - // on winelib, load native openvr_api directly - if (!(handle = ::dlopen("libopenvr_api.so", RTLD_LAZY | RTLD_NOLOAD))) - handle = ::dlopen("libopenvr_api_dxvk.so", RTLD_LAZY | RTLD_LOCAL); - m_loadedOvrApi = handle != nullptr; - #else + HMODULE VrInstance::loadLibrary() { + HMODULE handle = nullptr; if (!(handle = ::GetModuleHandle("openvr_api.dll"))) { handle = ::LoadLibrary("openvr_api_dxvk.dll"); m_loadedOvrApi = handle != nullptr; } - #endif return handle; } void VrInstance::freeLibrary() { - #ifdef __WINE__ - ::dlclose(m_ovrApi); - #else ::FreeLibrary(m_ovrApi); - #endif } void* VrInstance::getSym(const char* sym) { - #ifdef __WINE__ - return reinterpret_cast( - ::dlsym(m_ovrApi, sym)); - #else return reinterpret_cast( ::GetProcAddress(m_ovrApi, sym)); - #endif } } diff --git a/src/dxvk/dxvk_openvr.h b/src/dxvk/dxvk_openvr.h index 58202695..a7d1042c 100644 --- a/src/dxvk/dxvk_openvr.h +++ b/src/dxvk/dxvk_openvr.h @@ -5,12 +5,6 @@ #include "dxvk_extension_provider.h" -#ifdef __WINE__ -using SoHandle = void*; -#else -using SoHandle = HMODULE; -#endif - namespace vr { class IVRCompositor; class IVRSystem; @@ -52,7 +46,7 @@ namespace dxvk { dxvk::mutex m_mutex; HKEY m_vr_key = nullptr; vr::IVRCompositor* m_compositor = nullptr; - SoHandle m_ovrApi = nullptr; + HMODULE m_ovrApi = nullptr; bool m_no_vr; bool m_loadedOvrApi = false; @@ -75,7 +69,7 @@ namespace dxvk { void shutdown(); - SoHandle loadLibrary(); + HMODULE loadLibrary(); void freeLibrary(); diff --git a/src/dxvk/dxvk_openxr.cpp b/src/dxvk/dxvk_openxr.cpp index 1722ff8e..98f2dd9a 100644 --- a/src/dxvk/dxvk_openxr.cpp +++ b/src/dxvk/dxvk_openxr.cpp @@ -146,8 +146,8 @@ namespace dxvk { } - SoHandle DxvkXrProvider::loadLibrary() { - SoHandle handle = nullptr; + HMODULE DxvkXrProvider::loadLibrary() { + HMODULE handle = nullptr; if (!(handle = ::GetModuleHandle("wineopenxr.dll"))) { handle = ::LoadLibrary("wineopenxr.dll"); m_loadedOxrApi = handle != nullptr; diff --git a/src/dxvk/dxvk_openxr.h b/src/dxvk/dxvk_openxr.h index f6c20484..a3680350 100644 --- a/src/dxvk/dxvk_openxr.h +++ b/src/dxvk/dxvk_openxr.h @@ -5,12 +5,6 @@ #include "dxvk_extension_provider.h" -#ifdef __WINE__ -using SoHandle = void*; -#else -using SoHandle = HMODULE; -#endif - namespace dxvk { class DxvkInstance; @@ -44,7 +38,7 @@ namespace dxvk { private: dxvk::mutex m_mutex; - SoHandle m_wineOxr = nullptr; + HMODULE m_wineOxr = nullptr; bool m_loadedOxrApi = false; bool m_initializedInsExt = false; @@ -64,7 +58,7 @@ namespace dxvk { void shutdown(); - SoHandle loadLibrary(); + HMODULE loadLibrary(); void freeLibrary(); @@ -72,4 +66,4 @@ namespace dxvk { }; -} \ No newline at end of file +} diff --git a/src/vulkan/vulkan_loader.cpp b/src/vulkan/vulkan_loader.cpp index cd2b739d..faa5155f 100644 --- a/src/vulkan/vulkan_loader.cpp +++ b/src/vulkan/vulkan_loader.cpp @@ -2,18 +2,8 @@ namespace dxvk::vk { -#if defined(__WINE__) - - extern "C" - PFN_vkVoidFunction native_vkGetInstanceProcAddrWINE(VkInstance instance, const char *name); - static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = native_vkGetInstanceProcAddrWINE; - -#else - static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = vkGetInstanceProcAddr; -#endif - PFN_vkVoidFunction LibraryLoader::sym(const char* name) const { return dxvk::vk::GetInstanceProcAddr(nullptr, name); }