@@ -93,6 +93,7 @@ struct OpenXrProgram : IOpenXrProgram {
9393 : m_options(options),
9494 m_platformPlugin (platformPlugin),
9595 m_graphicsPlugin(graphicsPlugin),
96+ m_ViewConfigType(m_options->Parsed.ViewConfigType),
9697 m_acceptableBlendModes{XR_ENVIRONMENT_BLEND_MODE_OPAQUE, XR_ENVIRONMENT_BLEND_MODE_ADDITIVE,
9798 XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND} {}
9899
@@ -219,7 +220,7 @@ struct OpenXrProgram : IOpenXrProgram {
219220 Log::Write (Log::Level::Info, Fmt (" Available View Configuration Types: (%d)" , viewConfigTypeCount));
220221 for (XrViewConfigurationType viewConfigType : viewConfigTypes) {
221222 Log::Write (Log::Level::Verbose, Fmt (" View Configuration Type: %s %s" , to_string (viewConfigType),
222- viewConfigType == m_options-> Parsed . ViewConfigType ? " (Selected)" : " " ));
223+ viewConfigType == m_ViewConfigType ? " (Selected)" : " " ));
223224
224225 XrViewConfigurationProperties viewConfigProperties{XR_TYPE_VIEW_CONFIGURATION_PROPERTIES};
225226 CHECK_XRCMD (xrGetViewConfigurationProperties (m_instance, m_systemId, viewConfigType, &viewConfigProperties));
@@ -277,12 +278,11 @@ struct OpenXrProgram : IOpenXrProgram {
277278
278279 XrEnvironmentBlendMode GetPreferredBlendMode () const override {
279280 uint32_t count;
280- CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_options-> Parsed . ViewConfigType , 0 , &count, nullptr ));
281+ CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_ViewConfigType , 0 , &count, nullptr ));
281282 CHECK (count > 0 );
282283
283284 std::vector<XrEnvironmentBlendMode> blendModes (count);
284- CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_options->Parsed .ViewConfigType , count, &count,
285- blendModes.data ()));
285+ CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_ViewConfigType, count, &count, blendModes.data ()));
286286 for (const auto & blendMode : blendModes) {
287287 if (m_acceptableBlendModes.count (blendMode)) return blendMode;
288288 }
@@ -301,6 +301,8 @@ struct OpenXrProgram : IOpenXrProgram {
301301 Fmt (" Using system %d for form factor %s" , m_systemId, to_string (m_options->Parsed .FormFactor )));
302302 CHECK (m_instance != XR_NULL_HANDLE);
303303 CHECK (m_systemId != XR_NULL_SYSTEM_ID);
304+
305+ determineFinalViewConfigurationType ();
304306 }
305307
306308 void InitializeDevice () override {
@@ -589,19 +591,12 @@ struct OpenXrProgram : IOpenXrProgram {
589591 systemProperties.trackingProperties .orientationTracking == XR_TRUE ? " True" : " False" ,
590592 systemProperties.trackingProperties .positionTracking == XR_TRUE ? " True" : " False" ));
591593
592- // Note: No other view configurations exist at the time this code was written. If this
593- // condition is not met, the project will need to be audited to see how support should be
594- // added.
595- CHECK_MSG (m_options->Parsed .ViewConfigType == XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
596- " Unsupported view configuration type" );
597-
598594 // Query and cache view configuration views.
599595 uint32_t viewCount;
600- CHECK_XRCMD (
601- xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_options->Parsed .ViewConfigType , 0 , &viewCount, nullptr ));
596+ CHECK_XRCMD (xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_ViewConfigType, 0 , &viewCount, nullptr ));
602597 m_configViews.resize (viewCount, {XR_TYPE_VIEW_CONFIGURATION_VIEW});
603- CHECK_XRCMD (xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_options-> Parsed . ViewConfigType , viewCount,
604- &viewCount, m_configViews.data ()));
598+ CHECK_XRCMD (xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_ViewConfigType, viewCount, & viewCount,
599+ m_configViews.data ()));
605600
606601 // Create and cache view buffer for xrLocateViews later.
607602 m_views.resize (viewCount, {XR_TYPE_VIEW});
@@ -741,7 +736,7 @@ struct OpenXrProgram : IOpenXrProgram {
741736 case XR_SESSION_STATE_READY: {
742737 CHECK (m_session != XR_NULL_HANDLE);
743738 XrSessionBeginInfo sessionBeginInfo{XR_TYPE_SESSION_BEGIN_INFO};
744- sessionBeginInfo.primaryViewConfigurationType = m_options-> Parsed . ViewConfigType ;
739+ sessionBeginInfo.primaryViewConfigurationType = m_ViewConfigType ;
745740 CHECK_XRCMD (xrBeginSession (m_session, &sessionBeginInfo));
746741 m_sessionRunning = true ;
747742 break ;
@@ -895,7 +890,7 @@ struct OpenXrProgram : IOpenXrProgram {
895890 uint32_t viewCountOutput;
896891
897892 XrViewLocateInfo viewLocateInfo{XR_TYPE_VIEW_LOCATE_INFO};
898- viewLocateInfo.viewConfigurationType = m_options-> Parsed . ViewConfigType ;
893+ viewLocateInfo.viewConfigurationType = m_ViewConfigType ;
899894 viewLocateInfo.displayTime = predictedDisplayTime;
900895 viewLocateInfo.space = m_appSpace;
901896
@@ -990,6 +985,27 @@ struct OpenXrProgram : IOpenXrProgram {
990985 return true ;
991986 }
992987
988+ private:
989+ void determineFinalViewConfigurationType () {
990+ CHECK (m_instance != XR_NULL_HANDLE);
991+ CHECK (m_systemId != 0 );
992+
993+ uint32_t viewConfigTypeCount;
994+ CHECK_XRCMD (xrEnumerateViewConfigurations (m_instance, m_systemId, 0 , &viewConfigTypeCount, nullptr ));
995+ std::vector<XrViewConfigurationType> viewConfigTypes (viewConfigTypeCount);
996+ CHECK_XRCMD (xrEnumerateViewConfigurations (m_instance, m_systemId, viewConfigTypeCount, &viewConfigTypeCount,
997+ viewConfigTypes.data ()));
998+ CHECK ((uint32_t )viewConfigTypes.size () == viewConfigTypeCount);
999+
1000+ auto it = find (viewConfigTypes.begin (), viewConfigTypes.end (), m_ViewConfigType);
1001+ if (it == viewConfigTypes.end ()) {
1002+ Log::Write (Log::Level::Warning, Fmt (" Runtime not support xrViewConfigurationType(%d) which app expected, change to the "
1003+ " one the runtime prefers the application to use " ,
1004+ m_ViewConfigType, viewConfigTypes.at (0 )));
1005+ m_ViewConfigType = viewConfigTypes.at (0 );
1006+ }
1007+ }
1008+
9931009 private:
9941010 const std::shared_ptr<const Options> m_options;
9951011 std::shared_ptr<IPlatformPlugin> m_platformPlugin;
@@ -999,6 +1015,8 @@ struct OpenXrProgram : IOpenXrProgram {
9991015 XrSpace m_appSpace{XR_NULL_HANDLE};
10001016 XrSystemId m_systemId{XR_NULL_SYSTEM_ID};
10011017
1018+ XrViewConfigurationType m_ViewConfigType{XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO};
1019+
10021020 std::vector<XrViewConfigurationView> m_configViews;
10031021 std::vector<Swapchain> m_swapchains;
10041022 std::map<XrSwapchain, std::vector<XrSwapchainImageBaseHeader*>> m_swapchainImages;
0 commit comments