feat: implement XR_META_boundary_visibility
This commit is contained in:
@@ -1393,6 +1393,7 @@ void application::initialize()
|
||||
XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME,
|
||||
XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME,
|
||||
XR_META_LOCAL_DIMMING_EXTENSION_NAME,
|
||||
XR_META_BOUNDARY_VISIBILITY_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
for (const auto & i: interaction_profiles)
|
||||
@@ -1478,6 +1479,8 @@ void application::initialize()
|
||||
config.emplace(xr_system_id, xr_session, application::get_config_path() / "client.json");
|
||||
default_config.emplace(xr_system_id, xr_session);
|
||||
|
||||
xr_session.set_boundary_hidden(config->hide_boundary);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
set_usb_networking(config->usb_network);
|
||||
#endif
|
||||
@@ -2124,6 +2127,11 @@ void application::poll_events()
|
||||
spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_RESTORED_ERROR_BIT_FB");
|
||||
}
|
||||
break;
|
||||
case XR_TYPE_EVENT_DATA_BOUNDARY_VISIBILITY_CHANGED_META: {
|
||||
spdlog::info("Boundary visibility changed to {}", magic_enum::enum_name(e.boundary_visibility_changed.boundaryVisibility));
|
||||
xr_session.on_boundary_visibility_changed(e.boundary_visibility_changed.boundaryVisibility);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
spdlog::info("Received event type {}", xr::to_string(e.header.type));
|
||||
break;
|
||||
|
||||
@@ -327,6 +327,7 @@ const std::vector<config_field> & configuration::config_fields()
|
||||
scalar("theme_font_scale", &configuration::theme_font_scale),
|
||||
scalar("theme_background_alpha", &configuration::theme_background_alpha),
|
||||
scalar("passthrough_enabled", &configuration::passthrough_enabled),
|
||||
scalar("hide_boundary", &configuration::hide_boundary),
|
||||
scalar("mic_unprocessed_audio", &configuration::mic_unprocessed_audio),
|
||||
scalar("forward_keyboard", &configuration::forward_keyboard),
|
||||
scalar("forward_mouse", &configuration::forward_mouse),
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
uint8_t bit_depth = 10;
|
||||
|
||||
bool passthrough_enabled = false;
|
||||
// XR_META_boundary_visibility, the runtime only honours it while passthrough is shown
|
||||
bool hide_boundary = true;
|
||||
bool mic_unprocessed_audio = false;
|
||||
|
||||
// Input forwarding, per device. Off by default; only effective if the server permits it.
|
||||
|
||||
@@ -764,6 +764,19 @@ void settings_system(const settings_context & ctx)
|
||||
});
|
||||
}
|
||||
|
||||
if (ctx.session.boundary_visibility_supported())
|
||||
{
|
||||
list.push_back({
|
||||
.id = "##hide_boundary",
|
||||
.label = _C("setting name", "Hide boundary in passthrough"),
|
||||
.description = _("Lets you walk outside the boundary while passthrough is shown. The boundary always comes back in VR."),
|
||||
.ui = ui_kind::toggle,
|
||||
.get_bool = [&config] { return config.hide_boundary; },
|
||||
.set_bool = [&ctx, &config](bool v) { config.hide_boundary = v; config.save(); ctx.session.set_boundary_hidden(v); },
|
||||
.default_bool = default_config.hide_boundary,
|
||||
});
|
||||
}
|
||||
|
||||
bool disable_instream_gui = false;
|
||||
bool disable_instream_gui_popup_open = ImGui::IsPopupOpen("confirm disable in stream gui");
|
||||
list.push_back({
|
||||
|
||||
@@ -45,6 +45,7 @@ union event
|
||||
XrEventDataPassthroughStateChangedFB passthrough_state_changed;
|
||||
XrEventDataVisibilityMaskChangedKHR visibility_mask_changed;
|
||||
XrEventDataUserPresenceChangedEXT user_presence_changed;
|
||||
XrEventDataBoundaryVisibilityChangedMETA boundary_visibility_changed;
|
||||
};
|
||||
class instance : public utils::handle<XrInstance, xrDestroyInstance>
|
||||
{
|
||||
|
||||
+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)
|
||||
|
||||
@@ -48,6 +48,13 @@ class session : public utils::handle<XrSession, xrDestroySession>
|
||||
|
||||
PFN_xrPerfSettingsSetPerformanceLevelEXT xrPerfSettingsSetPerformanceLevelEXT = nullptr;
|
||||
|
||||
PFN_xrRequestBoundaryVisibilityMETA xrRequestBoundaryVisibilityMETA = nullptr;
|
||||
XrBoundaryVisibilityMETA boundary_visibility = XR_BOUNDARY_VISIBILITY_NOT_SUPPRESSED_META;
|
||||
bool boundary_hidden = false;
|
||||
bool boundary_request_failed = false;
|
||||
|
||||
void update_boundary_visibility();
|
||||
|
||||
public:
|
||||
session() = default;
|
||||
session(instance &, system &, vk::raii::Instance &, vk::raii::PhysicalDevice &, vk::raii::Device &, thread_safe<vk::raii::Queue> & queue, int queue_family_index);
|
||||
@@ -99,5 +106,12 @@ public:
|
||||
}
|
||||
|
||||
void set_performance_level(XrPerfSettingsDomainEXT, XrPerfSettingsLevelEXT);
|
||||
|
||||
bool boundary_visibility_supported() const
|
||||
{
|
||||
return xrRequestBoundaryVisibilityMETA;
|
||||
}
|
||||
void set_boundary_hidden(bool);
|
||||
void on_boundary_visibility_changed(XrBoundaryVisibilityMETA);
|
||||
};
|
||||
} // namespace xr
|
||||
|
||||
@@ -242,6 +242,24 @@ XrSystemBodyTrackingPropertiesBD xr::system::bd_body_tracking_properties() const
|
||||
return body_tracking_prop;
|
||||
}
|
||||
|
||||
XrSystemBoundaryVisibilityPropertiesMETA xr::system::boundary_visibility_properties() const
|
||||
{
|
||||
if (!id)
|
||||
throw std::invalid_argument("this");
|
||||
|
||||
XrSystemBoundaryVisibilityPropertiesMETA boundary_prop{
|
||||
.type = XR_TYPE_SYSTEM_BOUNDARY_VISIBILITY_PROPERTIES_META,
|
||||
};
|
||||
|
||||
XrSystemProperties prop{
|
||||
.type = XR_TYPE_SYSTEM_PROPERTIES,
|
||||
.next = &boundary_prop,
|
||||
};
|
||||
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
|
||||
|
||||
return boundary_prop;
|
||||
}
|
||||
|
||||
xr::passthrough_type xr::system::passthrough_supported() const
|
||||
{
|
||||
if (utils::contains(environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND))
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
XrSystemBodyTrackingPropertiesFB fb_body_tracking_properties() const;
|
||||
XrSystemPropertiesBodyTrackingFullBodyMETA meta_body_tracking_properties() const;
|
||||
XrSystemBodyTrackingPropertiesBD bd_body_tracking_properties() const;
|
||||
XrSystemBoundaryVisibilityPropertiesMETA boundary_visibility_properties() const;
|
||||
|
||||
bool hand_tracking_supported() const;
|
||||
bool hand_mesh_fb_supported() const;
|
||||
|
||||
Reference in New Issue
Block a user