Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55fabe839b | ||
|
|
36a0377dc8 | ||
|
|
fb7703cb76 | ||
|
|
6dedfda0f9 | ||
|
|
456d65ef8c | ||
|
|
902a665c36 | ||
|
|
ae000d5163 | ||
|
|
a491561271 | ||
|
|
78d7fc40f2 | ||
|
|
7164a7dbeb | ||
|
|
45907329c7 | ||
|
|
64093238d3 | ||
|
|
515010aeab | ||
|
|
accac9b150 | ||
|
|
caa191ff06 | ||
|
|
4dbb506df0 | ||
|
|
78addc1f22 | ||
|
|
26f21348f3 | ||
|
|
7d9031e843 | ||
|
|
79df7370f3 | ||
|
|
13e4105bcd | ||
|
|
2b7409b363 | ||
|
|
2cf80c9a88 | ||
|
|
b3b2c49da4 | ||
|
|
13a94f3dec | ||
|
|
d7174dcefa | ||
|
|
94ef8945cc | ||
|
|
324aec8c6b | ||
|
|
02d06562a6 | ||
|
|
9690633030 |
@@ -141,6 +141,8 @@ jobs:
|
||||
-DFETCHCONTENT_BASE_DIR=${{github.workspace}}/cmake-fetch
|
||||
--preset dashboard
|
||||
-DWIVRN_USE_SYSTEM_OPENXR=OFF
|
||||
-DGIT_DESC=${{github.sha}}
|
||||
-DGIT_COMMIT=${{github.sha}}
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
|
||||
+14
-4
@@ -177,10 +177,6 @@ if (WIVRN_BUILD_DASHBOARD)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml)
|
||||
qcoro_enable_coroutines()
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
endif()
|
||||
|
||||
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
|
||||
@@ -282,6 +278,20 @@ FetchContent_Declare(monado
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
add_custom_target(wivrn-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/common/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_BINARY_DIR}/version.cpp
|
||||
-D INPUT_FILE_1=${CMAKE_CURRENT_SOURCE_DIR}/server/u_git_tag.cpp.in
|
||||
-D OUTPUT_FILE_1=${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
-D GIT_DESC="${GIT_DESC}"
|
||||
-D GIT_COMMIT="${GIT_COMMIT}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/version.cpp ${CMAKE_BINARY_DIR}/u_git_tag.cpp
|
||||
SOURCES common/version.cpp.in server/u_git_tag.cpp.in
|
||||
)
|
||||
|
||||
add_subdirectory(external)
|
||||
if (NEED_COMMON)
|
||||
add_subdirectory(common)
|
||||
|
||||
@@ -180,6 +180,15 @@ If the server list is empty in the headset app:
|
||||
|
||||
Note: WiVRn isn't properly optimized for NVIDIA GPUs due to the lack of developers with NVIDIA hardware. Motion latency may be significantly worse at rendering resolutions higher than default.</details>
|
||||
|
||||
# Community Support
|
||||
|
||||
We are available on either **Discord** or **Matrix space**:
|
||||
|
||||
[](https://discord.gg/EHAYe3tTYa) [](https://matrix.to/#/#linux-vr-adventures:matrix.org)
|
||||
|
||||
Please use the `wivrn` chat room for questions or issues specific to WiVRn.
|
||||
|
||||
|
||||
# Contributing
|
||||
|
||||
## Translations
|
||||
|
||||
+80
-47
@@ -322,6 +322,9 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
self->network_session->send_control(from_headset::session_state_changed{
|
||||
.state = application::get_session_state(),
|
||||
});
|
||||
self->network_session->send_control(from_headset::stream_tab_changed{
|
||||
.tab = self->gui_status,
|
||||
});
|
||||
|
||||
if (self->instance.has_extension(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME))
|
||||
{
|
||||
@@ -678,13 +681,43 @@ std::shared_ptr<shard_accumulator::blit_handle> scenes::stream::accumulator_imag
|
||||
|
||||
void scenes::stream::update_gui_position(xr::spaces controller)
|
||||
{
|
||||
auto aim = application::locate_controller(
|
||||
application::space(controller),
|
||||
application::space(xr::spaces::view),
|
||||
predicted_display_time);
|
||||
std::optional<std::pair<glm::vec3, glm::quat>> aim;
|
||||
|
||||
if (not aim)
|
||||
return;
|
||||
switch (guess_model())
|
||||
{
|
||||
case model::pico_4:
|
||||
case model::pico_4s:
|
||||
case model::pico_4_pro:
|
||||
case model::pico_4_enterprise: {
|
||||
// Pico fails to find its controllers within view space, so use the head position in
|
||||
// world space as a reference
|
||||
aim = application::locate_controller(
|
||||
application::space(controller),
|
||||
application::space(xr::spaces::world),
|
||||
predicted_display_time);
|
||||
|
||||
auto head_position = application::locate_controller(application::space(xr::spaces::view),
|
||||
application::space(xr::spaces::world),
|
||||
predicted_display_time);
|
||||
if (not aim || not head_position)
|
||||
return;
|
||||
|
||||
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
|
||||
aim->second = glm::conjugate(head_position->second) * aim->second;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
aim = application::locate_controller(
|
||||
application::space(controller),
|
||||
application::space(xr::spaces::view),
|
||||
predicted_display_time);
|
||||
|
||||
if (not aim)
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
auto [offset_position, offset_orientation] = input->offset[controller];
|
||||
|
||||
@@ -729,26 +762,30 @@ void scenes::stream::update_gui_position(xr::spaces controller)
|
||||
}
|
||||
}
|
||||
|
||||
bool scenes::stream::is_gui_interactable() const
|
||||
bool scenes::stream::is_interactable(stream_tab tab)
|
||||
{
|
||||
switch (gui_status)
|
||||
switch (tab)
|
||||
{
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
return true;
|
||||
|
||||
case gui_status::hidden:
|
||||
case gui_status::overlay_only:
|
||||
case gui_status::compact:
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::overlay_only:
|
||||
case stream_tab::compact:
|
||||
return false;
|
||||
}
|
||||
spdlog::warn("Invalid tab value {}", int(tab));
|
||||
return false;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
__builtin_unreachable();
|
||||
bool scenes::stream::is_gui_interactable() const
|
||||
{
|
||||
return is_interactable(gui_status);
|
||||
}
|
||||
|
||||
void scenes::stream::render(const XrFrameState & frame_state)
|
||||
@@ -778,7 +815,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
.variant = application::get_messages_info().variant,
|
||||
});
|
||||
|
||||
gui_status = stream::gui_status::hidden;
|
||||
next_gui_status = stream_tab::hidden;
|
||||
application::pop_scene();
|
||||
}
|
||||
|
||||
@@ -1014,17 +1051,17 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
{
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::compact:
|
||||
case gui_status::overlay_only:
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
case stream_tab::compact:
|
||||
case stream_tab::overlay_only:
|
||||
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
|
||||
break;
|
||||
}
|
||||
@@ -1105,23 +1142,14 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
|
||||
if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync))
|
||||
{
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::compact:
|
||||
case gui_status::overlay_only:
|
||||
gui_status = next_gui_status;
|
||||
break;
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
gui_status = gui_status::hidden;
|
||||
break;
|
||||
}
|
||||
// Arbitraty transitions can happen from network commands
|
||||
// Ensure we can't have a set of 2 non interactable states
|
||||
if (is_gui_interactable())
|
||||
next_gui_status = stream_tab::hidden;
|
||||
else if (is_interactable(stored_gui_status))
|
||||
next_gui_status = stored_gui_status;
|
||||
else
|
||||
next_gui_status = stream_tab::applications;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1137,8 +1165,10 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
{
|
||||
session.set_refresh_rate(description.fps);
|
||||
|
||||
spdlog::info("Creating decoders, size {}x{}", description.width, description.height);
|
||||
std::unique_lock lock(decoder_mutex);
|
||||
if (video_stream_description == description)
|
||||
return;
|
||||
spdlog::info("Creating decoders, size {}x{}", description.width, description.height);
|
||||
video_stream_description = description;
|
||||
|
||||
for (const auto & [stream_index, item]: utils::enumerate(decoders))
|
||||
@@ -1147,6 +1177,9 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, description, shared_from_this(), stream_index),
|
||||
};
|
||||
}
|
||||
|
||||
if (defoveator)
|
||||
defoveator->reset_pipelines();
|
||||
}
|
||||
|
||||
void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint32_t swapchain_height)
|
||||
|
||||
+8
-16
@@ -131,30 +131,21 @@ private:
|
||||
uint32_t height;
|
||||
|
||||
std::optional<imgui_context> imgui_ctx;
|
||||
enum class gui_status
|
||||
{
|
||||
hidden,
|
||||
overlay_only,
|
||||
compact,
|
||||
stats,
|
||||
settings,
|
||||
bitrate_settings,
|
||||
foveation_settings,
|
||||
applications,
|
||||
application_launcher,
|
||||
};
|
||||
|
||||
struct gui_toast
|
||||
{
|
||||
std::string content;
|
||||
bool is_urgent = false;
|
||||
};
|
||||
|
||||
static bool is_interactable(stream_tab);
|
||||
bool is_gui_interactable() const;
|
||||
|
||||
std::atomic<gui_status> gui_status = gui_status::hidden;
|
||||
enum gui_status last_gui_status = gui_status::hidden;
|
||||
enum gui_status next_gui_status = gui_status::applications;
|
||||
// Tab currently being displayed
|
||||
stream_tab gui_status = stream_tab::hidden;
|
||||
// Tab that we will switch to if button is pressed
|
||||
stream_tab stored_gui_status = stream_tab::applications;
|
||||
// Tab that will be displayed on next render()
|
||||
std::atomic<stream_tab> next_gui_status = stream_tab::hidden;
|
||||
float dimming = 0;
|
||||
|
||||
thread_safe<std::optional<gui_toast>> gui_toast;
|
||||
@@ -227,6 +218,7 @@ public:
|
||||
void operator()(to_headset::audio_stream_description &&);
|
||||
void operator()(to_headset::video_stream_description &&);
|
||||
void operator()(to_headset::refresh_rate_change &&);
|
||||
void operator()(to_headset::stream_tab_change &&);
|
||||
void operator()(to_headset::application_list &&);
|
||||
void operator()(to_headset::application_icon &&);
|
||||
void operator()(to_headset::running_applications &&);
|
||||
|
||||
@@ -283,6 +283,14 @@ stream_defoveator::stream_defoveator(
|
||||
}
|
||||
}
|
||||
|
||||
void stream_defoveator::reset_pipelines()
|
||||
{
|
||||
for (auto & p: pipeline_rgb)
|
||||
p = {};
|
||||
for (auto & p: pipeline_a)
|
||||
p = {};
|
||||
}
|
||||
|
||||
static size_t required_vertices(const wivrn::to_headset::foveation_parameter & p)
|
||||
{
|
||||
// strips are constructed like this:
|
||||
|
||||
@@ -81,6 +81,8 @@ public:
|
||||
|
||||
stream_defoveator(const stream_defoveator &) = delete;
|
||||
|
||||
void reset_pipelines();
|
||||
|
||||
void defoveate(
|
||||
vk::raii::CommandBuffer & command_buffer,
|
||||
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
|
||||
|
||||
@@ -462,7 +462,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
ImGui::SameLine(0.f, 10.f);
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (size.y / 4.f) - style.FramePadding.y * 3.f);
|
||||
if (ImGui::Button(fmt::format("{}Mbit/s", config.bitrate_bps / 1'000'000).c_str()))
|
||||
gui_status = gui_status::bitrate_settings;
|
||||
next_gui_status = stream_tab::bitrate_settings;
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
if (ImGui::IsItemHovered())
|
||||
imgui_ctx->tooltip(_("Click to adjust bitrate"));
|
||||
@@ -554,7 +554,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(_S("Change")))
|
||||
gui_status = gui_status::foveation_settings;
|
||||
next_gui_status = stream_tab::foveation_settings;
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
ImGui::EndDisabled();
|
||||
@@ -600,7 +600,7 @@ void scenes::stream::gui_bitrate_settings(float predicted_display_period)
|
||||
if (ok)
|
||||
{
|
||||
config.save();
|
||||
gui_status = gui_status::settings;
|
||||
next_gui_status = stream_tab::settings;
|
||||
}
|
||||
|
||||
send_settings_changed_packet(session, network_session.get(), application::get_config(), predicted_display_period);
|
||||
@@ -629,7 +629,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
|
||||
if (ok)
|
||||
{
|
||||
gui_status = gui_status::settings;
|
||||
next_gui_status = stream_tab::settings;
|
||||
|
||||
// Save settings
|
||||
auto & config = application::get_config();
|
||||
@@ -640,7 +640,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
|
||||
}
|
||||
else if (cancel)
|
||||
{
|
||||
gui_status = gui_status::settings;
|
||||
next_gui_status = stream_tab::settings;
|
||||
|
||||
// Restore settings
|
||||
const auto & config = application::get_config();
|
||||
@@ -744,25 +744,43 @@ void scenes::stream::gui_toasts()
|
||||
|
||||
void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period)
|
||||
{
|
||||
if (not(plots_toggle_1 and plots_toggle_2))
|
||||
return;
|
||||
if (auto new_status = next_gui_status.load(); new_status != gui_status)
|
||||
{
|
||||
spdlog::info("Switch tab from {} to {}", magic_enum::enum_name(gui_status), magic_enum::enum_name(new_status));
|
||||
stored_gui_status = gui_status;
|
||||
gui_status = new_status;
|
||||
gui_status_last_change = predicted_display_time;
|
||||
|
||||
// Override session state if the GUI is interactable
|
||||
if (not is_gui_interactable())
|
||||
network_session->send_control(from_headset::session_state_changed{
|
||||
.state = application::get_session_state(),
|
||||
});
|
||||
else if (application::get_session_state() == XR_SESSION_STATE_FOCUSED)
|
||||
network_session->send_control(from_headset::session_state_changed{
|
||||
.state = XR_SESSION_STATE_VISIBLE,
|
||||
});
|
||||
|
||||
network_session->send_control(from_headset::stream_tab_changed{.tab = new_status});
|
||||
}
|
||||
|
||||
bool interactable = true;
|
||||
XrSpace world_space = application::space(xr::spaces::world);
|
||||
auto views = session.locate_views(viewconfig, predicted_display_time, world_space).second;
|
||||
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case gui_status::overlay_only:
|
||||
case gui_status::compact:
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
case stream_tab::overlay_only:
|
||||
case stream_tab::compact:
|
||||
interactable = false;
|
||||
break;
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
break;
|
||||
}
|
||||
imgui_ctx->set_controllers_enabled(interactable);
|
||||
@@ -782,27 +800,9 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
right_hand.reset();
|
||||
}
|
||||
|
||||
if (gui_status != last_gui_status)
|
||||
{
|
||||
last_gui_status = gui_status;
|
||||
if (is_gui_interactable())
|
||||
next_gui_status = gui_status;
|
||||
gui_status_last_change = predicted_display_time;
|
||||
|
||||
// Override session state if the GUI is interactable
|
||||
if (not is_gui_interactable())
|
||||
network_session->send_control(from_headset::session_state_changed{
|
||||
.state = application::get_session_state(),
|
||||
});
|
||||
else if (application::get_session_state() == XR_SESSION_STATE_FOCUSED)
|
||||
network_session->send_control(from_headset::session_state_changed{
|
||||
.state = XR_SESSION_STATE_VISIBLE,
|
||||
});
|
||||
}
|
||||
|
||||
float alpha = 1;
|
||||
bool is_urgent = false;
|
||||
if (gui_status == gui_status::hidden)
|
||||
if (gui_status == stream_tab::hidden)
|
||||
{
|
||||
auto toast = gui_toast.lock();
|
||||
if (toast->has_value())
|
||||
@@ -827,24 +827,24 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
glm::mat3 M = glm::mat3_cast(head_position->second);
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
imgui_ctx->layers()[0].orientation = head_position->second;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
|
||||
break;
|
||||
|
||||
case gui_status::hidden:
|
||||
case stream_tab::hidden:
|
||||
// Always use the same position for the GUI shortcut tip
|
||||
imgui_ctx->layers()[0].orientation = head_position->second;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0.0, -0.4, -1.0};
|
||||
break;
|
||||
|
||||
case gui_status::overlay_only:
|
||||
case gui_status::compact:
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::overlay_only:
|
||||
case stream_tab::compact:
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
case stream_tab::application_launcher:
|
||||
imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation;
|
||||
imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position;
|
||||
break;
|
||||
@@ -864,36 +864,36 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
bool display_tabs, always_auto_resize;
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::overlay_only:
|
||||
case stream_tab::overlay_only:
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::SetNextWindowSize(content_size);
|
||||
always_auto_resize = false;
|
||||
display_tabs = false;
|
||||
break;
|
||||
|
||||
case gui_status::hidden:
|
||||
case gui_status::bitrate_settings:
|
||||
case gui_status::foveation_settings:
|
||||
case stream_tab::hidden:
|
||||
case stream_tab::bitrate_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
ImGui::SetNextWindowPos(viewport_size / 2, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
always_auto_resize = true;
|
||||
display_tabs = false;
|
||||
break;
|
||||
|
||||
case gui_status::compact:
|
||||
case stream_tab::compact:
|
||||
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
always_auto_resize = true;
|
||||
display_tabs = false;
|
||||
break;
|
||||
|
||||
case gui_status::stats:
|
||||
case gui_status::settings:
|
||||
case gui_status::applications:
|
||||
case stream_tab::stats:
|
||||
case stream_tab::settings:
|
||||
case stream_tab::applications:
|
||||
ImGui::SetNextWindowPos(margin_around_window);
|
||||
ImGui::SetNextWindowSize(viewport_size - margin_around_window * 2);
|
||||
always_auto_resize = false;
|
||||
display_tabs = true;
|
||||
break;
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::application_launcher:
|
||||
ImGui::SetNextWindowPos(margin_around_window);
|
||||
ImGui::SetNextWindowSize(viewport_size - margin_around_window * 2);
|
||||
always_auto_resize = false;
|
||||
@@ -930,53 +930,53 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
|
||||
switch (gui_status)
|
||||
{
|
||||
case gui_status::hidden:
|
||||
case stream_tab::hidden:
|
||||
gui_toasts();
|
||||
break;
|
||||
|
||||
case gui_status::overlay_only:
|
||||
case stream_tab::overlay_only:
|
||||
ImGui::SetCursorPos({20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_performance_metrics();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::compact:
|
||||
case stream_tab::compact:
|
||||
gui_compact_view();
|
||||
break;
|
||||
|
||||
case gui_status::stats:
|
||||
case stream_tab::stats:
|
||||
ImGui::SetCursorPos({tab_width + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_performance_metrics();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::settings:
|
||||
case stream_tab::settings:
|
||||
ImGui::SetCursorPos({tab_width + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_settings(predicted_display_period * 1.e-9f);
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::bitrate_settings:
|
||||
case stream_tab::bitrate_settings:
|
||||
gui_bitrate_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
|
||||
case gui_status::foveation_settings:
|
||||
case stream_tab::foveation_settings:
|
||||
gui_foveation_settings(predicted_display_period * 1.e-9f);
|
||||
break;
|
||||
|
||||
case gui_status::applications:
|
||||
case stream_tab::applications:
|
||||
ImGui::SetCursorPos({tab_width + 20, 20});
|
||||
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
|
||||
gui_applications();
|
||||
ImGui::EndChild();
|
||||
break;
|
||||
|
||||
case gui_status::application_launcher:
|
||||
case stream_tab::application_launcher:
|
||||
if (apps.draw_gui(*imgui_ctx, _("Cancel")) != app_launcher::None)
|
||||
gui_status = gui_status::applications;
|
||||
next_gui_status = stream_tab::applications;
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding
|
||||
@@ -990,10 +990,11 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_LIST " " + _("Applications"), gui_status, gui_status::applications, {tab_width, 0});
|
||||
auto target = gui_status;
|
||||
RadioButtonWithoutCheckBox(ICON_FA_LIST " " + _("Applications"), target, stream_tab::applications, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
if (RadioButtonWithoutCheckBox(ICON_FA_ROCKET " " + _("Start"), gui_status, gui_status::application_launcher, {tab_width, 0}))
|
||||
if (RadioButtonWithoutCheckBox(ICON_FA_ROCKET " " + _("Start"), target, stream_tab::application_launcher, {tab_width, 0}))
|
||||
{
|
||||
apps.reset();
|
||||
network_session->send_control(from_headset::get_application_list{
|
||||
@@ -1004,22 +1005,22 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
}
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), gui_status, gui_status::settings, {tab_width, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), target, stream_tab::settings, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), gui_status, gui_status::stats, {tab_width, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), target, stream_tab::stats, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
int n_items_at_end = 4;
|
||||
ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - n_items_at_end * ImGui::GetCurrentContext()->FontSize - (n_items_at_end * 2) * style.FramePadding.y - (n_items_at_end - 1) * style.ItemSpacing.y - style.WindowPadding.y);
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_CHART_LINE " " + _("Statistics overlay"), gui_status, gui_status::overlay_only, {tab_width, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_CHART_LINE " " + _("Statistics overlay"), target, stream_tab::overlay_only, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_MINIMIZE " " + _("Compact view"), gui_status, gui_status::compact, {tab_width, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_MINIMIZE " " + _("Compact view"), target, stream_tab::compact, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
RadioButtonWithoutCheckBox(ICON_FA_XMARK " " + _("Close"), gui_status, gui_status::hidden, {tab_width, 0});
|
||||
RadioButtonWithoutCheckBox(ICON_FA_XMARK " " + _("Close"), target, stream_tab::hidden, {tab_width, 0});
|
||||
imgui_ctx->vibrate_on_hover();
|
||||
|
||||
bool dummy = false;
|
||||
@@ -1029,6 +1030,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
|
||||
|
||||
ImGui::PopStyleVar(); // ImGuiStyleVar_FramePadding
|
||||
ImGui::EndChild();
|
||||
next_gui_status = target;
|
||||
}
|
||||
ImGui::PopStyleColor(); // ImGuiCol_ChildBg
|
||||
}
|
||||
|
||||
@@ -117,6 +117,11 @@ void scenes::stream::operator()(to_headset::refresh_rate_change && rate)
|
||||
video_stream_description->fps = rate.fps;
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::stream_tab_change && tab)
|
||||
{
|
||||
next_gui_status = tab.tab;
|
||||
}
|
||||
|
||||
void scenes::stream::operator()(to_headset::timesync_query && query)
|
||||
{
|
||||
network_session->send_stream(from_headset::timesync_response{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
function(add_file_to_target TARGET OUTPUT_FILE)
|
||||
string(REPLACE "/" "_" TARGET_SUFFIX ${OUTPUT_FILE})
|
||||
file(RELATIVE_PATH TARGET_SUFFIX "${CMAKE_SOURCE_DIR}" "${OUTPUT_FILE}")
|
||||
string(REPLACE "/" "_" TARGET_SUFFIX "${TARGET_SUFFIX}")
|
||||
|
||||
add_custom_target(${TARGET}-${TARGET_SUFFIX} ALL DEPENDS ${OUTPUT_FILE})
|
||||
add_dependencies(${TARGET} ${TARGET}-${TARGET_SUFFIX})
|
||||
|
||||
@@ -20,15 +20,14 @@ if (NOT GIT_COMMIT)
|
||||
endif()
|
||||
|
||||
if (NOT GIT_DESC)
|
||||
set(GIT_DESC v${CMAKE_PROJECT_VERSION})
|
||||
message(STATUS "Setting version to ${GIT_DESC} from CMakeLists")
|
||||
message(FATAL_ERROR "GIT_DESC cannot be inferred from .git and was not provided at build time")
|
||||
endif()
|
||||
|
||||
if (GIT_COMMIT)
|
||||
message(STATUS "Setting commit to ${GIT_COMMIT}")
|
||||
else()
|
||||
set(GIT_COMMIT "")
|
||||
message(STATUS "Not setting commit")
|
||||
message(FATAL_ERROR "GIT_COMMIT cannot be inferred from .git and was not provided at build time")
|
||||
endif()
|
||||
|
||||
configure_file(${INPUT_FILE} ${OUTPUT_FILE})
|
||||
configure_file(${INPUT_FILE_1} ${OUTPUT_FILE_1})
|
||||
|
||||
+1
-14
@@ -5,25 +5,12 @@ else()
|
||||
FetchContent_MakeAvailable(boost)
|
||||
endif()
|
||||
|
||||
add_custom_target(wivrn-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
-D OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
-D CMAKE_PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
|
||||
-D GIT_DESC="${GIT_DESC}"
|
||||
-D GIT_COMMIT="${GIT_COMMIT}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
|
||||
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
|
||||
)
|
||||
|
||||
configure_file(wivrn_config.h.in wivrn_config.h)
|
||||
|
||||
add_library(wivrn-common-base STATIC EXCLUDE_FROM_ALL
|
||||
utils/strings.cpp
|
||||
utils/xdg_base_directory.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
|
||||
${CMAKE_BINARY_DIR}/version.cpp
|
||||
)
|
||||
|
||||
add_library(wivrn-common STATIC EXCLUDE_FROM_ALL
|
||||
|
||||
@@ -173,6 +173,19 @@ enum video_codec
|
||||
raw,
|
||||
};
|
||||
|
||||
enum class stream_tab : uint8_t
|
||||
{
|
||||
hidden,
|
||||
overlay_only,
|
||||
compact,
|
||||
stats,
|
||||
settings,
|
||||
bitrate_settings,
|
||||
foveation_settings,
|
||||
applications,
|
||||
application_launcher,
|
||||
};
|
||||
|
||||
struct audio_data
|
||||
{
|
||||
XrTime timestamp;
|
||||
@@ -512,6 +525,11 @@ struct user_presence_changed
|
||||
bool present;
|
||||
};
|
||||
|
||||
struct stream_tab_changed
|
||||
{
|
||||
stream_tab tab;
|
||||
};
|
||||
|
||||
struct override_foveation_center
|
||||
{
|
||||
bool enabled;
|
||||
@@ -565,6 +583,7 @@ using packets = std::variant<
|
||||
refresh_rate_changed,
|
||||
session_state_changed,
|
||||
user_presence_changed,
|
||||
stream_tab_changed,
|
||||
override_foveation_center,
|
||||
get_application_list,
|
||||
start_app,
|
||||
@@ -659,6 +678,8 @@ struct video_stream_description
|
||||
uint16_t height;
|
||||
std::array<video_codec, 3> codec; // left, right, alpha
|
||||
float fps;
|
||||
|
||||
bool operator==(const video_stream_description &) const = default;
|
||||
};
|
||||
|
||||
class video_stream_data_shard
|
||||
@@ -746,6 +767,11 @@ struct refresh_rate_change
|
||||
float fps;
|
||||
};
|
||||
|
||||
struct stream_tab_change
|
||||
{
|
||||
stream_tab tab;
|
||||
};
|
||||
|
||||
struct application_list
|
||||
{
|
||||
std::string language;
|
||||
@@ -792,6 +818,7 @@ using packets = std::variant<
|
||||
tracking_control,
|
||||
feature_control,
|
||||
refresh_rate_change,
|
||||
stream_tab_change,
|
||||
application_list,
|
||||
application_icon,
|
||||
running_applications>;
|
||||
|
||||
@@ -7,6 +7,10 @@ include(I18n)
|
||||
ecm_find_qmlmodule(org.kde.kirigami REQUIRED)
|
||||
ecm_find_qmlmodule(org.kde.kirigamiaddons.formcard REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
add_executable(wivrn-dashboard
|
||||
avahi.cpp
|
||||
main.cpp
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
<property name="PairingEnabled" type="b" access="read"/>
|
||||
<property name="EncryptionEnabled" type="b" access="read"/>
|
||||
|
||||
<property name="ClientTab" type="s" access="read"/>
|
||||
<method name="SetClientTab">
|
||||
<arg type="s" name="Tab"/>
|
||||
</method>
|
||||
|
||||
<signal name="ServerError">
|
||||
<arg type="s" name="where"/>
|
||||
<arg type="s" name="message"/>
|
||||
|
||||
@@ -58,12 +58,16 @@
|
||||
# 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-aIHry5C30pZVIkB5fptJ0Ncbmg8EKf0M7evB4IJZEI0=";
|
||||
hash = "sha256-M0SQMu1rgY++a+4r0DK//ralFEO5w7I3UrgLecoLO+A=";
|
||||
};
|
||||
};
|
||||
|
||||
buildInputs = oldAttrs.buildInputs ++ extraBuildInputs;
|
||||
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ extraNativeBuildInputs;
|
||||
cmakeFlags = (oldAttrs.cmakeFlags or []) ++ [
|
||||
(lib.cmakeFeature "GIT_DESC" "nightly")
|
||||
(lib.cmakeFeature "GIT_COMMIT" "nightly")
|
||||
];
|
||||
}));
|
||||
in {
|
||||
packages = {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
ee655a920cb4b50bafa2af2c92333a503e40cae6
|
||||
ef152c973b94a313e1ba9552162818b5151ac671
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 563f347bf4d59b4a82144e25c3be894a0cd17c8d Mon Sep 17 00:00:00 2001
|
||||
From 6317d6556f2510cc63aa5f71d86585830a38b2a1 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 22 Oct 2024 15:23:19 +0200
|
||||
Subject: [PATCH 1/9] c/multi: early wake of compositor
|
||||
@@ -10,7 +10,7 @@ Subject: [PATCH 1/9] c/multi: early wake of compositor
|
||||
3 files changed, 41 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/multi/comp_multi_compositor.c b/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
index 94cea110e..88347a092 100644
|
||||
index 1fc135ce4..25b64aca8 100644
|
||||
--- a/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
+++ b/src/xrt/compositor/multi/comp_multi_compositor.c
|
||||
@@ -236,7 +236,21 @@ wait_for_scheduled_free(struct multi_compositor *mc)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 7d7c139b9ed03ec492256760c6acd1c7364c2e2a Mon Sep 17 00:00:00 2001
|
||||
From 71b4f13a8b7cb90edf83f75bef8459d2db66c386 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Tue, 8 Oct 2024 22:13:15 +0200
|
||||
Subject: [PATCH 2/9] Use extern socket fd
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 1328192bc28f312e728460d6c29ab150a9b655bd Mon Sep 17 00:00:00 2001
|
||||
From d3fc5ebb88a59ce5fc1120ed33de921eec03384f Mon Sep 17 00:00:00 2001
|
||||
From: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
|
||||
Date: Sat, 23 Nov 2024 02:42:12 +0900
|
||||
Subject: [PATCH 3/9] change environment blend mode selection logic
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 18f87ff2f292e2f4cab8718601e6d5ba236a5013 Mon Sep 17 00:00:00 2001
|
||||
From 42e1e561a98f5c9fd6f757232bd4821124ae9bb3 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Sat, 15 Mar 2025 22:19:48 +0100
|
||||
Subject: [PATCH 4/9] st/oxr: forward 0 refresh rate
|
||||
@@ -9,10 +9,10 @@ Subject: [PATCH 4/9] st/oxr: forward 0 refresh rate
|
||||
2 files changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c
|
||||
index b6c4947bf..0e8ed02b7 100644
|
||||
index 3364aaead..deec90a73 100644
|
||||
--- a/src/xrt/compositor/main/comp_compositor.c
|
||||
+++ b/src/xrt/compositor/main/comp_compositor.c
|
||||
@@ -372,7 +372,7 @@ compositor_request_display_refresh_rate(struct xrt_compositor *xc, float display
|
||||
@@ -377,7 +377,7 @@ compositor_request_display_refresh_rate(struct xrt_compositor *xc, float display
|
||||
if (c->target && c->target->request_refresh_rate) {
|
||||
xrt_result_t result = comp_target_request_refresh_rate(c->target, display_refresh_rate_hz);
|
||||
// Assume refresh rate change is immediate
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 8c322edfafa6179875bfe1dca1517c4043f0c5b4 Mon Sep 17 00:00:00 2001
|
||||
From 4b5685fc3177fd2f54996e0a87c1efe985db9c7b Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Nicolas <patricknicolas@laposte.net>
|
||||
Date: Wed, 11 Sep 2024 22:56:29 +0200
|
||||
Subject: [PATCH 5/9] Replace distortion with foveation
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From b9acd6d83db324c6f31572615fb6738a6f93d63c Mon Sep 17 00:00:00 2001
|
||||
From 5664ae214c09deb241507526e749f83f3a16298c Mon Sep 17 00:00:00 2001
|
||||
From: no name <git-am@invalid>
|
||||
Date: Sun, 28 Sep 2025 11:33:10 +0200
|
||||
Subject: [PATCH 6/9] d/steamvr_lh: prevent crash on vive pro2/WiVRn
|
||||
|
||||
@@ -1,49 +1,27 @@
|
||||
From 8c6580e84690ffe8f082cdff5ead8443d1f6bf23 Mon Sep 17 00:00:00 2001
|
||||
From 4fdc8798f4810145c446fe147ae94e4c717b6b28 Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Fri, 7 Nov 2025 20:41:16 -0600
|
||||
Subject: [PATCH 7/9] st/oxr: push XrEventDataInteractionProfileChanged when
|
||||
profile changes to NULL
|
||||
|
||||
---
|
||||
src/xrt/state_trackers/oxr/actions/oxr_input.c | 15 +++++----------
|
||||
1 file changed, 5 insertions(+), 10 deletions(-)
|
||||
src/xrt/state_trackers/oxr/actions/oxr_input.c | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/state_trackers/oxr/actions/oxr_input.c b/src/xrt/state_trackers/oxr/actions/oxr_input.c
|
||||
index 349c9adcb..667163142 100644
|
||||
index 269c6ec62..05a747f74 100644
|
||||
--- a/src/xrt/state_trackers/oxr/actions/oxr_input.c
|
||||
+++ b/src/xrt/state_trackers/oxr/actions/oxr_input.c
|
||||
@@ -1945,26 +1945,21 @@ oxr_session_update_action_bindings(struct oxr_logger *log, struct oxr_session *s
|
||||
}
|
||||
}
|
||||
|
||||
- /*
|
||||
- * This code will only send events (and update the bindings) if there
|
||||
- * is a profile mapped to the subaction path. Meaning it won't update
|
||||
- * the cache or generate events when a controller goes away, basically
|
||||
- * latching the interaction profile to the last active device.
|
||||
- */
|
||||
+ bool any_profile_changed = false;
|
||||
@@ -1947,9 +1947,6 @@ session_update_action_bindings(struct oxr_logger *log,
|
||||
#define POPULATE_PROFILE(X) \
|
||||
do { \
|
||||
XrPath path = profiles.X != NULL ? profiles.X->path : XR_NULL_PATH; \
|
||||
- if (path == XR_NULL_PATH) { \
|
||||
- break; /* Only update on "active" interaction profiles per sub-action path. */ \
|
||||
- } \
|
||||
if (sess->X != path) { \
|
||||
sess->X = path; \
|
||||
- oxr_event_push_XrEventDataInteractionProfileChanged(log, sess); \
|
||||
+ any_profile_changed = true; \
|
||||
} \
|
||||
} while (false);
|
||||
OXR_FOR_EACH_VALID_SUBACTION_PATH(POPULATE_PROFILE)
|
||||
#undef POPULATE_PROFILE
|
||||
|
||||
+ if (any_profile_changed) {
|
||||
+ oxr_event_push_XrEventDataInteractionProfileChanged(log, sess);
|
||||
+ }
|
||||
return oxr_session_success_result(sess);
|
||||
}
|
||||
|
||||
if (action_context->X != path) { \
|
||||
action_context->X = path; \
|
||||
interaction_profile_changed = true; \
|
||||
--
|
||||
2.53.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 959707499b31f8db80f28492d1bfc01e34b23368 Mon Sep 17 00:00:00 2001
|
||||
From 025dcad51542cd6c23d9a6ad16cca982bf2fa5ca Mon Sep 17 00:00:00 2001
|
||||
From: no name <git-am@invalid>
|
||||
Date: Thu, 15 Jan 2026 12:13:06 +0100
|
||||
Subject: [PATCH 8/9] Don't get pose data in compositor
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
From 14e5d4a2f29b95f0f7933dbf2dde5000c0a98866 Mon Sep 17 00:00:00 2001
|
||||
From dfacf60061206ca6f41b8bc44e9cd7166230d77e Mon Sep 17 00:00:00 2001
|
||||
From: no name <git-am@invalid>
|
||||
Date: Sun, 25 Jan 2026 10:09:10 +0100
|
||||
Subject: [PATCH 9/9] don't verify GL stuff
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From a9ac675eab72a6ce96adb38215e83f7b3e9b51e7 Mon Sep 17 00:00:00 2001
|
||||
From: no name <git-am@invalid>
|
||||
Date: Fri, 20 Mar 2026 16:51:18 +0100
|
||||
Subject: [PATCH] configure u_git_tag in WiVRn
|
||||
|
||||
---
|
||||
src/xrt/auxiliary/util/CMakeLists.txt | 7 +------
|
||||
1 file changed, 1 insertion(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/auxiliary/util/CMakeLists.txt b/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
index d45cd60c9..ec0d45434 100644
|
||||
--- a/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
+++ b/src/xrt/auxiliary/util/CMakeLists.txt
|
||||
@@ -10,11 +10,6 @@
|
||||
# by applications like the OpenXR runtime library.
|
||||
#
|
||||
|
||||
-configure_file(
|
||||
- "${CMAKE_CURRENT_SOURCE_DIR}/u_git_tag.c.in" "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
|
||||
- @ONLY
|
||||
- )
|
||||
-
|
||||
add_library(
|
||||
aux_util STATIC
|
||||
u_autoexpgain.c
|
||||
@@ -118,7 +113,7 @@ add_library(
|
||||
u_worker.cpp
|
||||
u_worker.h
|
||||
u_worker.hpp
|
||||
- "${CMAKE_CURRENT_BINARY_DIR}/u_git_tag.c"
|
||||
+ "${U_GIT_TAG_CPP}"
|
||||
)
|
||||
target_link_libraries(
|
||||
aux_util
|
||||
--
|
||||
2.53.0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
set(U_GIT_TAG_CPP "${CMAKE_BINARY_DIR}/u_git_tag.cpp")
|
||||
|
||||
set(XRT_BUILD_DRIVER_ARDUINO OFF)
|
||||
set(XRT_BUILD_DRIVER_BLUBUR_S1 OFF)
|
||||
|
||||
+270
-293
@@ -2,6 +2,7 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2026 Sapphire <imsapphire0@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@@ -22,6 +23,7 @@
|
||||
#include "driver/wivrn_session.h"
|
||||
#include "encoder/video_encoder.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "utils/method.h"
|
||||
#include "utils/scoped_lock.h"
|
||||
#include "wivrn_config.h"
|
||||
#include "wivrn_foveation.h"
|
||||
@@ -72,15 +74,6 @@ std::vector<const char *> wivrn_comp_target::wanted_device_extensions = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static void target_init_semaphores(struct wivrn_comp_target * cn);
|
||||
|
||||
static void target_fini_semaphores(struct wivrn_comp_target * cn);
|
||||
|
||||
static inline struct vk_bundle * get_vk(struct wivrn_comp_target * cn)
|
||||
{
|
||||
return &cn->c->base.vk;
|
||||
}
|
||||
|
||||
#ifdef XRT_FEATURE_RENDERDOC
|
||||
static auto renderdoc()
|
||||
{
|
||||
@@ -103,72 +96,57 @@ static auto renderdoc()
|
||||
}
|
||||
#endif
|
||||
|
||||
static void destroy_images(struct wivrn_comp_target * cn)
|
||||
void wivrn_comp_target::init_semaphores()
|
||||
{
|
||||
if (cn->images == nullptr)
|
||||
return;
|
||||
auto vk = get_vk();
|
||||
VkResult ret;
|
||||
|
||||
if (cn->wivrn_bundle)
|
||||
cn->wivrn_bundle->device.waitIdle();
|
||||
fini_semaphores();
|
||||
|
||||
cn->psc.status = 1;
|
||||
cn->psc.status.notify_all();
|
||||
cn->encoder_threads.clear();
|
||||
cn->encoders.clear();
|
||||
VkSemaphoreCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
||||
};
|
||||
|
||||
cn->psc.images.clear();
|
||||
|
||||
free(cn->images);
|
||||
cn->images = NULL;
|
||||
|
||||
target_fini_semaphores(cn);
|
||||
}
|
||||
|
||||
static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_target * cn, int index, std::vector<std::shared_ptr<video_encoder>> encoders);
|
||||
|
||||
static void create_encoders(wivrn_comp_target * cn)
|
||||
{
|
||||
auto vk = get_vk(cn);
|
||||
assert(cn->encoders.empty());
|
||||
assert(cn->encoder_threads.empty());
|
||||
assert(cn->wivrn_bundle);
|
||||
cn->psc.status = 0;
|
||||
|
||||
to_headset::video_stream_description & desc = cn->desc;
|
||||
desc.width = cn->width;
|
||||
desc.height = cn->height;
|
||||
|
||||
std::map<int, std::vector<std::shared_ptr<video_encoder>>> thread_params;
|
||||
|
||||
for (auto [i, settings]: std::ranges::enumerate_view(cn->settings))
|
||||
ret = vk->vkCreateSemaphore(vk->device, &info, nullptr, &semaphores.present_complete);
|
||||
if (ret != VK_SUCCESS)
|
||||
{
|
||||
auto & encoder = cn->encoders.emplace_back(
|
||||
video_encoder::create(*cn->wivrn_bundle, settings, i));
|
||||
desc.codec[i] = settings.codec;
|
||||
|
||||
thread_params[settings.group].emplace_back(encoder);
|
||||
COMP_ERROR(c, "vkCreateSemaphore: %s", vk_result_string(ret));
|
||||
}
|
||||
|
||||
for (auto & [group, params]: thread_params)
|
||||
semaphores.render_complete_is_timeline = false;
|
||||
ret = vk->vkCreateSemaphore(vk->device, &info, nullptr, &semaphores.render_complete);
|
||||
if (ret != VK_SUCCESS)
|
||||
{
|
||||
auto & thread = cn->encoder_threads.emplace_back(
|
||||
comp_wivrn_present_thread, cn, cn->encoder_threads.size(), std::move(params));
|
||||
std::string name = "encoder " + std::to_string(group);
|
||||
pthread_setname_np(thread.native_handle(), name.c_str());
|
||||
COMP_ERROR(c, "vkCreateSemaphore: %s", vk_result_string(ret));
|
||||
}
|
||||
}
|
||||
void wivrn_comp_target::fini_semaphores()
|
||||
{
|
||||
auto vk = get_vk();
|
||||
|
||||
if (semaphores.present_complete != VK_NULL_HANDLE)
|
||||
{
|
||||
vk->vkDestroySemaphore(vk->device, semaphores.present_complete, nullptr);
|
||||
semaphores.present_complete = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (semaphores.render_complete != VK_NULL_HANDLE)
|
||||
{
|
||||
vk->vkDestroySemaphore(vk->device, semaphores.render_complete, nullptr);
|
||||
semaphores.render_complete = VK_NULL_HANDLE;
|
||||
}
|
||||
cn->cnx.send_control(to_headset::video_stream_description{desc});
|
||||
}
|
||||
|
||||
static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags flags)
|
||||
VkResult wivrn_comp_target::create_images_impl(vk::ImageUsageFlags flags)
|
||||
{
|
||||
auto vk = get_vk(cn);
|
||||
assert(cn->image_count > 0);
|
||||
COMP_DEBUG(cn->c, "Creating %d images.", cn->image_count);
|
||||
auto & device = cn->wivrn_bundle->device;
|
||||
auto vk = get_vk();
|
||||
assert(image_count > 0);
|
||||
COMP_DEBUG(c, "Creating %d images.", image_count);
|
||||
auto & device = wivrn_bundle->device;
|
||||
|
||||
destroy_images(cn);
|
||||
destroy_images();
|
||||
|
||||
auto format = vk::Format(cn->format);
|
||||
auto format = vk::Format(this->format);
|
||||
|
||||
bool is_10bit = format == vk::Format::eG10X6B10X6R10X62Plane420Unorm3Pack16;
|
||||
|
||||
@@ -177,7 +155,7 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
|
||||
is_10bit ? vk::Format::eR16G16Unorm : vk::Format::eR8G8Unorm,
|
||||
format};
|
||||
|
||||
cn->images = U_TYPED_ARRAY_CALLOC(struct comp_target_image, cn->image_count);
|
||||
images = U_TYPED_ARRAY_CALLOC(comp_target_image, image_count);
|
||||
|
||||
vk::StructureChain image_info{
|
||||
vk::ImageCreateInfo{
|
||||
@@ -185,8 +163,8 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
|
||||
.imageType = vk::ImageType::e2D,
|
||||
.format = format,
|
||||
.extent = {
|
||||
.width = cn->width,
|
||||
.height = cn->height,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.depth = 1,
|
||||
},
|
||||
.mipLevels = 1,
|
||||
@@ -205,7 +183,7 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
|
||||
if (
|
||||
vk->features.video_maintenance_1 and
|
||||
std::ranges::contains(
|
||||
cn->settings,
|
||||
settings,
|
||||
encoder_vulkan,
|
||||
&encoder_settings::encoder_name))
|
||||
{
|
||||
@@ -214,21 +192,21 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
|
||||
}
|
||||
#endif
|
||||
|
||||
cn->psc.images.resize(cn->image_count);
|
||||
for (uint32_t i = 0; i < cn->image_count; i++)
|
||||
psc.images.resize(image_count);
|
||||
for (uint32_t i = 0; i < image_count; i++)
|
||||
{
|
||||
auto & image = cn->psc.images[i].image;
|
||||
auto & image = psc.images[i].image;
|
||||
image = image_allocation(
|
||||
device,
|
||||
image_info.get(),
|
||||
{.usage = VMA_MEMORY_USAGE_AUTO},
|
||||
std::format("comp target image {}", i));
|
||||
cn->images[i].handle = image;
|
||||
images[i].handle = image;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < cn->image_count; i++)
|
||||
for (uint32_t i = 0; i < image_count; i++)
|
||||
{
|
||||
auto & item = cn->psc.images[i];
|
||||
auto & item = psc.images[i];
|
||||
vk::ImageViewUsageCreateInfo usage{
|
||||
.usage = flags,
|
||||
};
|
||||
@@ -256,44 +234,93 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
|
||||
.layerCount = vk::RemainingArrayLayers,
|
||||
},
|
||||
});
|
||||
cn->images[i].view = VkImageView(*item.image_view_y);
|
||||
cn->images[i].view_cbcr = VkImageView(*item.image_view_cbcr);
|
||||
cn->wivrn_bundle->name(item.image_view_y, "comp target image view (y)");
|
||||
cn->wivrn_bundle->name(item.image_view_cbcr, "comp target image view (CbCr)");
|
||||
images[i].view = VkImageView(*item.image_view_y);
|
||||
images[i].view_cbcr = VkImageView(*item.image_view_cbcr);
|
||||
wivrn_bundle->name(item.image_view_y, "comp target image view (y)");
|
||||
wivrn_bundle->name(item.image_view_cbcr, "comp target image view (CbCr)");
|
||||
}
|
||||
|
||||
cn->psc.fence = vk::raii::Fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled});
|
||||
cn->wivrn_bundle->name(cn->psc.fence, "comp target fence");
|
||||
psc.fence = vk::raii::Fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled});
|
||||
wivrn_bundle->name(psc.fence, "comp target fence");
|
||||
|
||||
cn->psc.command_buffer = std::move(device.allocateCommandBuffers(
|
||||
{.commandPool = *cn->command_pool,
|
||||
psc.command_buffer = std::move(device.allocateCommandBuffers(
|
||||
{.commandPool = *command_pool,
|
||||
.commandBufferCount = 1})[0]);
|
||||
cn->wivrn_bundle->name(cn->psc.command_buffer, "comp target command buffer");
|
||||
wivrn_bundle->name(psc.command_buffer, "comp target command buffer");
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
void wivrn_comp_target::destroy_images()
|
||||
{
|
||||
if (images == nullptr)
|
||||
return;
|
||||
|
||||
static bool comp_wivrn_init_pre_vulkan(struct comp_target * ct)
|
||||
if (wivrn_bundle)
|
||||
wivrn_bundle->device.waitIdle();
|
||||
|
||||
psc.status = 1;
|
||||
psc.status.notify_all();
|
||||
encoder_threads.clear();
|
||||
encoders.clear();
|
||||
|
||||
psc.images.clear();
|
||||
|
||||
free(images);
|
||||
images = nullptr;
|
||||
|
||||
fini_semaphores();
|
||||
}
|
||||
|
||||
void wivrn_comp_target::create_encoders()
|
||||
{
|
||||
auto vk = get_vk();
|
||||
assert(encoders.empty());
|
||||
assert(encoder_threads.empty());
|
||||
assert(wivrn_bundle);
|
||||
psc.status = 0;
|
||||
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
|
||||
std::map<int, std::vector<std::shared_ptr<video_encoder>>> thread_params;
|
||||
|
||||
for (auto [i, settings]: std::ranges::enumerate_view(settings))
|
||||
{
|
||||
auto & encoder = encoders.emplace_back(
|
||||
video_encoder::create(*wivrn_bundle, settings, i));
|
||||
desc.codec[i] = settings.codec;
|
||||
|
||||
thread_params[settings.group].emplace_back(encoder);
|
||||
}
|
||||
|
||||
for (auto & [group, params]: thread_params)
|
||||
{
|
||||
auto & thread = encoder_threads.emplace_back([this](auto stop_token, auto... args) { return run_present(stop_token, args...); }, encoder_threads.size(), std::move(params));
|
||||
std::string name = "encoder " + std::to_string(group);
|
||||
pthread_setname_np(thread.native_handle(), name.c_str());
|
||||
}
|
||||
cnx.send_control(to_headset::video_stream_description{desc});
|
||||
}
|
||||
|
||||
bool wivrn_comp_target::init_pre_vulkan()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t preferred_width, uint32_t preferred_height)
|
||||
bool wivrn_comp_target::init_post_vulkan(uint32_t preferred_width, uint32_t preferred_height)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
auto vk = get_vk(cn);
|
||||
auto vk = get_vk();
|
||||
try
|
||||
{
|
||||
cn->wivrn_bundle.emplace(*vk,
|
||||
wivrn_comp_target::wanted_instance_extensions,
|
||||
wivrn_comp_target::wanted_device_extensions);
|
||||
cn->command_pool = vk::raii::CommandPool(
|
||||
cn->wivrn_bundle->device,
|
||||
wivrn_bundle.emplace(*vk,
|
||||
wivrn_comp_target::wanted_instance_extensions,
|
||||
wivrn_comp_target::wanted_device_extensions);
|
||||
command_pool = vk::raii::CommandPool(
|
||||
wivrn_bundle->device,
|
||||
{
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
|
||||
.queueFamilyIndex = vk->main_queue->family_index,
|
||||
});
|
||||
cn->wivrn_bundle->name(cn->command_pool, "comp target command pool");
|
||||
wivrn_bundle->name(command_pool, "comp target command pool");
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
@@ -303,14 +330,14 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer
|
||||
|
||||
try
|
||||
{
|
||||
cn->settings = get_encoder_settings(
|
||||
*cn->wivrn_bundle,
|
||||
cn->cnx.get_info(),
|
||||
*cn->cnx.get_settings());
|
||||
print_encoders(cn->settings);
|
||||
settings = get_encoder_settings(
|
||||
*wivrn_bundle,
|
||||
cnx.get_info(),
|
||||
*cnx.get_settings());
|
||||
print_encoders(settings);
|
||||
|
||||
cn->c->settings.preferred.width = cn->settings[0].width;
|
||||
cn->c->settings.preferred.height = cn->settings[0].height;
|
||||
c->settings.preferred.width = settings[0].width;
|
||||
c->settings.preferred.height = settings[0].height;
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
@@ -321,114 +348,67 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer
|
||||
U_LOG_E("Failed to create video encoder: %s", e.what());
|
||||
return false;
|
||||
}
|
||||
cn->cnx.set_foveated_size(cn->c->settings.preferred.width, cn->c->settings.preferred.height);
|
||||
cn->foveation.emplace(*cn->wivrn_bundle, *cn->cnx.get_hmd().hmd);
|
||||
cnx.set_foveated_size(c->settings.preferred.width, c->settings.preferred.height);
|
||||
foveation.emplace(*wivrn_bundle, *cnx.get_hmd().hmd);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool comp_wivrn_check_ready(struct comp_target * ct)
|
||||
bool wivrn_comp_target::check_ready()
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
if (not cn->cnx.connected())
|
||||
if (not cnx.connected())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void target_fini_semaphores(struct wivrn_comp_target * cn)
|
||||
void wivrn_comp_target::create_images(const comp_target_create_images_info * create_info, vk_bundle_queue * present_queue)
|
||||
{
|
||||
struct vk_bundle * vk = get_vk(cn);
|
||||
|
||||
if (cn->semaphores.present_complete != VK_NULL_HANDLE)
|
||||
{
|
||||
vk->vkDestroySemaphore(vk->device, cn->semaphores.present_complete, NULL);
|
||||
cn->semaphores.present_complete = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
if (cn->semaphores.render_complete != VK_NULL_HANDLE)
|
||||
{
|
||||
vk->vkDestroySemaphore(vk->device, cn->semaphores.render_complete, NULL);
|
||||
cn->semaphores.render_complete = VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
static void target_init_semaphores(struct wivrn_comp_target * cn)
|
||||
{
|
||||
struct vk_bundle * vk = get_vk(cn);
|
||||
VkResult ret;
|
||||
|
||||
target_fini_semaphores(cn);
|
||||
|
||||
VkSemaphoreCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
||||
};
|
||||
|
||||
ret = vk->vkCreateSemaphore(vk->device, &info, NULL, &cn->semaphores.present_complete);
|
||||
if (ret != VK_SUCCESS)
|
||||
{
|
||||
COMP_ERROR(cn->c, "vkCreateSemaphore: %s", vk_result_string(ret));
|
||||
}
|
||||
|
||||
cn->semaphores.render_complete_is_timeline = false;
|
||||
ret = vk->vkCreateSemaphore(vk->device, &info, NULL, &cn->semaphores.render_complete);
|
||||
if (ret != VK_SUCCESS)
|
||||
{
|
||||
COMP_ERROR(cn->c, "vkCreateSemaphore: %s", vk_result_string(ret));
|
||||
}
|
||||
}
|
||||
|
||||
static void comp_wivrn_create_images(struct comp_target * ct, const struct comp_target_create_images_info * create_info, struct vk_bundle_queue * present_queue)
|
||||
{
|
||||
assert(present_queue != NULL);
|
||||
assert(present_queue != nullptr);
|
||||
(void)present_queue;
|
||||
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
|
||||
// Free old images.
|
||||
destroy_images(cn);
|
||||
destroy_images();
|
||||
|
||||
target_init_semaphores(cn);
|
||||
init_semaphores();
|
||||
|
||||
// will fail on encoder init if bit_depth is arbitrary garbage
|
||||
if (cn->settings[0].bit_depth == 10)
|
||||
ct->format = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
|
||||
if (settings[0].bit_depth == 10)
|
||||
format = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16;
|
||||
else
|
||||
ct->format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||
|
||||
ct->width = create_info->extent.width;
|
||||
ct->height = create_info->extent.height;
|
||||
ct->surface_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
width = create_info->extent.width;
|
||||
height = create_info->extent.height;
|
||||
surface_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
|
||||
cn->image_count = 3;
|
||||
cn->color_space = create_info->color_space;
|
||||
image_count = 3;
|
||||
color_space = create_info->color_space;
|
||||
|
||||
VkResult res = create_images(cn, vk::ImageUsageFlags(create_info->image_usage));
|
||||
VkResult res = create_images_impl(vk::ImageUsageFlags(create_info->image_usage));
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
vk_print_result(get_vk(cn), __FILE__, __LINE__, __func__, res, "create_images");
|
||||
vk_print_result(get_vk(), __FILE__, __LINE__, __func__, res, "create_images");
|
||||
// TODO
|
||||
abort();
|
||||
}
|
||||
create_encoders(cn);
|
||||
create_encoders();
|
||||
}
|
||||
|
||||
static bool comp_wivrn_has_images(struct comp_target * ct)
|
||||
bool wivrn_comp_target::has_images()
|
||||
{
|
||||
return ct->images;
|
||||
return images;
|
||||
}
|
||||
|
||||
static VkResult comp_wivrn_acquire(struct comp_target * ct, uint32_t * out_index)
|
||||
VkResult wivrn_comp_target::acquire(uint32_t * out_index)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
|
||||
while (true)
|
||||
{
|
||||
for (uint32_t i = 0; i < ct->image_count; i++)
|
||||
for (uint32_t i = 0; i < image_count; i++)
|
||||
{
|
||||
if (cn->psc.images[i].status == pseudo_swapchain::status_t::free)
|
||||
if (psc.images[i].status == pseudo_swapchain::status_t::free)
|
||||
{
|
||||
cn->psc.images[i].status = pseudo_swapchain::status_t::acquired;
|
||||
psc.images[i].status = pseudo_swapchain::status_t::acquired;
|
||||
*out_index = i;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
@@ -436,9 +416,9 @@ static VkResult comp_wivrn_acquire(struct comp_target * ct, uint32_t * out_index
|
||||
};
|
||||
}
|
||||
|
||||
static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_target * cn, int index, std::vector<std::shared_ptr<video_encoder>> encoders)
|
||||
void wivrn_comp_target::run_present(std::stop_token stop_token, int index, std::vector<std::shared_ptr<video_encoder>> encoders)
|
||||
{
|
||||
auto & vk = *cn->wivrn_bundle;
|
||||
auto & vk = *wivrn_bundle;
|
||||
U_LOG_I("Starting encoder thread %d", index);
|
||||
|
||||
const uint8_t status_bit = 1 << (index + 1);
|
||||
@@ -446,30 +426,30 @@ static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_tar
|
||||
while (not stop_token.stop_requested())
|
||||
{
|
||||
{
|
||||
auto status = cn->psc.status.load();
|
||||
auto status = psc.status.load();
|
||||
// Bit 0 to request exit
|
||||
if (status & 1)
|
||||
return;
|
||||
|
||||
if (not(status & status_bit))
|
||||
{
|
||||
cn->psc.status.wait(status);
|
||||
psc.status.wait(status);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Get local copies before releasing the image
|
||||
auto view_info = cn->psc.view_info;
|
||||
auto frame_index = cn->psc.frame_index;
|
||||
auto view_info = psc.view_info;
|
||||
auto frame_index = psc.frame_index;
|
||||
|
||||
auto res = vk.device.waitForFences(*cn->psc.fence, true, UINT64_MAX);
|
||||
auto res = vk.device.waitForFences(*psc.fence, true, UINT64_MAX);
|
||||
|
||||
try
|
||||
{
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
if (encoder->stream_idx < 2 or view_info.alpha)
|
||||
encoder->encode(cn->cnx, view_info, frame_index);
|
||||
encoder->encode(cnx, view_info, frame_index);
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
@@ -482,10 +462,10 @@ static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_tar
|
||||
}
|
||||
|
||||
// Update encoder status, release image
|
||||
if ((cn->psc.status &= ~status_bit) == 0)
|
||||
if ((psc.status &= ~status_bit) == 0)
|
||||
{
|
||||
cn->psc.status.notify_all();
|
||||
for (auto & img: cn->psc.images)
|
||||
psc.status.notify_all();
|
||||
for (auto & img: psc.images)
|
||||
{
|
||||
if (img.status == pseudo_swapchain::status_t::encoding)
|
||||
{
|
||||
@@ -497,25 +477,23 @@ static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_tar
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
struct vk_bundle_queue * present_queue,
|
||||
uint32_t index,
|
||||
uint64_t timeline_semaphore_value,
|
||||
int64_t desired_present_time_ns,
|
||||
int64_t present_slop_ns)
|
||||
VkResult wivrn_comp_target::present(
|
||||
vk_bundle_queue * present_queue,
|
||||
uint32_t index,
|
||||
uint64_t timeline_semaphore_value,
|
||||
int64_t desired_present_time_ns,
|
||||
int64_t present_slop_ns)
|
||||
{
|
||||
assert(present_queue != NULL);
|
||||
assert(present_queue != nullptr);
|
||||
(void)present_queue;
|
||||
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
assert(index < image_count);
|
||||
assert(psc.images[index].status == pseudo_swapchain::status_t::acquired);
|
||||
|
||||
assert(index < cn->image_count);
|
||||
assert(cn->psc.images[index].status == pseudo_swapchain::status_t::acquired);
|
||||
auto vk = get_vk();
|
||||
auto res = wivrn_bundle->device.waitForFences(*psc.fence, true, UINT64_MAX);
|
||||
|
||||
struct vk_bundle * vk = get_vk(cn);
|
||||
auto res = cn->wivrn_bundle->device.waitForFences(*cn->psc.fence, true, UINT64_MAX);
|
||||
|
||||
vk::Semaphore wait_semaphore(cn->semaphores.render_complete);
|
||||
vk::Semaphore wait_semaphore(semaphores.render_complete);
|
||||
vk::PipelineStageFlags wait_stage = vk::PipelineStageFlagBits::eTransfer;
|
||||
vk::SubmitInfo submit_info{
|
||||
.waitSemaphoreCount = 1,
|
||||
@@ -523,34 +501,34 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
.pWaitDstStageMask = &wait_stage,
|
||||
};
|
||||
|
||||
if (cn->c->base.layer_accum.layer_count == 0 or not cn->cnx.get_offset() or cn->skip_encoding)
|
||||
if (c->base.layer_accum.layer_count == 0 or not cnx.get_offset() or skip_encoding)
|
||||
{
|
||||
scoped_lock lock(vk->main_queue->mutex);
|
||||
cn->wivrn_bundle->queue.submit(submit_info);
|
||||
cn->psc.images[index].status = pseudo_swapchain::status_t::free;
|
||||
wivrn_bundle->queue.submit(submit_info);
|
||||
psc.images[index].status = pseudo_swapchain::status_t::free;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
auto & command_buffer = cn->psc.command_buffer;
|
||||
auto & psc_image = cn->psc.images[index];
|
||||
auto & command_buffer = psc.command_buffer;
|
||||
auto & psc_image = psc.images[index];
|
||||
|
||||
// Wait for encoders to be done with previous frame
|
||||
for (auto status = cn->psc.status.load(); status != 0; status = cn->psc.status)
|
||||
cn->psc.status.wait(status);
|
||||
for (auto status = psc.status.load(); status != 0; status = psc.status)
|
||||
psc.status.wait(status);
|
||||
|
||||
command_buffer.reset();
|
||||
command_buffer.begin(vk::CommandBufferBeginInfo{
|
||||
.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit,
|
||||
});
|
||||
|
||||
cn->wivrn_bundle->device.resetFences(*cn->psc.fence);
|
||||
wivrn_bundle->device.resetFences(*psc.fence);
|
||||
psc_image.status = pseudo_swapchain::status_t::encoding;
|
||||
auto info = cn->pacer.present_to_info(desired_present_time_ns);
|
||||
const bool do_alpha = cn->c->base.layer_accum.data.env_blend_mode == XRT_BLEND_MODE_ALPHA_BLEND;
|
||||
auto info = pacer.present_to_info(desired_present_time_ns);
|
||||
const bool do_alpha = c->base.layer_accum.data.env_blend_mode == XRT_BLEND_MODE_ALPHA_BLEND;
|
||||
|
||||
bool need_queue_transfer = false;
|
||||
std::vector<vk::Semaphore> present_done_sem;
|
||||
for (auto & encoder: cn->encoders)
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
if (encoder->stream_idx == 2 and not do_alpha)
|
||||
continue;
|
||||
@@ -594,8 +572,8 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
|
||||
{
|
||||
scoped_lock lock(vk->main_queue->mutex);
|
||||
cn->wivrn_bundle->queue.submit(submit_info, *cn->psc.fence);
|
||||
for (auto & encoder: cn->encoders)
|
||||
wivrn_bundle->queue.submit(submit_info, *psc.fence);
|
||||
for (auto & encoder: encoders)
|
||||
{
|
||||
if (encoder->stream_idx == 2 and not do_alpha)
|
||||
continue;
|
||||
@@ -605,23 +583,23 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
|
||||
#ifdef XRT_FEATURE_RENDERDOC
|
||||
if (auto r = renderdoc())
|
||||
r->EndFrameCapture(NULL, NULL);
|
||||
r->EndFrameCapture(nullptr, nullptr);
|
||||
#endif
|
||||
|
||||
auto & view_info = cn->psc.view_info;
|
||||
view_info.foveation = cn->foveation->get_parameters();
|
||||
view_info.display_time = cn->cnx.get_offset().to_headset(info.predicted_display_time);
|
||||
auto & view_info = psc.view_info;
|
||||
view_info.foveation = foveation->get_parameters();
|
||||
view_info.display_time = cnx.get_offset().to_headset(info.predicted_display_time);
|
||||
if (view_info.alpha != do_alpha)
|
||||
cn->pacer.reset();
|
||||
pacer.reset();
|
||||
view_info.alpha = do_alpha;
|
||||
for (int eye = 0; eye < 2; ++eye)
|
||||
{
|
||||
const auto & frame_params = cn->c->base.frame_params;
|
||||
const auto & frame_params = c->base.frame_params;
|
||||
view_info.fov[eye] = xrt_cast(frame_params.fovs[eye]);
|
||||
view_info.pose[eye] = xrt_cast(frame_params.poses[eye]);
|
||||
if (cn->c->base.frame_params.one_projection_layer_fast_path)
|
||||
if (c->base.frame_params.one_projection_layer_fast_path)
|
||||
{
|
||||
const auto & proj = cn->c->base.layer_accum.layers[0].data.proj;
|
||||
const auto & proj = c->base.layer_accum.layers[0].data.proj;
|
||||
view_info.pose[eye] = xrt_cast(proj.v[eye].pose);
|
||||
view_info.fov[eye] = xrt_cast(proj.v[eye].fov);
|
||||
}
|
||||
@@ -635,46 +613,44 @@ static VkResult comp_wivrn_present(struct comp_target * ct,
|
||||
}
|
||||
}
|
||||
// set bits to 1 for index 1..num encoder threads + 1
|
||||
cn->psc.status = (1 << (cn->encoder_threads.size() + 1)) - 2;
|
||||
cn->psc.frame_index = info.frame_id;
|
||||
cn->psc.status.notify_all();
|
||||
psc.status = (1 << (encoder_threads.size() + 1)) - 2;
|
||||
psc.frame_index = info.frame_id;
|
||||
psc.status.notify_all();
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static void comp_wivrn_flush(struct comp_target * ct)
|
||||
void wivrn_comp_target::flush()
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
|
||||
#ifdef XRT_FEATURE_RENDERDOC
|
||||
if (auto r = renderdoc())
|
||||
r->StartFrameCapture(NULL, NULL);
|
||||
r->StartFrameCapture(nullptr, nullptr);
|
||||
#endif
|
||||
|
||||
if (cn->cnx.get_info().eye_gaze)
|
||||
if (cnx.get_info().eye_gaze)
|
||||
{
|
||||
// FIXME: actually get the gaze data here
|
||||
auto now = os_monotonic_get_ns();
|
||||
cn->cnx.add_tracking_request(device_id::EYE_GAZE, cn->c->base.layer_accum.data.display_time_ns, now, now);
|
||||
cnx.add_tracking_request(device_id::EYE_GAZE, c->base.layer_accum.data.display_time_ns, now, now);
|
||||
}
|
||||
|
||||
vk::CommandBuffer cmd;
|
||||
// apply foveation for current frame
|
||||
if (cn->c->base.frame_params.one_projection_layer_fast_path)
|
||||
if (c->base.frame_params.one_projection_layer_fast_path)
|
||||
{
|
||||
const auto & data = cn->c->base.layer_accum.layers[0].data;
|
||||
const auto & hmd = cn->cnx.get_hmd().hmd;
|
||||
const auto & data = c->base.layer_accum.layers[0].data;
|
||||
const auto & hmd = cnx.get_hmd().hmd;
|
||||
xrt_rect rect[] = {data.proj.v[0].sub.rect, data.proj.v[1].sub.rect};
|
||||
xrt_fov fov[] = {data.proj.v[0].fov, data.proj.v[1].fov};
|
||||
cmd = cn->foveation->update_foveation_buffer(
|
||||
ct->c->nr.distortion.buffer,
|
||||
cmd = foveation->update_foveation_buffer(
|
||||
c->nr.distortion.buffer,
|
||||
data.flip_y,
|
||||
rect,
|
||||
fov);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto & hmd = cn->cnx.get_hmd().hmd;
|
||||
const auto & hmd = cnx.get_hmd().hmd;
|
||||
xrt_rect rect[] = {
|
||||
{.extent = {
|
||||
.w = int(hmd->views[0].display.w_pixels),
|
||||
@@ -685,16 +661,16 @@ static void comp_wivrn_flush(struct comp_target * ct)
|
||||
.h = int(hmd->views[1].display.h_pixels),
|
||||
}},
|
||||
};
|
||||
cmd = cn->foveation->update_foveation_buffer(
|
||||
ct->c->nr.distortion.buffer,
|
||||
cmd = foveation->update_foveation_buffer(
|
||||
c->nr.distortion.buffer,
|
||||
false,
|
||||
rect,
|
||||
hmd->distortion.fov);
|
||||
}
|
||||
|
||||
struct vk_bundle * vk = get_vk(cn);
|
||||
auto vk = get_vk();
|
||||
|
||||
vk::Semaphore sem(cn->semaphores.present_complete);
|
||||
vk::Semaphore sem(semaphores.present_complete);
|
||||
|
||||
vk::SubmitInfo submit_info{
|
||||
.commandBufferCount = cmd ? 1u : 0,
|
||||
@@ -705,20 +681,18 @@ static void comp_wivrn_flush(struct comp_target * ct)
|
||||
|
||||
{
|
||||
scoped_lock lock(vk->main_queue->mutex);
|
||||
cn->wivrn_bundle->queue.submit(submit_info);
|
||||
wivrn_bundle->queue.submit(submit_info);
|
||||
}
|
||||
}
|
||||
|
||||
static void comp_wivrn_calc_frame_pacing(struct comp_target * ct,
|
||||
int64_t * out_frame_id,
|
||||
int64_t * out_wake_up_time_ns,
|
||||
int64_t * out_desired_present_time_ns,
|
||||
int64_t * out_present_slop_ns,
|
||||
int64_t * out_predicted_display_time_ns)
|
||||
void wivrn_comp_target::calc_frame_pacing(
|
||||
int64_t * out_frame_id,
|
||||
int64_t * out_wake_up_time_ns,
|
||||
int64_t * out_desired_present_time_ns,
|
||||
int64_t * out_present_slop_ns,
|
||||
int64_t * out_predicted_display_time_ns)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
|
||||
cn->pacer.predict(
|
||||
pacer.predict(
|
||||
*out_frame_id,
|
||||
*out_wake_up_time_ns,
|
||||
*out_desired_present_time_ns,
|
||||
@@ -726,68 +700,63 @@ static void comp_wivrn_calc_frame_pacing(struct comp_target * ct,
|
||||
*out_predicted_display_time_ns);
|
||||
}
|
||||
|
||||
static void comp_wivrn_mark_timing_point(struct comp_target * ct,
|
||||
enum comp_target_timing_point point,
|
||||
int64_t frame_id,
|
||||
int64_t when_ns)
|
||||
void wivrn_comp_target::mark_timing_point(
|
||||
enum comp_target_timing_point point,
|
||||
int64_t frame_id,
|
||||
int64_t when_ns)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
|
||||
cn->pacer.mark_timing_point(point, frame_id, when_ns);
|
||||
pacer.mark_timing_point(point, frame_id, when_ns);
|
||||
|
||||
switch (point)
|
||||
{
|
||||
case COMP_TARGET_TIMING_POINT_WAKE_UP:
|
||||
cn->cnx.dump_time("wake_up", frame_id, when_ns);
|
||||
cnx.dump_time("wake_up", frame_id, when_ns);
|
||||
break;
|
||||
case COMP_TARGET_TIMING_POINT_BEGIN:
|
||||
cn->cnx.dump_time("begin", frame_id, when_ns);
|
||||
cnx.dump_time("begin", frame_id, when_ns);
|
||||
break;
|
||||
case COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN:
|
||||
break;
|
||||
case COMP_TARGET_TIMING_POINT_SUBMIT_END:
|
||||
cn->cnx.dump_time("submit", frame_id, when_ns);
|
||||
cnx.dump_time("submit", frame_id, when_ns);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult comp_wivrn_update_timings(struct comp_target * ct)
|
||||
VkResult wivrn_comp_target::update_timings()
|
||||
{
|
||||
// TODO
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static void comp_wivrn_set_title(struct comp_target * ct, const char * title)
|
||||
void wivrn_comp_target::set_title(const char * title)
|
||||
{}
|
||||
|
||||
static xrt_result_t comp_wivrn_get_refresh_rates(struct comp_target * ct, uint32_t * count, float * refresh_rates_hz)
|
||||
xrt_result_t wivrn_comp_target::get_refresh_rates(uint32_t * count, float * refresh_rates_hz)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
const auto & rates = cn->cnx.get_info().available_refresh_rates;
|
||||
const auto & rates = cnx.get_info().available_refresh_rates;
|
||||
*count = std::min<uint32_t>(rates.size(), XRT_MAX_SUPPORTED_REFRESH_RATES);
|
||||
std::copy_n(rates.begin(), *count, refresh_rates_hz);
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
static xrt_result_t comp_wivrn_get_current_refresh_rate(struct comp_target * ct, float * refresh_rate_hz)
|
||||
xrt_result_t wivrn_comp_target::get_current_refresh_rate(float * refresh_rate_hz)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
*refresh_rate_hz = cn->desc.fps;
|
||||
*refresh_rate_hz = desc.fps;
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
static xrt_result_t comp_wivrn_request_refresh_rate(struct comp_target * ct, float refresh_rate_hz)
|
||||
xrt_result_t wivrn_comp_target::request_refresh_rate(float refresh_rate_hz)
|
||||
{
|
||||
struct wivrn_comp_target * cn = (struct wivrn_comp_target *)ct;
|
||||
cn->requested_refresh_rate = refresh_rate_hz;
|
||||
requested_refresh_rate = refresh_rate_hz;
|
||||
if (refresh_rate_hz == 0.0f)
|
||||
refresh_rate_hz = get_default_rate(cn->cnx.get_info(), *cn->cnx.get_settings());
|
||||
refresh_rate_hz = get_default_rate(cnx.get_info(), *cnx.get_settings());
|
||||
|
||||
try
|
||||
{
|
||||
cn->cnx.send_control(to_headset::refresh_rate_change{.fps = refresh_rate_hz});
|
||||
cnx.send_control(to_headset::refresh_rate_change{.fps = refresh_rate_hz});
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -799,17 +768,16 @@ static xrt_result_t comp_wivrn_request_refresh_rate(struct comp_target * ct, flo
|
||||
|
||||
wivrn_comp_target::~wivrn_comp_target()
|
||||
{
|
||||
destroy_images(this);
|
||||
destroy_images();
|
||||
}
|
||||
|
||||
static void comp_wivrn_destroy(struct comp_target * ct)
|
||||
void wivrn_comp_target::destroy()
|
||||
{
|
||||
auto cn = (struct wivrn_comp_target *)ct;
|
||||
cn->cnx.unset_comp_target();
|
||||
delete cn;
|
||||
cnx.unset_comp_target();
|
||||
delete this;
|
||||
}
|
||||
|
||||
static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
|
||||
void wivrn_comp_target::info_gpu(int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
|
||||
{
|
||||
COMP_TRACE_MARKER();
|
||||
}
|
||||
@@ -835,6 +803,15 @@ void wivrn_comp_target::reset_encoders()
|
||||
cnx.send_control(to_headset::video_stream_description{desc});
|
||||
}
|
||||
|
||||
float wivrn_comp_target::get_requested_refresh_rate() const
|
||||
{
|
||||
return requested_refresh_rate;
|
||||
}
|
||||
void wivrn_comp_target::reset_requested_refresh_rate()
|
||||
{
|
||||
requested_refresh_rate = 0;
|
||||
}
|
||||
|
||||
void wivrn_comp_target::pause()
|
||||
{
|
||||
skip_encoding = true;
|
||||
@@ -877,27 +854,27 @@ float wivrn_comp_target::get_refresh_rate()
|
||||
wivrn_comp_target::wivrn_comp_target(wivrn::wivrn_session & cnx, struct comp_compositor * c) :
|
||||
comp_target{
|
||||
.c = c,
|
||||
.init_pre_vulkan = comp_wivrn_init_pre_vulkan,
|
||||
.init_post_vulkan = comp_wivrn_init_post_vulkan,
|
||||
.check_ready = comp_wivrn_check_ready,
|
||||
.create_images = comp_wivrn_create_images,
|
||||
.has_images = comp_wivrn_has_images,
|
||||
.acquire = comp_wivrn_acquire,
|
||||
.present = comp_wivrn_present,
|
||||
.flush = comp_wivrn_flush,
|
||||
.calc_frame_pacing = comp_wivrn_calc_frame_pacing,
|
||||
.mark_timing_point = comp_wivrn_mark_timing_point,
|
||||
.update_timings = comp_wivrn_update_timings,
|
||||
.info_gpu = comp_wivrn_info_gpu,
|
||||
.set_title = comp_wivrn_set_title,
|
||||
.get_refresh_rates = comp_wivrn_get_refresh_rates,
|
||||
.get_current_refresh_rate = comp_wivrn_get_current_refresh_rate,
|
||||
.request_refresh_rate = comp_wivrn_request_refresh_rate,
|
||||
.destroy = comp_wivrn_destroy,
|
||||
.init_pre_vulkan = method_pointer<&wivrn_comp_target::init_pre_vulkan>,
|
||||
.init_post_vulkan = method_pointer<&wivrn_comp_target::init_post_vulkan>,
|
||||
.check_ready = method_pointer<&wivrn_comp_target::check_ready>,
|
||||
.create_images = method_pointer<&wivrn_comp_target::create_images>,
|
||||
.has_images = method_pointer<&wivrn_comp_target::has_images>,
|
||||
.acquire = method_pointer<&wivrn_comp_target::acquire>,
|
||||
.present = method_pointer<&wivrn_comp_target::present>,
|
||||
.flush = method_pointer<&wivrn_comp_target::flush>,
|
||||
.calc_frame_pacing = method_pointer<&wivrn_comp_target::calc_frame_pacing>,
|
||||
.mark_timing_point = method_pointer<&wivrn_comp_target::mark_timing_point>,
|
||||
.update_timings = method_pointer<&wivrn_comp_target::update_timings>,
|
||||
.info_gpu = method_pointer<&wivrn_comp_target::info_gpu>,
|
||||
.set_title = method_pointer<&wivrn_comp_target::set_title>,
|
||||
.get_refresh_rates = method_pointer<&wivrn_comp_target::get_refresh_rates>,
|
||||
.get_current_refresh_rate = method_pointer<&wivrn_comp_target::get_current_refresh_rate>,
|
||||
.request_refresh_rate = method_pointer<&wivrn_comp_target::request_refresh_rate>,
|
||||
.destroy = method_pointer<&wivrn_comp_target::destroy>,
|
||||
},
|
||||
desc{.fps = get_default_rate(cnx.get_info(), *cnx.get_settings())},
|
||||
pacer(U_TIME_1S_IN_NS / desc.fps),
|
||||
cnx(cnx)
|
||||
cnx(cnx),
|
||||
pacer(U_TIME_1S_IN_NS / desc.fps)
|
||||
{
|
||||
c->frame_interval_ns = U_TIME_1S_IN_NS / desc.fps;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2026 Sapphire <imsapphire0@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@@ -19,6 +20,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "main/comp_compositor.h"
|
||||
#include "main/comp_target.h"
|
||||
|
||||
#include "encoder/encoder_settings.h"
|
||||
@@ -28,11 +30,11 @@
|
||||
#include "wivrn_pacer.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include <array>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
namespace wivrn
|
||||
@@ -76,10 +78,9 @@ struct pseudo_swapchain
|
||||
to_headset::video_stream_data_shard::view_info_t view_info{};
|
||||
};
|
||||
|
||||
struct wivrn_comp_target : public comp_target
|
||||
class wivrn_comp_target : public comp_target
|
||||
{
|
||||
to_headset::video_stream_description desc{};
|
||||
wivrn_pacer pacer;
|
||||
|
||||
std::optional<wivrn_vk_bundle> wivrn_bundle;
|
||||
vk::raii::CommandPool command_pool = nullptr;
|
||||
@@ -90,25 +91,73 @@ 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;
|
||||
|
||||
std::array<encoder_settings, 3> settings;
|
||||
std::list<std::jthread> encoder_threads;
|
||||
std::vector<std::shared_ptr<video_encoder>> encoders;
|
||||
|
||||
wivrn::wivrn_session & cnx;
|
||||
std::optional<wivrn_foveation> foveation;
|
||||
|
||||
std::atomic<float> requested_refresh_rate;
|
||||
std::atomic<bool> skip_encoding;
|
||||
|
||||
inline vk_bundle * get_vk()
|
||||
{
|
||||
return &c->base.vk;
|
||||
}
|
||||
|
||||
void init_semaphores();
|
||||
void fini_semaphores();
|
||||
VkResult create_images_impl(vk::ImageUsageFlags flags);
|
||||
void destroy_images();
|
||||
void create_encoders();
|
||||
|
||||
void run_present(std::stop_token stop_token, int index, std::vector<std::shared_ptr<video_encoder>> encoders);
|
||||
|
||||
bool init_pre_vulkan();
|
||||
bool init_post_vulkan(uint32_t preferred_width, uint32_t preferred_height);
|
||||
bool check_ready();
|
||||
void create_images(const struct comp_target_create_images_info * create_info, struct vk_bundle_queue * present_queue);
|
||||
bool has_images();
|
||||
VkResult acquire(uint32_t * out_index);
|
||||
VkResult present(struct vk_bundle_queue * present_queue,
|
||||
uint32_t index,
|
||||
uint64_t timeline_semaphore_value,
|
||||
int64_t desired_present_time_ns,
|
||||
int64_t present_slop_ns);
|
||||
void flush();
|
||||
void calc_frame_pacing(int64_t * out_frame_id,
|
||||
int64_t * out_wake_up_time_ns,
|
||||
int64_t * out_desired_present_time_ns,
|
||||
int64_t * out_present_slop_ns,
|
||||
int64_t * out_predicted_display_time_ns);
|
||||
void mark_timing_point(enum comp_target_timing_point point,
|
||||
int64_t frame_id,
|
||||
int64_t when_ns);
|
||||
VkResult update_timings();
|
||||
void info_gpu(int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns);
|
||||
void set_title(const char * title);
|
||||
xrt_result_t get_refresh_rates(uint32_t * count, float * refresh_rates_hz);
|
||||
xrt_result_t get_current_refresh_rate(float * refresh_rate_hz);
|
||||
xrt_result_t request_refresh_rate(float refresh_rate_hz);
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
static std::vector<const char *> wanted_instance_extensions;
|
||||
static std::vector<const char *> wanted_device_extensions;
|
||||
|
||||
wivrn_pacer pacer;
|
||||
std::optional<wivrn_foveation> foveation;
|
||||
|
||||
using base = comp_target;
|
||||
wivrn_comp_target(wivrn::wivrn_session & cnx, struct comp_compositor * c);
|
||||
~wivrn_comp_target();
|
||||
|
||||
void on_feedback(const from_headset::feedback &, const clock_offset &);
|
||||
void reset_encoders();
|
||||
|
||||
float get_requested_refresh_rate() const;
|
||||
void reset_requested_refresh_rate();
|
||||
|
||||
void pause();
|
||||
void resume();
|
||||
|
||||
|
||||
@@ -34,20 +34,11 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static void handle_event_from_main_loop(to_monado::stop)
|
||||
{
|
||||
// Ignore stop request when no headset is connected
|
||||
}
|
||||
|
||||
static void handle_event_from_main_loop(to_monado::disconnect)
|
||||
{
|
||||
// Ignore disconnect request when no headset is connected
|
||||
}
|
||||
|
||||
static void handle_event_from_main_loop(to_monado::set_bitrate)
|
||||
{
|
||||
// Ignore bitrate request when no headset is connected
|
||||
}
|
||||
// Ignored until connection is established
|
||||
static void handle_event_from_main_loop(to_monado::stop) {}
|
||||
static void handle_event_from_main_loop(to_monado::disconnect) {}
|
||||
static void handle_event_from_main_loop(to_monado::set_bitrate) {}
|
||||
static void handle_event_from_main_loop(wivrn::to_headset::stream_tab_change) {}
|
||||
|
||||
static std::string clean_key(std::string key)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include "math/m_api.h"
|
||||
#endif
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "util/u_logging.h"
|
||||
#include "util/u_system.h"
|
||||
#include "utils/load_icon.h"
|
||||
#include "utils/method.h"
|
||||
#include "utils/scoped_lock.h"
|
||||
|
||||
#include "audio/audio_setup.h"
|
||||
@@ -66,14 +67,6 @@
|
||||
#include "solarxr_interface.h"
|
||||
#endif
|
||||
|
||||
static std::string xrt_result_to_string(xrt_result_t xret)
|
||||
{
|
||||
struct u_pp_sink_stack_only sink;
|
||||
u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink);
|
||||
u_pp_xrt_result(dg, xret);
|
||||
return sink.buffer;
|
||||
}
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
@@ -122,10 +115,10 @@ bool is_forced_extension(const char * ext_name)
|
||||
|
||||
wivrn::wivrn_session::wivrn_session(std::unique_ptr<wivrn_connection> connection, 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); },
|
||||
.feature_dec = [](xrt_system_devices * self, xrt_device_feature_type f) { return ((wivrn_session *)self)->feature_dec(f); },
|
||||
.destroy = [](xrt_system_devices * self) { delete ((wivrn_session *)self); },
|
||||
.get_roles = method_pointer<&wivrn_session::get_roles>,
|
||||
.feature_inc = method_pointer<&wivrn_session::feature_inc>,
|
||||
.feature_dec = method_pointer<&wivrn_session::feature_dec>,
|
||||
.destroy = method_pointer<&wivrn_session::destroy>,
|
||||
},
|
||||
connection(std::move(connection)),
|
||||
headset_info(this->connection->info()),
|
||||
@@ -331,7 +324,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
||||
auto xret = comp_main_create_system_compositor(&self->hmd, &ctf, &self->app_pacers, out_xsysc);
|
||||
if (xret != XRT_SUCCESS)
|
||||
{
|
||||
U_LOG_E("Failed to create system compositor: %s", xrt_result_to_string(xret).c_str());
|
||||
U_LOG_E("Failed to create system compositor: %s", u_str_xrt_result(xret));
|
||||
return xret;
|
||||
}
|
||||
self->system_compositor = *out_xsysc;
|
||||
@@ -361,7 +354,7 @@ xrt_result_t wivrn::wivrn_session::create_session(std::unique_ptr<wivrn_connecti
|
||||
}
|
||||
if (res != XRT_SUCCESS)
|
||||
{
|
||||
U_LOG_W("failed to initialize eye tracker: %s", xrt_result_to_string(res).c_str());
|
||||
U_LOG_W("failed to initialize eye tracker: %s", u_str_xrt_result(xret));
|
||||
self->static_roles.eyes = nullptr;
|
||||
self->eye_tracker.reset();
|
||||
}
|
||||
@@ -833,6 +826,11 @@ void wivrn_session::operator()(from_headset::refresh_rate_changed && event)
|
||||
});
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::stream_tab_changed && event)
|
||||
{
|
||||
send_to_main(std::move(event));
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::get_application_list && request)
|
||||
{
|
||||
to_headset::application_list response{
|
||||
@@ -941,7 +939,7 @@ void wivrn_session::operator()(const from_headset::stop_application & req)
|
||||
xrt_result_t xret = xrt_session_request_exit(t.ics.xs);
|
||||
if (xret != XRT_SUCCESS)
|
||||
{
|
||||
U_LOG_W("Failed to request exit for application %s: %s", t.ics.client_state.info.application_name, xrt_result_to_string(xret).c_str());
|
||||
U_LOG_W("Failed to request exit for application %s: %s", t.ics.client_state.info.application_name, u_str_xrt_result(xret));
|
||||
}
|
||||
|
||||
auto when = os_monotonic_get_ns() + 10l * U_TIME_1S_IN_NS;
|
||||
@@ -975,6 +973,11 @@ void wivrn_session::operator()(to_monado::set_bitrate && data)
|
||||
comp_target->set_bitrate(data.bitrate_bps);
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(to_headset::stream_tab_change && data)
|
||||
{
|
||||
send_control(std::move(data));
|
||||
}
|
||||
|
||||
struct refresh_rate_adjuster
|
||||
{
|
||||
std::chrono::seconds period{10};
|
||||
@@ -1085,9 +1088,9 @@ void wivrn_session::run_worker(std::stop_token stop)
|
||||
{
|
||||
scoped_lock lock(xrt_system.sessions.mutex);
|
||||
if (xrt_system.sessions.count == 0)
|
||||
comp_target->requested_refresh_rate = 0;
|
||||
comp_target->reset_requested_refresh_rate();
|
||||
}
|
||||
if (comp_target->requested_refresh_rate == 0)
|
||||
if (comp_target->get_requested_refresh_rate() == 0)
|
||||
refresh.adjust(*connection);
|
||||
}
|
||||
if (do_control)
|
||||
@@ -1369,4 +1372,9 @@ xrt_result_t wivrn_session::feature_dec(xrt_device_feature_type type)
|
||||
return XRT_ERROR_FEATURE_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_session::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -123,6 +123,7 @@ class wivrn_session : public xrt_system_devices
|
||||
wivrn_session(std::unique_ptr<wivrn_connection> connection, u_system &);
|
||||
|
||||
public:
|
||||
using base = xrt_system_devices;
|
||||
~wivrn_session();
|
||||
|
||||
static xrt_result_t create_session(std::unique_ptr<wivrn_connection> connection,
|
||||
@@ -178,6 +179,7 @@ public:
|
||||
void operator()(from_headset::session_state_changed &&);
|
||||
void operator()(from_headset::user_presence_changed &&);
|
||||
void operator()(from_headset::refresh_rate_changed &&);
|
||||
void operator()(from_headset::stream_tab_changed &&);
|
||||
void operator()(from_headset::override_foveation_center &&);
|
||||
void operator()(from_headset::get_application_list &&);
|
||||
void operator()(const from_headset::start_app &);
|
||||
@@ -189,6 +191,7 @@ public:
|
||||
void operator()(to_monado::stop &&);
|
||||
void operator()(to_monado::disconnect &&);
|
||||
void operator()(to_monado::set_bitrate &&);
|
||||
void operator()(to_headset::stream_tab_change &&);
|
||||
|
||||
bool has_stream()
|
||||
{
|
||||
@@ -230,6 +233,7 @@ private:
|
||||
xrt_result_t get_roles(xrt_system_roles * out_roles);
|
||||
xrt_result_t feature_inc(xrt_device_feature_type type);
|
||||
xrt_result_t feature_dec(xrt_device_feature_type type);
|
||||
void destroy();
|
||||
};
|
||||
|
||||
} // namespace wivrn
|
||||
|
||||
@@ -314,7 +314,7 @@ 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();
|
||||
ssize_t max_payload_size = (cnx->has_stream() and not control) ? to_headset::video_stream_data_shard::max_payload_size : std::numeric_limits<uint32_t>::max();
|
||||
|
||||
auto begin = data.begin();
|
||||
auto end = data.end();
|
||||
|
||||
@@ -498,7 +498,7 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
|
||||
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
|
||||
.queueFamilyIndex = vk.encode_queue_family_index,
|
||||
});
|
||||
vk.name(query_pool, "vulkan encoder video command pool");
|
||||
vk.name(video_command_pool, "vulkan encoder video command pool");
|
||||
|
||||
auto command_buffers = vk.device.allocateCommandBuffers(
|
||||
{.commandPool = *video_command_pool,
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <libnotify/notification.h>
|
||||
#include <magic_enum.hpp>
|
||||
#include <memory>
|
||||
#include <poll.h>
|
||||
#include <random>
|
||||
@@ -537,6 +538,10 @@ gboolean control_received(gint fd, GIOCondition condition, gpointer user_data)
|
||||
start_publishing();
|
||||
inhibitor.reset();
|
||||
wivrn_server_set_headset_connected(dbus_server, false);
|
||||
wivrn_server_set_client_tab(dbus_server, "");
|
||||
},
|
||||
[&](const wivrn::from_headset::stream_tab_changed & event) {
|
||||
wivrn_server_set_client_tab(dbus_server, magic_enum::enum_name(event.tab).data());
|
||||
},
|
||||
[&](const from_monado::server_error & e) {
|
||||
wivrn_server_emit_server_error(dbus_server, e.where.c_str(), e.message.c_str());
|
||||
@@ -694,6 +699,29 @@ gboolean on_handle_disable_pairing(WivrnServer * skeleton, GDBusMethodInvocation
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
gboolean on_handle_set_client_tab(WivrnServer * skeleton, GDBusMethodInvocation * invocation, gpointer user_data)
|
||||
{
|
||||
GVariant * args = g_dbus_method_invocation_get_parameters(invocation);
|
||||
char * c_tab;
|
||||
g_variant_get_child(args, 0, "s", &c_tab);
|
||||
std::string tab(c_tab);
|
||||
g_free(c_tab);
|
||||
|
||||
for (auto [val, name]: magic_enum::enum_entries<stream_tab>())
|
||||
{
|
||||
if (tab == name)
|
||||
{
|
||||
wivrn_ipc_socket_main_loop->send(to_headset::stream_tab_change{.tab = val});
|
||||
g_dbus_method_invocation_return_value(invocation, nullptr);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
std::cerr << "Invalid tab name " << tab << std::endl;
|
||||
g_dbus_method_invocation_return_dbus_error(invocation, "io.github.wivrn.Server.InvalidTab", "invalid tab");
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
void on_bitrate(WivrnServer * server, const GParamSpec * pspec, gpointer data)
|
||||
{
|
||||
auto bitrate = wivrn_server_get_bitrate(server);
|
||||
@@ -841,6 +869,8 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_signal_connect(dbus_server, "handle-set-client-tab", G_CALLBACK(on_handle_set_client_tab), NULL);
|
||||
|
||||
wivrn_server_set_steam_command(dbus_server, steam_command().c_str());
|
||||
|
||||
on_headset_info_packet({});
|
||||
@@ -870,6 +900,8 @@ void on_name_acquired(GDBusConnection * connection, const gchar * name, gpointer
|
||||
set_encryption_state(wivrn_connection::encryption_state::pairing);
|
||||
else
|
||||
set_encryption_state(enc_state);
|
||||
|
||||
wivrn_server_set_client_tab(dbus_server, "");
|
||||
}
|
||||
|
||||
auto create_dbus_connection()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
#include <stdint.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace
|
||||
{
|
||||
uint16_t version(int digit)
|
||||
{
|
||||
std::string_view tag = "@GIT_DESC@";
|
||||
if (not tag.empty() and tag[0] == 'v')
|
||||
tag = tag.substr(1);
|
||||
for (; digit > 0; --digit)
|
||||
{
|
||||
while (not tag.empty() and std::isdigit(tag[0]))
|
||||
tag = tag.substr(1);
|
||||
if (not tag.empty() and tag[0] == '.')
|
||||
tag = tag.substr(1);
|
||||
}
|
||||
tag = tag.substr(0, tag.find('.'));
|
||||
|
||||
uint16_t val = 0;
|
||||
// We don't care if parsing fail, return 0
|
||||
std::from_chars(tag.begin(), tag.end(), val);
|
||||
return val;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern const char u_git_tag[] = "@GIT_DESC@";
|
||||
extern const uint16_t u_version_major = version(0);
|
||||
extern const uint16_t u_version_minor = version(1);
|
||||
extern const uint16_t u_version_patch = version(2);
|
||||
extern const char u_runtime_description[] = "WiVRn";
|
||||
}
|
||||
+2
-1
@@ -52,6 +52,7 @@ using packets = std::variant<
|
||||
wivrn::from_headset::headset_info_packet,
|
||||
wivrn::from_headset::settings_changed,
|
||||
wivrn::from_headset::start_app,
|
||||
wivrn::from_headset::stream_tab_changed,
|
||||
headset_connected,
|
||||
headset_disconnected,
|
||||
server_error>;
|
||||
@@ -70,7 +71,7 @@ struct set_bitrate
|
||||
uint32_t bitrate_bps;
|
||||
};
|
||||
|
||||
using packets = std::variant<stop, disconnect, set_bitrate>;
|
||||
using packets = std::variant<stop, disconnect, set_bitrate, wivrn::to_headset::stream_tab_change>;
|
||||
} // namespace to_monado
|
||||
|
||||
extern std::optional<wivrn::typed_socket<wivrn::UnixDatagram, to_monado::packets, from_monado::packets>> wivrn_ipc_socket_monado;
|
||||
|
||||
@@ -89,6 +89,22 @@ sd_bus_message_ptr get_property(const sd_bus_ptr & bus, const char * member, con
|
||||
return sd_bus_message_ptr(msg);
|
||||
}
|
||||
|
||||
std::string get_property_string(const sd_bus_ptr & bus, const char * member)
|
||||
{
|
||||
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
char * val;
|
||||
int ret = sd_bus_get_property_string(bus.get(), destination, path, interface, member, &error, &val);
|
||||
if (ret < 0)
|
||||
{
|
||||
std::runtime_error e(std::string("read property ") + member + " failed: " + error.message);
|
||||
sd_bus_error_free(&error);
|
||||
throw e;
|
||||
}
|
||||
std::string res(val);
|
||||
free(val);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void set_property(const sd_bus_ptr & bus, const char * member, const char * signature, Args &&... args)
|
||||
{
|
||||
@@ -218,6 +234,23 @@ void unpair(size_t headset_id)
|
||||
call_method(bus, "RevokeKey", "s", values.at(headset_id - 1).public_key.c_str());
|
||||
}
|
||||
|
||||
void tab(std::string tab_name)
|
||||
{
|
||||
auto bus = get_user_bus();
|
||||
if (tab_name.empty())
|
||||
{
|
||||
auto val = get_property_string(bus, "ClientTab");
|
||||
if (val.empty())
|
||||
std::cout << "<No tab>" << std::endl;
|
||||
else
|
||||
std::cout << val << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
call_method(bus, "SetClientTab", "s", tab_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
auto member(T U::* x)
|
||||
{
|
||||
@@ -340,6 +373,11 @@ int main(int argc, char ** argv)
|
||||
app.add_subcommand("disconnect", "Disconnect headset")
|
||||
->callback(disconnect);
|
||||
|
||||
std::string tab_name;
|
||||
app.add_subcommand("tab", "Show or set current tab on headset")
|
||||
->callback([&]() { return tab(tab_name); })
|
||||
->add_option("[TAB]", tab_name, "Tab to select");
|
||||
|
||||
try
|
||||
{
|
||||
CLI11_PARSE(app, argc, argv);
|
||||
|
||||
Reference in New Issue
Block a user