feat: implement XR_META_boundary_visibility
This commit is contained in:
+45
-2
@@ -60,6 +60,9 @@ xr::session::session(xr::instance & inst, xr::system & sys, vk::raii::Instance &
|
||||
|
||||
if (inst.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
|
||||
xrPerfSettingsSetPerformanceLevelEXT = inst.get_proc<PFN_xrPerfSettingsSetPerformanceLevelEXT>("xrPerfSettingsSetPerformanceLevelEXT");
|
||||
|
||||
if (inst.has_extension(XR_META_BOUNDARY_VISIBILITY_EXTENSION_NAME) and sys.boundary_visibility_properties().supportsBoundaryVisibility)
|
||||
xrRequestBoundaryVisibilityMETA = inst.get_proc<PFN_xrRequestBoundaryVisibilityMETA>("xrRequestBoundaryVisibilityMETA");
|
||||
}
|
||||
|
||||
std::vector<XrReferenceSpaceType> xr::session::get_reference_spaces() const
|
||||
@@ -158,8 +161,12 @@ void xr::session::end_frame(XrTime display_time, const std::vector<XrComposition
|
||||
.layers = layers.data(),
|
||||
};
|
||||
|
||||
auto lock = queue->lock();
|
||||
CHECK_XR(xrEndFrame(id, &end_info));
|
||||
{
|
||||
auto lock = queue->lock();
|
||||
CHECK_XR(xrEndFrame(id, &end_info));
|
||||
}
|
||||
|
||||
update_boundary_visibility();
|
||||
}
|
||||
|
||||
void xr::session::begin_session(XrViewConfigurationType view_config)
|
||||
@@ -378,6 +385,42 @@ void xr::session::disable_passthrough()
|
||||
passthrough.emplace<std::monostate>();
|
||||
}
|
||||
|
||||
void xr::session::set_boundary_hidden(bool hidden)
|
||||
{
|
||||
boundary_hidden = hidden;
|
||||
boundary_request_failed = false;
|
||||
}
|
||||
|
||||
void xr::session::on_boundary_visibility_changed(XrBoundaryVisibilityMETA v)
|
||||
{
|
||||
boundary_visibility = v;
|
||||
}
|
||||
|
||||
// the runtime only allows suppression while passthrough is shown and restores
|
||||
// the boundary when it stops, so this re-requests every time passthrough comes back
|
||||
void xr::session::update_boundary_visibility()
|
||||
{
|
||||
if (not xrRequestBoundaryVisibilityMETA)
|
||||
return;
|
||||
|
||||
auto v = boundary_hidden and not std::holds_alternative<std::monostate>(passthrough)
|
||||
? XR_BOUNDARY_VISIBILITY_SUPPRESSED_META
|
||||
: XR_BOUNDARY_VISIBILITY_NOT_SUPPRESSED_META;
|
||||
if (v == boundary_visibility)
|
||||
return;
|
||||
|
||||
if (auto res = xrRequestBoundaryVisibilityMETA(id, v); res == XR_SUCCESS)
|
||||
{
|
||||
boundary_visibility = v;
|
||||
boundary_request_failed = false;
|
||||
}
|
||||
else if (not boundary_request_failed)
|
||||
{
|
||||
spdlog::warn("Boundary visibility change failed: {}", xr::to_string(res));
|
||||
boundary_request_failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void xr::session::set_performance_level(XrPerfSettingsDomainEXT domain, XrPerfSettingsLevelEXT level)
|
||||
{
|
||||
if (xrPerfSettingsSetPerformanceLevelEXT)
|
||||
|
||||
Reference in New Issue
Block a user