1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 11:52:12 +01:00

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.
This commit is contained in:
Connor Abbott 2021-07-02 14:23:27 +02:00 committed by Philip Rebohle
parent 120585c66d
commit b9135ca0cd
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 9 additions and 61 deletions

View File

@ -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<bool>("d3d11.apitraceMode", apitraceAttached);

View File

@ -5,20 +5,8 @@
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
#ifdef __WINE__
#include <dlfcn.h>
#pragma push_macro("_WIN32")
//request UNIX ABI from openvr.hpp
#undef _WIN32
#endif
#include <openvr/openvr.hpp>
#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<void*>(
::dlsym(m_ovrApi, sym));
#else
return reinterpret_cast<void*>(
::GetProcAddress(m_ovrApi, sym));
#endif
}
}

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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);
}