mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-21 09:31:33 -08:00
Don't fake user presence, use focused instead
This commit is contained in:
1 parent
4e5eca204f
commit
fcbdda9908
13 files changed
+518
-96
No files matched your search
@@ -235,6 +235,7 @@ struct headset_info_packet
|
||||
bool hand_tracking;
|
||||
bool eye_gaze;
|
||||
bool palm_pose;
|
||||
bool user_presence;
|
||||
bool passthrough;
|
||||
face_type face_tracking;
|
||||
uint32_t num_generic_trackers;
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
From 36c63e58e4d54c31872b95fdc7fb431c8cfc57ab Mon Sep 17 00:00:00 2001
|
||||
From: Jakob Bornecrantz <[email protected]>
|
||||
Date: Fri, 15 Nov 2024 22:51:32 +0000
|
||||
Subject: [PATCH] ipc: Add callbacks and unify main functions
|
||||
|
||||
---
|
||||
src/xrt/ipc/server/ipc_server_interface.h | 58 +++++++++----
|
||||
src/xrt/ipc/server/ipc_server_process.c | 84 ++++++++++---------
|
||||
.../targets/service-lib/service_target.cpp | 38 +++++++--
|
||||
3 files changed, 118 insertions(+), 62 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/ipc/server/ipc_server_interface.h b/src/xrt/ipc/server/ipc_server_interface.h
|
||||
index b870a52c8c..1b44af8a82 100644
|
||||
--- a/src/xrt/ipc/server/ipc_server_interface.h
|
||||
+++ b/src/xrt/ipc/server/ipc_server_interface.h
|
||||
@@ -10,12 +10,10 @@
|
||||
* @ingroup ipc_server
|
||||
*/
|
||||
|
||||
-#include "xrt/xrt_compiler.h"
|
||||
#include "xrt/xrt_config_os.h"
|
||||
+#include "xrt/xrt_results.h"
|
||||
|
||||
-#ifndef XRT_OS_ANDROID
|
||||
#include "util/u_debug_gui.h"
|
||||
-#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -23,7 +21,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
-#ifndef XRT_OS_ANDROID
|
||||
+struct ipc_server;
|
||||
|
||||
/*!
|
||||
* Information passed into the IPC server main function, used for customization
|
||||
@@ -38,31 +36,57 @@ struct ipc_server_main_info
|
||||
};
|
||||
|
||||
/*!
|
||||
- * Main entrypoint to the compositor process.
|
||||
*
|
||||
* @ingroup ipc_server
|
||||
*/
|
||||
-int
|
||||
-ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi);
|
||||
-
|
||||
-#endif
|
||||
+struct ipc_server_callbacks
|
||||
+{
|
||||
+ /*!
|
||||
+ * The IPC server failed to init.
|
||||
+ *
|
||||
+ * @param[in] xret The error code generated during init.
|
||||
+ * @param[in] data User data given passed into the main function.
|
||||
+ */
|
||||
+ void (*init_failed)(xrt_result_t xret, void *data);
|
||||
|
||||
+ /*!
|
||||
+ * The service has completed init and is entering its mainloop.
|
||||
+ *
|
||||
+ * @param[in] s The IPC server.
|
||||
+ * @param[in] xinst Instance that was created by the IPC server.
|
||||
+ * @param[in] data User data given passed into the main function.
|
||||
+ */
|
||||
+ void (*mainloop_entering)(struct ipc_server *s, struct xrt_instance *xinst, void *data);
|
||||
|
||||
-#ifdef XRT_OS_ANDROID
|
||||
+ /*!
|
||||
+ * The service is leaving the mainloop, after this callback returns the
|
||||
+ * IPC server will destroy all resources created.
|
||||
+ *
|
||||
+ * @param[in] s The IPC server.
|
||||
+ * @param[in] xinst Instance that was created by the IPC server.
|
||||
+ * @param[in] data User data given passed into the main function.
|
||||
+ */
|
||||
+ void (*mainloop_leaving)(struct ipc_server *s, struct xrt_instance *xinst, void *data);
|
||||
+};
|
||||
|
||||
/*!
|
||||
- * Main entrypoint to the server process.
|
||||
+ * Common main function for starting the IPC service.
|
||||
*
|
||||
- * @param ps Pointer to populate with the server struct.
|
||||
- * @param startup_complete_callback Function to call upon completing startup
|
||||
- * and populating *ps, but before entering
|
||||
- * the mainloop.
|
||||
- * @param data user data to pass to your callback.
|
||||
+ * @ingroup ipc_server
|
||||
+ */
|
||||
+int
|
||||
+ipc_server_main_common(const struct ipc_server_main_info *ismi, const struct ipc_server_callbacks *iscb, void *data);
|
||||
+
|
||||
+
|
||||
+#ifndef XRT_OS_ANDROID
|
||||
+
|
||||
+/*!
|
||||
+ * Main entrypoint to the compositor process.
|
||||
*
|
||||
* @ingroup ipc_server
|
||||
*/
|
||||
int
|
||||
-ipc_server_main_android(struct ipc_server **ps, void (*startup_complete_callback)(void *data), void *data);
|
||||
+ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi);
|
||||
|
||||
#endif
|
||||
|
||||
diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c
|
||||
index f972d6835a..32bad0ec56 100644
|
||||
--- a/src/xrt/ipc/server/ipc_server_process.c
|
||||
+++ b/src/xrt/ipc/server/ipc_server_process.c
|
||||
@@ -972,9 +972,10 @@ ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_proper
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
-#ifndef XRT_OS_ANDROID
|
||||
int
|
||||
-ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi)
|
||||
+ipc_server_main_common(const struct ipc_server_main_info *ismi,
|
||||
+ const struct ipc_server_callbacks *callbacks,
|
||||
+ void *data)
|
||||
{
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
int ret = -1;
|
||||
@@ -1002,11 +1003,8 @@ ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi)
|
||||
xret = init_all(s, log_level);
|
||||
U_LOG_CHK_ONLY_PRINT(log_level, xret, "init_all");
|
||||
if (xret != XRT_SUCCESS) {
|
||||
-#ifdef XRT_OS_LINUX
|
||||
- // Print information how to debug issues.
|
||||
- print_linux_end_user_failed_information(log_level);
|
||||
-#endif
|
||||
-
|
||||
+ // Propegate the failure.
|
||||
+ callbacks->init_failed(xret, data);
|
||||
u_debug_gui_stop(&s->debug_gui);
|
||||
free(s);
|
||||
return -1;
|
||||
@@ -1015,13 +1013,15 @@ ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi)
|
||||
// Start the debug UI now (if enabled).
|
||||
u_debug_gui_start(s->debug_gui, s->xinst, s->xsysd);
|
||||
|
||||
-#ifdef XRT_OS_LINUX
|
||||
- // Print a very clear service started message.
|
||||
- print_linux_end_user_started_information(log_level);
|
||||
-#endif
|
||||
+ // Tell the callbacks we are entering the main-loop.
|
||||
+ callbacks->mainloop_entering(s, s->xinst, data);
|
||||
+
|
||||
// Main loop.
|
||||
ret = main_loop(s);
|
||||
|
||||
+ // Tell the callbacks we are leaving the main-loop.
|
||||
+ callbacks->mainloop_leaving(s, s->xinst, data);
|
||||
+
|
||||
// Stop the UI before tearing everything down.
|
||||
u_debug_gui_stop(&s->debug_gui);
|
||||
|
||||
@@ -1038,39 +1038,43 @@ ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi)
|
||||
return ret;
|
||||
}
|
||||
|
||||
-#endif // !XRT_OS_ANDROID
|
||||
-
|
||||
-#ifdef XRT_OS_ANDROID
|
||||
-int
|
||||
-ipc_server_main_android(struct ipc_server **ps, void (*startup_complete_callback)(void *data), void *data)
|
||||
-{
|
||||
- xrt_result_t xret = XRT_SUCCESS;
|
||||
- int ret = -1;
|
||||
-
|
||||
- // Get log level first.
|
||||
- enum u_logging_level log_level = debug_get_log_option_ipc_log();
|
||||
|
||||
- struct ipc_server *s = U_TYPED_CALLOC(struct ipc_server);
|
||||
- U_LOG_D("Created IPC server!");
|
||||
-
|
||||
- xret = init_all(s, log_level);
|
||||
- U_LOG_CHK_ONLY_PRINT(log_level, xret, "init_all");
|
||||
- if (xret != XRT_SUCCESS) {
|
||||
- free(s);
|
||||
- startup_complete_callback(data);
|
||||
- return -1;
|
||||
- }
|
||||
+#ifndef XRT_OS_ANDROID
|
||||
|
||||
- *ps = s;
|
||||
- startup_complete_callback(data);
|
||||
+static void
|
||||
+init_failed(xrt_result_t xret, void *data)
|
||||
+{
|
||||
+#ifdef XRT_OS_LINUX
|
||||
+ // Print information how to debug issues.
|
||||
+ print_linux_end_user_failed_information(debug_get_log_option_ipc_log());
|
||||
+#endif
|
||||
+}
|
||||
|
||||
- ret = main_loop(s);
|
||||
+static void
|
||||
+mainloop_entering(struct ipc_server *s, struct xrt_instance *xinst, void *data)
|
||||
+{
|
||||
+#ifdef XRT_OS_LINUX
|
||||
+ // Print a very clear service started message.
|
||||
+ print_linux_end_user_started_information(s->log_level);
|
||||
+#endif
|
||||
+}
|
||||
|
||||
- teardown_all(s);
|
||||
- free(s);
|
||||
+static void
|
||||
+mainloop_leaving(struct ipc_server *s, struct xrt_instance *xinst, void *data)
|
||||
+{
|
||||
+ // No-op
|
||||
+}
|
||||
|
||||
- U_LOG_I("Server exiting '%i'!", ret);
|
||||
+int
|
||||
+ipc_server_main(int argc, char **argv, const struct ipc_server_main_info *ismi)
|
||||
+{
|
||||
+ const struct ipc_server_callbacks callbacks = {
|
||||
+ .init_failed = init_failed,
|
||||
+ .mainloop_entering = mainloop_entering,
|
||||
+ .mainloop_leaving = mainloop_leaving,
|
||||
+ };
|
||||
|
||||
- return ret;
|
||||
+ return ipc_server_main_common(ismi, &callbacks, NULL);
|
||||
}
|
||||
-#endif // XRT_OS_ANDROID
|
||||
+
|
||||
+#endif // !XRT_OS_ANDROID
|
||||
diff --git a/src/xrt/targets/service-lib/service_target.cpp b/src/xrt/targets/service-lib/service_target.cpp
|
||||
index 45877803d3..71c581da6b 100644
|
||||
--- a/src/xrt/targets/service-lib/service_target.cpp
|
||||
+++ b/src/xrt/targets/service-lib/service_target.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
// Copyright 2020, Collabora, Ltd.
|
||||
+// Copyright 2024, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
@@ -41,10 +42,11 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
- signalStartupComplete()
|
||||
+ signalStartupComplete(ipc_server *s)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock{server_mutex};
|
||||
startup_complete = true;
|
||||
+ server = s;
|
||||
startup_cond.notify_all();
|
||||
}
|
||||
|
||||
@@ -53,15 +55,27 @@ public:
|
||||
{
|
||||
std::unique_lock lock(server_mutex);
|
||||
if (!server && !server_thread) {
|
||||
- server_thread = std::make_unique<std::thread>(
|
||||
- [&]() { ipc_server_main_android(&server, signalStartupCompleteTrampoline, this); });
|
||||
+ server_thread =
|
||||
+ std::make_unique<std::thread>([&]() { ipc_server_main_common(&ismi, &callbacks, this); });
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
- signalStartupCompleteTrampoline(void *data)
|
||||
+ signalInitFailed(xrt_result_t xret, void *data)
|
||||
{
|
||||
- static_cast<IpcServerHelper *>(data)->signalStartupComplete();
|
||||
+ static_cast<IpcServerHelper *>(data)->signalStartupComplete(nullptr);
|
||||
+ }
|
||||
+
|
||||
+ static void
|
||||
+ signalStartupCompleteTrampoline(ipc_server *s, xrt_instance *xsint, void *data)
|
||||
+ {
|
||||
+ static_cast<IpcServerHelper *>(data)->signalStartupComplete(s);
|
||||
+ }
|
||||
+
|
||||
+ static void
|
||||
+ signalShuttingDownTrampoline(ipc_server *s, xrt_instance *xsint, void *data)
|
||||
+ {
|
||||
+ // No-op
|
||||
}
|
||||
|
||||
int32_t
|
||||
@@ -114,6 +128,20 @@ private:
|
||||
return server && completed;
|
||||
}
|
||||
|
||||
+ const struct ipc_server_main_info ismi = {
|
||||
+ .udgci =
|
||||
+ {
|
||||
+ .window_title = "Monado Android Service",
|
||||
+ .open = U_DEBUG_GUI_OPEN_NEVER,
|
||||
+ },
|
||||
+ };
|
||||
+
|
||||
+ const struct ipc_server_callbacks callbacks = {
|
||||
+ .init_failed = signalInitFailed,
|
||||
+ .mainloop_entering = signalStartupCompleteTrampoline,
|
||||
+ .mainloop_leaving = signalShuttingDownTrampoline,
|
||||
+ };
|
||||
+
|
||||
//! Reference to the ipc_server, managed by ipc_server_process
|
||||
struct ipc_server *server = NULL;
|
||||
|
||||
--
|
||||
GitLab
|
||||
|
||||
@@ -79,6 +79,7 @@ if (WIVRN_BUILD_SERVER)
|
||||
main.cpp
|
||||
sleep_inhibitor.cpp
|
||||
start_application.cpp
|
||||
ipc_server_cb.cpp
|
||||
target_instance_wivrn.cpp
|
||||
wivrn_ipc.cpp
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ wivrn_hmd::wivrn_hmd(wivrn::wivrn_session * cnx,
|
||||
.supported = {
|
||||
.orientation_tracking = true,
|
||||
.position_tracking = true,
|
||||
.presence = true,
|
||||
.presence = info.user_presence,
|
||||
.battery_status = true,
|
||||
},
|
||||
.update_inputs = [](xrt_device *) { return XRT_SUCCESS; },
|
||||
@@ -231,28 +231,13 @@ void wivrn_hmd::update_visibility_mask(const from_headset::visibility_mask_chang
|
||||
m->at(mask.view_index) = mask.data;
|
||||
}
|
||||
|
||||
bool wivrn_hmd::update_presence(bool new_presence, bool real)
|
||||
bool wivrn_hmd::update_presence(bool new_presence)
|
||||
{
|
||||
// if this presence change comes from headset, always honor it,
|
||||
// otherwise try to keep it in sync with the real presence,
|
||||
// while still changing presence to false when session is not
|
||||
// visible
|
||||
if (real || new_presence == this->real_presence || !new_presence)
|
||||
if (this->presence.exchange(new_presence) != new_presence)
|
||||
{
|
||||
if (real && this->real_presence != new_presence)
|
||||
{
|
||||
U_LOG_I("Updating real user presence: %s -> %s", real_presence ? "true" : "false", new_presence ? "true" : "false");
|
||||
this->real_presence = new_presence;
|
||||
}
|
||||
|
||||
if (this->presence == new_presence)
|
||||
return false;
|
||||
|
||||
U_LOG_I("Updating user presence: %s -> %s", this->presence ? "true" : "false", new_presence ? "true" : "false");
|
||||
this->presence = new_presence;
|
||||
U_LOG_I("user presence changed to %s", new_presence ? "true" : "false");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace wivrn
|
||||
@@ -54,10 +54,6 @@ class wivrn_hmd : public xrt_device
|
||||
from_headset::battery battery{};
|
||||
|
||||
std::atomic<bool> presence{true};
|
||||
// last XR_EVENT_DATA_USER_PRESENCE_CHANGED_EXT from headset
|
||||
// we must keep track of this to not go out of sync with headset when
|
||||
// a session state change also triggers presence change
|
||||
std::atomic<bool> real_presence{true};
|
||||
thread_safe<std::array<std::optional<from_headset::visibility_mask_changed::masks>, 2>> visibility_mask;
|
||||
|
||||
wivrn::wivrn_session * cnx;
|
||||
@@ -86,7 +82,6 @@ public:
|
||||
void update_battery(const from_headset::battery &);
|
||||
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||
void update_visibility_mask(const from_headset::visibility_mask_changed &);
|
||||
// real if this update comes from a presence changed event
|
||||
bool update_presence(bool new_presence, bool real);
|
||||
bool update_presence(bool);
|
||||
};
|
||||
} // namespace wivrn
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "main/comp_compositor.h"
|
||||
#include "main/comp_main_interface.h"
|
||||
#include "main/comp_target.h"
|
||||
#include "server/ipc_server.h"
|
||||
#include "target_instance_wivrn.h"
|
||||
#include "util/u_builders.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "util/u_system.h"
|
||||
@@ -139,7 +141,7 @@ bool wivrn::tracking_control_t::set_enabled(to_headset::tracking_control::id id,
|
||||
return changed;
|
||||
}
|
||||
|
||||
wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection, u_system & system) :
|
||||
wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection, instance & inst, u_system & system) :
|
||||
xrt_system_devices{
|
||||
.get_roles = [](xrt_system_devices * self, xrt_system_roles * out_roles) { return ((wivrn_session *)self)->get_roles(out_roles); },
|
||||
.feature_inc = [](xrt_system_devices * self, xrt_device_feature_type f) { return ((wivrn_session *)self)->feature_inc(f); },
|
||||
@@ -147,6 +149,7 @@ wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection
|
||||
.destroy = [](xrt_system_devices * self) { delete ((wivrn_session *)self); },
|
||||
},
|
||||
connection(std::move(connection)),
|
||||
inst(inst),
|
||||
xrt_system(system),
|
||||
hmd(this, get_info()),
|
||||
left_controller(0, &hmd, this),
|
||||
@@ -305,6 +308,7 @@ wivrn_session::~wivrn_session()
|
||||
}
|
||||
|
||||
xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connection> connection,
|
||||
instance & inst,
|
||||
u_system & system,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
xrt_space_overseer ** out_xspovrs,
|
||||
@@ -313,7 +317,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
||||
std::unique_ptr<wivrn_session> self;
|
||||
try
|
||||
{
|
||||
self.reset(new wivrn_session(std::move(connection), system));
|
||||
self.reset(new wivrn_session(std::move(connection), inst, system));
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
@@ -330,6 +334,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
||||
U_LOG_E("Failed to create system compositor");
|
||||
return xret;
|
||||
}
|
||||
self->system_compositor = *out_xsysc;
|
||||
|
||||
u_builder_create_space_overseer_legacy(
|
||||
&self->xrt_system.broadcast,
|
||||
@@ -668,49 +673,34 @@ void wivrn_session::operator()(from_headset::session_state_changed && event)
|
||||
{
|
||||
U_LOG_I("Session state changed: %s", xr::to_string(event.state));
|
||||
bool visible, focused;
|
||||
bool changed = false;
|
||||
switch (event.state)
|
||||
{
|
||||
case XR_SESSION_STATE_SYNCHRONIZED:
|
||||
visible = false;
|
||||
focused = false;
|
||||
changed = hmd.update_presence(false, false);
|
||||
break;
|
||||
case XR_SESSION_STATE_VISIBLE:
|
||||
visible = true;
|
||||
focused = false;
|
||||
changed = hmd.update_presence(true, false);
|
||||
break;
|
||||
case XR_SESSION_STATE_FOCUSED:
|
||||
visible = true;
|
||||
focused = true;
|
||||
changed = hmd.update_presence(true, false);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
visible = false;
|
||||
focused = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
scoped_lock lock(inst.server->global_state.lock);
|
||||
for (auto & t: inst.server->threads)
|
||||
{
|
||||
xrt_session_event_user_presence_change event = {
|
||||
.type = XRT_SESSION_EVENT_USER_PRESENCE_CHANGE,
|
||||
};
|
||||
hmd.get_presence(&event.is_user_present);
|
||||
push_event({.presence_change = event});
|
||||
if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr)
|
||||
continue;
|
||||
bool current = t.ics.client_state.session_overlay or
|
||||
inst.server->global_state.active_client_index == t.ics.server_thread_index;
|
||||
xrt_syscomp_set_state(system_compositor, t.ics.xc, visible and current, focused and current);
|
||||
}
|
||||
|
||||
push_event(
|
||||
{
|
||||
.state = {
|
||||
.type = XRT_SESSION_EVENT_STATE_CHANGE,
|
||||
.visible = visible,
|
||||
.focused = focused,
|
||||
},
|
||||
});
|
||||
}
|
||||
void wivrn_session::operator()(from_headset::user_presence_changed && event)
|
||||
{
|
||||
if (hmd.update_presence(event.present, true))
|
||||
if (hmd.update_presence(event.present))
|
||||
push_event(
|
||||
{
|
||||
.presence_change = {
|
||||
|
||||
@@ -43,6 +43,7 @@ union xrt_session_event;
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class instance;
|
||||
class wivrn_eye_tracker;
|
||||
class wivrn_fb_face2_tracker;
|
||||
class wivrn_htc_face_tracker;
|
||||
@@ -92,10 +93,12 @@ class wivrn_session : public xrt_system_devices
|
||||
{
|
||||
friend wivrn_comp_target_factory;
|
||||
std::unique_ptr<wivrn_connection> connection;
|
||||
instance & inst;
|
||||
pacing_app_factory app_pacers;
|
||||
|
||||
u_system & xrt_system;
|
||||
xrt_space_overseer * space_overseer;
|
||||
xrt_system_compositor * system_compositor;
|
||||
|
||||
std::mutex roles_mutex;
|
||||
xrt_system_roles roles{
|
||||
@@ -133,12 +136,13 @@ class wivrn_session : public xrt_system_devices
|
||||
|
||||
std::jthread thread;
|
||||
|
||||
wivrn_session(std::unique_ptr<wivrn_connection> connection, u_system &);
|
||||
wivrn_session(std::unique_ptr<wivrn_connection> connection, instance &, u_system &);
|
||||
|
||||
public:
|
||||
~wivrn_session();
|
||||
|
||||
static xrt_result_t create_session(std::unique_ptr<wivrn_connection> connection,
|
||||
instance & instance,
|
||||
u_system & system,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
xrt_space_overseer ** out_xspovrs,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ipc_server_cb.h"
|
||||
#include "target_instance_wivrn.h"
|
||||
#include "utils/method.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
void ipc_server_cb::init_failed(xrt_result res)
|
||||
{
|
||||
}
|
||||
|
||||
void ipc_server_cb::mainloop_entering(ipc_server * server, xrt_instance * xrt_inst)
|
||||
{
|
||||
auto inst = static_cast<wivrn::instance *>(xrt_inst);
|
||||
inst->server = server;
|
||||
}
|
||||
|
||||
void ipc_server_cb::mainloop_leaving(ipc_server * server, xrt_instance * xrt_inst)
|
||||
{
|
||||
auto inst = static_cast<wivrn::instance *>(xrt_inst);
|
||||
inst->server = nullptr;
|
||||
}
|
||||
|
||||
ipc_server_cb::ipc_server_cb() :
|
||||
ipc_server_callbacks{
|
||||
.init_failed = method_pointer2<&ipc_server_cb::init_failed>,
|
||||
.mainloop_entering = method_pointer2<&ipc_server_cb::mainloop_entering>,
|
||||
.mainloop_leaving = method_pointer2<&ipc_server_cb::mainloop_leaving>,
|
||||
}
|
||||
{}
|
||||
} // namespace wivrn
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/ipc_server_interface.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class ipc_server_cb : public ipc_server_callbacks
|
||||
{
|
||||
void init_failed(xrt_result);
|
||||
void mainloop_entering(ipc_server *, xrt_instance *);
|
||||
void mainloop_leaving(ipc_server *, xrt_instance *);
|
||||
|
||||
public:
|
||||
using base = void;
|
||||
ipc_server_cb();
|
||||
};
|
||||
} // namespace wivrn
|
||||
+4
-3
@@ -16,6 +16,7 @@
|
||||
#include "driver/wivrn_connection.h"
|
||||
#include "exit_codes.h"
|
||||
#include "hostname.h"
|
||||
#include "ipc_server_cb.h"
|
||||
#include "protocol_version.h"
|
||||
#include "start_application.h"
|
||||
#include "utils/overloaded.h"
|
||||
@@ -48,7 +49,6 @@
|
||||
#include <glib.h>
|
||||
#include <libnotify/notify.h>
|
||||
|
||||
#include <server/ipc_server_interface.h>
|
||||
#include <shared/ipc_protocol.h>
|
||||
#include <util/u_file.h>
|
||||
|
||||
@@ -249,11 +249,12 @@ void start_server(configuration config)
|
||||
// foveation code does not allow oversampling
|
||||
setenv("XRT_COMPOSITOR_SCALE_PERCENTAGE", "100", true);
|
||||
|
||||
// FIXME: synchronization fails on gfx pipeline
|
||||
setenv("XRT_COMPOSITOR_COMPUTE", "1", true);
|
||||
|
||||
setenv("AMD_DEBUG", "lowlatencyenc", false);
|
||||
|
||||
wivrn::ipc_server_cb server_cb;
|
||||
|
||||
ipc_server_main_info server_info{
|
||||
.udgci = {
|
||||
.window_title = "WiVRn",
|
||||
@@ -267,7 +268,7 @@ void start_server(configuration config)
|
||||
|
||||
try
|
||||
{
|
||||
exit(ipc_server_main(0, 0, &server_info /*argc, argv, ismi*/));
|
||||
exit(ipc_server_main_common(&server_info, &server_cb, nullptr));
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
// Copyright 2020-2022, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Shared default implementation of the instance with compositor.
|
||||
* @author Jakob Bornecrantz <[email protected]>
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "target_instance_wivrn.h"
|
||||
|
||||
#include "utils/method.h"
|
||||
|
||||
#include "xrt/xrt_instance.h"
|
||||
#include "xrt/xrt_system.h"
|
||||
|
||||
#include "os/os_time.h"
|
||||
|
||||
#include "util/u_system.h"
|
||||
#include "util/u_trace_marker.h"
|
||||
|
||||
@@ -19,18 +31,13 @@
|
||||
#include "driver/wivrn_session.h"
|
||||
#include "wivrn_ipc.h"
|
||||
|
||||
/*
|
||||
*
|
||||
* Internal functions.
|
||||
*
|
||||
*/
|
||||
|
||||
static xrt_result_t
|
||||
wivrn_instance_create_system(struct xrt_instance * xinst,
|
||||
struct xrt_system ** out_xsys,
|
||||
struct xrt_system_devices ** out_xsysd,
|
||||
struct xrt_space_overseer ** out_xspovrs,
|
||||
struct xrt_system_compositor ** out_xsysc)
|
||||
namespace wivrn
|
||||
{
|
||||
xrt_result_t instance::create_system(
|
||||
struct xrt_system ** out_xsys,
|
||||
struct xrt_system_devices ** out_xsysd,
|
||||
struct xrt_space_overseer ** out_xspovrs,
|
||||
struct xrt_system_compositor ** out_xsysc)
|
||||
{
|
||||
assert(out_xsysd != NULL);
|
||||
assert(*out_xsysd == NULL);
|
||||
@@ -41,6 +48,7 @@ wivrn_instance_create_system(struct xrt_instance * xinst,
|
||||
struct xrt_system_compositor * xsysc = NULL;
|
||||
auto res = wivrn::wivrn_session::create_session(
|
||||
std::move(connection),
|
||||
*this,
|
||||
*u_sys,
|
||||
out_xsysd,
|
||||
out_xspovrs,
|
||||
@@ -49,36 +57,29 @@ wivrn_instance_create_system(struct xrt_instance * xinst,
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
wivrn_instance_destroy(struct xrt_instance * xinst)
|
||||
{
|
||||
delete xinst;
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
wivrn_instance_get_prober(struct xrt_instance * xinst, struct xrt_prober ** out_xp)
|
||||
xrt_result_t instance::get_prober(struct xrt_prober ** out_xp)
|
||||
{
|
||||
*out_xp = nullptr;
|
||||
return XRT_ERROR_PROBER_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Exported function(s).
|
||||
*
|
||||
*/
|
||||
instance::instance() :
|
||||
xrt_instance{
|
||||
.create_system = method_pointer<&instance::create_system>,
|
||||
.get_prober = method_pointer<&instance::get_prober>,
|
||||
.destroy = [](xrt_instance * ptr) { delete (instance *)ptr; },
|
||||
.startup_timestamp = os_monotonic_get_ns(),
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace wivrn
|
||||
xrt_result_t
|
||||
xrt_instance_create(struct xrt_instance_info * ii, struct xrt_instance ** out_xinst)
|
||||
{
|
||||
u_trace_marker_init();
|
||||
|
||||
*out_xinst = new xrt_instance{
|
||||
.create_system = wivrn_instance_create_system,
|
||||
.get_prober = wivrn_instance_get_prober,
|
||||
.destroy = wivrn_instance_destroy,
|
||||
.startup_timestamp = os_monotonic_get_ns(),
|
||||
};
|
||||
*out_xinst = new wivrn::instance();
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2025 Patrick Nicolas <[email protected]>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "server/ipc_server.h"
|
||||
#include "xrt/xrt_instance.h"
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class instance : public xrt_instance
|
||||
{
|
||||
xrt_result_t create_system(
|
||||
xrt_system **,
|
||||
xrt_system_devices **,
|
||||
xrt_space_overseer **,
|
||||
xrt_system_compositor **);
|
||||
|
||||
xrt_result_t get_prober(xrt_prober **);
|
||||
|
||||
public:
|
||||
ipc_server * server = nullptr;
|
||||
using base = xrt_instance;
|
||||
instance();
|
||||
};
|
||||
} // namespace wivrn
|
||||
@@ -32,6 +32,10 @@ struct method_trait<Method, Result (Class::*)(Args...)>
|
||||
{
|
||||
return std::invoke(Method, static_cast<Class *>(arg), args...);
|
||||
}
|
||||
static Result magic2(Args... args, Class::base * arg)
|
||||
{
|
||||
return std::invoke(Method, static_cast<Class *>(arg), args...);
|
||||
}
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
@@ -54,4 +58,8 @@ namespace wivrn
|
||||
// }
|
||||
template <auto Method>
|
||||
auto method_pointer = ::details::method_trait<Method>::magic;
|
||||
|
||||
// same, but "this" argument is last
|
||||
template <auto Method>
|
||||
auto method_pointer2 = ::details::method_trait<Method>::magic2;
|
||||
} // namespace wivrn
|
||||
Reference in new issue
Block a user