@@ -86,6 +86,12 @@ constexpr int gFudgeMinAlpha = 128;
8686int gLayerPlacement = 0 ;
8787float gLayerRotationalOffset = 0 .f;
8888bool gEmptyFrame = false ;
89+ bool gAllInputExtensions = false ;
90+
91+ std::vector<const char *> gInputExtensionList {
92+ XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME, XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME,
93+ XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME, XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME,
94+ XR_MSFT_HAND_INTERACTION_EXTENSION_NAME};
8995
9096// OpenXR will give us a LUID. This function will walk adapters to find
9197// the adapter matching that LUID, then create an ID3D11Device* from it so
@@ -334,6 +340,7 @@ class OpenXRProgram
334340void OpenXRProgram::CreateInstance (const std::string& appName, uint32_t appVersion, const std::string& engineName, uint32_t engineVersion)
335341{
336342 std::map<std::string, uint32_t > extensions;
343+ auto HasExtension = [&extensions](const char * extName) { return extensions.find (std::string (extName)) != extensions.end (); };
337344
338345 uint32_t extPropCount;
339346 CHECK_XR (xrEnumerateInstanceExtensionProperties (nullptr , 0 , &extPropCount, nullptr ));
@@ -353,30 +360,41 @@ void OpenXRProgram::CreateInstance(const std::string& appName, uint32_t appVersi
353360 std::cout << " Extensions supported:\n " ;
354361 for (const auto & p: extensions) {
355362 std::cout << " " << p.first << " , version " << p.second << " \n " ;
356- if (std::string (p.first ) == " XR_EXT_debug_utils" ) {
357- mDebugUtilsAvailable = true ;
358- }
359- if (std::string (p.first ) == " XR_EXT_permissions_support" ) {
360- mPermissionsSupportAvailable = true ;
361- }
362363 }
363364 } else {
364365 std::cout << " Warning: No extensions supported.\n " ;
365366 }
366367
367368 std::vector<const char *> requiredExtensionNames;
368- requiredExtensionNames.push_back (" XR_KHR_D3D11_enable" );
369369
370- if (mRequestOverlaySession ) {
371- requiredExtensionNames.push_back (XR_EXTX_OVERLAY_EXTENSION_NAME);
372- }
370+ auto RequestExtension = [&HasExtension, &requiredExtensionNames](const char * extName) {
371+ if (HasExtension (extName)) {
372+ requiredExtensionNames.push_back (extName);
373+ return true ;
374+ }
375+ return false ;
376+ };
373377
374- if (mDebugUtilsAvailable ) {
375- requiredExtensionNames.push_back (" XR_EXT_debug_utils" );
378+ if (!RequestExtension (" XR_KHR_D3D11_enable" )) {
379+ // Fatal error to not have graphics support
380+ std::cerr << " Error: required D3D11 extension not present" << std::endl;
381+ exit (1 );
376382 }
377383
378- if (mPermissionsSupportAvailable ) {
379- requiredExtensionNames.push_back (" XR_EXT_permissions_support" );
384+ if (mRequestOverlaySession ) {
385+ if (!RequestExtension (XR_EXTX_OVERLAY_EXTENSION_NAME)) {
386+ // Fatal error to not have graphics support
387+ std::cerr << " Error: cannot start overlay session without overlay extension" << std::endl;
388+ exit (1 );
389+ }
390+ }
391+ RequestExtension (" XR_EXT_debug_utils" );
392+ RequestExtension (" XR_EXT_permissions_support" );
393+ if (gAllInputExtensions ) {
394+ // Enable all input extensions that are *present* -- typically when as service
395+ for (auto & ext : gInputExtensionList ) {
396+ RequestExtension (ext);
397+ }
380398 }
381399
382400 XrInstanceCreateInfo createInstance{XR_TYPE_INSTANCE_CREATE_INFO};
@@ -1059,10 +1077,12 @@ int main( int argc, char **argv )
10591077 arg += 2 ;
10601078 } else if (strcmp (argv[arg], " --main" ) == 0 ) {
10611079 createOverlaySession = false ;
1080+ gAllInputExtensions = true ; // Need to support anything an overlay session *could* ask for
10621081 arg += 1 ;
10631082 } else if (strcmp (argv[arg], " --service" ) == 0 ) {
10641083 createOverlaySession = false ;
10651084 gEmptyFrame = true ;
1085+ gAllInputExtensions = true ; // Need to support anything an overlay session *could* ask for
10661086 arg += 1 ;
10671087
10681088 } else if ((strcmp (argv[arg], " --rotational-offset" ) == 0 ) || (strcmp (argv[arg], " --rot" ) == 0 )) {
0 commit comments