clang-format

This commit is contained in:
Guillaume Meunier
2024-03-30 17:00:34 +01:00
parent bb660cfb3f
commit 9cceaac648
122 changed files with 2904 additions and 2783 deletions
+4 -3
View File
@@ -22,7 +22,8 @@
#include <filesystem>
#include <iostream>
active_runtime::active_runtime() : pid(getpid()), active_runtime_json(xdg_config_home() / "openxr" / "1" / "active_runtime.json")
active_runtime::active_runtime() :
pid(getpid()), active_runtime_json(xdg_config_home() / "openxr" / "1" / "active_runtime.json")
{
try
{
@@ -40,7 +41,7 @@ active_runtime::active_runtime() : pid(getpid()), active_runtime_json(xdg_config
to_be_deleted = true;
}
catch(std::exception& e)
catch (std::exception & e)
{
std::cerr << "Cannot set active OpenXR runtime: " << e.what() << std::endl;
}
@@ -55,7 +56,7 @@ active_runtime::~active_runtime()
std::filesystem::remove(active_runtime_json);
}
}
catch(std::exception& e)
catch (std::exception & e)
{
std::cerr << "Cannot unset active OpenXR runtime: " << e.what() << std::endl;
}
+3 -3
View File
@@ -18,8 +18,8 @@
#pragma once
#include <unistd.h>
#include <filesystem>
#include <unistd.h>
class active_runtime
{
@@ -29,7 +29,7 @@ class active_runtime
public:
active_runtime();
active_runtime(const active_runtime&) = delete;
active_runtime& operator=(const active_runtime&) = delete;
active_runtime(const active_runtime &) = delete;
active_runtime & operator=(const active_runtime &) = delete;
~active_runtime();
};
+6 -5
View File
@@ -200,13 +200,13 @@ void pipewire_device::mic_process(void * self_v)
}
const auto & data = buffer->buffer->datas[0];
uint8_t* data_ptr = (uint8_t*)data.data;
uint8_t * data_ptr = (uint8_t *)data.data;
if (not data.data)
return;
const size_t frame_size = self->desc.microphone->num_channels * sizeof(int16_t);
#if PW_CHECK_VERSION(0,3,49)
#if PW_CHECK_VERSION(0, 3, 49)
size_t num_frames = buffer->requested;
#else
size_t num_frames = 0;
@@ -222,7 +222,7 @@ void pipewire_device::mic_process(void * self_v)
while (num_frames != 0)
{
// remaining bytes in existing buffer
auto& current = self->mic_current;
auto & current = self->mic_current;
ptrdiff_t tmp_remain = current.payload.size_bytes();
// limit to requested frames
tmp_remain = std::min<ptrdiff_t>(tmp_remain, num_frames * frame_size);
@@ -265,10 +265,11 @@ void pipewire_device::speaker_process(void * self_v)
(uint8_t *)data.data + data.chunk->offset,
data.chunk->size),
};
try {
try
{
self->session.send_control(packet);
}
catch (std::exception& e)
catch (std::exception & e)
{
U_LOG_W("Failed to send audio data: %s", e.what());
}
+1 -1
View File
@@ -26,4 +26,4 @@ std::shared_ptr<audio_device> create_pipewire_handle(
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session& session);
xrt::drivers::wivrn::wivrn_session & session);
+1 -1
View File
@@ -1,11 +1,11 @@
#include "audio_pulse.h"
#include "../wivrn_ipc.h"
#include "driver/wivrn_session.h"
#include "os/os_time.h"
#include "util/u_logging.h"
#include "utils/sync_queue.h"
#include "utils/wrap_lambda.h"
#include "driver/wivrn_session.h"
#include <pulse/context.h>
#include <pulse/ext-device-manager.h>
+1 -1
View File
@@ -26,4 +26,4 @@ std::shared_ptr<audio_device> create_pulse_handle(
const std::string & sink_name,
const std::string & sink_description,
const xrt::drivers::wivrn::from_headset::headset_info_packet & info,
xrt::drivers::wivrn::wivrn_session& session);
xrt::drivers::wivrn::wivrn_session & session);
+1 -1
View File
@@ -45,7 +45,7 @@ std::shared_ptr<audio_device> audio_device::create(
#ifdef WIVRN_USE_PULSEAUDIO
if (auto res = create_pulse_handle(source_name, source_description, sink_name, sink_description, info, session))
return res;
return res;
#endif
U_LOG_W("No audio backend available");
return nullptr;
+1 -1
View File
@@ -32,7 +32,7 @@ class avahi_publisher
void * userdata /**< The user data that was passed to avahi_client_new() */);
public:
avahi_publisher(const char * name, std::string type, int port, const std::map<std::string, std::string>& txt = {});
avahi_publisher(const char * name, std::string type, int port, const std::map<std::string, std::string> & txt = {});
~avahi_publisher();
+3 -3
View File
@@ -50,13 +50,13 @@ void clock_offset_estimator::add_sample(const xrt::drivers::wivrn::from_headset:
{
sample_interval = std::chrono::seconds(1);
int64_t latency = 0;
for (const auto& s: samples)
for (const auto & s: samples)
latency += s.received - s.query;
latency /= samples.size();
// packets with too high latency are likely to be retransmitted
if (sample.received - sample.query > 3 * latency)
{
U_LOG_D("drop packet for latency %ldµs > %ldµs", (sample.received - sample.query) /1000, latency/1000);
U_LOG_D("drop packet for latency %ldµs > %ldµs", (sample.received - sample.query) / 1000, latency / 1000);
return;
}
@@ -96,7 +96,7 @@ void clock_offset_estimator::add_sample(const xrt::drivers::wivrn::from_headset:
{
#if 1
// assume symmetrical latency
double x = (s.query + s.received)* 0.5 - x0;
double x = (s.query + s.received) * 0.5 - x0;
#else
// assume latency is only on server -> headset link
double x = s.received - x0;
+8 -5
View File
@@ -36,7 +36,10 @@ struct clock_offset
int64_t b = 0;
double a = 1;
operator bool() { return b != 0;}
operator bool()
{
return b != 0;
}
XrTime from_headset(XrTime) const;
@@ -45,7 +48,7 @@ struct clock_offset
class clock_offset_estimator
{
struct sample: public xrt::drivers::wivrn::from_headset::timesync_response
struct sample : public xrt::drivers::wivrn::from_headset::timesync_response
{
XrTime received;
};
@@ -58,9 +61,9 @@ class clock_offset_estimator
std::chrono::steady_clock::time_point next_sample{};
std::atomic<std::chrono::milliseconds> sample_interval = std::chrono::milliseconds(10);
public:
void request_sample(wivrn_connection& connection);
void add_sample(const xrt::drivers::wivrn::from_headset::timesync_response& sample);
public:
void request_sample(wivrn_connection & connection);
void add_sample(const xrt::drivers::wivrn::from_headset::timesync_response & sample);
clock_offset get_offset();
};
+12 -11
View File
@@ -25,8 +25,8 @@
#endif
#define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>
#include <stdlib.h>
#include <random>
#include <stdlib.h>
#include "util/u_logging.h"
@@ -45,14 +45,15 @@ static std::filesystem::path get_cookie_file()
namespace xrt::drivers::wivrn
{
NLOHMANN_JSON_SERIALIZE_ENUM(video_codec, {
{video_codec(-1), ""},
{h264, "h264"},
{h264, "avc"},
{h265, "h265"},
{h265, "hevc"},
})
NLOHMANN_JSON_SERIALIZE_ENUM(
video_codec,
{
{video_codec(-1), ""},
{h264, "h264"},
{h264, "avc"},
{h265, "h265"},
{h265, "hevc"},
})
}
configuration configuration::read_user_configuration()
@@ -110,7 +111,7 @@ configuration configuration::read_user_configuration()
result.application.push_back(json["application"]);
else
{
for(const auto& i: json["application"])
for (const auto & i: json["application"])
{
result.application.push_back(i);
}
@@ -146,7 +147,7 @@ std::string server_cookie()
std::uniform_int_distribution<int> dist(0, 61);
char buffer[33];
for(int i = 0; i < 32; i++)
for (int i = 0; i < 32; i++)
{
int c = dist(engine);
+16 -17
View File
@@ -28,19 +28,18 @@ static_assert(XRT_HAND_JOINT_COUNT == XR_HAND_JOINT_COUNT_EXT);
namespace
{
xrt_hand_joint_value interpolate(const xrt_hand_joint_value & a, const xrt_hand_joint_value & b, float t)
{
return {
.relation = pose_list::interpolate(a.relation, b.relation, t),
.radius = a.radius * (1-t) + b.radius * t
};
}
xrt_hand_joint_value interpolate(const xrt_hand_joint_value & a, const xrt_hand_joint_value & b, float t)
{
return {
.relation = pose_list::interpolate(a.relation, b.relation, t),
.radius = a.radius * (1 - t) + b.radius * t};
}
} // namespace
xrt_hand_joint_set hand_joints_list::interpolate(const xrt_hand_joint_set & a, const xrt_hand_joint_set & b, float t)
{
xrt_hand_joint_set j = a;
for(int i = 0; i < XRT_HAND_JOINT_COUNT; i++)
for (int i = 0; i < XRT_HAND_JOINT_COUNT; i++)
{
j.values.hand_joint_set_default[i] = ::interpolate(a.values.hand_joint_set_default[i], b.values.hand_joint_set_default[i], t);
}
@@ -49,7 +48,7 @@ xrt_hand_joint_set hand_joints_list::interpolate(const xrt_hand_joint_set & a, c
xrt_hand_joint_set hand_joints_list::extrapolate(const xrt_hand_joint_set & a, const xrt_hand_joint_set & b, uint64_t ta, uint64_t tb, uint64_t t)
{
xrt_hand_joint_set j = t <= ta ? a : b;
xrt_hand_joint_set j = t <= ta ? a : b;
// Only extrapolate the hand pose, individual joints are too noisy
j.hand_pose = pose_list::extrapolate(a.hand_pose, b.hand_pose, ta, tb, t);
return j;
@@ -78,17 +77,17 @@ static xrt_space_relation_flags cast_flags(uint8_t in_flags)
return xrt_space_relation_flags(flags);
}
static xrt_space_relation to_relation(const from_headset::hand_tracking::pose& pose)
static xrt_space_relation to_relation(const from_headset::hand_tracking::pose & pose)
{
return {
.relation_flags = cast_flags(pose.flags),
.pose = xrt_cast(pose.pose),
.linear_velocity = xrt_cast(pose.linear_velocity),
.angular_velocity = xrt_cast(pose.angular_velocity),
.relation_flags = cast_flags(pose.flags),
.pose = xrt_cast(pose.pose),
.linear_velocity = xrt_cast(pose.linear_velocity),
.angular_velocity = xrt_cast(pose.angular_velocity),
};
}
static xrt_hand_joint_set convert_joints(const std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT>>& input_joints)
static xrt_hand_joint_set convert_joints(const std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT_COUNT_EXT>> & input_joints)
{
xrt_hand_joint_set output_joints{};
@@ -101,9 +100,9 @@ static xrt_hand_joint_set convert_joints(const std::optional<std::array<from_hea
xrt_space_relation * joint_rel = m_relation_chain_reserve(&rel_chain);
m_relation_chain_push_inverted_relation(&rel_chain, &output_joints.hand_pose);
for(int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
xrt_hand_joint_value& res = output_joints.values.hand_joint_set_default[i];
xrt_hand_joint_value & res = output_joints.values.hand_joint_set_default[i];
res.radius = (*input_joints)[i].radius;
*joint_rel = to_relation((*input_joints)[i]);
+2 -2
View File
@@ -22,7 +22,6 @@
#include "history.h"
#include "xrt/xrt_defines.h"
class hand_joints_list : public history<hand_joints_list, xrt_hand_joint_set>
{
int hand_id;
@@ -31,7 +30,8 @@ public:
static xrt_hand_joint_set interpolate(const xrt_hand_joint_set & a, const xrt_hand_joint_set & b, float t);
static xrt_hand_joint_set extrapolate(const xrt_hand_joint_set & a, const xrt_hand_joint_set & b, uint64_t ta, uint64_t tb, uint64_t t);
hand_joints_list(int hand_id) : hand_id(hand_id) {}
hand_joints_list(int hand_id) :
hand_id(hand_id) {}
void update_tracking(const xrt::drivers::wivrn::from_headset::hand_tracking & tracking, const clock_offset & offset);
};
+4 -3
View File
@@ -19,12 +19,12 @@
#pragma once
#include "clock_offset.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <mutex>
#include <vector>
#include <algorithm>
#include "clock_offset.h"
template <typename Derived, typename Data, bool extrapolate = false, size_t MaxSamples = 10>
class history
@@ -97,7 +97,8 @@ public:
const auto & d1 = data.back();
return Derived::extrapolate(d0, d1, d0.at_timestamp_ns, d1.at_timestamp_ns, at_timestamp_ns);
}
else {
else
{
return data.back();
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ xrt_space_relation pose_list::extrapolate(const xrt_space_relation & a, const xr
xrt_space_relation res = t < ta ? a : b;
xrt_vec3 lin_vel = res.relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT ? res.linear_velocity : (b.pose.position - a.pose.position ) / h;
xrt_vec3 lin_vel = res.relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT ? res.linear_velocity : (b.pose.position - a.pose.position) / h;
float dt = (t - tb) / 1.e9;
+1 -2
View File
@@ -19,12 +19,11 @@
#pragma once
#include "wivrn_packets.h"
#include "clock_offset.h"
#include "history.h"
#include "wivrn_packets.h"
#include "xrt/xrt_defines.h"
class pose_list : public history<pose_list, xrt_space_relation>
{
xrt::drivers::wivrn::device_id device;
-1
View File
@@ -30,7 +30,6 @@ struct tracked_views
std::array<xrt_fov, 2> fovs;
};
class view_list : public history<view_list, tracked_views, true>
{
public:
+2 -3
View File
@@ -21,7 +21,6 @@
#include "encoder/video_encoder.h"
#include "main/comp_compositor.h"
#include "math/m_space.h"
#include "encoder/video_encoder.h"
#include "xrt_cast.h"
#include <condition_variable>
#include <list>
@@ -540,12 +539,12 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
view_info.display_time = cn->cnx->get_offset().to_headset(desired_present_time_ns);
for (int eye = 0; eye < 2; ++eye)
{
const auto &slot = cn->c->base.slot;
const auto & slot = cn->c->base.slot;
view_info.fov[eye] = xrt_cast(slot.fovs[eye]);
view_info.pose[eye] = xrt_cast(slot.poses[eye]);
if (cn->c->debug.atw_off)
{
const auto &stereo = slot.layers[0].data.stereo;
const auto & stereo = slot.layers[0].data.stereo;
view_info.pose[eye] = xrt_cast(eye ? stereo.r.pose : stereo.l.pose);
}
else
+3 -3
View File
@@ -28,12 +28,12 @@
#include "utils/wivrn_vk_bundle.h"
#include "vk/allocation.h"
#include "driver/wivrn_pacer.h"
#include <condition_variable>
#include <list>
#include <memory>
#include <optional>
#include <vector>
#include "driver/wivrn_pacer.h"
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
@@ -74,8 +74,8 @@ struct wivrn_comp_target : public comp_target
VkColorSpaceKHR color_space;
static std::vector<const char*> wanted_instance_extensions;
static std::vector<const char*> wanted_device_extensions;
static std::vector<const char *> wanted_instance_extensions;
static std::vector<const char *> wanted_device_extensions;
struct encoder_thread
{
+3 -4
View File
@@ -29,11 +29,11 @@ wivrn_connection::wivrn_connection(TCP && tcp) :
{
sockaddr_in6 server_address;
socklen_t len = sizeof(server_address);
if (getsockname(control.get_fd(), (sockaddr*)&server_address, &len) < 0)
if (getsockname(control.get_fd(), (sockaddr *)&server_address, &len) < 0)
{
throw std::system_error(errno, std::system_category(), "Cannot get socket port");
}
int port = ntohs(((struct sockaddr_in6*)&server_address)->sin6_port);
int port = ntohs(((struct sockaddr_in6 *)&server_address)->sin6_port);
sockaddr_in6 client_address;
len = sizeof(client_address);
@@ -78,7 +78,6 @@ wivrn_connection::wivrn_connection(TCP && tcp) :
stream.set_send_buffer_size(1024 * 1024 * 5);
break;
}
}
if (std::chrono::steady_clock::now() > timeout)
@@ -92,7 +91,7 @@ wivrn_connection::wivrn_connection(TCP && tcp) :
// Set Expedited forwarding https://datatracker.ietf.org/doc/html/rfc3246
stream.set_tos(IPTOS_DSCP_EF);
}
catch (std::exception& e)
catch (std::exception & e)
{
U_LOG_I("Failed to set IP ToS to Expedited Forwarding: %s", e.what());
}
+27 -27
View File
@@ -111,24 +111,24 @@ static const size_t left_hand_bindings_count = ARRAY_SIZE(left_hand_bindings);
static const size_t right_hand_bindings_count = ARRAY_SIZE(right_hand_bindings);
static xrt_binding_input_pair simple_input_binding[] = {
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_TOUCH_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
{XRT_INPUT_SIMPLE_SELECT_CLICK, XRT_INPUT_TOUCH_TRIGGER_VALUE},
{XRT_INPUT_SIMPLE_MENU_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
{XRT_INPUT_SIMPLE_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE},
{XRT_INPUT_SIMPLE_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
};
static xrt_binding_output_pair simple_output_binding[] = {
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
{XRT_OUTPUT_NAME_SIMPLE_VIBRATION, XRT_OUTPUT_NAME_TOUCH_HAPTIC},
};
static xrt_binding_profile wivrn_binding_profiles[] = {
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = simple_input_binding,
.input_count = std::size(simple_input_binding),
.outputs = simple_output_binding,
.output_count = std::size(simple_output_binding),
},
{
.name = XRT_DEVICE_SIMPLE_CONTROLLER,
.inputs = simple_input_binding,
.input_count = std::size(simple_input_binding),
.outputs = simple_output_binding,
.output_count = std::size(simple_output_binding),
},
};
static void wivrn_controller_destroy(xrt_device * xdev);
@@ -139,10 +139,10 @@ static void wivrn_controller_get_tracked_pose(xrt_device * xdev,
xrt_space_relation * out_relation);
static void wivrn_controller_get_hand_tracking(xrt_device * xdev,
xrt_input_name name,
uint64_t desired_timestamp_ns,
xrt_hand_joint_set * out_value,
uint64_t *out_timestamp_ns);
xrt_input_name name,
uint64_t desired_timestamp_ns,
xrt_hand_joint_set * out_value,
uint64_t * out_timestamp_ns);
static void wivrn_controller_set_output(struct xrt_device * xdev, enum xrt_output_name name, const union xrt_output_value * value);
@@ -152,10 +152,10 @@ wivrn_controller::wivrn_controller(int hand_id,
xrt_device * hmd,
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx) :
xrt_device{},
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM),
joints(hand_id),
cnx(cnx)
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
aim(hand_id == 0 ? device_id::LEFT_AIM : device_id::RIGHT_AIM),
joints(hand_id),
cnx(cnx)
{
xrt_device * base = this;
@@ -252,7 +252,7 @@ void wivrn_controller::update_inputs()
inputs_array = inputs_staging;
}
void wivrn_controller::set_inputs(const from_headset::inputs & inputs, const clock_offset& clock_offset)
void wivrn_controller::set_inputs(const from_headset::inputs & inputs, const clock_offset & clock_offset)
{
std::lock_guard lock{mutex};
for (const auto & input: inputs.values)
@@ -325,11 +325,11 @@ xrt_space_relation wivrn_controller::get_tracked_pose(xrt_input_name name, uint6
std::pair<xrt_hand_joint_set, uint64_t> wivrn_controller::get_hand_tracking(xrt_input_name name, uint64_t desired_timestamp_ns)
{
switch(name)
switch (name)
{
case XRT_INPUT_GENERIC_HAND_TRACKING_LEFT:
case XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT:
return { joints.get_at(desired_timestamp_ns), desired_timestamp_ns };
return {joints.get_at(desired_timestamp_ns), desired_timestamp_ns};
default:
U_LOG_W("Unknown input name requested");
@@ -392,10 +392,10 @@ static void wivrn_controller_get_tracked_pose(xrt_device * xdev,
}
static void wivrn_controller_get_hand_tracking(xrt_device * xdev,
xrt_input_name name,
uint64_t desired_timestamp_ns,
xrt_hand_joint_set * out_value,
uint64_t *out_timestamp_ns)
xrt_input_name name,
uint64_t desired_timestamp_ns,
xrt_hand_joint_set * out_value,
uint64_t * out_timestamp_ns)
{
std::tie(*out_value, *out_timestamp_ns) = static_cast<wivrn_controller *>(xdev)->get_hand_tracking(name, desired_timestamp_ns);
}
+1 -1
View File
@@ -21,8 +21,8 @@
#include "xrt/xrt_device.h"
#include "pose_list.h"
#include "hand_joints_list.h"
#include "pose_list.h"
#include "wivrn_session.h"
#include <memory>
+1 -1
View File
@@ -91,7 +91,7 @@ static std::tuple<float, float> solve_foveation(float λ, float c)
//
// Use eq. 2 to express a as function of b, then replace in eq. 1
// equation that needs to be null is:
auto b = [λ, c](double a) { return atan(a * (1 - c) / λ) - a;};
auto b = [λ, c](double a) { return atan(a * (1 - c) / λ) - a; };
auto eq = [λ, c](double a) { return atan(a * (1 - c) / λ) + atan(a * (1 + c) / λ) - 2 * a; }; // (eq. 3)
// function starts positive, reaches a maximum then decreases to -∞
+5 -3
View File
@@ -41,7 +41,8 @@ class wivrn_pacer
uint64_t last_wake_up_ns = 0;
// Client wait time for each decoder
struct stream_data{
struct stream_data
{
// Last feedback for each encoder
xrt::drivers::wivrn::from_headset::feedback last_feedback;
std::vector<uint64_t> times;
@@ -49,7 +50,8 @@ class wivrn_pacer
};
std::vector<stream_data> streams;
struct frame_history{
struct frame_history
{
uint64_t frame_id;
uint64_t present_ns;
};
@@ -69,7 +71,7 @@ public:
uint64_t & out_present_slop_ns,
uint64_t & out_predicted_display_time_ns);
void on_feedback(const xrt::drivers::wivrn::from_headset::feedback &, const clock_offset&);
void on_feedback(const xrt::drivers::wivrn::from_headset::feedback &, const clock_offset &);
void mark_timing_point(
comp_target_timing_point point,
+2 -2
View File
@@ -74,7 +74,7 @@ public:
clock_offset get_offset();
void operator()(from_headset::handshake&&) {}
void operator()(from_headset::handshake &&) {}
void operator()(from_headset::headset_info_packet &&);
void operator()(from_headset::tracking &&);
void operator()(from_headset::hand_tracking &&);
@@ -97,7 +97,7 @@ public:
std::array<to_headset::video_stream_description::foveation_parameter, 2> get_foveation_parameters();
void dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream = -1, const char* extra = "");
void dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream = -1, const char * extra = "");
private:
static void run(std::weak_ptr<wivrn_session>);
+20 -20
View File
@@ -43,10 +43,10 @@ static bool is_nvidia(vk::PhysicalDevice physical_device)
return props.vendorID == 0x10DE;
}
static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> &encoders, uint64_t bitrate)
static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> & encoders, uint64_t bitrate)
{
double total_weight = 0;
for (auto& encoder: encoders)
for (auto & encoder: encoders)
{
double w = encoder.width * encoder.height;
switch (encoder.codec)
@@ -61,7 +61,7 @@ static void split_bitrate(std::vector<xrt::drivers::wivrn::encoder_settings> &en
total_weight += w;
}
for (auto& encoder: encoders)
for (auto & encoder: encoders)
{
encoder.bitrate = encoder.bitrate * bitrate / total_weight;
}
@@ -94,21 +94,21 @@ static std::vector<xrt::drivers::wivrn::encoder_settings> get_encoder_default_se
else
{
#ifdef WIVRN_USE_VAAPI
/* Split in 3 parts:
* +--------+--------+
* | | |
* | | |
* +--------+ |
* | | |
* | | |
* | | |
* | | |
* | | |
* +--------+--------+
* All 3 are encoded sequentially, so that the smallest is ready earlier.
* Decoder can start work as fast as possible, reducing idle time.
*
*/
/* Split in 3 parts:
* +--------+--------+
* | | |
* | | |
* +--------+ |
* | | |
* | | |
* | | |
* | | |
* | | |
* +--------+--------+
* All 3 are encoded sequentially, so that the smallest is ready earlier.
* Decoder can start work as fast as possible, reducing idle time.
*
*/
settings.encoder_name = encoder_vaapi;
settings.width = std::ceil(width * 0.5);
std::vector<xrt::drivers::wivrn::encoder_settings> encoders(3, settings);
@@ -133,9 +133,9 @@ static std::vector<xrt::drivers::wivrn::encoder_settings> get_encoder_default_se
return {settings};
}
static void make_even(uint16_t& value, uint16_t max)
static void make_even(uint16_t & value, uint16_t max)
{
value += value %2;
value += value % 2;
value = std::min(value, max);
}
+1 -1
View File
@@ -94,7 +94,7 @@ get_render_device(vk::raii::PhysicalDevice & physical_device)
return path;
}
av_buffer_ptr make_drm_hw_ctx(vk::raii::PhysicalDevice & physical_device, const std::optional<std::string>& device)
av_buffer_ptr make_drm_hw_ctx(vk::raii::PhysicalDevice & physical_device, const std::optional<std::string> & device)
{
const auto render_device = device ? *device : get_render_device(physical_device);
AVBufferRef * hw_ctx;
+2 -2
View File
@@ -19,9 +19,9 @@
#pragma once
#include "video_encoder_ffmpeg.h"
#include "ffmpeg_helper.h"
#include "utils/wivrn_vk_bundle.h"
#include "video_encoder_ffmpeg.h"
#include <vulkan/vulkan_raii.hpp>
namespace xrt::drivers::wivrn
@@ -40,7 +40,7 @@ class video_encoder_va : public VideoEncoderFFMPEG
std::vector<vk::raii::DeviceMemory> mem;
public:
video_encoder_va(wivrn_vk_bundle&, xrt::drivers::wivrn::encoder_settings & settings, float fps);
video_encoder_va(wivrn_vk_bundle &, xrt::drivers::wivrn::encoder_settings & settings, float fps);
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
+2 -2
View File
@@ -72,7 +72,7 @@ std::unique_ptr<VideoEncoder> VideoEncoder::Create(
throw std::runtime_error("Failed to create encoder " + settings.encoder_name);
res->stream_idx = stream_idx;
auto wivrn_dump_video= std::getenv("WIVRN_DUMP_VIDEO");
auto wivrn_dump_video = std::getenv("WIVRN_DUMP_VIDEO");
if (wivrn_dump_video)
{
std::string file(wivrn_dump_video);
@@ -124,7 +124,7 @@ void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
if (end_of_frame)
timing_info.send_end = clock.to_headset(os_monotonic_get_ns());
if (video_dump)
video_dump.write((char*)data.data(), data.size());
video_dump.write((char *)data.data(), data.size());
if (shard.shard_idx == 0)
{
cnx->dump_time("send_begin", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
+1 -1
View File
@@ -287,7 +287,7 @@ void VideoEncoderNvenc::PresentImage(yuv_converter & src_yuv, vk::raii::CommandB
*yuv_buffer,
vk::BufferImageCopy{
.bufferOffset = pitch * rect.extent.height,
.bufferRowLength = uint32_t(pitch/2),
.bufferRowLength = uint32_t(pitch / 2),
.imageSubresource = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.layerCount = 1,
+3 -3
View File
@@ -29,7 +29,7 @@ namespace xrt::drivers::wivrn
class VideoEncoderNvenc : public VideoEncoder
{
wivrn_vk_bundle& vk;
wivrn_vk_bundle & vk;
// relevant part of the input image to encode
vk::Rect2D rect;
@@ -51,10 +51,10 @@ class VideoEncoderNvenc : public VideoEncoder
int bitrate;
public:
VideoEncoderNvenc(wivrn_vk_bundle& vk, const encoder_settings & settings, float fps);
VideoEncoderNvenc(wivrn_vk_bundle & vk, const encoder_settings & settings, float fps);
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
void Encode( bool idr, std::chrono::steady_clock::time_point pts) override;
void Encode(bool idr, std::chrono::steady_clock::time_point pts) override;
};
} // namespace xrt::drivers::wivrn
+1 -1
View File
@@ -57,7 +57,7 @@ class VideoEncoderX264 : public VideoEncoder
std::list<pending_nal> pending_nals;
public:
VideoEncoderX264(wivrn_vk_bundle& vk, encoder_settings & settings, float fps);
VideoEncoderX264(wivrn_vk_bundle & vk, encoder_settings & settings, float fps);
void PresentImage(yuv_converter & src_yuv, vk::raii::CommandBuffer & cmd_buf) override;
+6 -4
View File
@@ -28,9 +28,11 @@ class yuv_converter
vk::Extent2D extent;
vk::Image rgb;
public:
image_allocation luma;
image_allocation chroma;
private:
vk::raii::ImageView view_rgb = nullptr;
vk::raii::ImageView view_luma = nullptr;
@@ -44,13 +46,13 @@ private:
std::vector<vk::raii::DeviceMemory> mem;
public:
public:
yuv_converter();
yuv_converter(vk::PhysicalDevice, vk::raii::Device& device, vk::Image rgb, vk::Format format, vk::Extent2D extent);
yuv_converter(vk::PhysicalDevice, vk::raii::Device & device, vk::Image rgb, vk::Format format, vk::Extent2D extent);
// Converts the given image to yuv, stored in luma and chroma images.
// The output images will be in transfer src optimal layout
void record_draw_commands(vk::raii::CommandBuffer& cmd_buf);
void record_draw_commands(vk::raii::CommandBuffer & cmd_buf);
void assemble_planes(vk::Rect2D, vk::raii::CommandBuffer&, vk::Image target);
void assemble_planes(vk::Rect2D, vk::raii::CommandBuffer &, vk::Image target);
};
-1
View File
@@ -11,7 +11,6 @@
std::string hostname()
{
#ifdef WIVRN_USE_SYSTEMD
sd_bus * bus;
if (sd_bus_default_system(&bus) < 0)
+2 -2
View File
@@ -25,11 +25,11 @@
#include "version.h"
#include "wivrn_config.h"
#include "active_runtime.h"
#include "avahi_publisher.h"
#include "hostname.h"
#include <shared/ipc_protocol.h>
#include <util/u_file.h>
#include "active_runtime.h"
// Insert the on load constructor to init trace marker.
U_TRACE_TARGET_SETUP(U_TRACE_WHICH_SERVICE)
@@ -265,7 +265,7 @@ int inner_main(int argc, char * argv[])
setenv("LISTEN_PID", std::to_string(getpid()).c_str(), true);
//FIXME: synchronization fails on gfx pipeline
// FIXME: synchronization fails on gfx pipeline
setenv("XRT_COMPOSITOR_COMPUTE", "1", true);
try
+3 -4
View File
@@ -28,12 +28,11 @@ extern "C"
#else
#include <fcntl.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <signal.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#ifndef __NR_pidfd_open
#define __NR_pidfd_open 434
#endif
@@ -45,7 +44,7 @@ static int pidfd_open(pid_t pid, unsigned int flags)
#ifndef __NR_pidfd_send_signal
#define __NR_pidfd_send_signal 424
#endif
static int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, unsigned int flags)
static int pidfd_send_signal(int pidfd, int sig, siginfo_t * info, unsigned int flags)
{
return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags);
}
+4 -4
View File
@@ -31,7 +31,7 @@ struct vk_bundle;
// however we don't own it, so deactivate the destructor
struct raii_instance : public vk::raii::Instance
{
raii_instance(vk::raii::Context &ctx, VkInstance i) :
raii_instance(vk::raii::Context & ctx, VkInstance i) :
vk::raii::Instance(ctx, i) {}
raii_instance & operator=(raii_instance &&) noexcept = default;
~raii_instance()
@@ -60,10 +60,10 @@ struct wivrn_vk_bundle
vk::raii::Queue queue;
uint32_t queue_family_index;
std::vector<const char*> instance_extensions;
std::vector<const char*> device_extensions;
std::vector<const char *> instance_extensions;
std::vector<const char *> device_extensions;
wivrn_vk_bundle(vk_bundle& vk, std::span<const char*> requested_instance_extensions, std::span<const char*> requested_device_extensions);
wivrn_vk_bundle(vk_bundle & vk, std::span<const char *> requested_instance_extensions, std::span<const char *> requested_device_extensions);
uint32_t get_memory_type(uint32_t type_bits, vk::MemoryPropertyFlags memory_props);
};
+4 -4
View File
@@ -42,7 +42,7 @@ void init_cleanup_functions()
void add_cleanup_function(void (*callback)(uintptr_t), uintptr_t userdata)
{
for(auto& i: *cleanup_functions)
for (auto & i: *cleanup_functions)
{
if (i.callback == nullptr)
{
@@ -54,7 +54,7 @@ void add_cleanup_function(void (*callback)(uintptr_t), uintptr_t userdata)
void remove_cleanup_function(void (*callback)(uintptr_t), uintptr_t userdata)
{
for(auto& i: *cleanup_functions)
for (auto & i: *cleanup_functions)
{
if (i.callback == callback && i.userdata == userdata)
{
@@ -67,7 +67,7 @@ void remove_cleanup_function(void (*callback)(uintptr_t), uintptr_t userdata)
void run_cleanup_functions()
{
// Don't fork if cleanup_functions is empty
if (std::ranges::all_of(*cleanup_functions, [](auto& i){ return i.callback == nullptr; }))
if (std::ranges::all_of(*cleanup_functions, [](auto & i) { return i.callback == nullptr; }))
return;
// Fork because pulseaudio doesn't like being initialized in the parent and the child
@@ -80,7 +80,7 @@ void run_cleanup_functions()
}
else if (child == 0)
{
for(auto& i: *cleanup_functions)
for (auto & i: *cleanup_functions)
{
if (i.callback)
{