mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[vr] Load native openvr library on winelib builds
This commit is contained in:
parent
0b4f1b6d6f
commit
bc367fd817
@ -10,7 +10,7 @@ winelib = true
|
|||||||
|
|
||||||
c_args=['-m32', '-msse', '-msse2']
|
c_args=['-m32', '-msse', '-msse2']
|
||||||
cpp_args=['-m32', '--no-gnu-unique', '-Wno-attributes', '-msse', '-msse2']
|
cpp_args=['-m32', '--no-gnu-unique', '-Wno-attributes', '-msse', '-msse2']
|
||||||
cpp_link_args=['-m32', '-mwindows']
|
cpp_link_args=['-m32', '-mwindows', '-ldl']
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
system = 'linux'
|
system = 'linux'
|
||||||
|
@ -10,7 +10,7 @@ winelib = true
|
|||||||
|
|
||||||
c_args=['-m64']
|
c_args=['-m64']
|
||||||
cpp_args=['-m64', '--no-gnu-unique', '-Wno-attributes']
|
cpp_args=['-m64', '--no-gnu-unique', '-Wno-attributes']
|
||||||
cpp_link_args=['-m64', '-mwindows']
|
cpp_link_args=['-m64', '-mwindows', '-ldl']
|
||||||
|
|
||||||
[host_machine]
|
[host_machine]
|
||||||
system = 'linux'
|
system = 'linux'
|
||||||
|
@ -5,8 +5,20 @@
|
|||||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WINE__
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#pragma push_macro("_WIN32")
|
||||||
|
//request UNIX ABI from openvr.hpp
|
||||||
|
#undef _WIN32
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <openvr/openvr.hpp>
|
#include <openvr/openvr.hpp>
|
||||||
|
|
||||||
|
#ifdef __WINE__
|
||||||
|
#pragma pop_macro("_WIN32")
|
||||||
|
#endif
|
||||||
|
|
||||||
using VR_InitInternalProc = vr::IVRSystem* (VR_CALLTYPE *)(vr::EVRInitError*, vr::EVRApplicationType);
|
using VR_InitInternalProc = vr::IVRSystem* (VR_CALLTYPE *)(vr::EVRInitError*, vr::EVRApplicationType);
|
||||||
using VR_ShutdownInternalProc = void (VR_CALLTYPE *)();
|
using VR_ShutdownInternalProc = void (VR_CALLTYPE *)();
|
||||||
using VR_GetGenericInterfaceProc = void* (VR_CALLTYPE *)(const char*, vr::EVRInitError*);
|
using VR_GetGenericInterfaceProc = void* (VR_CALLTYPE *)(const char*, vr::EVRInitError*);
|
||||||
@ -109,12 +121,22 @@ namespace dxvk {
|
|||||||
// Locate the OpenVR DLL if loaded by the process. Some
|
// Locate the OpenVR DLL if loaded by the process. Some
|
||||||
// applications may not have OpenVR loaded at the time
|
// applications may not have OpenVR loaded at the time
|
||||||
// they create the DXGI instance, so we try our own DLL.
|
// they create the DXGI instance, so we try our own DLL.
|
||||||
|
#ifdef __WINE__
|
||||||
|
// on winelib, load native openvr_api directly
|
||||||
|
m_ovrApi = ::dlopen("libopenvr_api.so", RTLD_LAZY | RTLD_NOLOAD);
|
||||||
|
|
||||||
|
if (m_ovrApi == nullptr) {
|
||||||
|
m_ovrApi = ::dlopen("libopenvr_api_dxvk.so", RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
m_loadedOvrApi = m_ovrApi != nullptr;
|
||||||
|
}
|
||||||
|
#else
|
||||||
m_ovrApi = ::GetModuleHandle("openvr_api.dll");
|
m_ovrApi = ::GetModuleHandle("openvr_api.dll");
|
||||||
|
|
||||||
if (m_ovrApi == nullptr) {
|
if (m_ovrApi == nullptr) {
|
||||||
m_ovrApi = ::LoadLibrary("openvr_api_dxvk.dll");
|
m_ovrApi = ::LoadLibrary("openvr_api_dxvk.dll");
|
||||||
m_loadedOvrApi = m_ovrApi != nullptr;
|
m_loadedOvrApi = m_ovrApi != nullptr;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_ovrApi == nullptr) {
|
if (m_ovrApi == nullptr) {
|
||||||
Logger::warn("OpenVR: Failed to locate module");
|
Logger::warn("OpenVR: Failed to locate module");
|
||||||
@ -122,9 +144,15 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load method used to retrieve the IVRCompositor interface
|
// Load method used to retrieve the IVRCompositor interface
|
||||||
|
#ifdef __WINE__
|
||||||
|
g_vrFunctions.initInternal = reinterpret_cast<VR_InitInternalProc> (::dlsym(m_ovrApi, "VR_InitInternal"));
|
||||||
|
g_vrFunctions.shutdownInternal = reinterpret_cast<VR_ShutdownInternalProc> (::dlsym(m_ovrApi, "VR_ShutdownInternal"));
|
||||||
|
g_vrFunctions.getGenericInterface = reinterpret_cast<VR_GetGenericInterfaceProc>(::dlsym(m_ovrApi, "VR_GetGenericInterface"));
|
||||||
|
#else
|
||||||
g_vrFunctions.initInternal = reinterpret_cast<VR_InitInternalProc> (::GetProcAddress(m_ovrApi, "VR_InitInternal"));
|
g_vrFunctions.initInternal = reinterpret_cast<VR_InitInternalProc> (::GetProcAddress(m_ovrApi, "VR_InitInternal"));
|
||||||
g_vrFunctions.shutdownInternal = reinterpret_cast<VR_ShutdownInternalProc> (::GetProcAddress(m_ovrApi, "VR_ShutdownInternal"));
|
g_vrFunctions.shutdownInternal = reinterpret_cast<VR_ShutdownInternalProc> (::GetProcAddress(m_ovrApi, "VR_ShutdownInternal"));
|
||||||
g_vrFunctions.getGenericInterface = reinterpret_cast<VR_GetGenericInterfaceProc>(::GetProcAddress(m_ovrApi, "VR_GetGenericInterface"));
|
g_vrFunctions.getGenericInterface = reinterpret_cast<VR_GetGenericInterfaceProc>(::GetProcAddress(m_ovrApi, "VR_GetGenericInterface"));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (g_vrFunctions.getGenericInterface == nullptr) {
|
if (g_vrFunctions.getGenericInterface == nullptr) {
|
||||||
Logger::warn("OpenVR: VR_GetGenericInterface not found");
|
Logger::warn("OpenVR: VR_GetGenericInterface not found");
|
||||||
@ -173,8 +201,13 @@ namespace dxvk {
|
|||||||
if (m_initializedOpenVr)
|
if (m_initializedOpenVr)
|
||||||
g_vrFunctions.shutdownInternal();
|
g_vrFunctions.shutdownInternal();
|
||||||
|
|
||||||
|
#if __WINE__
|
||||||
|
if (m_loadedOvrApi)
|
||||||
|
::dlclose(m_ovrApi);
|
||||||
|
#else
|
||||||
if (m_loadedOvrApi)
|
if (m_loadedOvrApi)
|
||||||
::FreeLibrary(m_ovrApi);
|
::FreeLibrary(m_ovrApi);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_initializedOpenVr = false;
|
m_initializedOpenVr = false;
|
||||||
m_loadedOvrApi = false;
|
m_loadedOvrApi = false;
|
||||||
|
@ -66,7 +66,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
vr::IVRCompositor* m_compositor = nullptr;
|
vr::IVRCompositor* m_compositor = nullptr;
|
||||||
|
#ifdef __WINE__
|
||||||
|
void* m_ovrApi = nullptr;
|
||||||
|
#else
|
||||||
HMODULE m_ovrApi = nullptr;
|
HMODULE m_ovrApi = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool m_loadedOvrApi = false;
|
bool m_loadedOvrApi = false;
|
||||||
bool m_initializedOpenVr = false;
|
bool m_initializedOpenVr = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user