@@ -299,7 +299,8 @@ void OpenXR::Init(IDirect3DDevice9* dev, const Config& cfg, IDirect3DVR9** vrdev
299
299
.type = XR_TYPE_EVENT_DATA_BUFFER,
300
300
.next = nullptr ,
301
301
};
302
- while (true ) {
302
+ auto retries = 10 ;
303
+ while (retries-- > 0 ) {
303
304
if (auto res = xrPollEvent (instance, &eventData); res == XR_SUCCESS) {
304
305
if (eventData.type == XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED) {
305
306
const XrEventDataSessionStateChanged* sessionStateChangedEvent = reinterpret_cast <const XrEventDataSessionStateChanged*>(&eventData);
@@ -314,12 +315,25 @@ void OpenXR::Init(IDirect3DDevice9* dev, const Config& cfg, IDirect3DVR9** vrdev
314
315
if (auto res = xrBeginSession (session, &sessionBeginInfo); res != XR_SUCCESS) {
315
316
throw std::runtime_error (std::format (" Failed to initialize OpenXR. xrBeginSession: {}" , XrResultToString (instance, res)));
316
317
}
318
+
317
319
break ;
318
320
}
319
321
}
320
322
}
321
323
}
322
324
325
+ if (retries == 0 ) {
326
+ Dbg (" Did not receive XR_SESSION_STATE_READY event, launching the session anyway..." );
327
+ XrSessionBeginInfo sessionBeginInfo = {
328
+ .type = XR_TYPE_SESSION_BEGIN_INFO,
329
+ .next = nullptr ,
330
+ .primaryViewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
331
+ };
332
+ if (auto res = xrBeginSession (session, &sessionBeginInfo); res != XR_SUCCESS) {
333
+ throw std::runtime_error (std::format (" Failed to initialize OpenXR. xrBeginSession: {}" , XrResultToString (instance, res)));
334
+ }
335
+ }
336
+
323
337
eyePos[LeftEye] = glm::identity<glm::mat4x4>();
324
338
eyePos[RightEye] = glm::identity<glm::mat4x4>();
325
339
}
0 commit comments