-
Notifications
You must be signed in to change notification settings - Fork 288
WIP: Add basic run as overlay functionality #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,15 @@ inline XrEnvironmentBlendMode GetXrEnvironmentBlendMode(const std::string& envir | |
| throw std::invalid_argument(Fmt("Unknown environment blend mode '%s'", environmentBlendModeStr.c_str())); | ||
| } | ||
|
|
||
| inline uint32_t GetXrOverlayPlacement(const std::string& overlayPlacement) { | ||
| try { | ||
| unsigned long value = stoul(overlayPlacement); | ||
| return static_cast<uint32_t>(value); | ||
| } catch (...) { | ||
| } | ||
| throw std::invalid_argument(Fmt("Invalid overlay placement '%s'", overlayPlacement.c_str())); | ||
| } | ||
|
|
||
| namespace Math { | ||
| namespace Pose { | ||
| XrPosef Identity() { | ||
|
|
@@ -224,6 +233,10 @@ struct OpenXrProgram : IOpenXrProgram { | |
| std::transform(graphicsExtensions.begin(), graphicsExtensions.end(), std::back_inserter(extensions), | ||
| [](const std::string& ext) { return ext.c_str(); }); | ||
|
|
||
| if (m_overlayApp) { | ||
| extensions.push_back(XR_EXTX_OVERLAY_EXTENSION_NAME); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before adding overlay extension as enabled extensions list, should it need to check whether runtime supports this extension likes xrgears(https://gitlab.freedesktop.org/monado/demos/xrgears/-/merge_requests/10/diffs#575c3212e3fa074fbb40562ade4bdfad41bd74d7_130_136)? |
||
| } | ||
|
|
||
| XrInstanceCreateInfo createInfo{XR_TYPE_INSTANCE_CREATE_INFO}; | ||
| createInfo.next = m_platformPlugin->GetInstanceCreateExtension(); | ||
| createInfo.enabledExtensionCount = (uint32_t)extensions.size(); | ||
|
|
@@ -325,6 +338,11 @@ struct OpenXrProgram : IOpenXrProgram { | |
| systemInfo.formFactor = m_formFactor; | ||
| CHECK_XRCMD(xrGetSystem(m_instance, &systemInfo, &m_systemId)); | ||
|
|
||
| if (!m_options->OverlayPlacement.empty()) { | ||
| m_overlayApp = true; | ||
| m_overlayPlacement = GetXrOverlayPlacement(m_options->OverlayPlacement); | ||
| } | ||
|
|
||
| Log::Write(Log::Level::Verbose, Fmt("Using system %d for form factor %s", m_systemId, to_string(m_formFactor))); | ||
| CHECK(m_instance != XR_NULL_HANDLE); | ||
| CHECK(m_systemId != XR_NULL_SYSTEM_ID); | ||
|
|
@@ -581,6 +599,14 @@ struct OpenXrProgram : IOpenXrProgram { | |
| XrSessionCreateInfo createInfo{XR_TYPE_SESSION_CREATE_INFO}; | ||
| createInfo.next = m_graphicsPlugin->GetGraphicsBinding(); | ||
| createInfo.systemId = m_systemId; | ||
|
|
||
| XrSessionCreateInfoOverlayEXTX overlayCreateInfo = {XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX, nullptr, 0U, 0U}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember OpenXR spec says the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea both the graphics binding and XrSessionCreateInfoOverlayEXTX need to be in the next chain of XrSessionCreateInfo. Note that the validation layer has an issue there #264. |
||
| if (m_overlayApp) { | ||
| overlayCreateInfo.next = createInfo.next; | ||
| createInfo.next = &overlayCreateInfo; | ||
| overlayCreateInfo.sessionLayersPlacement = m_overlayPlacement; | ||
| } | ||
|
|
||
| CHECK_XRCMD(xrCreateSession(m_instance, &createInfo, &m_session)); | ||
| } | ||
|
|
||
|
|
@@ -1020,6 +1046,8 @@ struct OpenXrProgram : IOpenXrProgram { | |
| XrViewConfigurationType m_viewConfigType{XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO}; | ||
| XrEnvironmentBlendMode m_environmentBlendMode{XR_ENVIRONMENT_BLEND_MODE_OPAQUE}; | ||
| XrSystemId m_systemId{XR_NULL_SYSTEM_ID}; | ||
| bool m_overlayApp = false; | ||
| uint32_t m_overlayPlacement = 0; | ||
|
|
||
| std::vector<XrViewConfigurationView> m_configViews; | ||
| std::vector<Swapchain> m_swapchains; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance to support those parameters for Android? Monado has two flavors, out of process and in process, and we can build two versions with different package name for different usage. Could hello_xr support similar flags to build two versions with different package name, one for normal usage, and one for overlay usage?