Move *_supported into xr::system

This commit is contained in:
Patrick Nicolas
2025-08-20 22:07:08 +02:00
parent d2ea30e70f
commit 68edc66fb7
12 changed files with 76 additions and 66 deletions
+7 -3
View File
@@ -38,6 +38,7 @@
#include <chrono>
#include <ctype.h>
#include <exception>
#include <magic_enum.hpp>
#include <string>
#include <thread>
#include <vector>
@@ -1261,17 +1262,20 @@ void application::initialize()
switch (xr_system_id.passthrough_supported())
{
case xr::system::passthrough_type::no_passthrough:
case xr::passthrough_type::none:
spdlog::info(" Passthrough: not supported");
break;
case xr::system::passthrough_type::bw:
case xr::passthrough_type::bw:
spdlog::info(" Passthrough: black and white");
break;
case xr::system::passthrough_type::color:
case xr::passthrough_type::color:
spdlog::info(" Passthrough: color");
break;
}
spdlog::info(" Face tracker: {}", magic_enum::enum_name(xr_system_id.face_tracker_supported()));
spdlog::info(" Body tracker: {}", magic_enum::enum_name(xr_system_id.body_tracker_supported()));
// Log view configurations and blend modes
log_views();
-10
View File
@@ -388,21 +388,11 @@ public:
return instance().vk_instance;
}
static xr::instance & get_instance()
{
return instance().xr_instance;
}
static xr::system & get_system()
{
return instance().xr_system_id;
}
static xr::session & get_session()
{
return instance().xr_session;
}
static vk::raii::PipelineCache & get_pipeline_cache()
{
return instance().pipeline_cache;
+5 -9
View File
@@ -20,8 +20,6 @@
#include "configuration.h"
#include "application.h"
#include "xr/body_tracker.h"
#include "xr/face_tracker.h"
#include <fstream>
#include <magic_enum.hpp>
@@ -84,9 +82,7 @@ bool configuration::check_feature(feature f) const
{
std::lock_guard lock(mutex);
auto & instance = application::get_instance();
auto & system = application::get_system();
auto & session = application::get_session();
auto it = features.find(f);
if (it == features.end())
@@ -108,11 +104,11 @@ bool configuration::check_feature(feature f) const
return false;
break;
case feature::face_tracking:
if (xr::face_tracker_supported(instance, system) == xr::face_tracker_type::none)
if (system.face_tracker_supported() == xr::face_tracker_type::none)
return false;
break;
case feature::body_tracking:
if (xr::body_tracker_supported(instance, system) == xr::body_tracker_type::none)
if (system.body_tracker_supported() == xr::body_tracker_type::none)
return false;
break;
}
@@ -149,7 +145,7 @@ void configuration::set_feature(feature f, bool state)
configuration::configuration(xr::system & system)
{
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
features[feature::hand_tracking] = system.hand_tracking_supported();
try
{
@@ -211,7 +207,7 @@ configuration::configuration(xr::system & system)
features[i] = val.get_bool();
}
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
if (system.passthrough_supported() == xr::passthrough_type::none)
passthrough_enabled = false;
if (auto val = root["override_foveation_enable"]; val.is_bool())
@@ -237,7 +233,7 @@ configuration::configuration(xr::system & system)
resolution_scale = 1.4;
sgsr = {};
openxr_post_processing = {};
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
}
}
-2
View File
@@ -51,8 +51,6 @@ scene::scene(key, const meta & current_meta, std::span<const vk::Format> support
queue_family_index(application::instance().vk_queue_family_index),
current_meta(current_meta)
{
passthrough_supported = system.passthrough_supported();
swapchain_format = vk::Format::eUndefined;
spdlog::info("Supported swapchain formats:");
-1
View File
@@ -103,7 +103,6 @@ public:
protected:
vk::Format swapchain_format;
vk::Format depth_format;
xr::system::passthrough_type passthrough_supported;
bool composition_layer_depth_test_supported;
bool composition_layer_color_scale_bias_supported;
+4 -4
View File
@@ -926,7 +926,7 @@ void scenes::lobby::gui_settings()
imgui_ctx->vibrate_on_hover();
}
auto body_tracker = xr::body_tracker_supported(instance, system);
auto body_tracker = system.body_tracker_supported();
{
ImGui::BeginDisabled(body_tracker == xr::body_tracker_type::none);
bool enabled = config.check_feature(feature::body_tracking);
@@ -976,7 +976,7 @@ void scenes::lobby::gui_settings()
ImGui::EndDisabled();
}
ImGui::BeginDisabled(passthrough_supported == xr::system::passthrough_type::no_passthrough);
ImGui::BeginDisabled(system.passthrough_supported() == xr::passthrough_type::none);
if (ImGui::Checkbox(_S("Enable video passthrough in lobby"), &config.passthrough_enabled))
{
setup_passthrough();
@@ -1310,7 +1310,7 @@ void scenes::lobby::gui_first_run()
item{
.f = feature::body_tracking,
.text = _S("Enable body tracking?"),
.supported = xr::body_tracker_supported(instance, system) != xr::body_tracker_type::none,
.supported = system.body_tracker_supported() != xr::body_tracker_type::none,
},
};
@@ -1730,7 +1730,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
});
}
if (xr::body_tracker_supported(instance, system) != xr::body_tracker_type::none)
if (system.body_tracker_supported() != xr::body_tracker_type::none)
{
items.push_back({
.f = feature::body_tracking,
+3 -3
View File
@@ -254,7 +254,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (config.check_feature(feature::face_tracking))
{
switch (xr::face_tracker_supported(self->instance, self->system))
switch (self->system.face_tracker_supported())
{
case xr::face_tracker_type::none:
info.face_tracking = from_headset::face_type::none;
@@ -272,7 +272,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
info.num_generic_trackers = 0;
if (config.check_feature(feature::body_tracking))
{
switch (xr::body_tracker_supported(self->instance, self->system))
switch (self->system.body_tracker_supported())
{
case xr::body_tracker_type::none:
break;
@@ -289,7 +289,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
}
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
info.passthrough = self->system.passthrough_supported() != xr::system::passthrough_type::no_passthrough;
info.passthrough = self->system.passthrough_supported() != xr::passthrough_type::none;
info.system_name = std::string(self->system.properties().systemName);
audio::get_audio_description(info);
+5 -11
View File
@@ -21,29 +21,23 @@
#include "fb_body_tracker.h"
#include "htc_body_tracker.h"
#include "pico_body_tracker.h"
#include "xr/system.h"
#include <utility>
#include <variant>
#include <vector>
#include <openxr/openxr.h>
namespace xr
{
class instance;
class system;
enum class body_tracker_type
{
none,
fb,
htc,
pico,
};
class session;
using body_tracker = std::variant<std::monostate, xr::fb_body_tracker, xr::htc_body_tracker, xr::pico_body_tracker>;
body_tracker_type body_tracker_supported(xr::instance &, xr::system &);
body_tracker make_body_tracker(xr::instance &, xr::system &, xr::session &, std::vector<std::pair<XrPath, xr::space>> & generic_trackers, bool full_body, bool hips);
body_tracker_type body_tracker_supported(xr::instance &, xr::system &);
} // namespace xr
+4 -11
View File
@@ -21,6 +21,7 @@
#include "fb_face_tracker2.h"
#include "htc_face_tracker.h"
#include "pico_face_tracker.h"
#include "xr/system.h"
#include <variant>
@@ -28,20 +29,12 @@ namespace xr
{
class instance;
class system;
enum class face_tracker_type
{
none,
fb,
htc,
pico,
};
class session;
using face_tracker = std::variant<std::monostate, xr::fb_face_tracker2, xr::htc_face_tracker, xr::pico_face_tracker>;
face_tracker_type face_tracker_supported(xr::instance &, xr::system &);
face_tracker make_face_tracker(xr::instance &, xr::system &, xr::session &);
face_tracker_type face_tracker_supported(xr::instance &, xr::system &);
} // namespace xr
+1 -1
View File
@@ -344,7 +344,7 @@ void xr::session::enable_passthrough(xr::system & system)
if (not std::holds_alternative<std::monostate>(passthrough))
return;
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
if (system.passthrough_supported() == xr::passthrough_type::none)
return;
if (utils::contains(application::get_xr_extensions(), XR_FB_PASSTHROUGH_EXTENSION_NAME))
+17 -3
View File
@@ -20,7 +20,9 @@
#include "system.h"
#include "application.h"
#include "body_tracker.h"
#include "details/enumerate.h"
#include "face_tracker.h"
#include "openxr/openxr.h"
#include "utils/contains.h"
#include "vk/check.h"
@@ -44,6 +46,9 @@ xr::system::system(xr::instance & inst, XrFormFactor formfactor)
if (inst.has_extension(XR_EXT_HAND_TRACKING_EXTENSION_NAME))
hand_tracking_supported_ = hand_tracking_properties().supportsHandTracking;
body_tracker = xr::body_tracker_supported(inst, *this);
face_tracker = xr::face_tracker_supported(inst, *this);
}
XrGraphicsRequirementsVulkan2KHR xr::system::graphics_requirements() const
@@ -198,7 +203,7 @@ XrSystemBodyTrackingPropertiesBD xr::system::bd_body_tracking_properties() const
return body_tracking_prop;
}
xr::system::passthrough_type xr::system::passthrough_supported() const
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))
return passthrough_type::color;
@@ -227,7 +232,7 @@ xr::system::passthrough_type xr::system::passthrough_supported() const
if (passthrough_prop.supportsPassthrough)
{
if (!(passthrough_prop2.capabilities & XR_PASSTHROUGH_CAPABILITY_BIT_FB))
return passthrough_type::no_passthrough;
return passthrough_type::none;
if (passthrough_prop2.capabilities & XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB)
return passthrough_type::color;
@@ -236,7 +241,16 @@ xr::system::passthrough_type xr::system::passthrough_supported() const
}
}
return passthrough_type::no_passthrough;
return passthrough_type::none;
}
xr::face_tracker_type xr::system::face_tracker_supported() const
{
return face_tracker;
}
xr::body_tracker_type xr::system::body_tracker_supported() const
{
return body_tracker;
}
bool xr::system::hand_tracking_supported() const
+30 -8
View File
@@ -32,20 +32,39 @@ namespace xr
{
class instance;
enum class passthrough_type
{
none,
bw,
color
};
enum class body_tracker_type
{
none,
fb,
htc,
pico,
};
enum class face_tracker_type
{
none,
fb,
htc,
pico,
};
class system
{
instance * inst = nullptr;
XrSystemId id = XR_NULL_SYSTEM_ID;
bool hand_tracking_supported_ = false;
passthrough_type passthrough;
body_tracker_type body_tracker;
face_tracker_type face_tracker;
public:
enum class passthrough_type
{
no_passthrough,
bw,
color
};
system() = default;
system(const system &) = default;
system & operator=(const system &) = default;
@@ -68,8 +87,11 @@ public:
XrSystemFacialTrackingPropertiesHTC htc_face_tracking_properties() const;
XrSystemBodyTrackingPropertiesFB fb_body_tracking_properties() const;
XrSystemBodyTrackingPropertiesBD bd_body_tracking_properties() const;
passthrough_type passthrough_supported() const;
bool hand_tracking_supported() const;
passthrough_type passthrough_supported() const;
face_tracker_type face_tracker_supported() const;
body_tracker_type body_tracker_supported() const;
XrGraphicsRequirementsVulkan2KHR graphics_requirements() const;
vk::raii::PhysicalDevice physical_device(vk::raii::Instance & vulkan) const;