mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
Revert "[vr] Cosmetic code cleanup"
This reverts commit a3bf90f5a3fe050ffae353f80bc5608c7c9a1244. Crashes SuperHot VR for some reason.
This commit is contained in:
parent
556e0d1dba
commit
de29174d42
@ -57,10 +57,10 @@ namespace dxvk {
|
|||||||
void VrInstance::initInstanceExtensions() {
|
void VrInstance::initInstanceExtensions() {
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (!m_compositor)
|
if (m_compositor == nullptr)
|
||||||
m_compositor = this->getCompositor();
|
m_compositor = this->getCompositor();
|
||||||
|
|
||||||
if (!m_compositor || m_initializedInsExt)
|
if (m_compositor == nullptr || m_initializedInsExt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_insExtensions = this->queryInstanceExtensions();
|
m_insExtensions = this->queryInstanceExtensions();
|
||||||
@ -71,7 +71,7 @@ namespace dxvk {
|
|||||||
void VrInstance::initDeviceExtensions(const DxvkInstance* instance) {
|
void VrInstance::initDeviceExtensions(const DxvkInstance* instance) {
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
if (!m_compositor || m_initializedDevExt)
|
if (m_compositor == nullptr || m_initializedDevExt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (uint32_t i = 0; instance->enumAdapters(i) != nullptr; i++) {
|
for (uint32_t i = 0; instance->enumAdapters(i) != nullptr; i++) {
|
||||||
@ -121,20 +121,40 @@ 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.
|
||||||
m_ovrApi = this->loadLibrary();
|
#ifdef __WINE__
|
||||||
m_loadedOvrApi = m_ovrApi != nullptr;
|
// 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");
|
||||||
|
|
||||||
|
if (m_ovrApi == nullptr) {
|
||||||
|
m_ovrApi = ::LoadLibrary("openvr_api_dxvk.dll");
|
||||||
|
m_loadedOvrApi = m_ovrApi != nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!m_ovrApi) {
|
if (m_ovrApi == nullptr) {
|
||||||
Logger::warn("OpenVR: Failed to locate module");
|
Logger::warn("OpenVR: Failed to locate module");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load method used to retrieve the IVRCompositor interface
|
// Load method used to retrieve the IVRCompositor interface
|
||||||
g_vrFunctions.initInternal = reinterpret_cast<VR_InitInternalProc> (this->getSym("VR_InitInternal"));
|
#ifdef __WINE__
|
||||||
g_vrFunctions.shutdownInternal = reinterpret_cast<VR_ShutdownInternalProc> (this->getSym("VR_ShutdownInternal"));
|
g_vrFunctions.initInternal = reinterpret_cast<VR_InitInternalProc> (::dlsym(m_ovrApi, "VR_InitInternal"));
|
||||||
g_vrFunctions.getGenericInterface = reinterpret_cast<VR_GetGenericInterfaceProc>(this->getSym("VR_GetGenericInterface"));
|
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.shutdownInternal = reinterpret_cast<VR_ShutdownInternalProc> (::GetProcAddress(m_ovrApi, "VR_ShutdownInternal"));
|
||||||
|
g_vrFunctions.getGenericInterface = reinterpret_cast<VR_GetGenericInterfaceProc>(::GetProcAddress(m_ovrApi, "VR_GetGenericInterface"));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!g_vrFunctions.getGenericInterface) {
|
if (g_vrFunctions.getGenericInterface == nullptr) {
|
||||||
Logger::warn("OpenVR: VR_GetGenericInterface not found");
|
Logger::warn("OpenVR: VR_GetGenericInterface not found");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -145,9 +165,9 @@ namespace dxvk {
|
|||||||
vr::IVRCompositor* compositor = reinterpret_cast<vr::IVRCompositor*>(
|
vr::IVRCompositor* compositor = reinterpret_cast<vr::IVRCompositor*>(
|
||||||
g_vrFunctions.getGenericInterface(vr::IVRCompositor_Version, &error));
|
g_vrFunctions.getGenericInterface(vr::IVRCompositor_Version, &error));
|
||||||
|
|
||||||
if (error != vr::VRInitError_None || !compositor) {
|
if (error != vr::VRInitError_None || compositor == nullptr) {
|
||||||
if (!g_vrFunctions.initInternal
|
if (g_vrFunctions.initInternal == nullptr
|
||||||
|| !g_vrFunctions.shutdownInternal) {
|
|| g_vrFunctions.shutdownInternal == nullptr) {
|
||||||
Logger::warn("OpenVR: VR_InitInternal or VR_ShutdownInternal not found");
|
Logger::warn("OpenVR: VR_InitInternal or VR_ShutdownInternal not found");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -165,7 +185,7 @@ namespace dxvk {
|
|||||||
compositor = reinterpret_cast<vr::IVRCompositor*>(
|
compositor = reinterpret_cast<vr::IVRCompositor*>(
|
||||||
g_vrFunctions.getGenericInterface(vr::IVRCompositor_Version, &error));
|
g_vrFunctions.getGenericInterface(vr::IVRCompositor_Version, &error));
|
||||||
|
|
||||||
if (error != vr::VRInitError_None || !compositor) {
|
if (error != vr::VRInitError_None || compositor == nullptr) {
|
||||||
Logger::warn("OpenVR: Failed to query compositor interface");
|
Logger::warn("OpenVR: Failed to query compositor interface");
|
||||||
this->shutdown();
|
this->shutdown();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -181,45 +201,16 @@ namespace dxvk {
|
|||||||
if (m_initializedOpenVr)
|
if (m_initializedOpenVr)
|
||||||
g_vrFunctions.shutdownInternal();
|
g_vrFunctions.shutdownInternal();
|
||||||
|
|
||||||
|
#if __WINE__
|
||||||
if (m_loadedOvrApi)
|
if (m_loadedOvrApi)
|
||||||
this->freeLibrary();
|
::dlclose(m_ovrApi);
|
||||||
|
#else
|
||||||
|
if (m_loadedOvrApi)
|
||||||
|
::FreeLibrary(m_ovrApi);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_initializedOpenVr = false;
|
m_initializedOpenVr = false;
|
||||||
m_loadedOvrApi = false;
|
m_loadedOvrApi = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
#else
|
|
||||||
if (!(handle = ::GetModuleHandle("openvr_api.dll")))
|
|
||||||
handle = ::LoadLibrary("openvr_api_dxvk.dll");
|
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
|
|
||||||
#include "dxvk_include.h"
|
#include "dxvk_include.h"
|
||||||
|
|
||||||
#ifdef __WINE__
|
|
||||||
using SoHandle = void*;
|
|
||||||
#else
|
|
||||||
using SoHandle = HMODULE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace vr {
|
namespace vr {
|
||||||
class IVRCompositor;
|
class IVRCompositor;
|
||||||
class IVRSystem;
|
class IVRSystem;
|
||||||
@ -72,7 +66,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
vr::IVRCompositor* m_compositor = nullptr;
|
vr::IVRCompositor* m_compositor = nullptr;
|
||||||
SoHandle m_ovrApi = nullptr;
|
#ifdef __WINE__
|
||||||
|
void* m_ovrApi = nullptr;
|
||||||
|
#else
|
||||||
|
HMODULE m_ovrApi = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool m_loadedOvrApi = false;
|
bool m_loadedOvrApi = false;
|
||||||
bool m_initializedOpenVr = false;
|
bool m_initializedOpenVr = false;
|
||||||
@ -93,12 +91,6 @@ namespace dxvk {
|
|||||||
vr::IVRCompositor* getCompositor();
|
vr::IVRCompositor* getCompositor();
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
SoHandle loadLibrary();
|
|
||||||
|
|
||||||
void freeLibrary();
|
|
||||||
|
|
||||||
void* getSym(const char* sym);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user