diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5113db4a..2062c671 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -38,6 +38,10 @@
+
+
+
+
diff --git a/client/application.cpp b/client/application.cpp
index eda4471b..2cd4d0d7 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -726,6 +726,8 @@ void application::initialize()
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_COLOR_SCALE_BIAS_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME);
opt_extensions.push_back(XR_EXT_HAND_TRACKING_EXTENSION_NAME);
+ opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
+ opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
for(const auto& i: interaction_profiles)
{
@@ -802,6 +804,8 @@ void application::initialize()
}
}
+ spdlog::info("Passthrough: {}", xr_system_id.passthrough_supported() ? "supported" : "not supported");
+
vk::CommandPoolCreateInfo cmdpool_create_info;
cmdpool_create_info.queueFamilyIndex = vk_queue_family_index;
@@ -1343,6 +1347,18 @@ void application::poll_events()
e.refresh_rate_changed.toDisplayRefreshRate);
}
break;
+ case XR_TYPE_EVENT_DATA_PASSTHROUGH_STATE_CHANGED_FB: {
+ spdlog::info("Passthrough state changed:");
+ if (e.passthrough_state_changed.flags & XR_PASSTHROUGH_STATE_CHANGED_REINIT_REQUIRED_BIT_FB)
+ spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_REINIT_REQUIRED_BIT_FB");
+ if (e.passthrough_state_changed.flags & XR_PASSTHROUGH_STATE_CHANGED_NON_RECOVERABLE_ERROR_BIT_FB)
+ spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_NON_RECOVERABLE_ERROR_BIT_FB");
+ if (e.passthrough_state_changed.flags & XR_PASSTHROUGH_STATE_CHANGED_RECOVERABLE_ERROR_BIT_FB)
+ spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_RECOVERABLE_ERROR_BIT_FB");
+ if (e.passthrough_state_changed.flags & XR_PASSTHROUGH_STATE_CHANGED_RESTORED_ERROR_BIT_FB)
+ spdlog::info(" XR_PASSTHROUGH_STATE_CHANGED_RESTORED_ERROR_BIT_FB");
+ }
+ break;
default:
spdlog::info("Received event type {}", xr::to_string(e.header.type));
break;
diff --git a/client/application.h b/client/application.h
index 9d1aa0b6..ce0690d6 100644
--- a/client/application.h
+++ b/client/application.h
@@ -404,4 +404,9 @@ public:
{
return instance().right_hand;
}
+
+ static const std::vector& get_xr_extensions()
+ {
+ return instance().xr_extensions;
+ }
};
diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp
index 6a76cf00..17b0ffcc 100644
--- a/client/scenes/lobby.cpp
+++ b/client/scenes/lobby.cpp
@@ -18,7 +18,7 @@
*/
#include "lobby.h"
-#include "../common/version.h"
+#include "version.h"
#include "application.h"
#include "glm/geometric.hpp"
#include "imgui.h"
@@ -28,9 +28,10 @@
#include "render/scene_renderer.h"
#include "stream.h"
#include "hardware.h"
+#include "utils/contains.h"
#include "wivrn_client.h"
+#include "xr/passthrough.h"
#include
-#include
#include
#include "wivrn_discover.h"
@@ -45,7 +46,6 @@
#include
#include
#include
-#include
#include
#include
@@ -223,6 +223,10 @@ scenes::lobby::lobby()
auto mic = root["microphone"];
if (mic.is_bool())
microphone = mic.get_bool();
+
+ auto passthrough = root["passthrough_enabled"];
+ if (passthrough.is_bool())
+ passthrough_enabled = passthrough.get_bool();
}
catch(std::exception& e)
{
@@ -260,6 +264,22 @@ scenes::lobby::lobby()
throw std::runtime_error("No supported swapchain format");
spdlog::info("Using format {}", vk::to_string(swapchain_format));
+
+ passthrough_supported = system.passthrough_supported();
+
+ if (passthrough_supported)
+ {
+ if (utils::contains(application::get_xr_extensions(), XR_FB_PASSTHROUGH_EXTENSION_NAME))
+ {
+ passthrough = xr::passthrough_fb(instance, session);
+ }
+ else if (utils::contains(application::get_xr_extensions(), XR_HTC_PASSTHROUGH_EXTENSION_NAME))
+ {
+ passthrough = xr::passthrough_htc(instance, session);
+ }
+
+ std::visit([](auto& p) {p.start();}, passthrough);
+ }
}
void scenes::lobby::save_config()
@@ -292,6 +312,7 @@ void scenes::lobby::save_config()
if (preferred_refresh_rate != 0.)
json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate ;
json << ",\"microphone\":" << std::boolalpha << microphone;
+ json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
json << "}";
}
@@ -585,13 +606,19 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render)
assert(renderer);
renderer->start_frame();
- auto lobby_layer_views = render_layer(views, swapchains_lobby, *renderer, *lobby_scene, {0, 0.25, 0.5, 1});
+ std::vector lobby_layer_views;
+ if (!passthrough_enabled)
+ lobby_layer_views = render_layer(views, swapchains_lobby, *renderer, *lobby_scene, {0, 0.25, 0.5, 1});
+
auto controllers_layer_views = render_layer(views, swapchains_controllers, *renderer, *controllers_scene, {0, 0, 0, 0});
renderer->end_frame();
// After end_frame because the command buffers are submitted in end_frame
- for (auto & swapchain: swapchains_lobby)
- swapchain.release();
+ if (!passthrough_enabled)
+ {
+ for (auto & swapchain: swapchains_lobby)
+ swapchain.release();
+ }
for (auto & swapchain: swapchains_controllers)
swapchain.release();
@@ -613,7 +640,17 @@ void scenes::lobby::render(XrTime predicted_display_time, bool should_render)
};
std::vector layers_base;
- layers_base.push_back(reinterpret_cast(&lobby_layer));
+
+ if (passthrough_enabled)
+ {
+ std::visit([&](auto& p){
+ layers_base.push_back(p.layer());
+ }, passthrough);
+ }
+ else
+ {
+ layers_base.push_back(reinterpret_cast(&lobby_layer));
+ }
layers_base.push_back(reinterpret_cast(&imgui_layer));
layers_base.push_back(reinterpret_cast(&controllers_layer));
diff --git a/client/scenes/lobby.h b/client/scenes/lobby.h
index 0e129bd4..fcd12ba2 100644
--- a/client/scenes/lobby.h
+++ b/client/scenes/lobby.h
@@ -24,6 +24,7 @@
#include
#include "wivrn_discover.h"
+#include "xr/passthrough.h"
#include
#include
#include