mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:53:51 +00:00
More useful error messages for typical init failures
This commit is contained in:
parent
697caaff84
commit
f9c13f3163
4 changed files with 70 additions and 16 deletions
|
@ -76,15 +76,7 @@ namespace MWVR
|
||||||
if (!realized())
|
if (!realized())
|
||||||
{
|
{
|
||||||
gc->makeCurrent();
|
gc->makeCurrent();
|
||||||
try {
|
mPrivate = std::make_shared<OpenXRManagerImpl>(gc);
|
||||||
mPrivate = std::make_shared<OpenXRManagerImpl>(gc);
|
|
||||||
}
|
|
||||||
catch (std::exception& e)
|
|
||||||
{
|
|
||||||
std::string error = std::string("Exception thrown while initializing OpenXR: ") + e.what();
|
|
||||||
Log(Debug::Error) << error;
|
|
||||||
throw std::runtime_error(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,9 @@ namespace MWVR
|
||||||
// Get system ID
|
// Get system ID
|
||||||
XrSystemGetInfo systemInfo{ XR_TYPE_SYSTEM_GET_INFO };
|
XrSystemGetInfo systemInfo{ XR_TYPE_SYSTEM_GET_INFO };
|
||||||
systemInfo.formFactor = mFormFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
systemInfo.formFactor = mFormFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
||||||
CHECK_XRCMD(xrGetSystem(mInstance, &systemInfo, &mSystemId));
|
auto res = CHECK_XRCMD(xrGetSystem(mInstance, &systemInfo, &mSystemId));
|
||||||
assert(mSystemId);
|
if (!XR_SUCCEEDED(res))
|
||||||
|
mPlatform.initFailure(res, mInstance);
|
||||||
|
|
||||||
// Create session
|
// Create session
|
||||||
mSession = mPlatform.createXrSession(mInstance, mSystemId);
|
mSession = mPlatform.createXrSession(mInstance, mSystemId);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace MWVR
|
namespace MWVR
|
||||||
{
|
{
|
||||||
|
@ -409,13 +410,17 @@ namespace MWVR
|
||||||
createInfo.enabledExtensionNames = mEnabledExtensions.data();
|
createInfo.enabledExtensionNames = mEnabledExtensions.data();
|
||||||
strcpy(createInfo.applicationInfo.applicationName, "openmw_vr");
|
strcpy(createInfo.applicationInfo.applicationName, "openmw_vr");
|
||||||
createInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
|
createInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
|
||||||
CHECK_XRCMD(xrCreateInstance(&createInfo, &instance));
|
|
||||||
|
auto res = CHECK_XRCMD(xrCreateInstance(&createInfo, &instance));
|
||||||
|
if (!XR_SUCCEEDED(res))
|
||||||
|
initFailure(res, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
XrSession OpenXRPlatform::createXrSession(XrInstance instance, XrSystemId systemId)
|
XrSession OpenXRPlatform::createXrSession(XrInstance instance, XrSystemId systemId)
|
||||||
{
|
{
|
||||||
XrSession session = XR_NULL_HANDLE;
|
XrSession session = XR_NULL_HANDLE;
|
||||||
|
XrResult res = XR_SUCCESS;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::string graphicsAPIExtension = graphicsAPIExtensionName();
|
std::string graphicsAPIExtension = graphicsAPIExtensionName();
|
||||||
if(graphicsAPIExtension == XR_KHR_OPENGL_ENABLE_EXTENSION_NAME)
|
if(graphicsAPIExtension == XR_KHR_OPENGL_ENABLE_EXTENSION_NAME)
|
||||||
|
@ -448,7 +453,7 @@ namespace MWVR
|
||||||
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
||||||
createInfo.next = &graphicsBindings;
|
createInfo.next = &graphicsBindings;
|
||||||
createInfo.systemId = systemId;
|
createInfo.systemId = systemId;
|
||||||
CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
res = CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
||||||
}
|
}
|
||||||
#ifdef XR_USE_GRAPHICS_API_D3D11
|
#ifdef XR_USE_GRAPHICS_API_D3D11
|
||||||
else if(graphicsAPIExtension == XR_KHR_D3D11_ENABLE_EXTENSION_NAME)
|
else if(graphicsAPIExtension == XR_KHR_D3D11_ENABLE_EXTENSION_NAME)
|
||||||
|
@ -462,7 +467,7 @@ namespace MWVR
|
||||||
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
||||||
createInfo.next = &mPrivate->mD3D11bindings;
|
createInfo.next = &mPrivate->mD3D11bindings;
|
||||||
createInfo.systemId = systemId;
|
createInfo.systemId = systemId;
|
||||||
CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
res = CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
@ -510,10 +515,11 @@ namespace MWVR
|
||||||
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
XrSessionCreateInfo createInfo{ XR_TYPE_SESSION_CREATE_INFO };
|
||||||
createInfo.next = &graphicsBindings;
|
createInfo.next = &graphicsBindings;
|
||||||
createInfo.systemId = systemId;
|
createInfo.systemId = systemId;
|
||||||
CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
res = CHECK_XRCMD(xrCreateSession(instance, &createInfo, &session));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
assert(session);
|
if (!XR_SUCCEEDED(res))
|
||||||
|
initFailure(res, instance);
|
||||||
|
|
||||||
uint32_t swapchainFormatCount;
|
uint32_t swapchainFormatCount;
|
||||||
CHECK_XRCMD(xrEnumerateSwapchainFormats(session, 0, &swapchainFormatCount, nullptr));
|
CHECK_XRCMD(xrEnumerateSwapchainFormats(session, 0, &swapchainFormatCount, nullptr));
|
||||||
|
@ -678,4 +684,56 @@ namespace MWVR
|
||||||
mPrivate->wglDXUnlockObjectsNV(mPrivate->wglDXDevice, 1, &dxResourceShareHandle);
|
mPrivate->wglDXUnlockObjectsNV(mPrivate->wglDXDevice, 1, &dxResourceShareHandle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static XrInstanceProperties
|
||||||
|
getInstanceProperties(XrInstance instance)
|
||||||
|
{
|
||||||
|
XrInstanceProperties properties{ XR_TYPE_INSTANCE_PROPERTIES };
|
||||||
|
if (instance)
|
||||||
|
xrGetInstanceProperties(instance, &properties);
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string OpenXRPlatform::getInstanceName(XrInstance instance)
|
||||||
|
{
|
||||||
|
if (instance)
|
||||||
|
return getInstanceProperties(instance).runtimeName;
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
XrVersion OpenXRPlatform::getInstanceVersion(XrInstance instance)
|
||||||
|
{
|
||||||
|
if (instance)
|
||||||
|
return getInstanceProperties(instance).runtimeVersion;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
void OpenXRPlatform::initFailure(XrResult res, XrInstance instance)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
std::string runtimeName = getInstanceName(instance);
|
||||||
|
XrVersion runtimeVersion = getInstanceVersion(instance);
|
||||||
|
ss << "Error caught while initializing VR device: " << XrResultString(res) << std::endl;
|
||||||
|
ss << "Device: " << runtimeName << std::endl;
|
||||||
|
ss << "Version: " << runtimeVersion << std::endl;
|
||||||
|
if (res == XR_ERROR_FORM_FACTOR_UNAVAILABLE)
|
||||||
|
{
|
||||||
|
ss << "Cause: Unable to open VR device. Make sure your device is plugged in and the VR driver is running." << std::endl;
|
||||||
|
ss << std::endl;
|
||||||
|
if (runtimeName == "Oculus" || runtimeName == "Quest")
|
||||||
|
{
|
||||||
|
ss << "Your device has been identified as an Oculus device." << std::endl;
|
||||||
|
ss << "The most common cause for this error when using an oculus device, is quest users attempting to run the game via Virtual Desktop." << std::endl;
|
||||||
|
ss << "Unfortunately this is currently broken, and quest users will need to play via a link cable." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (res == XR_ERROR_LIMIT_REACHED)
|
||||||
|
{
|
||||||
|
ss << "Cause: Device resources exhausted. Close other VR applications if you have any open. If you have none, you may need to reboot to reset the driver." << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ss << "Cause: Unknown. Make sure your device is plugged in and ready." << std::endl;
|
||||||
|
}
|
||||||
|
throw std::runtime_error(ss.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@ namespace MWVR
|
||||||
/// Unlocks a DX object for use by DirectX as if calling wglDXUnlockObjectsNV
|
/// Unlocks a DX object for use by DirectX as if calling wglDXUnlockObjectsNV
|
||||||
void DXUnlockObject(void* dxResourceShareHandle);
|
void DXUnlockObject(void* dxResourceShareHandle);
|
||||||
|
|
||||||
|
std::string getInstanceName(XrInstance instance);
|
||||||
|
XrVersion getInstanceVersion(XrInstance instance);
|
||||||
|
void initFailure(XrResult, XrInstance);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void enumerateExtensions(const char* layerName, int logIndent);
|
void enumerateExtensions(const char* layerName, int logIndent);
|
||||||
|
|
Loading…
Reference in a new issue