Compare commits

...
10 changed files with 200 additions and 19 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.co
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.9.0.tar.gz
URL_HASH SHA256=0bb564e127b14c22f062db50f89381dd2e0a20dbaf4987ca138a4ae8728712f9)
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/releases/download/1.0.2/glm-1.0.2.zip
URL_HASH SHA256=203b64abc82e4d8697cc5aeedc93117fc1ee52d36e7cdcfc0854fa2c607edaae)
URL_HASH SHA256=77fff075c5ab0caf076fade41558c5458d9a242aba2b2076bb72008bdb51a35e)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.54.tar.gz
URL_HASH SHA256=2055688081066e37238be996534f349420ac52ed34f8514836704232121ee7f3)
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz
+2 -1
View File
@@ -207,7 +207,8 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
poses[i] = {
.pose = (*joints)[i].first.pose,
.position = (*joints)[i].first.pose.position,
.orientation = pack((*joints)[i].first.pose.orientation),
.linear_velocity = (*joints)[i].second.linearVelocity,
.angular_velocity = (*joints)[i].second.angularVelocity,
.radius = uint16_t((*joints)[i].first.radius * 10'000),
+105
View File
@@ -0,0 +1,105 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* 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 <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <openxr/openxr.h>
struct packed_quaternion
{
uint32_t value;
static packed_quaternion from_quaternion(const XrQuaternionf & q)
{
assert(std::abs(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z - 1) < 0.01);
float abs_w = std::abs(q.w);
float abs_x = std::abs(q.x);
float abs_y = std::abs(q.y);
float abs_z = std::abs(q.z);
const float scale_factor = 511 * std::sqrt(2);
if (abs_x > std::max({abs_y, abs_z, abs_w}))
{
uint32_t q1 = q.y * std::copysign(scale_factor, q.x) + 512.5;
uint32_t q2 = q.z * std::copysign(scale_factor, q.x) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.x) + 512.5;
return {(0 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else if (abs_y > std::max({abs_x, abs_z, abs_w}))
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.y) + 512.5;
uint32_t q2 = q.z * std::copysign(scale_factor, q.y) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.y) + 512.5;
return {(1 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else if (abs_z > std::max({abs_x, abs_y, abs_w}))
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.z) + 512.5;
uint32_t q2 = q.y * std::copysign(scale_factor, q.z) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.z) + 512.5;
return {(2 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.w) + 512.5;
uint32_t q2 = q.y * std::copysign(scale_factor, q.w) + 512.5;
uint32_t q3 = q.z * std::copysign(scale_factor, q.w) + 512.5;
return {(3 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
}
operator XrQuaternionf() const
{
const float scale_factor = 1. / (511 * std::sqrt(2));
float q1 = (int((value >> 20) & 0x3ff) - 512) * scale_factor;
float q2 = (int((value >> 10) & 0x3ff) - 512) * scale_factor;
float q3 = (int((value >> 0) & 0x3ff) - 512) * scale_factor;
float q0 = std::sqrt(1 - q1 * q1 - q2 * q2 - q3 * q3);
switch (value >> 30)
{
case 0:
return {q0, q1, q2, q3};
case 1:
return {q1, q0, q2, q3};
case 2:
return {q1, q2, q0, q3};
case 3:
return {q1, q2, q3, q0};
}
__builtin_unreachable();
}
};
inline packed_quaternion pack(const XrQuaternionf & q)
{
return packed_quaternion::from_quaternion(q);
}
+3 -1
View File
@@ -32,6 +32,7 @@
#include <vulkan/vulkan_core.h>
#include <openxr/openxr.h>
#include "packed_quaternion.h"
#include "smp.h"
#include "wivrn_serialization_types.h"
@@ -372,7 +373,8 @@ struct hand_tracking
};
struct pose
{
XrPosef pose;
XrVector3f position;
packed_quaternion orientation;
XrVector3f linear_velocity;
XrVector3f angular_velocity;
// In order to avoid packet fragmentation
+1 -1
View File
@@ -58,7 +58,7 @@
# Keep in sync with CMakeLists.txt monado rev
rev = lib.strings.trim (builtins.readFile ./monado-rev);
# Nix will output the correct hash when it doesn't match
hash = "sha256-nlfrx6NRYV9eMs+Rb9JBh+mwucL6v+bB3jBrPsSxh+Q=";
hash = "sha256-zU8TLRzd4pb9KzVT/xana6rArcSu31wlCD54p7PJ9UY=";
};
};
+10 -2
View File
@@ -72,11 +72,19 @@ modules:
sources:
- type: git
url: https://github.com/crosstool-ng/crosstool-ng.git
tag: 70c2b00ad79a0a21a48e5a0eedc9f91c374af21d
tag: 620b909cd0713f68084378b63cf61b5232757b90
- type: shell
commands:
# Make the build lighter:
# don't generate debug symbols at all
- sed -i 's/-O2 -g/-O2/' scripts/crosstool-NG.sh
- sed -i 's/-g -O2/-O2/' scripts/build/cc/gcc.sh
# Delete extracted sources when no longer needed
- sed -i '/# Cleanup/a rm -r "$(readlink "${kernel_path}")"' scripts/build/kernel/linux.sh
# Delete tarballs once extracted
- sed -i '2228i CT_DoExecLog FILE rm "$(readlink -f "${file}")"' scripts/functions
# Delete big test files
- sed -i '/CT_ExtractPatch GCC/a CT_Pushd "${CT_SRC_DIR}/gcc/gcc/testsuite/";CT_DoExecLog ALL rm -rf $(ls -1 | grep -v selftests);CT_Popd' scripts/build/cc/gcc.sh
cleanup:
- '*'
@@ -221,7 +229,7 @@ modules:
sources:
- type: git
url: https://gitlab.com/libeigen/eigen.git
tag: 3.4.0
tag: 5.0.1
cleanup:
- '*'
+1 -1
View File
@@ -1 +1 @@
86a0ea4d3e396d4d03274252c400ddb62d1049b0
93d5848d2f5f835fe29291dc7e0f094f3e02de78
+4 -1
View File
@@ -80,7 +80,10 @@ static xrt_space_relation to_relation(const from_headset::hand_tracking::pose &
{
return {
.relation_flags = cast_flags(pose.flags),
.pose = xrt_cast(pose.pose),
.pose = xrt_cast(XrPosef{
.orientation = pose.orientation,
.position = pose.position,
}),
.linear_velocity = xrt_cast(pose.linear_velocity),
.angular_velocity = xrt_cast(pose.angular_velocity),
};
+24 -1
View File
@@ -34,7 +34,30 @@ xrt_space_relation pose_list::interpolate(const xrt_space_relation & a, const xr
{
xrt_space_relation result;
xrt_space_relation_flags flags = xrt_space_relation_flags(a.relation_flags & b.relation_flags);
m_space_relation_interpolate(const_cast<xrt_space_relation *>(&a), const_cast<xrt_space_relation *>(&b), t, flags, &result);
if (math_quat_dot(&a.pose.orientation, &b.pose.orientation) > 0)
{
m_space_relation_interpolate(const_cast<xrt_space_relation *>(&a), const_cast<xrt_space_relation *>(&b), t, flags, &result);
}
else
{
xrt_space_relation b2{
.relation_flags = b.relation_flags,
.pose = {
.orientation = {
.x = -b.pose.orientation.x,
.y = -b.pose.orientation.y,
.z = -b.pose.orientation.z,
.w = -b.pose.orientation.w,
},
.position = b.pose.position,
},
.linear_velocity = b.linear_velocity,
.angular_velocity = b.angular_velocity,
};
m_space_relation_interpolate(const_cast<xrt_space_relation *>(&a), &b2, t, flags, &result);
}
return result;
}
+49 -10
View File
@@ -35,6 +35,10 @@
#include "wivrn_packets.h"
#if WIRESHARK_VERSION_MAJOR > 4 || (WIRESHARK_VERSION_MAJOR == 4 && WIRESHARK_VERSION_MINOR >= 4)
static inline uint32_t get_uint32(tvbuff_t * tvb, const int offset, const unsigned encoding)
{
return tvb_get_uint32(tvb, offset, encoding);
}
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
{
return tvb_get_uint16(tvb, offset, encoding);
@@ -45,6 +49,10 @@ static inline uint16_t get_uint8(tvbuff_t * tvb, const int offset)
return tvb_get_uint8(tvb, offset);
}
#else
static inline uint32_t get_uint32(tvbuff_t * tvb, const int offset, const unsigned encoding)
{
return tvb_get_guint32(tvb, offset, encoding);
}
static inline uint16_t get_uint16(tvbuff_t * tvb, const int offset, const unsigned encoding)
{
return tvb_get_guint16(tvb, offset, encoding);
@@ -439,6 +447,11 @@ struct tree_traits<abbrev, std::vector<T>>
size_t count = get_uint16(tvb, start, ENC_LITTLE_ENDIAN);
start += sizeof(uint16_t);
if (count & 0x8000)
{
count = (count & 0x7fff) | (get_uint16(tvb, start, ENC_LITTLE_ENDIAN) << 15);
start += sizeof(uint16_t);
}
for (size_t i = 0; i < count; i++)
{
@@ -452,6 +465,13 @@ struct tree_traits<abbrev, std::vector<T>>
start += sizeof(uint16_t);
size_t size = sizeof(uint16_t);
if (count & 0x8000)
{
count = (count & 0x7fff) | (get_uint16(tvb, start, ENC_LITTLE_ENDIAN) << 15);
start += sizeof(uint16_t);
size += sizeof(uint16_t);
}
for (size_t i = 0; i < count; i++)
{
size += tree_traits<details::join(abbrev, details::type_name<T>()), T>::size(tvb, start);
@@ -794,19 +814,38 @@ int dissect_wivrn(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, vo
/* Clear out stuff in the info column */
col_clear(pinfo->cinfo, COL_INFO);
proto_item * ti = proto_tree_add_item(tree, proto, tvb, 0, -1, ENC_NA);
proto_tree * subtree = proto_item_add_subtree(ti, subtree_handles.at(""));
int start = 0;
int offset = 0;
if (tcp)
start += sizeof(uint16_t);
while (true)
{
proto_item * ti = proto_tree_add_item(tree, proto, tvb, 0, -1, ENC_NA);
proto_tree * subtree = proto_item_add_subtree(ti, subtree_handles.at(""));
if (pinfo->destport == wivrn::default_port)
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, start);
else
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, start);
int remaining = tvb_reported_length_remaining(tvb, offset);
return tvb_captured_length(tvb);
if (tcp)
{
if (remaining < sizeof(uint32_t))
return remaining - sizeof(uint32_t);
remaining -= sizeof(uint32_t);
uint32_t size = get_uint32(tvb, offset, ENC_LITTLE_ENDIAN);
if (remaining < size)
return remaining - size;
offset += sizeof(uint32_t);
}
if (pinfo->destport == wivrn::default_port)
tree_traits<"wivrn.from_headset", from_headset::packets>::dissect(subtree, tvb, offset);
else
tree_traits<"wivrn.to_headset", to_headset::packets>::dissect(subtree, tvb, offset);
if (not tcp)
return offset;
if (tvb_reported_length(tvb) <= offset)
return offset;
}
}
int dissect_wivrn_udp(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree _U_, void * data _U_)