@@ -93,6 +93,7 @@ struct OpenXrProgram : IOpenXrProgram {
93
93
: m_options(options),
94
94
m_platformPlugin (platformPlugin),
95
95
m_graphicsPlugin(graphicsPlugin),
96
+ m_ViewConfigType(m_options->Parsed.ViewConfigType),
96
97
m_acceptableBlendModes{XR_ENVIRONMENT_BLEND_MODE_OPAQUE, XR_ENVIRONMENT_BLEND_MODE_ADDITIVE,
97
98
XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND} {}
98
99
@@ -219,7 +220,7 @@ struct OpenXrProgram : IOpenXrProgram {
219
220
Log::Write (Log::Level::Info, Fmt (" Available View Configuration Types: (%d)" , viewConfigTypeCount));
220
221
for (XrViewConfigurationType viewConfigType : viewConfigTypes) {
221
222
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)" : " " ));
223
224
224
225
XrViewConfigurationProperties viewConfigProperties{XR_TYPE_VIEW_CONFIGURATION_PROPERTIES};
225
226
CHECK_XRCMD (xrGetViewConfigurationProperties (m_instance, m_systemId, viewConfigType, &viewConfigProperties));
@@ -277,11 +278,11 @@ struct OpenXrProgram : IOpenXrProgram {
277
278
278
279
XrEnvironmentBlendMode GetPreferredBlendMode () const override {
279
280
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 ));
281
282
CHECK (count > 0 );
282
283
283
284
std::vector<XrEnvironmentBlendMode> blendModes (count);
284
- CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_options-> Parsed . ViewConfigType , count, &count,
285
+ CHECK_XRCMD (xrEnumerateEnvironmentBlendModes (m_instance, m_systemId, m_ViewConfigType , count, &count,
285
286
blendModes.data ()));
286
287
for (const auto & blendMode : blendModes) {
287
288
if (m_acceptableBlendModes.count (blendMode)) return blendMode;
@@ -301,6 +302,8 @@ struct OpenXrProgram : IOpenXrProgram {
301
302
Fmt (" Using system %d for form factor %s" , m_systemId, to_string (m_options->Parsed .FormFactor )));
302
303
CHECK (m_instance != XR_NULL_HANDLE);
303
304
CHECK (m_systemId != XR_NULL_SYSTEM_ID);
305
+
306
+ determineFinalViewConfigurationType ();
304
307
}
305
308
306
309
void InitializeDevice () override {
@@ -589,18 +592,12 @@ struct OpenXrProgram : IOpenXrProgram {
589
592
systemProperties.trackingProperties .orientationTracking == XR_TRUE ? " True" : " False" ,
590
593
systemProperties.trackingProperties .positionTracking == XR_TRUE ? " True" : " False" ));
591
594
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
-
598
595
// Query and cache view configuration views.
599
596
uint32_t viewCount;
600
597
CHECK_XRCMD (
601
- xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_options-> Parsed . ViewConfigType , 0 , &viewCount, nullptr ));
598
+ xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_ViewConfigType , 0 , &viewCount, nullptr ));
602
599
m_configViews.resize (viewCount, {XR_TYPE_VIEW_CONFIGURATION_VIEW});
603
- CHECK_XRCMD (xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_options-> Parsed . ViewConfigType , viewCount,
600
+ CHECK_XRCMD (xrEnumerateViewConfigurationViews (m_instance, m_systemId, m_ViewConfigType , viewCount,
604
601
&viewCount, m_configViews.data ()));
605
602
606
603
// Create and cache view buffer for xrLocateViews later.
@@ -741,7 +738,7 @@ struct OpenXrProgram : IOpenXrProgram {
741
738
case XR_SESSION_STATE_READY: {
742
739
CHECK (m_session != XR_NULL_HANDLE);
743
740
XrSessionBeginInfo sessionBeginInfo{XR_TYPE_SESSION_BEGIN_INFO};
744
- sessionBeginInfo.primaryViewConfigurationType = m_options-> Parsed . ViewConfigType ;
741
+ sessionBeginInfo.primaryViewConfigurationType = m_ViewConfigType ;
745
742
CHECK_XRCMD (xrBeginSession (m_session, &sessionBeginInfo));
746
743
m_sessionRunning = true ;
747
744
break ;
@@ -895,7 +892,7 @@ struct OpenXrProgram : IOpenXrProgram {
895
892
uint32_t viewCountOutput;
896
893
897
894
XrViewLocateInfo viewLocateInfo{XR_TYPE_VIEW_LOCATE_INFO};
898
- viewLocateInfo.viewConfigurationType = m_options-> Parsed . ViewConfigType ;
895
+ viewLocateInfo.viewConfigurationType = m_ViewConfigType ;
899
896
viewLocateInfo.displayTime = predictedDisplayTime;
900
897
viewLocateInfo.space = m_appSpace;
901
898
@@ -990,6 +987,30 @@ struct OpenXrProgram : IOpenXrProgram {
990
987
return true ;
991
988
}
992
989
990
+ private:
991
+ void determineFinalViewConfigurationType () {
992
+ CHECK (m_instance != XR_NULL_HANDLE);
993
+ CHECK (m_systemId != 0 );
994
+
995
+ uint32_t viewConfigTypeCount;
996
+ CHECK_XRCMD (xrEnumerateViewConfigurations (m_instance, m_systemId, 0 , &viewConfigTypeCount,
997
+ nullptr ));
998
+ std::vector<XrViewConfigurationType> viewConfigTypes (viewConfigTypeCount);
999
+ CHECK_XRCMD (xrEnumerateViewConfigurations (m_instance, m_systemId, viewConfigTypeCount,
1000
+ &viewConfigTypeCount,
1001
+ viewConfigTypes.data ()));
1002
+ CHECK ((uint32_t ) viewConfigTypes.size () == viewConfigTypeCount);
1003
+
1004
+ auto it = find (viewConfigTypes.begin (), viewConfigTypes.end (),
1005
+ m_ViewConfigType);
1006
+ if (it == viewConfigTypes.end ()) {
1007
+ Log::Write (Log::Level::Warning,
1008
+ Fmt (" Runtime not support xrViewConfigurationType(%d) which app expected, change to the one the runtime prefers the application to use " ,
1009
+ m_ViewConfigType, viewConfigTypes.at (0 )));
1010
+ m_ViewConfigType = viewConfigTypes.at (0 );
1011
+ }
1012
+ }
1013
+
993
1014
private:
994
1015
const std::shared_ptr<const Options> m_options;
995
1016
std::shared_ptr<IPlatformPlugin> m_platformPlugin;
@@ -999,6 +1020,8 @@ struct OpenXrProgram : IOpenXrProgram {
999
1020
XrSpace m_appSpace{XR_NULL_HANDLE};
1000
1021
XrSystemId m_systemId{XR_NULL_SYSTEM_ID};
1001
1022
1023
+ XrViewConfigurationType m_ViewConfigType{XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO};
1024
+
1002
1025
std::vector<XrViewConfigurationView> m_configViews;
1003
1026
std::vector<Swapchain> m_swapchains;
1004
1027
std::map<XrSwapchain, std::vector<XrSwapchainImageBaseHeader*>> m_swapchainImages;
0 commit comments