Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -40,10 +40,11 @@ set(XRT_FEATURE_OPENXR_FACIAL_TRACKING_HTC ON)
|
||||
set(XRT_FEATURE_OPENXR_HAND_TRACKING_EXT ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_EXT_HAND ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_EXT_PALM_POSE ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PRO ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PLUS ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_BYTEDANCE ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_VIVE_FOCUS3 ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PRO ON)
|
||||
set(XRT_FEATURE_OPENXR_INTERACTION_TOUCH_PLUS ON)
|
||||
set(XRT_FEATURE_OPENXR_LAYER_COLOR_SCALE_BIAS ON)
|
||||
|
||||
set(XRT_HAVE_BLUETOOTH OFF)
|
||||
set(XRT_HAVE_GST OFF)
|
||||
|
||||
@@ -293,9 +293,6 @@ std::optional<std::chrono::system_clock::time_point> from_iso8601(const std::str
|
||||
if (strptime(timestamp.c_str(), "%FT%H:%M:%S%z", &t) == nullptr)
|
||||
return std::nullopt;
|
||||
|
||||
// Convert from local time to UTC
|
||||
t.tm_sec += t.tm_gmtoff;
|
||||
|
||||
return std::chrono::system_clock::from_time_t(mktime(&t));
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer
|
||||
cn->wivrn_bundle->device,
|
||||
{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
|
||||
.queueFamilyIndex = vk->queue_family_index,
|
||||
.queueFamilyIndex = vk->main_queue.family_index,
|
||||
});
|
||||
cn->wivrn_bundle->name(cn->command_pool, "comp target command pool");
|
||||
}
|
||||
@@ -584,8 +584,8 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
.dstAccessMask = vk::AccessFlagBits::eMemoryWrite,
|
||||
.oldLayout = vk::ImageLayout::eTransferSrcOptimal,
|
||||
.newLayout = vk::ImageLayout::eVideoEncodeSrcKHR,
|
||||
.srcQueueFamilyIndex = vk->queue_family_index,
|
||||
.dstQueueFamilyIndex = vk->encode_queue_family_index,
|
||||
.srcQueueFamilyIndex = vk->main_queue.family_index,
|
||||
.dstQueueFamilyIndex = vk->encode_queue.family_index,
|
||||
.image = psc_image.image,
|
||||
.subresourceRange = {.aspectMask = vk::ImageAspectFlagBits::eColor,
|
||||
.baseMipLevel = 0,
|
||||
|
||||
@@ -64,6 +64,11 @@ public:
|
||||
wivrn_connection(const wivrn_connection &) = delete;
|
||||
wivrn_connection & operator=(const wivrn_connection &) = delete;
|
||||
|
||||
bool has_stream() const
|
||||
{
|
||||
return stream;
|
||||
}
|
||||
|
||||
bool is_active()
|
||||
{
|
||||
return active;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "xrt/xrt_defines.h"
|
||||
|
||||
#include <array>
|
||||
#include <charconv>
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <ranges>
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include "xrt/xrt_device.h"
|
||||
|
||||
#include "utils/singleton.h"
|
||||
#include <mutex>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
struct render_resources;
|
||||
@@ -34,7 +36,7 @@ namespace wivrn
|
||||
struct clock_offset;
|
||||
struct wivrn_vk_bundle;
|
||||
|
||||
class wivrn_foveation
|
||||
class wivrn_foveation : public singleton<wivrn_foveation>
|
||||
{
|
||||
std::mutex mutex;
|
||||
|
||||
@@ -53,8 +55,8 @@ class wivrn_foveation
|
||||
|
||||
vk::raii::CommandPool command_pool;
|
||||
vk::raii::CommandBuffer cmd;
|
||||
buffer_allocation gpu_buffer;
|
||||
buffer_allocation host_buffer;
|
||||
vk::Buffer gpu_buffer = nullptr;
|
||||
|
||||
// parameters used for last computation
|
||||
struct P
|
||||
@@ -81,6 +83,8 @@ public:
|
||||
void update_foveation_center_override(const from_headset::override_foveation_center &);
|
||||
std::array<to_headset::foveation_parameter, 2> get_parameters();
|
||||
|
||||
vk::Buffer get_gpu_buffer();
|
||||
|
||||
vk::CommandBuffer update_foveation_buffer(
|
||||
vk::Buffer target,
|
||||
bool flip_y,
|
||||
|
||||
@@ -41,14 +41,13 @@ xrt_result_t wivrn_hmd::get_visibility_mask(xrt_visibility_mask_type type, uint3
|
||||
{
|
||||
static_assert(sizeof(uint32_t) == sizeof(decltype(from_headset::visibility_mask_changed::mask::indices)::value_type));
|
||||
static_assert(sizeof(xrt_vec2) == sizeof(decltype(from_headset::visibility_mask_changed::mask::vertices)::value_type));
|
||||
type = xrt_visibility_mask_type((unsigned int)type - 1); // enum values start at 1
|
||||
const auto visibility_mask = this->visibility_mask.lock();
|
||||
if (type >= from_headset::visibility_mask_changed::num_types or view_index >= 2 or not(*visibility_mask)[view_index])
|
||||
if (type > from_headset::visibility_mask_changed::num_types or view_index >= 2 or not(*visibility_mask)[view_index])
|
||||
{
|
||||
*mask = (xrt_visibility_mask *)calloc(1, sizeof(xrt_visibility_mask));
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
const auto & in_mask = (*(*visibility_mask)[view_index])[int(type)];
|
||||
const auto & in_mask = (*(*visibility_mask)[view_index])[int(type - 1)];
|
||||
size_t index_size = in_mask.indices.size() * sizeof(uint32_t);
|
||||
size_t vertex_size = in_mask.vertices.size() * sizeof(xrt_vec2);
|
||||
*mask = (xrt_visibility_mask *)calloc(1, sizeof(xrt_visibility_mask) + index_size + vertex_size);
|
||||
|
||||
@@ -338,7 +338,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
||||
self->feedback_csv.open(dump_file);
|
||||
}
|
||||
|
||||
self->thread = std::jthread(&wivrn_session::run, self.get());
|
||||
self->thread = std::jthread([s = self.get()](auto stop_token) { return s->run(stop_token); });
|
||||
*out_xsysd = self.release();
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -197,6 +197,10 @@ public:
|
||||
void operator()(to_monado::disconnect &&);
|
||||
void operator()(to_monado::set_bitrate &&);
|
||||
|
||||
bool has_stream()
|
||||
{
|
||||
return connection->has_stream();
|
||||
}
|
||||
template <typename T>
|
||||
void send_stream(T && packet)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "video_encoder.h"
|
||||
|
||||
#include "wivrn_packets.h"
|
||||
#include <charconv>
|
||||
#include <cmath>
|
||||
#include <magic_enum.hpp>
|
||||
#include <string>
|
||||
@@ -307,34 +308,22 @@ static std::vector<configuration::encoder> get_encoder_default_settings(wivrn_vk
|
||||
#ifdef WIVRN_SPLIT_ENCODERS
|
||||
if (base.name != encoder_x264)
|
||||
{
|
||||
/* Split in 3 parts:
|
||||
/* Split in 2 parts:
|
||||
* +--------+--------+
|
||||
* | | |
|
||||
* | | |
|
||||
* +--------+ |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | left | right |
|
||||
* | eye | eye |
|
||||
* | | |
|
||||
* +--------+--------+
|
||||
* All 3 are encoded sequentially, so that the smallest is ready earlier.
|
||||
* Encoded sequentially, so the first eye is ready and transmitted earlier.
|
||||
* Decoder can start work as fast as possible, reducing idle time.
|
||||
* Splitting on eye boundaries allows for fast-path on headset.
|
||||
*
|
||||
*/
|
||||
return {
|
||||
{
|
||||
.name = base.name,
|
||||
.width = 0.5,
|
||||
.height = 0.25,
|
||||
.group = 0,
|
||||
.codec = base.codec,
|
||||
},
|
||||
{
|
||||
.name = base.name,
|
||||
.width = 0.5,
|
||||
.height = 0.75,
|
||||
.offset_y = 0.25,
|
||||
.group = 0,
|
||||
.codec = base.codec,
|
||||
},
|
||||
|
||||
@@ -331,13 +331,15 @@ void video_encoder::SendData(std::span<uint8_t> data, bool end_of_frame, bool co
|
||||
timing_info.send_begin = clock.to_headset(os_monotonic_get_ns());
|
||||
}
|
||||
|
||||
ssize_t max_payload_size = cnx->has_stream() ? to_headset::video_stream_data_shard::max_payload_size : std::numeric_limits<uint32_t>::max();
|
||||
|
||||
shard.flags = to_headset::video_stream_data_shard::start_of_slice;
|
||||
auto begin = data.begin();
|
||||
auto end = data.end();
|
||||
while (begin != end)
|
||||
{
|
||||
const size_t max_payload_size = std::max(0z, ssize_t(to_headset::video_stream_data_shard::max_payload_size) - ssize_t(serialized_size(shard.view_info)));
|
||||
auto next = std::min(end, begin + max_payload_size);
|
||||
const size_t payload_size = std::max(0z, max_payload_size - ssize_t(serialized_size(shard.view_info)));
|
||||
auto next = std::min(end, begin + payload_size);
|
||||
if (next == end)
|
||||
{
|
||||
shard.flags |= to_headset::video_stream_data_shard::end_of_slice;
|
||||
|
||||
+49
-33
@@ -18,7 +18,6 @@
|
||||
#include "hostname.h"
|
||||
#include "protocol_version.h"
|
||||
#include "start_application.h"
|
||||
#include "utils/flatpak.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "version.h"
|
||||
#include "wivrn_config.h"
|
||||
@@ -128,46 +127,51 @@ int create_listen_socket()
|
||||
return fd;
|
||||
}
|
||||
|
||||
static std::filesystem::path flatpak_app_path()
|
||||
static bool pressure_vessel_openxr_support()
|
||||
{
|
||||
if (auto value = flatpak_key(flatpak::section::instance, "app-path"))
|
||||
auto pv_var = std::getenv("PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES");
|
||||
return pv_var and pv_var == std::string_view("1");
|
||||
}
|
||||
|
||||
static void append_delim(std::string & to, std::string_view what, char delim)
|
||||
{
|
||||
if (not to.empty())
|
||||
to += delim;
|
||||
to += what;
|
||||
}
|
||||
|
||||
// search for the directory in path named needle
|
||||
// with d = /a/b/c/d/e and needle = c
|
||||
// return /a/b/c
|
||||
// if it can't be found, return the full path
|
||||
static std::filesystem::path find_dir(const std::filesystem::path & d, const std::filesystem::path & needle)
|
||||
{
|
||||
for (auto copy = d; not copy.empty(); copy = copy.parent_path())
|
||||
{
|
||||
std::filesystem::path path = *value;
|
||||
while (path != "" and path != path.parent_path() and path.filename() != "io.github.wivrn.wivrn")
|
||||
path = path.parent_path();
|
||||
|
||||
return path;
|
||||
if (copy.filename() == needle)
|
||||
return copy;
|
||||
}
|
||||
|
||||
return "/";
|
||||
return d;
|
||||
}
|
||||
|
||||
static std::string steam_command()
|
||||
{
|
||||
std::string pressure_vessel_filesystems_rw = "$XDG_RUNTIME_DIR/" XRT_IPC_MSG_SOCK_FILENAME;
|
||||
std::string vr_override;
|
||||
std::string command;
|
||||
|
||||
// Check if in a flatpak
|
||||
if (is_flatpak())
|
||||
{
|
||||
std::string app_path = flatpak_app_path().string();
|
||||
// /usr and /var are remapped by steam
|
||||
if (app_path.starts_with("/var"))
|
||||
pressure_vessel_filesystems_rw += ":" + app_path;
|
||||
}
|
||||
else if (auto p = active_runtime::openvr_compat_path().string(); not p.empty())
|
||||
if (not pressure_vessel_openxr_support())
|
||||
command = "PRESSURE_VESSEL_IMPORT_OPENXR_1_RUNTIMES=1";
|
||||
|
||||
if (auto p = active_runtime::openvr_compat_path().string(); not p.empty())
|
||||
{
|
||||
// /usr cannot be shared in pressure vessel container
|
||||
if (p.starts_with("/usr"))
|
||||
vr_override = " VR_OVERRIDE=/run/host" + p;
|
||||
append_delim(command, " VR_OVERRIDE=/run/host" + p, ' ');
|
||||
else if (p.starts_with("/var"))
|
||||
pressure_vessel_filesystems_rw += ":" + p;
|
||||
append_delim(command, "PRESSURE_VESSEL_FILESYSTEMS_RW=" + find_dir(p, "io.github.wivrn.wivrn").string(), ' ');
|
||||
}
|
||||
|
||||
std::string command = "PRESSURE_VESSEL_FILESYSTEMS_RW=" + pressure_vessel_filesystems_rw + vr_override + " %command%";
|
||||
|
||||
if (auto p = active_runtime::manifest_path().string(); p.starts_with("/usr"))
|
||||
command = "XR_RUNTIME_JSON=/run/host" + p + " " + command;
|
||||
if (not command.empty())
|
||||
command += " %command%";
|
||||
|
||||
return command;
|
||||
}
|
||||
@@ -350,7 +354,7 @@ void start_publishing()
|
||||
sprintf(protocol_string, "%016" PRIx64, wivrn::protocol_version);
|
||||
std::map<std::string, std::string> TXT = {
|
||||
{"protocol", protocol_string},
|
||||
{"version", wivrn::git_version},
|
||||
{"version", wivrn::display_version()},
|
||||
{"cookie", server_cookie()},
|
||||
};
|
||||
publisher.emplace(poll_api, hostname(), "_wivrn._tcp", wivrn::default_port, TXT);
|
||||
@@ -435,7 +439,7 @@ gboolean headset_connected_success(void *)
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::cerr << "Failed to start application: " << e.what();
|
||||
std::cerr << "Failed to start application: " << e.what() << std::endl;
|
||||
}
|
||||
|
||||
delay_next_try = default_delay_next_try;
|
||||
@@ -688,14 +692,18 @@ void on_json_configuration(WivrnServer * server, const GParamSpec * pspec, gpoin
|
||||
std::filesystem::path config_new = config;
|
||||
config_new += ".new";
|
||||
|
||||
std::ofstream file(config_new);
|
||||
file.write(json, strlen(json));
|
||||
{
|
||||
std::ofstream file(config_new);
|
||||
file.write(json, strlen(json));
|
||||
}
|
||||
|
||||
std::error_code ec;
|
||||
std::filesystem::rename(config_new, config, ec);
|
||||
|
||||
if (ec)
|
||||
std::cerr << "Failed to save configuration: " << ec.message() << std::endl;
|
||||
|
||||
wivrn_server_set_steam_command(dbus_server, steam_command().c_str());
|
||||
}
|
||||
|
||||
void expose_known_keys_on_dbus()
|
||||
@@ -881,10 +889,11 @@ auto create_dbus_connection()
|
||||
|
||||
int inner_main(int argc, char * argv[], bool show_instructions)
|
||||
{
|
||||
std::cerr << "WiVRn " << wivrn::git_version << " starting" << std::endl;
|
||||
std::cerr << "WiVRn " << wivrn::display_version() << " starting" << std::endl;
|
||||
if (show_instructions)
|
||||
{
|
||||
std::cerr << "For Steam games, set command to " << steam_command() << std::endl;
|
||||
if (auto command = steam_command(); not command.empty())
|
||||
std::cerr << "For Steam games, set command to " << command << std::endl;
|
||||
}
|
||||
|
||||
std::filesystem::create_directories(socket_path().parent_path());
|
||||
@@ -974,6 +983,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
std::string config_file;
|
||||
app.add_option("-f", config_file, "configuration file")->option_text("FILE")->check(CLI::ExistingFile);
|
||||
auto version_flag = app.add_flag("--version")->description("print version and exit");
|
||||
auto no_active_runtime = app.add_flag("--no-manage-active-runtime")->description("don't set the active runtime on connection");
|
||||
auto early_active_runtime = app.add_flag("--early-active-runtime")->description("forcibly manages the active runtime even if no headset present");
|
||||
auto no_instructions = app.add_flag("--no-instructions")->group("");
|
||||
@@ -986,6 +996,12 @@ int main(int argc, char * argv[])
|
||||
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
if (*version_flag)
|
||||
{
|
||||
std::cout << "WiVRn version " << wivrn::display_version() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (not config_file.empty())
|
||||
configuration::set_config_file(config_file);
|
||||
|
||||
|
||||
@@ -83,16 +83,17 @@ wivrn::wivrn_vk_bundle::wivrn_vk_bundle(vk_bundle & vk, std::span<const char *>
|
||||
physical_device(instance, vk.physical_device),
|
||||
device(physical_device, vk.device),
|
||||
allocator({
|
||||
.physicalDevice = vk.physical_device,
|
||||
.device = vk.device,
|
||||
.instance = vk.instance,
|
||||
.vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp
|
||||
}),
|
||||
queue(device, vk.queue_family_index, vk.queue_index),
|
||||
queue_family_index(vk.queue_family_index),
|
||||
.physicalDevice = vk.physical_device,
|
||||
.device = vk.device,
|
||||
.instance = vk.instance,
|
||||
.vulkanApiVersion = VK_MAKE_VERSION(1, 3, 0), // FIXME: sync with wivrn_session.cpp
|
||||
},
|
||||
vk.has_EXT_debug_utils),
|
||||
queue(device, vk.main_queue.family_index, vk.main_queue.index),
|
||||
queue_family_index(vk.main_queue.family_index),
|
||||
#ifdef VK_KHR_video_encode_queue
|
||||
encode_queue(make_queue(device, vk.encode_queue, vk.encode_queue_family_index, vk.encode_queue_index)),
|
||||
encode_queue_family_index(vk.encode_queue_family_index),
|
||||
encode_queue(make_queue(device, vk.encode_queue.queue, vk.encode_queue.family_index, vk.encode_queue.index)),
|
||||
encode_queue_family_index(vk.encode_queue.family_index),
|
||||
#else
|
||||
encode_queue(nullptr),
|
||||
encode_queue_family_index(vk::QueueFamilyIgnored),
|
||||
|
||||
Reference in New Issue
Block a user