Update monado, move create_system in wivrn_session
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ FetchContent_Declare(tinygltf URL https://github.com/syoyo/tinygltf/archive/refs
|
||||
FetchContent_Declare(boostpfr URL https://github.com/boostorg/pfr/archive/refs/tags/2.0.3.tar.gz)
|
||||
FetchContent_Declare(monado
|
||||
GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado
|
||||
GIT_TAG eee17ee2fffe1b2d0d0cc80c6ee8e9d9c9c6c2b6
|
||||
GIT_TAG c5f4f0ab7addd4631c295b2ca6e0c7458cd29788
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,11 @@
|
||||
#include "audio_setup.h"
|
||||
#include "main/comp_target.h"
|
||||
#include "os/os_time.h"
|
||||
#include "util/u_builders.h"
|
||||
#include "util/u_logging.h"
|
||||
|
||||
#include "main/comp_main_interface.h"
|
||||
#include "util/u_system_helpers.h"
|
||||
#include "wivrn_comp_target.h"
|
||||
#include "wivrn_controller.h"
|
||||
#include "wivrn_hmd.h"
|
||||
@@ -66,7 +69,10 @@ xrt::drivers::wivrn::wivrn_session::wivrn_session(xrt::drivers::wivrn::TCP && tc
|
||||
{
|
||||
}
|
||||
|
||||
wivrn_system_devices * xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wivrn::TCP && tcp)
|
||||
xrt_result_t xrt::drivers::wivrn::wivrn_session::create_session(xrt::drivers::wivrn::TCP && tcp,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
xrt_space_overseer ** out_xspovrs,
|
||||
xrt_system_compositor ** out_xsysc)
|
||||
{
|
||||
std::shared_ptr<wivrn_session> self;
|
||||
std::optional<xrt::drivers::wivrn::from_headset::control_packets> control;
|
||||
@@ -75,12 +81,13 @@ wivrn_system_devices * xrt::drivers::wivrn::wivrn_session::create_session(xrt::d
|
||||
self = std::shared_ptr<wivrn_session>(new wivrn_session(std::move(tcp)));
|
||||
while (not(control = self->connection.poll_control(-1)))
|
||||
{
|
||||
// FIXME: timeout
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
U_LOG_E("Error creating WiVRn session: %s", e.what());
|
||||
return nullptr;
|
||||
return XRT_ERROR_DEVICE_CREATION_FAILED;
|
||||
}
|
||||
|
||||
const auto & info = std::get<from_headset::headset_info_packet>(*control);
|
||||
@@ -99,24 +106,42 @@ wivrn_system_devices * xrt::drivers::wivrn::wivrn_session::create_session(xrt::d
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
U_LOG_E("Failed to register audio device: %s", e.what());
|
||||
return XRT_ERROR_DEVICE_CREATION_FAILED;
|
||||
}
|
||||
self->hmd = std::make_unique<wivrn_hmd>(self, info);
|
||||
self->left_hand = std::make_unique<wivrn_controller>(0, self->hmd.get(), self);
|
||||
self->right_hand = std::make_unique<wivrn_controller>(1, self->hmd.get(), self);
|
||||
|
||||
wivrn_system_devices * devices = new wivrn_system_devices{};
|
||||
|
||||
auto * usysds = u_system_devices_static_allocate();
|
||||
*out_xsysd = &usysds->base.base;
|
||||
auto & devices = *out_xsysd;
|
||||
int n = 0;
|
||||
if (self->hmd)
|
||||
devices->roles.head = devices->xdevs[n++] = self->hmd.get();
|
||||
usysds->base.base.static_roles.head = devices->xdevs[n++] = self->hmd.get();
|
||||
if (self->left_hand)
|
||||
devices->roles.left = devices->xdevs[n++] = self->left_hand.get();
|
||||
devices->xdevs[n++] = self->left_hand.get();
|
||||
if (self->right_hand)
|
||||
devices->roles.right = devices->xdevs[n++] = self->right_hand.get();
|
||||
|
||||
devices->xdevs[n++] = self->right_hand.get();
|
||||
devices->xdev_count = n;
|
||||
|
||||
devices->ctf = new wivrn_comp_target_factory(self, info.preferred_refresh_rate);
|
||||
u_system_devices_static_finalize(usysds, self->left_hand.get(), self->right_hand.get());
|
||||
|
||||
wivrn_comp_target_factory ctf(self, info.preferred_refresh_rate);
|
||||
auto xret = comp_main_create_system_compositor(self->hmd.get(), &ctf, out_xsysc);
|
||||
if (xret != XRT_SUCCESS)
|
||||
{
|
||||
U_LOG_E("Failed to create system compositor");
|
||||
return xret;
|
||||
}
|
||||
|
||||
u_builder_create_space_overseer_legacy(
|
||||
self->hmd.get(),
|
||||
self->left_hand.get(),
|
||||
self->right_hand.get(),
|
||||
devices->xdevs,
|
||||
devices->xdev_count,
|
||||
out_xspovrs);
|
||||
|
||||
devices->destroy = [](xrt_system_devices * xsd) {
|
||||
// TODO
|
||||
};
|
||||
@@ -128,7 +153,7 @@ wivrn_system_devices * xrt::drivers::wivrn::wivrn_session::create_session(xrt::d
|
||||
}
|
||||
|
||||
self->thread = std::thread(&wivrn_session::run, self);
|
||||
return devices;
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
clock_offset wivrn_session::get_offset()
|
||||
|
||||
@@ -33,16 +33,14 @@
|
||||
class wivrn_hmd;
|
||||
class wivrn_controller;
|
||||
struct audio_device;
|
||||
struct comp_target_factory;
|
||||
|
||||
struct xrt_system_devices;
|
||||
struct xrt_space_overseer;
|
||||
struct xrt_system_compositor;
|
||||
|
||||
namespace xrt::drivers::wivrn
|
||||
{
|
||||
|
||||
struct wivrn_system_devices : public xrt_system_devices
|
||||
{
|
||||
comp_target_factory *ctf;
|
||||
};
|
||||
|
||||
class wivrn_session : public std::enable_shared_from_this<wivrn_session>
|
||||
{
|
||||
wivrn_connection connection;
|
||||
@@ -67,8 +65,10 @@ class wivrn_session : public std::enable_shared_from_this<wivrn_session>
|
||||
wivrn_session(TCP && tcp);
|
||||
|
||||
public:
|
||||
static wivrn_system_devices *
|
||||
create_session(TCP && tcp);
|
||||
static xrt_result_t create_session(TCP && tcp,
|
||||
xrt_system_devices ** out_xsysd,
|
||||
xrt_space_overseer ** out_xspovrs,
|
||||
xrt_system_compositor ** out_xsysc);
|
||||
|
||||
clock_offset
|
||||
get_offset();
|
||||
|
||||
@@ -9,13 +9,11 @@
|
||||
#include "xrt/xrt_config_build.h"
|
||||
#include "xrt/xrt_instance.h"
|
||||
#include "xrt/xrt_system.h"
|
||||
#include "main/comp_main_interface.h"
|
||||
|
||||
#include "os/os_time.h"
|
||||
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_trace_marker.h"
|
||||
#include "util/u_builders.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -40,42 +38,9 @@ wivrn_instance_create_system(struct xrt_instance * xinst,
|
||||
assert(out_xsysc == NULL || *out_xsysc == NULL);
|
||||
|
||||
struct xrt_system_compositor * xsysc = NULL;
|
||||
auto * xsysd = xrt::drivers::wivrn::wivrn_session::create_session(std::move(*tcp));
|
||||
auto res = xrt::drivers::wivrn::wivrn_session::create_session(std::move(*tcp), out_xsysd, out_xspovrs, out_xsysc);
|
||||
tcp.reset();
|
||||
|
||||
if (!xsysd)
|
||||
return XRT_ERROR_DEVICE_CREATION_FAILED;
|
||||
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
struct xrt_device * head = xsysd->roles.head;
|
||||
|
||||
if (xret == XRT_SUCCESS && xsysc == NULL)
|
||||
{
|
||||
xret = comp_main_create_system_compositor(head, xsysd->ctf, &xsysc);
|
||||
}
|
||||
|
||||
if (xret != XRT_SUCCESS)
|
||||
{
|
||||
if (xsysd)
|
||||
xsysd->destroy(xsysd);
|
||||
return xret;
|
||||
}
|
||||
|
||||
*out_xsysd = xsysd;
|
||||
*out_xsysc = xsysc;
|
||||
|
||||
struct xrt_space_overseer * xspovrs = NULL;
|
||||
u_builder_create_space_overseer_legacy(
|
||||
xsysd->roles.head,
|
||||
xsysd->roles.left,
|
||||
xsysd->roles.right,
|
||||
xsysd->xdevs,
|
||||
xsysd->xdev_count,
|
||||
&xspovrs);
|
||||
*out_xspovrs = xspovrs;
|
||||
|
||||
return xret;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user