18 uint32_t extensionCount;
19 CHECK_XRCMD(xrEnumerateInstanceExtensionProperties(layerName, 0, &extensionCount,
nullptr));
20 std::vector<XrExtensionProperties> extensionProperties(extensionCount, {XR_TYPE_EXTENSION_PROPERTIES});
21 CHECK_XRCMD(xrEnumerateInstanceExtensionProperties(layerName, extensionCount, &extensionCount, extensionProperties.data()));
22 extensionProperties.resize(extensionCount);
23 return extensionProperties;
27 uint32_t viewConfigurationCount = 0;
28 CHECK_XRCMD(xrEnumerateViewConfigurations(instance, systemId, 0, &viewConfigurationCount,
nullptr));
30 std::vector<XrViewConfigurationType> viewConfigs(viewConfigurationCount);
31 CHECK_XRCMD(xrEnumerateViewConfigurations(instance, systemId, viewConfigurationCount, &viewConfigurationCount, viewConfigs.data()));
37 XrViewConfigurationType viewConfigurationType) {
39 CHECK_XRCMD(xrEnumerateViewConfigurationViews(instance, systemId, viewConfigurationType, 0, &viewCount,
nullptr));
41 std::vector<XrViewConfigurationView> viewConfigViews(viewCount, {XR_TYPE_VIEW_CONFIGURATION_VIEW});
43 instance, systemId, viewConfigurationType, (uint32_t)viewConfigViews.size(), &viewCount, viewConfigViews.data()));
45 return viewConfigViews;
50 XrViewConfigurationType viewConfigType) {
51 uint32_t blendModeCount;
52 CHECK_XRCMD(xrEnumerateEnvironmentBlendModes(instance, systemId, viewConfigType, 0, &blendModeCount,
nullptr));
54 std::vector<XrEnvironmentBlendMode> blendModes(blendModeCount);
56 xrEnumerateEnvironmentBlendModes(instance, systemId, viewConfigType, blendModeCount, &blendModeCount, blendModes.data()));
63 const std::vector<XrEnvironmentBlendMode>& appSupportedBlendModes) {
64 auto blendModeIt = std::find_first_of(systemSupportedBlendModes.begin(),
65 systemSupportedBlendModes.end(),
66 appSupportedBlendModes.begin(),
67 appSupportedBlendModes.end());
68 if (blendModeIt == std::end(systemSupportedBlendModes)) {
69 throw std::runtime_error(
"No blend modes supported");
76 uint32_t swapchainFormatsCount;
77 CHECK_XRCMD(xrEnumerateSwapchainFormats(session, 0, &swapchainFormatsCount,
nullptr));
79 std::vector<int64_t> runtimeFormats(swapchainFormatsCount);
80 CHECK_XRCMD(xrEnumerateSwapchainFormats(session, (uint32_t)runtimeFormats.size(), &swapchainFormatsCount, runtimeFormats.data()));
81 return runtimeFormats;
86 inline TAppPixelFormat
PickSwapchainFormat(
const std::vector<TSystemPixelFormat>& systemSupportedFormats,
87 const std::vector<TAppPixelFormat>& appSupportedFormats) {
89 auto swapchainFormatIt = std::find_first_of(
90 systemSupportedFormats.begin(), systemSupportedFormats.end(), appSupportedFormats.begin(), appSupportedFormats.end());
92 if (swapchainFormatIt == std::end(systemSupportedFormats)) {
93 throw std::runtime_error(
"No swapchain format supported");
96 return (TAppPixelFormat)*swapchainFormatIt;
100 uint32_t spaceCountOutput;
101 CHECK_XRCMD(xrEnumerateReferenceSpaces(session, 0, &spaceCountOutput,
nullptr));
103 std::vector<XrReferenceSpaceType> runtimeSupportedReferenceSpaces(spaceCountOutput);
105 session, (uint32_t)runtimeSupportedReferenceSpaces.size(), &spaceCountOutput, runtimeSupportedReferenceSpaces.data()));
106 return runtimeSupportedReferenceSpaces;
110 std::set<std::string> names;
111 uint32_t nameCapacityOutput = 0;
112 uint32_t sourcesCount;
114 XrBoundSourcesForActionEnumerateInfo enumerateBoundSourcesInfo{XR_TYPE_BOUND_SOURCES_FOR_ACTION_ENUMERATE_INFO};
115 enumerateBoundSourcesInfo.action = action;
116 CHECK_XRCMD(xrEnumerateBoundSourcesForAction(session, &enumerateBoundSourcesInfo, 0, &sourcesCount,
nullptr));
118 std::vector<XrPath> sourcesBuffer;
119 sourcesBuffer.resize(sourcesCount);
121 xrEnumerateBoundSourcesForAction(session, &enumerateBoundSourcesInfo, sourcesCount, &sourcesCount, sourcesBuffer.data()));
123 std::string nameBuffer;
124 for (uint32_t i = 0; i < sourcesCount; i++) {
125 XrInputSourceLocalizedNameGetInfo getLocalizedNameInfo{XR_TYPE_INPUT_SOURCE_LOCALIZED_NAME_GET_INFO};
126 getLocalizedNameInfo.sourcePath = sourcesBuffer[i];
127 getLocalizedNameInfo.whichComponents = flags;
129 CHECK_XRCMD(xrGetInputSourceLocalizedName(session, &getLocalizedNameInfo, 0, &nameCapacityOutput,
nullptr));
131 nameBuffer.resize(nameCapacityOutput);
133 xrGetInputSourceLocalizedName(session, &getLocalizedNameInfo, nameCapacityOutput, &nameCapacityOutput, nameBuffer.data()));
136 names.emplace(nameBuffer.data());