Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e29d9fe4e | ||
|
|
cb8fb11f11 | ||
|
|
40cf4fc799 | ||
|
|
1d730a3e9e | ||
|
|
66a81ea209 | ||
|
|
40de49af84 |
@@ -2,7 +2,7 @@ name: Release APK Only
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
branches: [ "apk-build" ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
# Checkout from upstream instead of WiVRn-APK to ensure the GIT_DESC variable is set correctly
|
||||
repository: 'WiVRn/WiVRn'
|
||||
repository: 'Vindicus999/WiVRn'
|
||||
ref: ${{ github.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
@@ -102,13 +102,13 @@ jobs:
|
||||
pattern: 'apk-*'
|
||||
merge-multiple: true
|
||||
|
||||
- name: Rename APK artifacts
|
||||
run: |
|
||||
cd apk
|
||||
for f in *.apk; do
|
||||
BASENAME=`echo ${f}|awk -F '-APK-' '{print $2}'`
|
||||
mv "${f}" "org.meumeu.wivrn-${BASENAME}"
|
||||
done
|
||||
# - name: Rename APK artifacts
|
||||
# run: |
|
||||
# cd apk
|
||||
# for f in *.apk; do
|
||||
# BASENAME=`echo ${f}|awk -F '-APK-' '{print $2}'`
|
||||
# mv "${f}" "org.meumeu.wivrn-${BASENAME}"
|
||||
# done
|
||||
|
||||
- name: Download APK debug artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
|
||||
@@ -45,14 +45,11 @@ jobs:
|
||||
packages: ccache libvulkan-dev glslang-tools spirv-tools libwayland-dev libxrandr-dev ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
with:
|
||||
# The trailing "." keeps one preset's key from being a prefix of another's
|
||||
key: linux-${{matrix.config.preset}}.
|
||||
verbose: 1
|
||||
job-summary: ''
|
||||
evict-old-files: job
|
||||
save: ${{ github.ref == 'refs/heads/master' }}
|
||||
key: linux-${{matrix.config.preset}}
|
||||
job-summary: ""
|
||||
restore-keys: linux-
|
||||
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
@@ -142,14 +139,10 @@ jobs:
|
||||
packages: librsvg2-bin npm
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
||||
with:
|
||||
key: steam-frame
|
||||
verbose: 1
|
||||
job-summary: ''
|
||||
evict-old-files: job
|
||||
save: ${{ github.ref == 'refs/heads/master' }}
|
||||
restore-keys: steam-frame
|
||||
job-summary: ""
|
||||
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
@@ -296,16 +289,6 @@ jobs:
|
||||
${{github.workspace}}/cmake-fetch/*.tgz
|
||||
restore-keys: cmake-android-
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.24
|
||||
with:
|
||||
# The trailing "." keeps one build type's key from being a prefix of another's
|
||||
key: android-${{matrix.buildtype}}.
|
||||
verbose: 1
|
||||
job-summary: ''
|
||||
evict-old-files: job
|
||||
save: ${{ github.ref == 'refs/heads/master' }}
|
||||
|
||||
# Gradle distribution and the Android plugin's dependencies.
|
||||
- uses: actions/cache@v5
|
||||
with:
|
||||
@@ -347,9 +330,6 @@ jobs:
|
||||
echo "$APK_KEYSTORE_BASE64" | base64 --decode --ignore-garbage > ks.keystore
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
# Paths under the workspace are hashed relative to it
|
||||
CCACHE_BASEDIR: ${{github.workspace}}
|
||||
run: |
|
||||
VERSION=$(git describe --tags --always | sed "s/^v\([0-9]\)/\1/")
|
||||
if [ ${{ matrix.buildtype }} = 'Oculus' ]
|
||||
@@ -387,7 +367,6 @@ jobs:
|
||||
-Pwivrn_app_name="$APPNAME" \
|
||||
-Pwivrn_compress_glb=ON \
|
||||
-Pfetchcontent_base_dir=${{github.workspace}}/cmake-fetch \
|
||||
-Pcompiler_launcher=ccache \
|
||||
assemble${{ matrix.buildtype }}
|
||||
|
||||
- name: Upload build dir
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
name: Sync Fork with Upstream
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: "https://github.com/wivrn/wivrn.git"
|
||||
WORKFLOW_TOKEN: ${{ secrets.DOWNSTREAM_GITHUB_TOKEN }}
|
||||
UPSTREAM_BRANCH: "master"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
upstream_repo: vindicus999/wivrn
|
||||
fetch-depth: 0
|
||||
token: ${{ env.WORKFLOW_TOKEN }}
|
||||
|
||||
- name: Add upstream
|
||||
run: |
|
||||
git remote add upstream ${{ env.UPSTREAM_URL }}
|
||||
|
||||
- name: Fetch all
|
||||
run: |
|
||||
git fetch origin
|
||||
git fetch upstream
|
||||
|
||||
- name: Update sync branch
|
||||
run: |
|
||||
git config --global user.email "sneed@feedandse.edu"
|
||||
git config --global user.name "Sneed Chuckinson"
|
||||
git checkout -B sync upstream/master
|
||||
git push origin sync --force
|
||||
|
||||
- name: Copy master -> apk-build
|
||||
run: |
|
||||
git checkout -B apk-build sync
|
||||
git push origin apk-build --force
|
||||
|
||||
- name: Apply sneed changes
|
||||
run: |
|
||||
git merge origin/sneed --no-edit
|
||||
|
||||
- name: Push apk build
|
||||
run: |
|
||||
git push origin apk-build --force
|
||||
@@ -1,10 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.28)
|
||||
project(WiVRn VERSION 0.0.0 LANGUAGES C CXX)
|
||||
|
||||
# Workaround for boost CMake error
|
||||
function(source_group)
|
||||
endfunction()
|
||||
|
||||
# Set default for FetchContent projects
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
@@ -12,7 +8,6 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
if(ANDROID)
|
||||
@@ -347,7 +342,6 @@ foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissec
|
||||
target_compile_options(${TARGET_NAME} PRIVATE
|
||||
-fdiagnostics-color -Wall -Wextra -pedantic
|
||||
-ffast-math
|
||||
-fno-finite-math-only
|
||||
-Wundef
|
||||
-Wno-missing-field-initializers
|
||||
-Wno-unused-parameter
|
||||
|
||||
@@ -62,7 +62,7 @@ Follow the wizard in the PC dashboard to install the client on your VR headset.
|
||||
It should either lead you to the [Meta Store](https://www.meta.com/experiences/7959676140827574/) (for Meta Quest headsets) or to download the correct APK (for other headsets).
|
||||
|
||||
> [!WARNING]
|
||||
> The VR client and PC server must use the same WiVRn protocol. For development builds, compare the full version string, including the Git commit suffix (for example, `26.8-42-g1234afe`); the release prefix alone (for example, `26.8`) does not identify the build.
|
||||
> The VR client and PC server need to be on the same version of WiVRn
|
||||
|
||||
> [!TIP]
|
||||
> If the headset fails to connect to the computer, see [troubleshooting](#troubleshooting).
|
||||
@@ -150,7 +150,7 @@ If the server list is empty in the headset app:
|
||||
<details><summary>My headset does not connect to my computer</summary>
|
||||
|
||||
- If you have a firewall, check that port 9757 (UDP and TCP) is open
|
||||
- If the app reports an incompatible server protocol, compare the full version shown in the headset app's About screen with the server's startup log. Package metadata may show only the release prefix. For development builds, use client and server built from the same source revision. If multiple builds are installed, make sure you start the intended server.</details>
|
||||
- The server and client must be the same version.</details>
|
||||
|
||||
<details><summary>How do I use a wired connection manually?</summary>
|
||||
|
||||
|
||||
+1
-4
@@ -117,8 +117,6 @@ android {
|
||||
def compressGlb = project.hasProperty('wivrn_compress_glb') ? wivrn_compress_glb : 'OFF'
|
||||
def fetchcontentBaseDir = project.hasProperty('fetchcontent_base_dir') ? ['-DFETCHCONTENT_BASE_DIR=' + fetchcontent_base_dir] : []
|
||||
|
||||
def compilerLauncher = project.hasProperty('compiler_launcher') ? ['-DCMAKE_C_COMPILER_LAUNCHER=' + compiler_launcher, '-DCMAKE_CXX_COMPILER_LAUNCHER=' + compiler_launcher] : []
|
||||
|
||||
def asan = use_asan ? 'ON': 'OFF'
|
||||
def stl = use_asan ? 'c++_shared' : "c++_static"
|
||||
|
||||
@@ -148,8 +146,7 @@ android {
|
||||
'-DWIVRN_COMPRESS_GLB=' + compressGlb,
|
||||
'-DWIVRN_ADDRESS_SANITIZER=' + asan,
|
||||
] +
|
||||
fetchcontentBaseDir +
|
||||
compilerLauncher
|
||||
fetchcontentBaseDir
|
||||
resValue "string", "app_name", project.hasProperty('wivrn_app_name') ? project.wivrn_app_name : "WiVRn Local"
|
||||
abiFilters 'arm64-v8a'//, 'x86_64'
|
||||
}
|
||||
|
||||
@@ -184,8 +184,6 @@ target_compile_definitions(wivrn PRIVATE IMGUI_DEFINE_MATH_OPERATORS)
|
||||
target_include_directories(wivrn PRIVATE .)
|
||||
|
||||
if(NOT ANDROID)
|
||||
configure_file(io.github.wivrn.wivrn-client.desktop.in io.github.wivrn.wivrn-client.desktop)
|
||||
|
||||
install(TARGETS wivrn)
|
||||
endif()
|
||||
|
||||
@@ -353,11 +351,4 @@ if(NOT ANDROID)
|
||||
set_target_properties(wivrn PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
install(DIRECTORY "${ASSETS_DIR}" DESTINATION ${CMAKE_INSTALL_DATADIR}/wivrn)
|
||||
install(FILES ../images/wivrn.svg
|
||||
DESTINATION share/icons/hicolor/scalable/apps
|
||||
RENAME io.github.wivrn.wivrn-client.svg
|
||||
)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/io.github.wivrn.wivrn-client.desktop
|
||||
DESTINATION share/applications
|
||||
)
|
||||
endif()
|
||||
|
||||
+18
-21
@@ -2,7 +2,6 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2024 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
|
||||
@@ -20,19 +19,20 @@
|
||||
|
||||
#include "battery.h"
|
||||
#include "android/jnipp.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
battery::battery(xr::instance & instance, xr::session & session, jobject activity) : battery(instance, session)
|
||||
namespace
|
||||
{
|
||||
jni::object<""> act(activity);
|
||||
auto app = act.call<jni::object<"android/app/Application">>("getApplication");
|
||||
auto ctx = app.call<jni::object<"android/content/Context">>("getApplicationContext");
|
||||
std::mutex last_status_lock;
|
||||
battery_status last_status;
|
||||
} // namespace
|
||||
|
||||
auto bat_receiver = act.field<jni::object<"android/content/BroadcastReceiver">>("BatteryInfoReceiver");
|
||||
ctx.call<jni::object<"android/content/Intent">>("registerReceiver", bat_receiver, jni::new_object<"android/content/IntentFilter">(jni::string{"android.intent.action.BATTERY_CHANGED"}));
|
||||
battery_status get_battery_status()
|
||||
{
|
||||
std::unique_lock _{last_status_lock};
|
||||
return last_status;
|
||||
}
|
||||
|
||||
extern "C" void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env, jobject instance, jobject ctxt_obj, jobject intent_obj)
|
||||
@@ -51,19 +51,16 @@ extern "C" void Java_org_meumeu_wivrn_BroadcastReceiver_onReceive(JNIEnv * env,
|
||||
auto scale_jint = intent.call<jni::Int>(get_int_extra, scale_jstr, default_jint);
|
||||
auto plugged_jint = intent.call<jni::Int>(get_int_extra, plugged_jstr, default_jint);
|
||||
|
||||
std::optional<float> charge{};
|
||||
if (level_jint && level_jint.value >= 0 && scale_jint && scale_jint.value >= 0)
|
||||
charge = (float)(level_jint.value) / (float)(scale_jint.value);
|
||||
{
|
||||
std::unique_lock _{last_status_lock};
|
||||
if (level_jint && level_jint.value >= 0 && scale_jint && scale_jint.value >= 0)
|
||||
last_status.charge = (float)(level_jint.value) / (float)(scale_jint.value);
|
||||
else
|
||||
last_status.charge = std::nullopt;
|
||||
|
||||
bool charging = plugged_jint && plugged_jint.value > 0;
|
||||
last_status.charging = plugged_jint && plugged_jint.value > 0;
|
||||
}
|
||||
|
||||
if (charge)
|
||||
spdlog::debug("Received ACTION_BATTERY_CHANGED: level {}%, plugged {}", *charge * 100, charging);
|
||||
|
||||
application::get_battery_monitor().on_status_update(
|
||||
battery::device::head,
|
||||
{
|
||||
.charge = charge,
|
||||
.charging = charging,
|
||||
});
|
||||
if (level_jint and scale_jint and plugged_jint)
|
||||
spdlog::debug("Received ACTION_BATTERY_CHANGED: level {}%, plugged {}", *last_status.charge * 100, last_status.charging);
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "property.h"
|
||||
#include "utils/wrap_lambda.h"
|
||||
|
||||
#include <sys/system_properties.h>
|
||||
|
||||
std::optional<std::string> get_property(const char * property)
|
||||
{
|
||||
auto info = __system_property_find(property);
|
||||
if (not info)
|
||||
return std::nullopt;
|
||||
|
||||
std::string result;
|
||||
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
|
||||
result = value;
|
||||
};
|
||||
|
||||
__system_property_read_callback(info, cb.userdata_first(), cb);
|
||||
return result;
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
std::optional<std::string> get_property(const char * property);
|
||||
@@ -16,6 +16,4 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
bool usb_link_properties_changed();
|
||||
|
||||
@@ -1376,7 +1376,6 @@ void application::initialize()
|
||||
XR_KHR_MAINTENANCE1_EXTENSION_NAME,
|
||||
XR_KHR_VISIBILITY_MASK_EXTENSION_NAME,
|
||||
|
||||
XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME,
|
||||
XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME,
|
||||
XR_EXT_HAND_INTERACTION_EXTENSION_NAME,
|
||||
XR_EXT_HAND_TRACKING_EXTENSION_NAME,
|
||||
@@ -1501,12 +1500,6 @@ void application::initialize()
|
||||
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
|
||||
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
battery_monitor.emplace(xr_instance, xr_session, app_info.native_app->activity->clazz);
|
||||
#else
|
||||
battery_monitor.emplace(xr_instance, xr_session);
|
||||
#endif
|
||||
|
||||
config.emplace(xr_system_id, xr_session, application::get_config_path() / "client.json");
|
||||
default_config.emplace(xr_system_id, xr_session);
|
||||
|
||||
@@ -1803,7 +1796,6 @@ application::~application()
|
||||
void application::loop()
|
||||
{
|
||||
poll_events();
|
||||
battery_monitor->poll_batteries();
|
||||
|
||||
auto scene = current_scene();
|
||||
if (not is_session_running())
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "battery.h"
|
||||
#ifdef __ANDROID__
|
||||
#include "android/hid.h"
|
||||
#include <android_native_app_glue.h>
|
||||
@@ -149,7 +148,6 @@ private:
|
||||
std::filesystem::path cache_path;
|
||||
|
||||
std::shared_ptr<wifi_lock> wifi;
|
||||
std::optional<battery> battery_monitor;
|
||||
|
||||
std::mutex server_intent_mutex;
|
||||
std::optional<wivrn_discover::service> server_intent;
|
||||
@@ -318,12 +316,6 @@ public:
|
||||
return *instance().wifi;
|
||||
}
|
||||
|
||||
static battery & get_battery_monitor()
|
||||
{
|
||||
assert(instance().battery_monitor);
|
||||
return *instance().battery_monitor;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
void set_usb_networking(bool enabled);
|
||||
#endif
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "battery.h"
|
||||
#include "application.h"
|
||||
#include "scene.h"
|
||||
#include <chrono>
|
||||
#include <magic_enum.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
battery::battery(xr::instance & instance, xr::session & session) :
|
||||
session(session)
|
||||
{
|
||||
if (instance.has_extension(XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME))
|
||||
{
|
||||
top_level_paths.emplace({
|
||||
std::make_pair(instance.string_to_path("/user/hand/left"), device::left_controller),
|
||||
std::make_pair(instance.string_to_path("/user/hand/right"), device::right_controller),
|
||||
std::make_pair(instance.string_to_path("/user/gamepad"), device::gamepad),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void battery::poll_batteries()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
if (now - last_poll < 10s)
|
||||
return;
|
||||
last_poll = now;
|
||||
|
||||
spdlog::debug("Polling batteries");
|
||||
|
||||
std::lock_guard lock(m);
|
||||
#ifndef __ANDROID__
|
||||
{
|
||||
battery_status status = get_hmd_battery();
|
||||
if (status != statuses.at(device::head))
|
||||
{
|
||||
on_status_update(device::head, std::move(status));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (top_level_paths)
|
||||
{
|
||||
for (auto [path, device]: *top_level_paths)
|
||||
{
|
||||
XrBatteryStateDisplayEXT battery_state{
|
||||
.type = XR_TYPE_BATTERY_STATE_DISPLAY_EXT,
|
||||
};
|
||||
XrInteractionProfileState profile_state{
|
||||
.type = XR_TYPE_INTERACTION_PROFILE_STATE,
|
||||
.next = &battery_state,
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
CHECK_XR(xrGetCurrentInteractionProfile(session, path, &profile_state));
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
spdlog::warn("Failed to get battery charge state for device {}: {}", magic_enum::enum_name(device), e.what());
|
||||
continue;
|
||||
}
|
||||
|
||||
std::optional<float> charge{};
|
||||
if (battery_state.stateFlags & XR_BATTERY_STATE_DISPLAY_STATE_VALID_BIT_EXT)
|
||||
charge = battery_state.batteryLevel;
|
||||
|
||||
battery_status status{
|
||||
.charge = charge,
|
||||
.charging = (battery_state.stateFlags & XR_BATTERY_STATE_DISPLAY_STATE_CHARGING_BIT_EXT) != 0,
|
||||
};
|
||||
if (status != statuses.at(device))
|
||||
{
|
||||
on_status_update(device, std::move(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void battery::on_status_update(battery::device device, battery::battery_status && new_status)
|
||||
{
|
||||
std::lock_guard lock(m);
|
||||
|
||||
if (std::shared_ptr<scene> s = application::instance().current_scene())
|
||||
{
|
||||
s->on_battery_update(device, new_status);
|
||||
}
|
||||
statuses.at(device) = std::move(new_status);
|
||||
}
|
||||
+5
-62
@@ -2,7 +2,6 @@
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2024 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
|
||||
@@ -20,68 +19,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "xr/instance.h"
|
||||
#include "xr/session.h"
|
||||
#ifdef __ANDROID__
|
||||
#include "jni.h"
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <inplace_vector.hpp>
|
||||
#include <magic_enum_containers.hpp>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
class battery
|
||||
struct battery_status
|
||||
{
|
||||
public:
|
||||
enum device : uint8_t
|
||||
{
|
||||
head = 0,
|
||||
left_controller,
|
||||
right_controller,
|
||||
gamepad,
|
||||
};
|
||||
|
||||
struct battery_status
|
||||
{
|
||||
std::optional<float> charge = std::nullopt;
|
||||
bool charging = false;
|
||||
|
||||
bool operator!=(const battery_status & other) const
|
||||
{
|
||||
return charge != other.charge || charging != other.charging;
|
||||
}
|
||||
};
|
||||
|
||||
battery(xr::instance & instance, xr::session & session);
|
||||
#ifdef __ANDROID__
|
||||
battery(xr::instance & instance, xr::session & session, jobject activity);
|
||||
#endif
|
||||
|
||||
private:
|
||||
xr::session & session;
|
||||
std::optional<beman::inplace_vector::inplace_vector<std::pair<XrPath, device>, 3>> top_level_paths;
|
||||
|
||||
std::recursive_mutex m;
|
||||
magic_enum::containers::array<device, battery_status> statuses;
|
||||
|
||||
// we need to poll for controller batteries, there's no XR event sent when their state changes
|
||||
// linux implementation also doesn't have an event-based API for battery
|
||||
std::chrono::steady_clock::time_point last_poll{};
|
||||
|
||||
#ifndef __ANDROID__
|
||||
battery_status get_hmd_battery();
|
||||
#endif
|
||||
|
||||
public:
|
||||
void poll_batteries();
|
||||
|
||||
// updates statuses and sends the new battery status to the focused scene
|
||||
void on_status_update(device device, battery_status && new_status);
|
||||
|
||||
inline battery_status get_battery_status(device device)
|
||||
{
|
||||
std::lock_guard lock(m);
|
||||
return statuses.at(device);
|
||||
};
|
||||
std::optional<float> charge = std::nullopt;
|
||||
bool charging = false;
|
||||
};
|
||||
|
||||
battery_status get_battery_status();
|
||||
|
||||
@@ -102,20 +102,6 @@ bool supports_format(int fd, v4l2_buf_type type, uint32_t pixel_format)
|
||||
}
|
||||
}
|
||||
|
||||
bool supports_p010_capture(int fd)
|
||||
{
|
||||
if (!supports_format(fd, capture_type, V4L2_PIX_FMT_P010))
|
||||
return false;
|
||||
|
||||
v4l2_format fmt{.type = capture_type};
|
||||
if (xioctl(fd, VIDIOC_G_FMT, &fmt) < 0)
|
||||
return false;
|
||||
fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_P010;
|
||||
return xioctl(fd, VIDIOC_TRY_FMT, &fmt) == 0 &&
|
||||
fmt.fmt.pix_mp.pixelformat == V4L2_PIX_FMT_P010 &&
|
||||
fmt.fmt.pix_mp.num_planes == 1;
|
||||
}
|
||||
|
||||
wivrn::fd_base find_device(wivrn::video_codec codec)
|
||||
{
|
||||
const uint32_t pixel_format = v4l2_codec(codec);
|
||||
@@ -608,18 +594,6 @@ void decoder::setup_capture_queue()
|
||||
fmt.type = capture_type;
|
||||
ioctl_or_throw(fd.get_fd(), VIDIOC_G_FMT, &fmt, "VIDIOC_G_FMT(CAPTURE)");
|
||||
|
||||
const uint32_t current = fmt.fmt.pix_mp.pixelformat;
|
||||
const bool ten_bit = current == V4L2_PIX_FMT_P010 || current == V4L2_PIX_FMT_QC10C;
|
||||
const uint32_t wanted = ten_bit && supports_p010_capture(fd.get_fd()) ? V4L2_PIX_FMT_P010 : V4L2_PIX_FMT_NV12;
|
||||
if (current != wanted)
|
||||
{
|
||||
fmt.fmt.pix_mp.pixelformat = wanted;
|
||||
fmt.fmt.pix_mp.plane_fmt[0] = {};
|
||||
ioctl_or_throw(fd.get_fd(), VIDIOC_S_FMT, &fmt, "VIDIOC_S_FMT(CAPTURE)");
|
||||
if (fmt.fmt.pix_mp.pixelformat != wanted)
|
||||
throw std::runtime_error("iris rejected requested NV12/P010 CAPTURE format");
|
||||
}
|
||||
|
||||
capture_width = fmt.fmt.pix_mp.width;
|
||||
capture_height = fmt.fmt.pix_mp.height;
|
||||
capture_pixelformat = fmt.fmt.pix_mp.pixelformat;
|
||||
@@ -1059,24 +1033,7 @@ bool decoder::supports_10bit(wivrn::video_codec codec)
|
||||
try
|
||||
{
|
||||
auto device = find_device(codec);
|
||||
v4l2_format fmt{
|
||||
.type = output_type,
|
||||
.fmt = {
|
||||
.pix_mp = {
|
||||
.width = 640,
|
||||
.height = 640,
|
||||
.pixelformat = v4l2_codec(codec),
|
||||
.field = V4L2_FIELD_NONE,
|
||||
.plane_fmt = {{
|
||||
.sizeimage = 4 * 1024 * 1024,
|
||||
}},
|
||||
.num_planes = 1,
|
||||
}},
|
||||
};
|
||||
if (xioctl(device.get_fd(), VIDIOC_S_FMT, &fmt) < 0 ||
|
||||
fmt.fmt.pix_mp.pixelformat != v4l2_codec(codec))
|
||||
return false;
|
||||
return supports_p010_capture(device.get_fd());
|
||||
return supports_format(device.get_fd(), capture_type, V4L2_PIX_FMT_P010);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
+108
-5
@@ -19,8 +19,8 @@
|
||||
|
||||
#include "hmd_traits.h"
|
||||
|
||||
#include "utils/env.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "utils/strings.h"
|
||||
#include "xr/to_string.h"
|
||||
|
||||
#include <boost/pfr.hpp>
|
||||
@@ -41,11 +41,114 @@
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/property.h"
|
||||
#include "utils/env.h"
|
||||
#include "utils/strings.h"
|
||||
#include "utils/wrap_lambda.h"
|
||||
|
||||
#include <sys/system_properties.h>
|
||||
|
||||
static std::optional<std::string> get_property(const char * property)
|
||||
{
|
||||
auto info = __system_property_find(property);
|
||||
if (not info)
|
||||
return std::nullopt;
|
||||
|
||||
std::string result;
|
||||
wrap_lambda cb = [&result](const char * name, const char * value, uint32_t serial) {
|
||||
result = value;
|
||||
};
|
||||
|
||||
__system_property_read_callback(info, cb.userdata_first(), cb);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
std::optional<T> env(std::string_view name);
|
||||
|
||||
template <>
|
||||
std::optional<std::string> env(std::string_view name)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
auto android_sysprop_name = std::format("debug.wivrn.{}", name);
|
||||
return get_property(android_sysprop_name.c_str());
|
||||
#else
|
||||
std::string env_name = "WIVRN_";
|
||||
env_name.reserve(env_name.size() + name.size());
|
||||
for (const auto & c: name)
|
||||
env_name += std::toupper(c);
|
||||
const char * value = std::getenv(env_name.c_str());
|
||||
if (value)
|
||||
return value;
|
||||
return std::nullopt;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
std::optional<uint32_t> env(std::string_view name)
|
||||
{
|
||||
const auto value = env<std::string>(name);
|
||||
if (not value)
|
||||
return std::nullopt;
|
||||
try
|
||||
{
|
||||
const unsigned long parsed = std::stoul(*value);
|
||||
if (parsed > std::numeric_limits<uint32_t>::max())
|
||||
return std::nullopt;
|
||||
return static_cast<uint32_t>(parsed);
|
||||
}
|
||||
catch (std::runtime_error & e)
|
||||
{
|
||||
spdlog::warn("failed to parse {} (value: {}: {}", name, *value, e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
std::optional<bool> env(std::string_view name)
|
||||
{
|
||||
const auto value = env<std::string>(name);
|
||||
if (not value)
|
||||
return std::nullopt;
|
||||
if (strcmp(value->c_str(), "1") == 0 || strcasecmp(value->c_str(), "true") == 0 || strcasecmp(value->c_str(), "yes") == 0 || strcasecmp(value->c_str(), "on") == 0)
|
||||
return true;
|
||||
if (strcmp(value->c_str(), "0") == 0 || strcasecmp(value->c_str(), "false") == 0 || strcasecmp(value->c_str(), "no") == 0 || strcasecmp(value->c_str(), "off") == 0)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::optional<std::unordered_map<std::string, std::string>> env(std::string_view name)
|
||||
{
|
||||
const auto values = env<std::string>(name);
|
||||
if (not values)
|
||||
return std::nullopt;
|
||||
|
||||
std::unordered_map<std::string, std::string> map;
|
||||
for (auto value: utils::split(*values, ","))
|
||||
{
|
||||
if (auto pos = value.find('='); pos != std::string::npos)
|
||||
map.insert(std::make_pair(value.substr(0, pos), value.substr(pos + 1)));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
template <>
|
||||
std::optional<std::unordered_set<std::string>> env(std::string_view name)
|
||||
{
|
||||
const auto values = env<std::string>(name);
|
||||
if (not values)
|
||||
return std::nullopt;
|
||||
|
||||
#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
|
||||
return std::unordered_set<std::string>{std::from_range, utils::split(*values, ",")};
|
||||
#else
|
||||
std::optional<std::unordered_set<std::string>> res{std::in_place};
|
||||
for (auto & val: utils::split(*values))
|
||||
res->insert(std::move(val));
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
void hmd_traits::init()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
@@ -341,7 +444,7 @@ static XrViewConfigurationView scale_view(XrViewConfigurationView view, uint32_t
|
||||
double ratio = double(width) / view.recommendedImageRectWidth;
|
||||
view.recommendedImageRectWidth = width;
|
||||
view.recommendedImageRectHeight *= ratio;
|
||||
spdlog::debug("Using panel size: {}x{}", view.recommendedImageRectWidth, view.recommendedImageRectHeight);
|
||||
spdlog::info("Using panel size: {}x{}", view.recommendedImageRectWidth, view.recommendedImageRectHeight);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Name=WiVRn
|
||||
Comment=Play your PC VR games on a standalone headset
|
||||
GenericName=WiVRn client
|
||||
Exec=@CMAKE_INSTALL_PREFIX@/bin/wivrn
|
||||
Icon=io.github.wivrn.wivrn-client
|
||||
Type=Application
|
||||
Categories=Network;
|
||||
Keywords=VR;Virtual reality;OpenVR;OpenXR;
|
||||
@@ -16,7 +16,7 @@ public class MainActivity extends android.app.NativeActivity
|
||||
@Override
|
||||
public native void onActivityResult(int requestCode, int resultCode, android.content.Intent data);
|
||||
|
||||
public android.content.BroadcastReceiver BatteryInfoReceiver = null;
|
||||
private android.content.BroadcastReceiver BatteryInfoReceiver = null;
|
||||
public android.net.ConnectivityManager.NetworkCallback netcb = null;
|
||||
|
||||
@Override
|
||||
@@ -24,7 +24,9 @@ public class MainActivity extends android.app.NativeActivity
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.BatteryInfoReceiver = new org.meumeu.wivrn.BroadcastReceiver();
|
||||
this.BatteryInfoReceiver = new BroadcastReceiver();
|
||||
this.netcb = new org.meumeu.wivrn.NetworkInfoCallback();
|
||||
|
||||
this.registerReceiver(this.BatteryInfoReceiver, new android.content.IntentFilter(android.content.Intent.ACTION_BATTERY_CHANGED));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
std::mutex last_status_lock;
|
||||
battery_status last_status;
|
||||
std::chrono::steady_clock::time_point last_read;
|
||||
|
||||
std::optional<std::string> read_line(const std::filesystem::path & path)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
@@ -33,6 +37,7 @@ std::optional<std::string> read_line(const std::filesystem::path & path)
|
||||
return line;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<float> read_percent(const std::filesystem::path & path)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
@@ -42,7 +47,7 @@ std::optional<float> read_percent(const std::filesystem::path & path)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
battery::battery_status read_battery_status(const std::filesystem::path & percent_path, const std::filesystem::path & status_path)
|
||||
battery_status read_battery_status(const std::filesystem::path & percent_path, const std::filesystem::path & status_path)
|
||||
{
|
||||
auto charge = read_percent(percent_path);
|
||||
if (not charge)
|
||||
@@ -53,9 +58,8 @@ battery::battery_status read_battery_status(const std::filesystem::path & percen
|
||||
.charging = status == "Charging" or status == "Full",
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
battery::battery_status battery::get_hmd_battery()
|
||||
battery_status read_battery_status()
|
||||
{
|
||||
// SteamOS on the Steam Frame: the charger daemon's percentage is what the system UI shows
|
||||
const std::filesystem::path deckard = "/run/deckardcharger";
|
||||
@@ -74,3 +78,17 @@ battery::battery_status battery::get_hmd_battery()
|
||||
|
||||
return {};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
battery_status get_battery_status()
|
||||
{
|
||||
// The lobby asks every frame, the files only change every few seconds
|
||||
std::unique_lock _{last_status_lock};
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
if (now - last_read > std::chrono::seconds(5))
|
||||
{
|
||||
last_status = read_battery_status();
|
||||
last_read = now;
|
||||
}
|
||||
return last_status;
|
||||
}
|
||||
|
||||
+21
-25
@@ -20,13 +20,10 @@
|
||||
#include "application.h"
|
||||
#include "scenes/lobby.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/env.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <string>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -44,28 +41,6 @@ void real_main(android_app * native_app)
|
||||
void real_main(int argc, char ** argv)
|
||||
#endif
|
||||
{
|
||||
auto log_level = env<std::string>("loglevel");
|
||||
if (log_level)
|
||||
{
|
||||
std::transform(log_level->begin(), log_level->end(), log_level->begin(), [](char c) { return tolower(c); });
|
||||
if (log_level == "trace")
|
||||
spdlog::set_level(spdlog::level::trace);
|
||||
else if (log_level == "debug")
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
else if (log_level == "info")
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
else if (log_level == "warning")
|
||||
spdlog::set_level(spdlog::level::warn);
|
||||
else if (log_level == "error")
|
||||
spdlog::set_level(spdlog::level::err);
|
||||
else if (log_level == "critical")
|
||||
spdlog::set_level(spdlog::level::critical);
|
||||
else if (log_level == "off")
|
||||
spdlog::set_level(spdlog::level::off);
|
||||
else
|
||||
spdlog::warn("Invalid value for log level: {}", *log_level);
|
||||
}
|
||||
|
||||
if (wivrn::is_tag)
|
||||
spdlog::info("Starting WiVRn version {}", wivrn::display_version());
|
||||
else
|
||||
@@ -132,6 +107,27 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
spdlog::set_default_logger(spdlog::stdout_color_mt("WiVRn"));
|
||||
|
||||
char * loglevel = getenv("WIVRN_LOGLEVEL");
|
||||
if (loglevel)
|
||||
{
|
||||
if (!strcasecmp(loglevel, "trace"))
|
||||
spdlog::set_level(spdlog::level::trace);
|
||||
else if (!strcasecmp(loglevel, "debug"))
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
else if (!strcasecmp(loglevel, "info"))
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
else if (!strcasecmp(loglevel, "warning"))
|
||||
spdlog::set_level(spdlog::level::warn);
|
||||
else if (!strcasecmp(loglevel, "error"))
|
||||
spdlog::set_level(spdlog::level::err);
|
||||
else if (!strcasecmp(loglevel, "critical"))
|
||||
spdlog::set_level(spdlog::level::critical);
|
||||
else if (!strcasecmp(loglevel, "off"))
|
||||
spdlog::set_level(spdlog::level::off);
|
||||
else
|
||||
spdlog::warn("Invalid value for WIVRN_LOGLEVEL environment variable");
|
||||
}
|
||||
|
||||
real_main(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -584,7 +584,6 @@ void scene::remove(entt::entity entity)
|
||||
void scene::on_unfocused() {}
|
||||
void scene::on_focused() {}
|
||||
void scene::on_xr_event(const xr::event &) {}
|
||||
void scene::on_battery_update(battery::device, const battery::battery_status &) {}
|
||||
|
||||
bool scene::on_input_key_down(uint8_t key_code)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "battery.h"
|
||||
#include "render/image_loader.h"
|
||||
#include "render/scene_loader.h"
|
||||
#include "render/scene_renderer.h"
|
||||
@@ -210,7 +209,6 @@ public:
|
||||
void set_focused(bool status);
|
||||
virtual void render(const XrFrameState &) = 0;
|
||||
virtual void on_xr_event(const xr::event &);
|
||||
virtual void on_battery_update(battery::device device, const battery::battery_status &);
|
||||
|
||||
virtual bool on_input_key_down(uint8_t key_code);
|
||||
virtual bool on_input_key_up(uint8_t key_code);
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "gui_common.h"
|
||||
|
||||
#include "application.h"
|
||||
#include "battery.h"
|
||||
#include "render/ui_theme.h"
|
||||
#include "render/ui_widgets.h"
|
||||
@@ -38,7 +37,7 @@ float toggle_width()
|
||||
|
||||
std::optional<battery_indicator> battery_status_indicator(XrTime now)
|
||||
{
|
||||
const auto battery = application::get_battery_monitor().get_battery_status(battery::device::head);
|
||||
const auto battery = get_battery_status();
|
||||
if (not battery.charge)
|
||||
return std::nullopt;
|
||||
|
||||
|
||||
@@ -267,11 +267,8 @@ void settings_video(const settings_context & ctx)
|
||||
}
|
||||
|
||||
{
|
||||
auto view = ctx.system.stereo_view();
|
||||
view = application::get_hmd_traits().override_view(view);
|
||||
const auto width = view.recommendedImageRectWidth;
|
||||
const auto height = view.recommendedImageRectHeight;
|
||||
|
||||
const auto width = ctx.recommended_width;
|
||||
const auto height = ctx.recommended_height;
|
||||
list.push_back({
|
||||
.id = "##resolution",
|
||||
.label = _("Render resolution"),
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
@@ -45,6 +46,10 @@ struct settings_context
|
||||
xr::system & system;
|
||||
imgui_context & imgui_ctx;
|
||||
|
||||
// recommended per-eye render resolution, for the resolution description
|
||||
uint32_t recommended_width = 0;
|
||||
uint32_t recommended_height = 0;
|
||||
|
||||
// streaming: connection-time settings are disabled, in-stream controls appear
|
||||
bool in_game = false;
|
||||
|
||||
|
||||
+9
-18
@@ -144,10 +144,6 @@ void scenes::lobby::move_gui(glm::vec3 head_position, glm::vec3 new_gui_position
|
||||
scenes::lobby::lobby() :
|
||||
scene_impl<lobby>(supported_color_formats, supported_depth_formats)
|
||||
{
|
||||
const auto & view = system.stereo_view();
|
||||
width = view.recommendedImageRectWidth;
|
||||
height = view.recommendedImageRectHeight;
|
||||
|
||||
spdlog::info("Using formats {} and {}", vk::to_string(swapchain_format), vk::to_string(depth_format));
|
||||
|
||||
if (composition_layer_depth_test_supported)
|
||||
@@ -1144,6 +1140,15 @@ void scenes::lobby::on_focused()
|
||||
{
|
||||
recenter_gui = true;
|
||||
|
||||
auto views = system.view_configuration_views(viewconfig);
|
||||
assert(views.size() == 2); // FIXME
|
||||
stream_view = application::get_hmd_traits().override_view(views[0]);
|
||||
width = views[0].recommendedImageRectWidth;
|
||||
height = views[0].recommendedImageRectHeight;
|
||||
|
||||
// assert(std::ranges::all_of(views, [width](const XrViewConfigurationView & view) { return view.recommendedImageRectWidth == width; }));
|
||||
// assert(std::ranges::all_of(views, [height](const XrViewConfigurationView & view) { return view.recommendedImageRectHeight == height; }));
|
||||
|
||||
auto & config = application::get_config();
|
||||
|
||||
try
|
||||
@@ -1411,11 +1416,6 @@ void scenes::lobby::on_xr_event(const xr::event & event)
|
||||
if (next_scene)
|
||||
next_scene->on_xr_event(event);
|
||||
}
|
||||
void scenes::lobby::on_battery_update(battery::device device, const battery::battery_status & battery)
|
||||
{
|
||||
if (next_scene)
|
||||
next_scene->on_battery_update(device, battery);
|
||||
}
|
||||
|
||||
scene::meta & scenes::lobby::get_meta_scene()
|
||||
{
|
||||
@@ -1467,15 +1467,6 @@ scene::meta & scenes::lobby::get_meta_scene()
|
||||
{"recenter_right", "/user/hand/right/input/squeeze/value"},
|
||||
},
|
||||
},
|
||||
suggested_binding{
|
||||
{
|
||||
"/interaction_profiles/valve/frame_controller_valve",
|
||||
},
|
||||
{
|
||||
{"left_trigger", "/user/hand/left/input/bumper/click"},
|
||||
{"right_trigger", "/user/hand/right/input/bumper/click"},
|
||||
},
|
||||
},
|
||||
suggested_binding{
|
||||
{
|
||||
"/interaction_profiles/khr/simple_controller",
|
||||
|
||||
@@ -95,6 +95,7 @@ class lobby : public scene_impl<lobby>
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
XrViewConfigurationView stream_view;
|
||||
|
||||
#if WIVRN_CLIENT_DEBUG_MENU
|
||||
// GUI debug
|
||||
@@ -270,7 +271,6 @@ public:
|
||||
void on_unfocused() override;
|
||||
void on_focused() override;
|
||||
void on_xr_event(const xr::event &) override;
|
||||
void on_battery_update(battery::device device, const battery::battery_status &) override;
|
||||
|
||||
static meta & get_meta_scene();
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr::session & session, xr::system & system, imgui_context & imgui_ctx, std::optional<bool> server_hid_forwarding)
|
||||
wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr::session & session, xr::system & system, imgui_context & imgui_ctx, const XrViewConfigurationView & stream_view, std::optional<bool> server_hid_forwarding)
|
||||
{
|
||||
return {
|
||||
.config = application::get_config(),
|
||||
@@ -35,6 +35,8 @@ wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr:
|
||||
.session = session,
|
||||
.system = system,
|
||||
.imgui_ctx = imgui_ctx,
|
||||
.recommended_width = stream_view.recommendedImageRectWidth,
|
||||
.recommended_height = stream_view.recommendedImageRectHeight,
|
||||
.in_game = false,
|
||||
.server_hid_forwarding = server_hid_forwarding,
|
||||
};
|
||||
@@ -43,40 +45,40 @@ wivrn::gui::settings_context lobby_settings_context(xr::instance & instance, xr:
|
||||
|
||||
void scenes::lobby::gui_video()
|
||||
{
|
||||
wivrn::gui::settings_video(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_video(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_streaming()
|
||||
{
|
||||
wivrn::gui::settings_streaming(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_streaming(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_post_processing()
|
||||
{
|
||||
wivrn::gui::settings_post_processing(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_post_processing(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_audio()
|
||||
{
|
||||
wivrn::gui::settings_audio(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_audio(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_devices()
|
||||
{
|
||||
wivrn::gui::settings_devices(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_devices(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_tracking()
|
||||
{
|
||||
wivrn::gui::settings_tracking(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_tracking(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_system()
|
||||
{
|
||||
wivrn::gui::settings_system(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_system(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
void scenes::lobby::gui_theme()
|
||||
{
|
||||
wivrn::gui::settings_theme(lobby_settings_context(instance, session, system, *imgui_ctx, server_hid_forwarding));
|
||||
wivrn::gui::settings_theme(lobby_settings_context(instance, session, system, *imgui_ctx, stream_view, server_hid_forwarding));
|
||||
}
|
||||
|
||||
+11
-47
@@ -59,21 +59,20 @@ using namespace beman::inplace_vector;
|
||||
static const std::unordered_map<std::string, device_id> device_ids = {
|
||||
{"/user/hand/left/input/dpad_up/click", device_id::DPAD_UP_CLICK},
|
||||
{"/user/hand/left/input/dpad_up/touch", device_id::DPAD_UP_TOUCH},
|
||||
{"/user/hand/left/input/dpad_left/click", device_id::DPAD_LEFT_CLICK},
|
||||
{"/user/hand/left/input/dpad_left/touch", device_id::DPAD_LEFT_TOUCH},
|
||||
{"/user/hand/left/input/dpad_down/click", device_id::LEFT_X_CLICK},
|
||||
{"/user/hand/left/input/dpad_down/touch", device_id::LEFT_X_TOUCH},
|
||||
{"/user/hand/left/input/dpad_left/click", device_id::DPAD_LEFT_CLICK},
|
||||
{"/user/hand/left/input/dpad_left/touch", device_id::DPAD_LEFT_TOUCH},
|
||||
{"/user/hand/left/input/dpad_right/click", device_id::LEFT_Y_CLICK},
|
||||
{"/user/hand/left/input/dpad_right/touch", device_id::LEFT_Y_TOUCH},
|
||||
{"/user/hand/left/input/x/click", device_id::LEFT_X_CLICK},
|
||||
{"/user/hand/left/input/x/touch", device_id::LEFT_X_TOUCH},
|
||||
{"/user/hand/left/input/y/click", device_id::LEFT_Y_CLICK},
|
||||
{"/user/hand/left/input/y/touch", device_id::LEFT_Y_TOUCH},
|
||||
{"/user/hand/left/input/view/click", device_id::LEFT_MENU_CLICK},
|
||||
{"/user/hand/left/input/view/touch", device_id::LEFT_MENU_TOUCH},
|
||||
{"/user/hand/left/input/view/click", device_id::VIEW_CLICK},
|
||||
{"/user/hand/left/input/view/touch", device_id::VIEW_TOUCH},
|
||||
{"/user/hand/left/input/menu/click", device_id::LEFT_MENU_CLICK},
|
||||
{"/user/hand/left/input/menu/touch", device_id::LEFT_MENU_TOUCH},
|
||||
{"/user/hand/left/input/system/click", device_id::LEFT_SYSTEM_CLICK},
|
||||
{"/user/hand/left/input/system/click", device_id::LEFT_MENU_CLICK},
|
||||
{"/user/hand/left/input/system/touch", device_id::LEFT_SYSTEM_TOUCH},
|
||||
{"/user/hand/left/input/bumper/click", device_id::LEFT_BUMPER_CLICK},
|
||||
{"/user/hand/left/input/bumper/touch", device_id::LEFT_BUMPER_TOUCH},
|
||||
@@ -116,10 +115,10 @@ static const std::unordered_map<std::string, device_id> device_ids = {
|
||||
{"/user/hand/right/input/x/touch", device_id::RIGHT_X_TOUCH},
|
||||
{"/user/hand/right/input/y/click", device_id::RIGHT_Y_CLICK},
|
||||
{"/user/hand/right/input/y/touch", device_id::RIGHT_Y_TOUCH},
|
||||
{"/user/hand/right/input/menu/click", device_id::RIGHT_MENU_CLICK},
|
||||
{"/user/hand/right/input/menu/touch", device_id::RIGHT_MENU_TOUCH},
|
||||
{"/user/hand/right/input/system/click", device_id::RIGHT_SYSTEM_CLICK},
|
||||
{"/user/hand/right/input/system/touch", device_id::RIGHT_SYSTEM_TOUCH},
|
||||
{"/user/hand/right/input/menu/click", device_id::RIGHT_MENU_CLICK},
|
||||
{"/user/hand/right/input/menu/touch", device_id::RIGHT_MENU_TOUCH},
|
||||
{"/user/hand/right/input/bumper/click", device_id::RIGHT_BUMPER_CLICK},
|
||||
{"/user/hand/right/input/bumper/touch", device_id::RIGHT_BUMPER_TOUCH},
|
||||
{"/user/hand/right/input/squeeze/click", device_id::RIGHT_SQUEEZE_CLICK},
|
||||
@@ -206,9 +205,9 @@ scenes::stream::stream(std::string server_name, scene & parent_scene) :
|
||||
apps{*this, std::move(server_name)},
|
||||
foveation_center{instance, system, session, device, commandpool, queue, swapchain_format}
|
||||
{
|
||||
const auto & view = system.stereo_view();
|
||||
width = view.recommendedImageRectWidth;
|
||||
height = view.recommendedImageRectHeight;
|
||||
auto views = system.view_configuration_views(viewconfig);
|
||||
width = views[0].recommendedImageRectWidth;
|
||||
height = views[0].recommendedImageRectHeight;
|
||||
}
|
||||
|
||||
static from_headset::visibility_mask_changed::masks get_visibility_mask(xr::instance & inst, xr::session & session, int view)
|
||||
@@ -254,7 +253,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
const auto & config = application::get_config();
|
||||
|
||||
{
|
||||
auto view = self->system.stereo_view();
|
||||
auto view = self->system.view_configuration_views(self->viewconfig)[0];
|
||||
view = application::get_hmd_traits().override_view(view);
|
||||
|
||||
info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale;
|
||||
@@ -286,7 +285,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
info.settings.mirror_gamepad = config.forward_gamepad;
|
||||
info.settings.enabled_body_parts = config.body_part_mask;
|
||||
|
||||
info.battery_status = self->instance.has_extension(XR_EXT_INTERACTION_PROFILE_BATTERY_STATE_DISPLAY_EXTENSION_NAME);
|
||||
info.hand_tracking = config.check_feature(feature::hand_tracking);
|
||||
info.eye_gaze = config.check_feature(feature::eye_gaze);
|
||||
|
||||
@@ -1305,12 +1303,6 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
|
||||
spdlog::info("setup, refresh rate {}", description.refresh_rate);
|
||||
session.set_refresh_rate(description.refresh_rate);
|
||||
|
||||
battery & battery_monitor = application::get_battery_monitor();
|
||||
for (auto device: magic_enum::enum_values<battery::device>())
|
||||
{
|
||||
on_battery_update(device, battery_monitor.get_battery_status(device));
|
||||
}
|
||||
|
||||
std::unique_lock lock(decoder_mutex);
|
||||
if (video_stream_description == description)
|
||||
return;
|
||||
@@ -1466,9 +1458,6 @@ scene::meta & scenes::stream::get_meta_scene()
|
||||
"/interaction_profiles/valve/frame_controller_valve",
|
||||
},
|
||||
{
|
||||
{"left_trigger", "/user/hand/left/input/bumper/click"},
|
||||
{"right_trigger", "/user/hand/right/input/bumper/click"},
|
||||
|
||||
{"gamepad_mode_1", "/user/hand/left/input/squeeze/click"},
|
||||
{"gamepad_mode_2", "/user/hand/right/input/squeeze/click"},
|
||||
},
|
||||
@@ -1542,31 +1531,6 @@ void scenes::stream::on_xr_event(const xr::event & event)
|
||||
}
|
||||
}
|
||||
|
||||
void scenes::stream::on_battery_update(battery::device device, const battery::battery_status & battery)
|
||||
{
|
||||
device_id id = [&] {
|
||||
switch (device)
|
||||
{
|
||||
case battery::device::head:
|
||||
return device_id::HEAD;
|
||||
case battery::device::left_controller:
|
||||
return device_id::LEFT_CONTROLLER;
|
||||
case battery::device::right_controller:
|
||||
return device_id::RIGHT_CONTROLLER;
|
||||
case battery::device::gamepad:
|
||||
return device_id::GAMEPAD;
|
||||
default:
|
||||
assert(false);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}();
|
||||
network_session->send_control(from_headset::battery{
|
||||
.device = id,
|
||||
.charge = battery.charge,
|
||||
.charging = battery.charging,
|
||||
});
|
||||
}
|
||||
|
||||
bool scenes::stream::forward_hid_input(from_headset::hid::input_t packet, bool device_enabled)
|
||||
{
|
||||
// hid_forwarding is whether the server permits it; device_enabled is the headset toggle.
|
||||
|
||||
@@ -248,7 +248,6 @@ public:
|
||||
void on_focused() override;
|
||||
void on_unfocused() override;
|
||||
void on_xr_event(const xr::event &) override;
|
||||
void on_battery_update(battery::device device, const battery::battery_status &) override;
|
||||
|
||||
bool on_input_key_down(uint8_t key_code) override;
|
||||
bool on_input_key_up(uint8_t key_code) override;
|
||||
|
||||
@@ -33,7 +33,7 @@ std::optional<device_id> frame_gamepad_input(device_id id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case device_id::LEFT_MENU_CLICK:
|
||||
case device_id::VIEW_CLICK:
|
||||
return device_id::GAMEPAD_VIEW_CLICK;
|
||||
case device_id::RIGHT_MENU_CLICK:
|
||||
return device_id::GAMEPAD_MENU_CLICK;
|
||||
@@ -47,10 +47,10 @@ std::optional<device_id> frame_gamepad_input(device_id id)
|
||||
return device_id::GAMEPAD_Y_CLICK;
|
||||
case device_id::DPAD_UP_CLICK:
|
||||
return device_id::GAMEPAD_DPAD_UP_CLICK;
|
||||
case device_id::DPAD_LEFT_CLICK:
|
||||
return device_id::GAMEPAD_DPAD_LEFT_CLICK;
|
||||
case device_id::LEFT_X_CLICK:
|
||||
return device_id::GAMEPAD_DPAD_DOWN_CLICK;
|
||||
case device_id::DPAD_LEFT_CLICK:
|
||||
return device_id::GAMEPAD_DPAD_LEFT_CLICK;
|
||||
case device_id::LEFT_Y_CLICK:
|
||||
return device_id::GAMEPAD_DPAD_RIGHT_CLICK;
|
||||
case device_id::LEFT_BUMPER_CLICK:
|
||||
|
||||
@@ -407,6 +407,8 @@ void scenes::stream::gui_settings(float)
|
||||
.session = session,
|
||||
.system = system,
|
||||
.imgui_ctx = *imgui_ctx,
|
||||
.recommended_width = width,
|
||||
.recommended_height = height,
|
||||
.in_game = true,
|
||||
.server_hid_forwarding = hid_forwarding_enabled(),
|
||||
.on_streaming_changed = [this] { send_settings_changed_packet(session, network_session.get(), application::get_config()); },
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "application.h"
|
||||
#include "battery.h"
|
||||
#include "stream.h"
|
||||
#include "utils/overloaded.h"
|
||||
#include "wivrn_packets.h"
|
||||
@@ -278,6 +279,9 @@ void scenes::stream::tracking()
|
||||
application::instance().setup_jni();
|
||||
#endif
|
||||
|
||||
XrTime next_battery_check = 0;
|
||||
const XrDuration battery_check_interval = 30'000'000'000; // 30s
|
||||
|
||||
magic_enum::containers::array<device_id, XrSpace> spaces{};
|
||||
|
||||
const auto & config = application::get_config();
|
||||
@@ -586,6 +590,19 @@ void scenes::stream::tracking()
|
||||
throw;
|
||||
}
|
||||
|
||||
// FIXME: switch to event based
|
||||
if (next_battery_check < now)
|
||||
{
|
||||
auto status = get_battery_status();
|
||||
network_session->send_stream(from_headset::battery{
|
||||
.charge = status.charge.value_or(-1),
|
||||
.present = status.charge.has_value(),
|
||||
.charging = status.charging,
|
||||
});
|
||||
|
||||
next_battery_check = now + battery_check_interval;
|
||||
}
|
||||
|
||||
if (auto fb = std::get_if<xr::fb_body_tracker>(&body_tracker); fb and fb->should_send_skeleton())
|
||||
{
|
||||
try
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2023 Guillaume Meunier <guillaume.meunier@centraliens.net>
|
||||
* Copyright (C) 2023 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/strings.h"
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "android/property.h"
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
std::optional<T> env(std::string_view name);
|
||||
|
||||
template <>
|
||||
inline std::optional<std::string> env(std::string_view name)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
auto android_sysprop_name = std::format("debug.wivrn.{}", name);
|
||||
return get_property(android_sysprop_name.c_str());
|
||||
#else
|
||||
std::string env_name = "WIVRN_";
|
||||
env_name.reserve(env_name.size() + name.size());
|
||||
for (const auto & c: name)
|
||||
env_name += std::toupper(c);
|
||||
const char * value = std::getenv(env_name.c_str());
|
||||
if (value)
|
||||
return value;
|
||||
return std::nullopt;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::optional<uint32_t> env(std::string_view name)
|
||||
{
|
||||
const auto value = env<std::string>(name);
|
||||
if (not value)
|
||||
return std::nullopt;
|
||||
try
|
||||
{
|
||||
const unsigned long parsed = std::stoul(*value);
|
||||
if (parsed > std::numeric_limits<uint32_t>::max())
|
||||
return std::nullopt;
|
||||
return static_cast<uint32_t>(parsed);
|
||||
}
|
||||
catch (std::runtime_error & e)
|
||||
{
|
||||
spdlog::warn("failed to parse {} (value: {}: {}", name, *value, e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::optional<bool> env(std::string_view name)
|
||||
{
|
||||
const auto value = env<std::string>(name);
|
||||
if (not value)
|
||||
return std::nullopt;
|
||||
if (strcmp(value->c_str(), "1") == 0 || strcasecmp(value->c_str(), "true") == 0 || strcasecmp(value->c_str(), "yes") == 0 || strcasecmp(value->c_str(), "on") == 0)
|
||||
return true;
|
||||
if (strcmp(value->c_str(), "0") == 0 || strcasecmp(value->c_str(), "false") == 0 || strcasecmp(value->c_str(), "no") == 0 || strcasecmp(value->c_str(), "off") == 0)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::optional<std::unordered_map<std::string, std::string>> env(std::string_view name)
|
||||
{
|
||||
const auto values = env<std::string>(name);
|
||||
if (not values)
|
||||
return std::nullopt;
|
||||
|
||||
std::unordered_map<std::string, std::string> map;
|
||||
for (auto value: utils::split(*values, ","))
|
||||
{
|
||||
if (auto pos = value.find('='); pos != std::string::npos)
|
||||
map.insert(std::make_pair(value.substr(0, pos), value.substr(pos + 1)));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::optional<std::unordered_set<std::string>> env(std::string_view name)
|
||||
{
|
||||
const auto values = env<std::string>(name);
|
||||
if (not values)
|
||||
return std::nullopt;
|
||||
|
||||
#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
|
||||
return std::unordered_set<std::string>{std::from_range, utils::split(*values, ",")};
|
||||
#else
|
||||
std::optional<std::unordered_set<std::string>> res{std::in_place};
|
||||
for (auto & val: utils::split(*values))
|
||||
res->insert(std::move(val));
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
@@ -53,10 +53,6 @@ xr::system::system(xr::instance & inst, XrFormFactor formfactor)
|
||||
|
||||
body_tracker = xr::body_tracker_supported(inst, *this);
|
||||
face_tracker = xr::face_tracker_supported(inst, *this);
|
||||
|
||||
auto views = view_configuration_views(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO);
|
||||
assert(views.size() == 2);
|
||||
stereo_view_ = views[0];
|
||||
}
|
||||
|
||||
XrGraphicsRequirementsVulkan2KHR xr::system::graphics_requirements() const
|
||||
|
||||
@@ -66,7 +66,6 @@ class system
|
||||
passthrough_type passthrough;
|
||||
body_tracker_type body_tracker;
|
||||
face_tracker_type face_tracker;
|
||||
XrViewConfigurationView stereo_view_;
|
||||
|
||||
public:
|
||||
system() = default;
|
||||
@@ -107,10 +106,6 @@ public:
|
||||
vk::raii::Device create_device(vk::raii::PhysicalDevice & pdev, vk::DeviceCreateInfo & create_info) const;
|
||||
|
||||
std::vector<XrViewConfigurationType> view_configurations() const;
|
||||
const XrViewConfigurationView & stereo_view() const
|
||||
{
|
||||
return stereo_view_;
|
||||
}
|
||||
XrViewConfigurationProperties view_configuration_properties(XrViewConfigurationType) const;
|
||||
std::vector<XrViewConfigurationView> view_configuration_views(XrViewConfigurationType) const;
|
||||
std::vector<XrEnvironmentBlendMode> environment_blend_modes(XrViewConfigurationType) const;
|
||||
|
||||
+1
-1
@@ -507,10 +507,10 @@ void decrypt_context::decrypt_in_place(std::span<std::span<uint8_t>> text)
|
||||
|
||||
std::vector<uint8_t> pbkdf2(std::string pass, std::string salt, std::span<uint8_t> secret, size_t size)
|
||||
{
|
||||
pass.append((char *)secret.data(), secret.size());
|
||||
std::array params{
|
||||
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, salt.data(), salt.size()),
|
||||
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD, pass.data(), pass.size()),
|
||||
OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET, secret.data(), secret.size()),
|
||||
OSSL_PARAM_construct_end(),
|
||||
};
|
||||
|
||||
|
||||
+89
-205
@@ -65,7 +65,6 @@ public:
|
||||
}
|
||||
|
||||
std::vector<std::string> string_table();
|
||||
std::vector<std::string> string_table(uint32_t count);
|
||||
|
||||
auto tellg()
|
||||
{
|
||||
@@ -102,15 +101,6 @@ std::vector<std::string> binary_reader::string_table()
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<std::string> binary_reader::string_table(uint32_t count)
|
||||
{
|
||||
std::vector<std::string> res;
|
||||
res.reserve(count);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
res.emplace_back(read<std::string>());
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_dict(binary_reader & in, T & visitor, const std::vector<std::string> * string_table = nullptr)
|
||||
{
|
||||
@@ -227,113 +217,15 @@ std::unordered_set<uint64_t> owned_appids(std::filesystem::path localconfig)
|
||||
return res;
|
||||
}
|
||||
|
||||
struct app_data
|
||||
{
|
||||
enum section
|
||||
{
|
||||
common,
|
||||
other,
|
||||
};
|
||||
|
||||
std::vector<enum section> section;
|
||||
wivrn::steam::application current{};
|
||||
std::string clienticon;
|
||||
std::string linuxclienticon;
|
||||
bool VR = false;
|
||||
|
||||
void clear()
|
||||
{
|
||||
section.clear();
|
||||
current.icon.clear();
|
||||
current.name.clear();
|
||||
current.url.clear();
|
||||
clienticon.clear();
|
||||
linuxclienticon.clear();
|
||||
VR = false;
|
||||
section.push_back(section::other);
|
||||
}
|
||||
|
||||
void begin_dict(const std::string & key)
|
||||
{
|
||||
if (key == "common")
|
||||
section.push_back(section::common);
|
||||
else
|
||||
section.push_back(section::other);
|
||||
}
|
||||
void end_dict()
|
||||
{
|
||||
section.pop_back();
|
||||
}
|
||||
void on_string(const std::string & key, std::string && val)
|
||||
{
|
||||
switch (section.back())
|
||||
{
|
||||
case common:
|
||||
if (strcasecmp(key.c_str(), "clienticon") == 0)
|
||||
clienticon = std::move(val);
|
||||
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
|
||||
linuxclienticon = std::move(val);
|
||||
else if (strcasecmp(key.c_str(), "name") == 0)
|
||||
current.name[""] = std::move(val);
|
||||
break;
|
||||
case other:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void on_uint32_t(const std::string & key, uint32_t val)
|
||||
{
|
||||
switch (section.back())
|
||||
{
|
||||
case common:
|
||||
if (key == "openvrsupport")
|
||||
VR = val;
|
||||
break;
|
||||
case other:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool is_appid_magic(uint32_t magic)
|
||||
{
|
||||
return (magic & 0xff'ff'ff'00) == 0x07'56'44'00;
|
||||
}
|
||||
|
||||
void try_parse_application(std::vector<wivrn::steam::application> & out, std::filesystem::path root, uint32_t app_id, binary_reader & in, app_data & v, const std::vector<std::string> * string_table)
|
||||
{
|
||||
try
|
||||
{
|
||||
v.clear();
|
||||
read_dict(in, v, string_table);
|
||||
if (v.VR)
|
||||
{
|
||||
auto & item = out.emplace_back(std::move(v.current));
|
||||
item.appid = app_id;
|
||||
item.url = std::format("steam://launch/{}/VR", app_id);
|
||||
|
||||
if (auto icon_path = root / "steam/games" / (v.clienticon + ".ico"); std::filesystem::exists(icon_path))
|
||||
item.icon = icon_path;
|
||||
|
||||
else if (auto icon_path = root / "steam/games" / (v.linuxclienticon + ".zip"); std::filesystem::exists(icon_path))
|
||||
item.icon = icon_path;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove when v42 appinfo is used in stable Steam Client
|
||||
std::vector<wivrn::steam::application> read_appinfo_pre_v42(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
|
||||
std::vector<wivrn::steam::application> read_appinfo(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
|
||||
{
|
||||
binary_reader in{std::ifstream{root / "appcache/appinfo.vdf"}};
|
||||
|
||||
uint32_t magic = in.read<uint32_t>();
|
||||
if (!is_appid_magic(magic))
|
||||
if ((magic & 0xff'ff'ff'00) != 0x07'56'44'00)
|
||||
throw std::runtime_error{"Wrong magic number"};
|
||||
|
||||
in.discard(4); // universe
|
||||
auto universe = in.read<uint32_t>();
|
||||
|
||||
int version = magic & 0xff;
|
||||
|
||||
@@ -346,7 +238,71 @@ std::vector<wivrn::steam::application> read_appinfo_pre_v42(std::filesystem::pat
|
||||
}
|
||||
std::vector<wivrn::steam::application> res;
|
||||
|
||||
app_data v;
|
||||
enum section
|
||||
{
|
||||
common,
|
||||
other,
|
||||
};
|
||||
struct V
|
||||
{
|
||||
std::vector<enum section> section;
|
||||
wivrn::steam::application current{};
|
||||
std::string clienticon;
|
||||
std::string linuxclienticon;
|
||||
bool VR = false;
|
||||
|
||||
void clear()
|
||||
{
|
||||
section.clear();
|
||||
current.icon.clear();
|
||||
current.name.clear();
|
||||
current.url.clear();
|
||||
clienticon.clear();
|
||||
linuxclienticon.clear();
|
||||
VR = false;
|
||||
section.push_back(section::other);
|
||||
}
|
||||
|
||||
void begin_dict(const std::string & key)
|
||||
{
|
||||
if (key == "common")
|
||||
section.push_back(section::common);
|
||||
else
|
||||
section.push_back(section::other);
|
||||
}
|
||||
void end_dict()
|
||||
{
|
||||
section.pop_back();
|
||||
}
|
||||
void on_string(const std::string & key, std::string && val)
|
||||
{
|
||||
switch (section.back())
|
||||
{
|
||||
case common:
|
||||
if (strcasecmp(key.c_str(), "clienticon") == 0)
|
||||
clienticon = std::move(val);
|
||||
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
|
||||
linuxclienticon = std::move(val);
|
||||
else if (strcasecmp(key.c_str(), "name") == 0)
|
||||
current.name[""] = std::move(val);
|
||||
break;
|
||||
case other:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void on_uint32_t(const std::string & key, uint32_t val)
|
||||
{
|
||||
switch (section.back())
|
||||
{
|
||||
case common:
|
||||
if (key == "openvrsupport")
|
||||
VR = val;
|
||||
break;
|
||||
case other:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} v;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -369,105 +325,33 @@ std::vector<wivrn::steam::application> read_appinfo_pre_v42(std::filesystem::pat
|
||||
);
|
||||
if (appids.contains(app_id))
|
||||
{
|
||||
try_parse_application(res, root, app_id, in, v, string_table_ptr);
|
||||
try
|
||||
{
|
||||
v.clear();
|
||||
read_dict(in, v, string_table_ptr);
|
||||
if (v.VR)
|
||||
{
|
||||
auto & item = res.emplace_back(std::move(v.current));
|
||||
item.appid = app_id;
|
||||
item.url = std::format("steam://launch/{}/VR", app_id);
|
||||
|
||||
if (auto icon_path = root / "steam/games" / (v.clienticon + ".ico"); std::filesystem::exists(icon_path))
|
||||
item.icon = icon_path;
|
||||
|
||||
else if (auto icon_path = root / "steam/games" / (v.linuxclienticon + ".zip"); std::filesystem::exists(icon_path))
|
||||
item.icon = icon_path;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
in.seekg(pos + size_data);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<wivrn::steam::application> read_appinfo_v42(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
|
||||
{
|
||||
std::vector<wivrn::steam::application> res;
|
||||
for (auto const & entry: std::filesystem::directory_iterator(root / "appcache/appinfo"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (auto extension = entry.path().extension(); extension != ".vdf")
|
||||
throw std::runtime_error{"Improper file extension"};
|
||||
|
||||
binary_reader in{std::ifstream{entry.path()}};
|
||||
|
||||
// https://github.com/xPaw/SteamAppInfo/blob/master/README.md#shard-header
|
||||
uint32_t magic = in.read<uint32_t>();
|
||||
if (!is_appid_magic(magic))
|
||||
throw std::runtime_error{"Wrong magic number"};
|
||||
|
||||
int version = magic & 0xff;
|
||||
if (version < 42)
|
||||
throw std::runtime_error{std::format("Invalid version {}", version)};
|
||||
|
||||
in.discard(4 // universe
|
||||
+ 4 // shard_index
|
||||
+ 4 // shard_count
|
||||
);
|
||||
|
||||
auto index_count = in.read<uint32_t>();
|
||||
auto index_size = in.read<uint32_t>();
|
||||
auto string_table_count = in.read<uint32_t>();
|
||||
auto string_table_size = in.read<uint32_t>();
|
||||
|
||||
in.discard(4 // data_size
|
||||
+ 4 // index_crc
|
||||
+ 4 // header_crc
|
||||
);
|
||||
|
||||
size_t index_data_pos = in.tellg();
|
||||
size_t string_table_pos = index_data_pos + index_size;
|
||||
size_t data_pos = string_table_pos + string_table_size;
|
||||
|
||||
in.seekg(string_table_pos);
|
||||
std::vector<std::string> string_table = in.string_table(string_table_count);
|
||||
|
||||
// https://github.com/xPaw/SteamAppInfo/blob/master/README.md#index-entry-repeated
|
||||
in.seekg(index_data_pos);
|
||||
app_data v;
|
||||
for (uint32_t i = 0; i < index_count; i++)
|
||||
{
|
||||
auto app_id = in.read<uint32_t>();
|
||||
if (app_id == 0)
|
||||
break;
|
||||
|
||||
auto data_offset = in.read<uint32_t>();
|
||||
in.discard(4); // data_size
|
||||
auto remaining = in.read<uint32_t>();
|
||||
auto next = (size_t)in.tellg() + remaining;
|
||||
|
||||
if (appids.contains(app_id))
|
||||
{
|
||||
in.seekg(data_pos + data_offset);
|
||||
in.discard(20); // SHA-1 of the bin data
|
||||
|
||||
try_parse_application(res, root, app_id, in, v, &string_table);
|
||||
}
|
||||
|
||||
in.seekg(next);
|
||||
}
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::cerr << "Failed to read appinfo shard " << entry.path().filename() << ": " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<wivrn::steam::application> read_appinfo(std::filesystem::path root, std::unordered_set<uint64_t> const & appids)
|
||||
{
|
||||
std::error_code ec;
|
||||
if (std::filesystem::exists(root / "appcache/appinfo.vdf", ec))
|
||||
{
|
||||
return read_appinfo_pre_v42(root, appids);
|
||||
}
|
||||
else if (std::filesystem::is_directory(root / "appcache/appinfo", ec))
|
||||
{
|
||||
return read_appinfo_v42(root, appids);
|
||||
}
|
||||
|
||||
throw std::runtime_error("No appinfos found in appcache");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void read_steam_shortcuts(
|
||||
|
||||
+20
-25
@@ -40,7 +40,7 @@
|
||||
namespace wivrn
|
||||
{
|
||||
|
||||
static constexpr int protocol_revision = 2;
|
||||
static constexpr int protocol_revision = 1;
|
||||
|
||||
enum class device_id : uint8_t
|
||||
{
|
||||
@@ -61,17 +61,13 @@ enum class device_id : uint8_t
|
||||
RIGHT_GRIP, // /user/hand/right/input/grip/pose
|
||||
RIGHT_AIM, // /user/hand/right/input/aim/pose
|
||||
RIGHT_PALM, // /user/hand/right/palm_ext/pose
|
||||
DPAD_UP_CLICK, // /user/hand/left/input/dpad_up/click
|
||||
DPAD_UP_TOUCH, // /user/hand/left/input/dpad_up/touch
|
||||
DPAD_LEFT_CLICK, // /user/hand/left/input/dpad_left/click
|
||||
DPAD_LEFT_TOUCH, // /user/hand/left/input/dpad_left/touch
|
||||
LEFT_X_CLICK, // /user/hand/left/input/x/click or /user/hand/left/input/dpad_down/click
|
||||
LEFT_X_TOUCH, // /user/hand/left/input/x/touch or /user/hand/left/input/dpad_down/touch
|
||||
LEFT_Y_CLICK, // /user/hand/left/input/y/click or /user/hand/left/input/dpad_right/click
|
||||
LEFT_Y_TOUCH, // /user/hand/left/input/y/touch or /user/hand/left/input/dpad_right/touch
|
||||
LEFT_MENU_CLICK, // /user/hand/left/input/{menu,view}/click
|
||||
LEFT_MENU_TOUCH, // /user/hand/left/input/{menu,view}/touch
|
||||
LEFT_SYSTEM_CLICK, // /user/hand/left/input/system/click
|
||||
LEFT_X_CLICK, // /user/hand/left/input/x/click
|
||||
LEFT_X_TOUCH, // /user/hand/left/input/x/touch
|
||||
LEFT_Y_CLICK, // /user/hand/left/input/y/click
|
||||
LEFT_Y_TOUCH, // /user/hand/left/input/y/touch
|
||||
VIEW_CLICK, // /user/hand/left/input/view/click
|
||||
VIEW_TOUCH, // /user/hand/left/input/view/touch
|
||||
LEFT_MENU_CLICK, // /user/hand/left/input/{menu,system}/click
|
||||
LEFT_SYSTEM_TOUCH, // /user/hand/left/input/system/touch
|
||||
LEFT_BUMPER_CLICK, // /user/hand/left/input/bumper/click
|
||||
LEFT_BUMPER_TOUCH, // /user/hand/left/input/bumper/touch
|
||||
@@ -107,6 +103,10 @@ enum class device_id : uint8_t
|
||||
LEFT_AIM_ACTIVATE_READY, // /user/hand/left/input/aim_activate_ext/ready_ext
|
||||
LEFT_GRASP_VALUE, // /user/hand/left/input/grasp_ext/value
|
||||
LEFT_GRASP_READY, // /user/hand/left/input/grasp_ext/ready_ext
|
||||
DPAD_UP_CLICK, // /user/hand/left/input/dpad_up/click
|
||||
DPAD_UP_TOUCH, // /user/hand/left/input/dpad_up/touch
|
||||
DPAD_LEFT_CLICK, // /user/hand/left/input/dpad_left/click
|
||||
DPAD_LEFT_TOUCH, // /user/hand/left/input/dpad_left/touch
|
||||
A_CLICK, // /user/hand/right/input/a/click
|
||||
A_TOUCH, // /user/hand/right/input/a/touch
|
||||
B_CLICK, // /user/hand/right/input/b/click
|
||||
@@ -115,10 +115,10 @@ enum class device_id : uint8_t
|
||||
RIGHT_X_TOUCH, // /user/hand/right/input/x/touch
|
||||
RIGHT_Y_CLICK, // /user/hand/right/input/y/click
|
||||
RIGHT_Y_TOUCH, // /user/hand/right/input/y/touch
|
||||
RIGHT_MENU_CLICK, // /user/hand/right/input/menu/click
|
||||
RIGHT_MENU_TOUCH, // /user/hand/right/input/menu/touch
|
||||
RIGHT_SYSTEM_CLICK, // /user/hand/right/input/system/click
|
||||
RIGHT_SYSTEM_TOUCH, // /user/hand/right/input/system/touch
|
||||
RIGHT_MENU_CLICK, // /user/hand/right/input/menu/click
|
||||
RIGHT_MENU_TOUCH, // /user/hand/right/input/menu/touch
|
||||
RIGHT_BUMPER_CLICK, // /user/hand/right/input/bumper/click
|
||||
RIGHT_BUMPER_TOUCH, // /user/hand/right/input/bumper/touch
|
||||
RIGHT_SQUEEZE_CLICK, // /user/hand/right/input/squeeze/click
|
||||
@@ -154,14 +154,10 @@ enum class device_id : uint8_t
|
||||
RIGHT_GRASP_VALUE, // /user/hand/right/input/grasp_ext/value
|
||||
RIGHT_GRASP_READY, // /user/hand/right/input/grasp_ext/ready_ext
|
||||
EYE_GAZE, // /user/eyes_ext/input/gaze_ext/pose
|
||||
|
||||
LEFT_CONTROLLER, // identify controller
|
||||
RIGHT_CONTROLLER, // identify controller
|
||||
LEFT_HAND = LEFT_CONTROLLER, // identify hand tracking
|
||||
RIGHT_HAND = RIGHT_CONTROLLER, // identify hand tracking
|
||||
BODY, // identify body tracking
|
||||
FACE, // identify face tracking
|
||||
GAMEPAD, // identify gamepad
|
||||
LEFT_HAND, // identify hand tracking
|
||||
RIGHT_HAND, // identify hand tracking
|
||||
BODY, // identify body tracking
|
||||
FACE, // identify face tracking
|
||||
|
||||
// Gamepad, microsoft/xbox_controller profile (/user/gamepad)
|
||||
GAMEPAD_MENU_CLICK, // /user/gamepad/input/menu/click
|
||||
@@ -350,7 +346,6 @@ struct headset_info_packet
|
||||
};
|
||||
std::optional<audio_description> speaker;
|
||||
std::optional<audio_description> microphone;
|
||||
bool battery_status; // supports XR_EXT_interaction_profile_battery_state_display, for reporting controller/gamepad battery status
|
||||
bool hand_tracking;
|
||||
bool eye_gaze;
|
||||
bool palm_pose;
|
||||
@@ -673,8 +668,8 @@ struct feedback
|
||||
|
||||
struct battery
|
||||
{
|
||||
device_id device;
|
||||
std::optional<float> charge;
|
||||
float charge;
|
||||
bool present;
|
||||
bool charging;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,17 +68,6 @@
|
||||
<content_rating type="oars-1.1" />
|
||||
|
||||
<releases>
|
||||
<release version="26.11" date="2026-11-28">
|
||||
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v26.11</url>
|
||||
<description>
|
||||
<ul>
|
||||
<li>Initial support for Steam Frame</li>
|
||||
<li>Use vulkan video encode by default on all GPU</li>
|
||||
<li>Experimental AV1 support for vulkan video encode, only if manually configured</li>
|
||||
<li>Don't show boundary/guardian by default</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="26.9" date="2026-09-12">
|
||||
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v26.9</url>
|
||||
<description>
|
||||
|
||||
@@ -39,7 +39,7 @@ One of `h264`, `h265`, `av1`, `raw`.
|
||||
|
||||
Not all encoders support every codec:
|
||||
- `x264` encoder only supports `h264` codec
|
||||
- `vulkan` encoder supports `h264`, `h265` and `av1` codecs, but `av1` is never selected automatically: it must be requested by setting `encoder` to `vulkan`
|
||||
- `vulkan` encoder supports `h264` and `h265` codecs
|
||||
- `raw` encoder only supports `raw` codec
|
||||
- `nvenc` and `vaapi` support all codecs, except `raw`
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ finish-args:
|
||||
# Set the active OpenXR / OpenVR runtime
|
||||
- --filesystem=xdg-config/openxr:create
|
||||
- --filesystem=xdg-config/openvr:create
|
||||
# Access to SlimeVR IPC sockets
|
||||
- --filesystem=xdg-run/SlimeVRInput
|
||||
# Access to SlimeVR IPC socket
|
||||
- --filesystem=xdg-run/SlimeVRRpc
|
||||
- --filesystem=xdg-run/.flatpak/dev.slimevr.SlimeVR
|
||||
- --filesystem=xdg-data/dev.slimevr.SlimeVR
|
||||
|
||||
+192
-264
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
From 9873bdc4f2432a2530c4bd559d5d80610ffbacbb Mon Sep 17 00:00:00 2001
|
||||
From cdd0a756a872e391f38b23ce73259497209c559b Mon Sep 17 00:00:00 2001
|
||||
From: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
|
||||
Date: Fri, 18 Sep 2026 14:59:50 +0900
|
||||
Subject: [PATCH 11/13] st/oxr: add XR_VALVE_frame_controller_interaction
|
||||
@@ -7,13 +7,13 @@ Signed-off-by: galister <85970-galister@users.noreply.gitlab.freedesktop.org>
|
||||
---
|
||||
CMakeLists.txt | 2 +
|
||||
cmake/MonadoSetOptions.cmake | 1 +
|
||||
.../XR_VALVE_frame_controller_interaction.h | 25 +++
|
||||
src/xrt/auxiliary/bindings/bindings.json | 191 ++++++++++++++++++
|
||||
.../XR_VALVE_frame_controller_interaction.h | 25 ++
|
||||
src/xrt/auxiliary/bindings/bindings.json | 257 ++++++++++++++++++
|
||||
.../include/xrt/xrt_config_build.h.cmake_in | 1 +
|
||||
src/xrt/include/xrt/xrt_defines.h | 48 +++++
|
||||
src/xrt/include/xrt/xrt_defines.h | 48 ++++
|
||||
src/xrt/include/xrt/xrt_openxr_includes.h | 1 +
|
||||
.../oxr_extension_support.py | 1 +
|
||||
8 files changed, 270 insertions(+)
|
||||
8 files changed, 336 insertions(+)
|
||||
create mode 100644 src/external/openxr_includes/openxr/XR_VALVE_frame_controller_interaction.h
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
@@ -81,10 +81,10 @@ index 000000000..d67826910
|
||||
+#endif
|
||||
\ No newline at end of file
|
||||
diff --git a/src/xrt/auxiliary/bindings/bindings.json b/src/xrt/auxiliary/bindings/bindings.json
|
||||
index 462ffbf43..003716a98 100644
|
||||
index 462ffbf43..dbb0129a3 100644
|
||||
--- a/src/xrt/auxiliary/bindings/bindings.json
|
||||
+++ b/src/xrt/auxiliary/bindings/bindings.json
|
||||
@@ -3258,6 +3258,197 @@
|
||||
@@ -3258,6 +3258,263 @@
|
||||
}
|
||||
},
|
||||
|
||||
@@ -268,6 +268,72 @@ index 462ffbf43..003716a98 100644
|
||||
+ "touch": "XRT_INPUT_FRAME_VIEW_TOUCH"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/bumper_left": {
|
||||
+ "type": "button",
|
||||
+ "localized_name": "Bumper",
|
||||
+ "components": ["click", "touch"],
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "click": "XRT_INPUT_FRAME_BUMPER_CLICK",
|
||||
+ "touch": "XRT_INPUT_FRAME_BUMPER_TOUCH"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/squeeze_left": {
|
||||
+ "type": "button",
|
||||
+ "localized_name": "Squeeze",
|
||||
+ "components": ["click", "touch", "value"],
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "click": "XRT_INPUT_FRAME_SQUEEZE_CLICK",
|
||||
+ "touch": "XRT_INPUT_FRAME_SQUEEZE_TOUCH",
|
||||
+ "value": "XRT_INPUT_FRAME_SQUEEZE_VALUE"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/trigger_left": {
|
||||
+ "type": "trigger",
|
||||
+ "localized_name": "Trigger",
|
||||
+ "components": ["click", "value", "touch"],
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "click": "XRT_INPUT_FRAME_TRIGGER_CLICK",
|
||||
+ "value": "XRT_INPUT_FRAME_TRIGGER_VALUE",
|
||||
+ "touch": "XRT_INPUT_FRAME_TRIGGER_TOUCH"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/thumbstick_left": {
|
||||
+ "type": "joystick",
|
||||
+ "localized_name": "Thumbstick",
|
||||
+ "components": ["click", "touch", "position"],
|
||||
+ "dpad_emulation": {
|
||||
+ "position": "position",
|
||||
+ "activate": "click",
|
||||
+ "center": true
|
||||
+ },
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "click": "XRT_INPUT_FRAME_THUMBSTICK_CLICK",
|
||||
+ "touch": "XRT_INPUT_FRAME_THUMBSTICK_TOUCH",
|
||||
+ "position": "XRT_INPUT_FRAME_THUMBSTICK"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/grip_left": {
|
||||
+ "type": "pose",
|
||||
+ "localized_name": "Grip",
|
||||
+ "components": ["pose"],
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "pose": "XRT_INPUT_FRAME_GRIP_POSE"
|
||||
+ }
|
||||
+ },
|
||||
+ "/input/aim_left": {
|
||||
+ "type": "pose",
|
||||
+ "localized_name": "Aim",
|
||||
+ "components": ["pose"],
|
||||
+ "side": "left",
|
||||
+ "monado_bindings": {
|
||||
+ "pose": "XRT_INPUT_FRAME_AIM_POSE"
|
||||
+ }
|
||||
+ },
|
||||
+ "/output/haptic": {
|
||||
+ "type": "vibration",
|
||||
+ "localized_name": "Haptic",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
From 1db037337db699783cb8e8f66fd6e592d51f1b1b Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Wed, 26 Aug 2026 04:07:59 -0500
|
||||
Subject: [PATCH 2/8] d/solarxr: Consume battery status for generic trackers
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_device.c | 55 ++++++++++++++++++++++++
|
||||
1 file changed, 55 insertions(+)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_device.c b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
index b3cc11e47..b976774ae 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
@@ -34,6 +34,8 @@ struct solarxr_generic_tracker
|
||||
uint32_t index;
|
||||
struct m_relation_history *history; // weak reference
|
||||
enum solarxr_body_part role;
|
||||
+ float charge; // -1.f == no battery info
|
||||
+ bool charging;
|
||||
};
|
||||
|
||||
struct solarxr_device
|
||||
@@ -682,6 +684,15 @@ solarxr_network_thread(void *const ptr)
|
||||
solarxr_handshake_status_to_str(header.message.handshake_response.status));
|
||||
device->shook_hands = false;
|
||||
atomic_store(&device->enabled_bones, 0);
|
||||
+ for (size_t i = 0; i < ARRAY_SIZE(device->tracker_refs); ++i) {
|
||||
+ struct solarxr_generic_tracker *const tracker = device->tracker_refs[i];
|
||||
+ if (tracker == NULL)
|
||||
+ break;
|
||||
+
|
||||
+ os_mutex_lock(&tracker->mutex);
|
||||
+ tracker->charge = -1.f;
|
||||
+ os_mutex_unlock(&tracker->mutex);
|
||||
+ }
|
||||
feeder_mark_unsent(&device->feeder);
|
||||
}
|
||||
break;
|
||||
@@ -705,6 +716,22 @@ solarxr_network_thread(void *const ptr)
|
||||
bones.data = header.message.skeleton_update.bones.data;
|
||||
}
|
||||
break;
|
||||
+ case SOLARXR_DRIVER_MESSAGE_TYPE_BONE_BATTERY_UPDATE:
|
||||
+ for (size_t i = 0; i < ARRAY_SIZE(device->tracker_refs); ++i) {
|
||||
+ struct solarxr_generic_tracker *const tracker = device->tracker_refs[i];
|
||||
+ if (tracker == NULL)
|
||||
+ break;
|
||||
+ if (tracker->role != header.message.bone_battery_update.bone)
|
||||
+ continue;
|
||||
+
|
||||
+ os_mutex_lock(&tracker->mutex);
|
||||
+ tracker->charge =
|
||||
+ (float)header.message.bone_battery_update.battery_level / 100.f;
|
||||
+ tracker->charging = header.message.bone_battery_update.charging;
|
||||
+ os_mutex_unlock(&tracker->mutex);
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
@@ -826,6 +853,31 @@ solarxr_generic_tracker_get_tracked_pose(struct xrt_device *const xdev,
|
||||
return result;
|
||||
}
|
||||
|
||||
+static xrt_result_t
|
||||
+solarxr_generic_tracker_get_battery_status(struct xrt_device *const xdev,
|
||||
+ bool *const out_present,
|
||||
+ bool *const out_charging,
|
||||
+ float *const out_charge)
|
||||
+{
|
||||
+ struct solarxr_generic_tracker *const device = solarxr_generic_tracker(xdev);
|
||||
+ assert(device != NULL);
|
||||
+
|
||||
+ os_mutex_lock(&device->mutex);
|
||||
+
|
||||
+ if (device->charge == -1.f) {
|
||||
+ *out_present = false;
|
||||
+ goto end;
|
||||
+ }
|
||||
+
|
||||
+ *out_present = true;
|
||||
+ *out_charge = device->charge;
|
||||
+ *out_charging = device->charging;
|
||||
+
|
||||
+end:
|
||||
+ os_mutex_unlock(&device->mutex);
|
||||
+ return XRT_SUCCESS;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
solarxr_generic_tracker_destroy(struct xrt_device *const xdev)
|
||||
{
|
||||
@@ -944,11 +996,14 @@ solarxr_device_create_xdevs(struct xrt_tracking_origin *const tracking_origin,
|
||||
tracker->base.tracking_origin = device->base.tracking_origin;
|
||||
tracker->base.supported.orientation_tracking = true;
|
||||
tracker->base.supported.position_tracking = true;
|
||||
+ tracker->base.supported.battery_status = true;
|
||||
tracker->base.update_inputs = solarxr_generic_tracker_update_inputs;
|
||||
tracker->base.get_tracked_pose = solarxr_generic_tracker_get_tracked_pose;
|
||||
+ tracker->base.get_battery_status = solarxr_generic_tracker_get_battery_status;
|
||||
tracker->base.destroy = solarxr_generic_tracker_destroy;
|
||||
tracker->base.inputs[0].name = XRT_INPUT_GENERIC_TRACKER_POSE;
|
||||
tracker->role = body_part;
|
||||
+ tracker->charge = -1.f;
|
||||
|
||||
assert(trackers_len < ARRAY_SIZE(trackers));
|
||||
m_relation_history_create(&device->trackers[trackers_len]);
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From b1f2190a7fb3367548c6a763b29e78c4331e0d32 Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Mon, 3 Aug 2026 02:48:40 -0500
|
||||
Subject: [PATCH 3/8] d/solarxr: Check for hang up event when polling IPC
|
||||
sockets
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_ipc_socket.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
index 85e9cad37..8a38a990c 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
@@ -239,7 +239,7 @@ solarxr_ipc_socket_wait_timeout(struct solarxr_ipc_socket *const state, const ti
|
||||
.tv_nsec = timeout % U_TIME_1S_IN_NS,
|
||||
};
|
||||
const bool result = (ppoll(&fd, 1, (timeout >= 0) ? &timeout_ts : NULL, NULL) != -1)
|
||||
- ? (fd.revents & POLLERR) == 0
|
||||
+ ? (fd.revents & (POLLERR | POLLHUP)) == 0
|
||||
: errno == EINTR;
|
||||
|
||||
xrt_reference_dec(&state->reference);
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
From b3c2ad7da88a0c509fc8237f25d06aba314a2e30 Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Mon, 3 Aug 2026 02:52:06 -0500
|
||||
Subject: [PATCH 4/8] d/solarxr: Reconnect to IPC sockets when connection
|
||||
breaks
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_device.c | 37 +++++++++++++++++++-
|
||||
src/xrt/drivers/solarxr/solarxr_ipc_socket.c | 2 --
|
||||
2 files changed, 36 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_device.c b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
index b976774ae..0993f4f41 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
@@ -591,10 +591,45 @@ solarxr_network_thread(void *const ptr)
|
||||
},
|
||||
};
|
||||
|
||||
- while (solarxr_ipc_socket_wait_timeout(&device->socket, -1)) {
|
||||
+ bool lost_connection = false;
|
||||
+ while (solarxr_ipc_socket_is_connected(&device->socket)) {
|
||||
+ if (!solarxr_ipc_socket_wait_timeout(&device->socket, -1)) {
|
||||
+ if (!solarxr_ipc_socket_is_connected(&device->socket)) {
|
||||
+ // We were woke up from wait_timeout when destroying the socket
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (!lost_connection) {
|
||||
+ U_LOG_IFL_E(debug_get_log_option_solarxr_log(),
|
||||
+ "solarxr_ipc_socket_wait_timeout failed; attempting socket reconnect");
|
||||
+ lost_connection = true;
|
||||
+ device->shook_hands = false;
|
||||
+ atomic_store(&device->enabled_bones, 0);
|
||||
+ for (size_t i = 0; i < ARRAY_SIZE(device->tracker_refs); ++i) {
|
||||
+ struct solarxr_generic_tracker *const tracker = device->tracker_refs[i];
|
||||
+ if (tracker == NULL)
|
||||
+ break;
|
||||
+
|
||||
+ os_mutex_lock(&tracker->mutex);
|
||||
+ tracker->charge = -1.f;
|
||||
+ os_mutex_unlock(&tracker->mutex);
|
||||
+ }
|
||||
+ feeder_mark_unsent(&device->feeder);
|
||||
+ }
|
||||
+
|
||||
+ //! @todo Maybe write a better way to silence the logs than passing in RAW log level?
|
||||
+ const struct sockaddr_un path = solarxr_ipc_socket_find(U_LOGGING_RAW, "SlimeVRRpc");
|
||||
+ if (solarxr_ipc_socket_connect(&device->socket, path)) {
|
||||
+ lost_connection = false;
|
||||
+ } else {
|
||||
+ os_nanosleep(U_TIME_1S_IN_NS);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
const struct span buffer = {solarxr_ipc_socket_receive(&device->socket), device->socket.buffer};
|
||||
|
||||
if (buffer.length == 0) {
|
||||
+ U_LOG_IFL_E(debug_get_log_option_solarxr_log(), "solarxr_ipc_socket_receive failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
index 8a38a990c..9492df71f 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
@@ -161,8 +161,6 @@ solarxr_ipc_socket_find(const enum u_logging_level log_level, const char filenam
|
||||
bool
|
||||
solarxr_ipc_socket_connect(struct solarxr_ipc_socket *const state, const struct sockaddr_un addr)
|
||||
{
|
||||
- solarxr_ipc_socket_close(state);
|
||||
-
|
||||
xrt_ipc_handle_t ipc_handle = XRT_IPC_HANDLE_INVALID;
|
||||
if (addr.sun_family != AF_UNIX) {
|
||||
goto fail;
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From 6980a355a5c7b623097f52f60e6595794778208e Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Wed, 26 Aug 2026 02:53:26 -0500
|
||||
Subject: [PATCH 5/8] d/solarxr: Add missing includes in solarxr_ipc_message
|
||||
header
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_ipc_message.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_ipc_message.h b/src/xrt/drivers/solarxr/solarxr_ipc_message.h
|
||||
index 72eeb381e..7d827a7b8 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_ipc_message.h
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_ipc_message.h
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
#include <endian.h>
|
||||
+#include <stdbool.h>
|
||||
+#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From 570b839dba744f592685fbc76a3dee00d397de9b Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Wed, 26 Aug 2026 04:30:16 -0500
|
||||
Subject: [PATCH 6/8] d/solarxr: Name the network thread
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_device.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_device.c b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
index 0993f4f41..e5c6303df 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_device.h"
|
||||
#include "util/u_time.h"
|
||||
+#include "util/u_trace_marker.h"
|
||||
|
||||
#include <endian.h>
|
||||
#include <stdatomic.h>
|
||||
@@ -348,6 +349,11 @@ solarxr_network_thread(void *const ptr)
|
||||
{
|
||||
struct solarxr_device *const device = (struct solarxr_device *)ptr;
|
||||
|
||||
+ const char *const thread_name = "SolarXR Network";
|
||||
+
|
||||
+ U_TRACE_SET_THREAD_NAME(thread_name);
|
||||
+ os_thread_name_self(thread_name);
|
||||
+
|
||||
static const char driver_name[] = "Monado";
|
||||
struct
|
||||
{
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
From 6987a5982092d91d142b065f5bf00ca9ea50d861 Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Wed, 26 Aug 2026 18:57:37 -0500
|
||||
Subject: [PATCH 7/8] d/solarxr: Add tracing markers
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/feeder.c | 8 ++++++++
|
||||
src/xrt/drivers/solarxr/solarxr_device.c | 6 ++++++
|
||||
2 files changed, 14 insertions(+)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/feeder.c b/src/xrt/drivers/solarxr/feeder.c
|
||||
index f217a446c..6f38fe24b 100644
|
||||
--- a/src/xrt/drivers/solarxr/feeder.c
|
||||
+++ b/src/xrt/drivers/solarxr/feeder.c
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "solarxr_ipc_message.h"
|
||||
|
||||
#include "util/u_hashmap.h"
|
||||
+#include "util/u_trace_marker.h"
|
||||
#include "xrt/xrt_device.h"
|
||||
|
||||
#include <math.h>
|
||||
@@ -777,6 +778,8 @@ feeder_device_send_feedback_cb(const uint64_t key, const void *const value, void
|
||||
struct send_feedback_userdata *const data = (struct send_feedback_userdata *)userptr;
|
||||
enum solarxr_tracker_status status = SOLARXR_TRACKER_STATUS_DISCONNECTED;
|
||||
|
||||
+ XRT_TRACE_MARKER();
|
||||
+
|
||||
if (xdev == NULL) {
|
||||
device->next_to_erase = data->to_erase;
|
||||
data->to_erase = device;
|
||||
@@ -827,6 +830,8 @@ feeder_device_send_feedback_cb(const uint64_t key, const void *const value, void
|
||||
void
|
||||
feeder_send_feedback(struct feeder *const feeder)
|
||||
{
|
||||
+ XRT_TRACE_MARKER();
|
||||
+
|
||||
os_mutex_lock(&feeder->mutex);
|
||||
|
||||
struct send_feedback_userdata data;
|
||||
@@ -834,7 +839,10 @@ feeder_send_feedback(struct feeder *const feeder)
|
||||
data.time = os_monotonic_get_ns();
|
||||
data.log_level = feeder->socket->log_level;
|
||||
data.packet_end = data.packet;
|
||||
+
|
||||
+ XRT_TRACE_BEGIN(feeder_device_send_feedback_foreach);
|
||||
u_hashmap_int_for_each(feeder->devices, feeder_device_send_feedback_cb, &data);
|
||||
+ XRT_TRACE_END(feeder_device_send_feedback_foreach);
|
||||
|
||||
// flush queued messages to socket
|
||||
if (data.packet_end != data.packet) {
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_device.c b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
index e5c6303df..c0fb60c10 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_device.c
|
||||
@@ -294,8 +294,11 @@ static void
|
||||
solarxr_device_handle_bones(struct solarxr_device *const device,
|
||||
const struct solarxr_bone bones[ARRAY_SIZE(device->bones)])
|
||||
{
|
||||
+ XRT_TRACE_MARKER();
|
||||
+
|
||||
os_mutex_lock(&device->mutex);
|
||||
|
||||
+ XRT_TRACE_BEGIN(solarxr_device_handle_generic_trackers);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(device->tracker_refs); ++i) {
|
||||
const struct solarxr_generic_tracker *const tracker = device->tracker_refs[i];
|
||||
if (tracker == NULL || tracker->role == SOLARXR_BODY_PART_NONE) {
|
||||
@@ -324,6 +327,7 @@ solarxr_device_handle_bones(struct solarxr_device *const device,
|
||||
};
|
||||
m_relation_history_push(history, &relation, device->socket.timestamp);
|
||||
}
|
||||
+ XRT_TRACE_END(solarxr_device_handle_generic_trackers);
|
||||
|
||||
bool generation_increased = false;
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(device->bones); ++i) {
|
||||
@@ -639,6 +643,8 @@ solarxr_network_thread(void *const ptr)
|
||||
continue;
|
||||
}
|
||||
|
||||
+ XRT_TRACE_IDENT(solarxr_network_frame);
|
||||
+
|
||||
struct solarxr_message_bundle bundle;
|
||||
if (!read_solarxr_message_bundle(&bundle, buffer.data, buffer.length,
|
||||
(const solarxr_message_bundle_t *)buffer.data)) {
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From 96a51c1a89db5fd07e44f6026173a44e050a0c43 Mon Sep 17 00:00:00 2001
|
||||
From: Sapphire <imsapphire0@gmail.com>
|
||||
Date: Tue, 1 Sep 2026 02:50:08 -0500
|
||||
Subject: [PATCH 8/8] d/solarxr: Try SLIMEVR_SOCKET_DIR override socket path
|
||||
|
||||
Signed-off-by: Sapphire <imsapphire0@gmail.com>
|
||||
---
|
||||
src/xrt/drivers/solarxr/solarxr_ipc_socket.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
index 9492df71f..2d833223b 100644
|
||||
--- a/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
+++ b/src/xrt/drivers/solarxr/solarxr_ipc_socket.c
|
||||
@@ -115,6 +115,18 @@ solarxr_ipc_socket_find(const enum u_logging_level log_level, const char filenam
|
||||
return (struct sockaddr_un){0};
|
||||
}
|
||||
|
||||
+ // try override path
|
||||
+ const char *override_env;
|
||||
+ int override_path_len = 0;
|
||||
+ if ((override_env = getenv("SLIMEVR_SOCKET_DIR")) != NULL) {
|
||||
+ override_path_len = snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s", override_env, filename);
|
||||
+ }
|
||||
+
|
||||
+ if (override_path_len > 0 && (unsigned)override_path_len < sizeof(addr.sun_path) &&
|
||||
+ check_socket_path(log_level, addr.sun_path)) {
|
||||
+ return addr;
|
||||
+ }
|
||||
+
|
||||
const ssize_t runtime_dir_len =
|
||||
u_file_get_path_in_runtime_dir("", addr.sun_path, sizeof(addr.sun_path) - 1 - filename_len);
|
||||
if (runtime_dir_len <= 0 || (size_t)runtime_dir_len >= sizeof(addr.sun_path) - 1 - filename_len) {
|
||||
--
|
||||
2.56.0
|
||||
|
||||
@@ -184,7 +184,6 @@ if (WIVRN_BUILD_SERVER)
|
||||
if(WIVRN_USE_VULKAN_ENCODE)
|
||||
target_sources(wivrn-server PRIVATE
|
||||
encoder/video_encoder_vulkan.cpp
|
||||
encoder/video_encoder_vulkan_av1.cpp
|
||||
encoder/video_encoder_vulkan_h264.cpp
|
||||
encoder/video_encoder_vulkan_h265.cpp
|
||||
)
|
||||
|
||||
@@ -127,11 +127,9 @@ struct pipewire_device : public audio_device
|
||||
"Audio/Sink",
|
||||
PW_KEY_MEDIA_ROLE,
|
||||
"Game",
|
||||
PW_KEY_PRIORITY_SESSION,
|
||||
"1700", // wireplumber gives priorities in range 1000-1600 for alsa sinks
|
||||
PW_KEY_NODE_RATE,
|
||||
// Set stream rate to match client, preventing PipeWire from doing
|
||||
// unnecessary resampling which degrades audio quality
|
||||
PW_KEY_NODE_RATE,
|
||||
rate_str.c_str(),
|
||||
// Declare target latency to help PipeWire optimize buffering
|
||||
PW_KEY_NODE_LATENCY,
|
||||
@@ -208,11 +206,9 @@ struct pipewire_device : public audio_device
|
||||
"Audio/Source",
|
||||
PW_KEY_MEDIA_ROLE,
|
||||
"Game",
|
||||
PW_KEY_PRIORITY_SESSION,
|
||||
"2700", // wireplumber gives priorities in range 2000-2600 for alsa sources
|
||||
PW_KEY_NODE_RATE,
|
||||
// Set stream rate to match client, preventing PipeWire from doing
|
||||
// unnecessary resampling which degrades audio quality
|
||||
PW_KEY_NODE_RATE,
|
||||
rate_str.c_str(),
|
||||
// Declare target latency to help PipeWire optimize buffering
|
||||
PW_KEY_NODE_LATENCY,
|
||||
|
||||
@@ -57,18 +57,20 @@ enum wivrn_controller_input_index
|
||||
WIVRN_CONTROLLER_MENU_TOUCH, // /user/hand/XXXX/input/menu/touch
|
||||
WIVRN_CONTROLLER_SYSTEM_CLICK, // /user/hand/XXXX/input/system/click
|
||||
WIVRN_CONTROLLER_SYSTEM_TOUCH, // /user/hand/XXXX/input/system/touch
|
||||
WIVRN_CONTROLLER_DPAD_UP_CLICK, // /user/hand/left/input/dpad_up/click
|
||||
WIVRN_CONTROLLER_DPAD_UP_TOUCH, // /user/hand/left/input/dpad_up/touch
|
||||
WIVRN_CONTROLLER_DPAD_LEFT_CLICK, // /user/hand/left/input/dpad_left/click
|
||||
WIVRN_CONTROLLER_DPAD_LEFT_TOUCH, // /user/hand/left/input/dpad_left/touch
|
||||
WIVRN_CONTROLLER_X_CLICK, // /user/hand/XXXX/input/x/click or /user/hand/left/input/dpad_down/click
|
||||
WIVRN_CONTROLLER_X_TOUCH, // /user/hand/XXXX/input/x/touch or /user/hand/left/input/dpad_down/touch
|
||||
WIVRN_CONTROLLER_Y_CLICK, // /user/hand/XXXX/input/y/click or /user/hand/left/input/dpad_right/click
|
||||
WIVRN_CONTROLLER_Y_TOUCH, // /user/hand/XXXX/input/y/touch or /user/hand/left/input/dpad_right/touch
|
||||
WIVRN_CONTROLLER_VIEW_CLICK, // /user/hand/left/input/view/click
|
||||
WIVRN_CONTROLLER_VIEW_TOUCH, // /user/hand/left/input/view/touch
|
||||
WIVRN_CONTROLLER_A_CLICK, // /user/hand/right/input/a/click
|
||||
WIVRN_CONTROLLER_A_TOUCH, // /user/hand/right/input/a/touch
|
||||
WIVRN_CONTROLLER_B_CLICK, // /user/hand/right/input/b/click
|
||||
WIVRN_CONTROLLER_B_TOUCH, // /user/hand/right/input/b/touch
|
||||
WIVRN_CONTROLLER_X_CLICK, // /user/hand/XXXX/input/x/click
|
||||
WIVRN_CONTROLLER_X_TOUCH, // /user/hand/XXXX/input/x/touch
|
||||
WIVRN_CONTROLLER_Y_CLICK, // /user/hand/XXXX/input/y/click
|
||||
WIVRN_CONTROLLER_Y_TOUCH, // /user/hand/XXXX/input/y/touch
|
||||
WIVRN_CONTROLLER_DPAD_UP_CLICK, // /user/hand/XXXX/input/dpad_up/click
|
||||
WIVRN_CONTROLLER_DPAD_UP_TOUCH, // /user/hand/XXXX/input/dpad_up/touch
|
||||
WIVRN_CONTROLLER_DPAD_LEFT_CLICK, // /user/hand/XXXX/input/dpad_left/click
|
||||
WIVRN_CONTROLLER_DPAD_LEFT_TOUCH, // /user/hand/XXXX/input/dpad_left/touch
|
||||
WIVRN_CONTROLLER_SQUEEZE_CLICK, // /user/hand/XXXX/input/squeeze/click
|
||||
WIVRN_CONTROLLER_SQUEEZE_FORCE, // /user/hand/XXXX/input/squeeze/force
|
||||
WIVRN_CONTROLLER_SQUEEZE_TOUCH, // /user/hand/XXXX/input/squeeze/touch
|
||||
@@ -148,14 +150,6 @@ input_data map_input(device_id id)
|
||||
return {WIVRN_CONTROLLER_PALM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::RIGHT_PALM:
|
||||
return {WIVRN_CONTROLLER_PALM_POSE, wivrn_input_type::POSE, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_UP_CLICK:
|
||||
return {WIVRN_CONTROLLER_DPAD_UP_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_UP_TOUCH:
|
||||
return {WIVRN_CONTROLLER_DPAD_UP_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_LEFT_CLICK:
|
||||
return {WIVRN_CONTROLLER_DPAD_LEFT_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_LEFT_TOUCH:
|
||||
return {WIVRN_CONTROLLER_DPAD_LEFT_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_X_CLICK:
|
||||
return {WIVRN_CONTROLLER_X_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_X_TOUCH:
|
||||
@@ -180,18 +174,26 @@ input_data map_input(device_id id)
|
||||
return {WIVRN_CONTROLLER_B_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::B_TOUCH:
|
||||
return {WIVRN_CONTROLLER_B_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_UP_CLICK:
|
||||
return {WIVRN_CONTROLLER_DPAD_UP_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_UP_TOUCH:
|
||||
return {WIVRN_CONTROLLER_DPAD_UP_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_LEFT_CLICK:
|
||||
return {WIVRN_CONTROLLER_DPAD_LEFT_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::DPAD_LEFT_TOUCH:
|
||||
return {WIVRN_CONTROLLER_DPAD_LEFT_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_MENU_CLICK:
|
||||
return {WIVRN_CONTROLLER_MENU_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_MENU_TOUCH:
|
||||
return {WIVRN_CONTROLLER_MENU_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::RIGHT_MENU_CLICK:
|
||||
return {WIVRN_CONTROLLER_MENU_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::RIGHT_MENU_TOUCH:
|
||||
return {WIVRN_CONTROLLER_MENU_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_SYSTEM_CLICK:
|
||||
return {WIVRN_CONTROLLER_SYSTEM_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::LEFT_SYSTEM_TOUCH:
|
||||
return {WIVRN_CONTROLLER_SYSTEM_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::VIEW_CLICK:
|
||||
return {WIVRN_CONTROLLER_VIEW_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::VIEW_TOUCH:
|
||||
return {WIVRN_CONTROLLER_VIEW_TOUCH, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER};
|
||||
case device_id::RIGHT_SYSTEM_CLICK:
|
||||
return {WIVRN_CONTROLLER_SYSTEM_CLICK, wivrn_input_type::BOOL, XRT_DEVICE_TYPE_RIGHT_HAND_CONTROLLER};
|
||||
case device_id::RIGHT_SYSTEM_TOUCH:
|
||||
@@ -404,15 +406,15 @@ xrt_binding_input_pair index_input_binding_right[] = {
|
||||
xrt_binding_input_pair frame_input_binding_left[] = {
|
||||
{XRT_INPUT_FRAME_DPAD_UP_CLICK, XRT_INPUT_FRAME_DPAD_UP_CLICK},
|
||||
{XRT_INPUT_FRAME_DPAD_UP_TOUCH, XRT_INPUT_FRAME_DPAD_UP_TOUCH},
|
||||
{XRT_INPUT_FRAME_DPAD_LEFT_CLICK, XRT_INPUT_FRAME_DPAD_LEFT_CLICK},
|
||||
{XRT_INPUT_FRAME_DPAD_LEFT_TOUCH, XRT_INPUT_FRAME_DPAD_LEFT_TOUCH},
|
||||
{XRT_INPUT_FRAME_DPAD_DOWN_CLICK, XRT_INPUT_TOUCH_X_CLICK},
|
||||
{XRT_INPUT_FRAME_DPAD_DOWN_TOUCH, XRT_INPUT_TOUCH_X_TOUCH},
|
||||
{XRT_INPUT_FRAME_DPAD_LEFT_CLICK, XRT_INPUT_FRAME_DPAD_LEFT_CLICK},
|
||||
{XRT_INPUT_FRAME_DPAD_LEFT_TOUCH, XRT_INPUT_FRAME_DPAD_LEFT_TOUCH},
|
||||
{XRT_INPUT_FRAME_DPAD_RIGHT_CLICK, XRT_INPUT_TOUCH_Y_CLICK},
|
||||
{XRT_INPUT_FRAME_DPAD_RIGHT_TOUCH, XRT_INPUT_TOUCH_Y_TOUCH},
|
||||
{XRT_INPUT_FRAME_VIEW_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
|
||||
{XRT_INPUT_FRAME_VIEW_CLICK, XRT_INPUT_FRAME_VIEW_CLICK},
|
||||
{XRT_INPUT_FRAME_VIEW_TOUCH, XRT_INPUT_FRAME_VIEW_TOUCH},
|
||||
{XRT_INPUT_FRAME_SYSTEM_CLICK, XRT_INPUT_FRAME_SYSTEM_CLICK},
|
||||
{XRT_INPUT_FRAME_SYSTEM_CLICK, XRT_INPUT_TOUCH_MENU_CLICK},
|
||||
{XRT_INPUT_FRAME_SYSTEM_TOUCH, XRT_INPUT_INDEX_SYSTEM_TOUCH},
|
||||
{XRT_INPUT_FRAME_BUMPER_CLICK, XRT_INPUT_FRAME_BUMPER_CLICK},
|
||||
{XRT_INPUT_FRAME_BUMPER_TOUCH, XRT_INPUT_FRAME_BUMPER_TOUCH},
|
||||
@@ -427,8 +429,6 @@ xrt_binding_input_pair frame_input_binding_left[] = {
|
||||
{XRT_INPUT_FRAME_THUMBSTICK, XRT_INPUT_TOUCH_THUMBSTICK},
|
||||
{XRT_INPUT_FRAME_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE},
|
||||
{XRT_INPUT_FRAME_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
|
||||
{XRT_INPUT_HAND_PINCH_POSE, XRT_INPUT_HAND_PINCH_POSE},
|
||||
{XRT_INPUT_HAND_POKE_POSE, XRT_INPUT_HAND_POKE_POSE},
|
||||
};
|
||||
|
||||
xrt_binding_input_pair frame_input_binding_right[] = {
|
||||
@@ -457,8 +457,6 @@ xrt_binding_input_pair frame_input_binding_right[] = {
|
||||
{XRT_INPUT_FRAME_THUMBSTICK, XRT_INPUT_TOUCH_THUMBSTICK},
|
||||
{XRT_INPUT_FRAME_GRIP_POSE, XRT_INPUT_TOUCH_GRIP_POSE},
|
||||
{XRT_INPUT_FRAME_AIM_POSE, XRT_INPUT_TOUCH_AIM_POSE},
|
||||
{XRT_INPUT_HAND_PINCH_POSE, XRT_INPUT_HAND_PINCH_POSE},
|
||||
{XRT_INPUT_HAND_POKE_POSE, XRT_INPUT_HAND_POKE_POSE},
|
||||
};
|
||||
|
||||
xrt_binding_output_pair frame_output_binding[] = {
|
||||
@@ -728,13 +726,11 @@ wivrn_controller::wivrn_controller(xrt_device_name name,
|
||||
.orientation_tracking = true,
|
||||
.position_tracking = true,
|
||||
.hand_tracking = name != XRT_DEVICE_EXT_HAND_INTERACTION and cnx->get_info().hand_tracking,
|
||||
.battery_status = cnx->get_info().battery_status,
|
||||
},
|
||||
.update_inputs = method_pointer<&wivrn_controller::update_inputs>,
|
||||
.get_tracked_pose = method_pointer<&wivrn_controller::get_tracked_pose>,
|
||||
.get_hand_tracking = method_pointer<&wivrn_controller::get_hand_tracking>,
|
||||
.set_output = method_pointer<&wivrn_controller::set_output>,
|
||||
.get_battery_status = method_pointer<&wivrn_controller::get_battery_status>,
|
||||
.destroy = [](xrt_device *) {},
|
||||
},
|
||||
grip(hand_id == 0 ? device_id::LEFT_GRIP : device_id::RIGHT_GRIP),
|
||||
@@ -783,19 +779,19 @@ wivrn_controller::wivrn_controller(xrt_device_name name,
|
||||
{
|
||||
inputs[WIVRN_CONTROLLER_HAND_TRACKING_LEFT].name = XRT_INPUT_HT_UNOBSTRUCTED_LEFT;
|
||||
inputs[WIVRN_CONTROLLER_HAND_TRACKING_LEFT].active = true;
|
||||
SET_INPUT(TOUCH, MENU_CLICK);
|
||||
inputs[WIVRN_CONTROLLER_MENU_TOUCH].name = XRT_INPUT_FRAME_VIEW_TOUCH;
|
||||
inputs[WIVRN_CONTROLLER_MENU_TOUCH].active = true;
|
||||
SET_INPUT(FRAME, VIEW_CLICK);
|
||||
SET_INPUT(FRAME, VIEW_TOUCH);
|
||||
|
||||
SET_INPUT(TOUCH, MENU_CLICK);
|
||||
SET_INPUT(TOUCH, X_CLICK);
|
||||
SET_INPUT(TOUCH, Y_CLICK);
|
||||
SET_INPUT(TOUCH, X_TOUCH);
|
||||
SET_INPUT(TOUCH, Y_TOUCH);
|
||||
|
||||
SET_INPUT(FRAME, SYSTEM_CLICK);
|
||||
SET_INPUT(FRAME, DPAD_UP_CLICK);
|
||||
SET_INPUT(FRAME, DPAD_UP_TOUCH);
|
||||
SET_INPUT(FRAME, DPAD_LEFT_CLICK);
|
||||
SET_INPUT(FRAME, DPAD_LEFT_TOUCH);
|
||||
SET_INPUT(TOUCH, X_CLICK);
|
||||
SET_INPUT(TOUCH, X_TOUCH);
|
||||
SET_INPUT(TOUCH, Y_CLICK);
|
||||
SET_INPUT(TOUCH, Y_TOUCH);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -806,12 +802,12 @@ wivrn_controller::wivrn_controller(xrt_device_name name,
|
||||
|
||||
SET_INPUT(TOUCH, SYSTEM_CLICK);
|
||||
SET_INPUT(TOUCH, A_CLICK);
|
||||
SET_INPUT(TOUCH, A_TOUCH);
|
||||
SET_INPUT(TOUCH, B_CLICK);
|
||||
SET_INPUT(TOUCH, A_TOUCH);
|
||||
SET_INPUT(TOUCH, B_TOUCH);
|
||||
SET_INPUT(FRAME, X_CLICK);
|
||||
SET_INPUT(FRAME, X_TOUCH);
|
||||
SET_INPUT(FRAME, Y_CLICK);
|
||||
SET_INPUT(FRAME, X_TOUCH);
|
||||
SET_INPUT(FRAME, Y_TOUCH);
|
||||
}
|
||||
SET_INPUT(VIVE_FOCUS3, SQUEEZE_CLICK);
|
||||
@@ -994,26 +990,6 @@ xrt_result_t wivrn_controller::get_hand_tracking(xrt_input_name name, int64_t de
|
||||
}
|
||||
}
|
||||
|
||||
xrt_result_t wivrn_controller::get_battery_status(bool * out_present,
|
||||
bool * out_charging,
|
||||
float * out_charge)
|
||||
{
|
||||
auto bat = battery.lock();
|
||||
|
||||
*out_charging = bat->charging;
|
||||
if (bat->charge)
|
||||
{
|
||||
*out_present = true;
|
||||
*out_charge = *bat->charge;
|
||||
}
|
||||
else
|
||||
{
|
||||
*out_present = false;
|
||||
}
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
void wivrn_controller::set_derived_pose(const from_headset::derived_pose & derived)
|
||||
{
|
||||
auto list = [this](device_id id) -> pose_list * {
|
||||
@@ -1030,14 +1006,6 @@ void wivrn_controller::set_derived_pose(const from_headset::derived_pose & deriv
|
||||
target->set_derived(source, xrt_cast(derived.relation));
|
||||
}
|
||||
|
||||
void wivrn_controller::update_battery(const from_headset::battery & new_battery)
|
||||
{
|
||||
const device_id device = device_type == XRT_DEVICE_TYPE_LEFT_HAND_CONTROLLER ? device_id::LEFT_CONTROLLER : device_id::RIGHT_CONTROLLER;
|
||||
if (new_battery.device == device)
|
||||
{
|
||||
*battery.lock() = new_battery;
|
||||
}
|
||||
}
|
||||
void wivrn_controller::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||
{
|
||||
aim.update_tracking(tracking, offset);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/thread_safe.h"
|
||||
#include "xrt/xrt_device.h"
|
||||
|
||||
#include "hand_joints_list.h"
|
||||
@@ -49,8 +48,6 @@ class wivrn_controller : public xrt_device
|
||||
std::vector<xrt_input> inputs_array;
|
||||
std::vector<xrt_output> outputs_array;
|
||||
|
||||
thread_safe<from_headset::battery> battery{};
|
||||
|
||||
wivrn::wivrn_session * cnx;
|
||||
|
||||
public:
|
||||
@@ -61,16 +58,12 @@ public:
|
||||
|
||||
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation);
|
||||
xrt_result_t get_hand_tracking(xrt_input_name name, int64_t desired_timestamp_ns, xrt_hand_joint_set * out_value, int64_t * out_timestamp_ns);
|
||||
xrt_result_t get_battery_status(bool * out_present,
|
||||
bool * out_charging,
|
||||
float * out_charge);
|
||||
|
||||
xrt_result_t set_output(xrt_output_name name, const xrt_output_value * value);
|
||||
|
||||
void set_inputs(const from_headset::inputs &, const clock_offset &);
|
||||
void set_derived_pose(const from_headset::derived_pose &);
|
||||
|
||||
void update_battery(const from_headset::battery &);
|
||||
void set_derived_pose(const from_headset::derived_pose &);
|
||||
void update_tracking(const from_headset::tracking &, const clock_offset &);
|
||||
void update_hand_tracking(const from_headset::hand_tracking &, const clock_offset &);
|
||||
|
||||
|
||||
@@ -42,13 +42,9 @@ wivrn_gamepad::wivrn_gamepad(wivrn::wivrn_session & cnx) :
|
||||
.str = "WiVRn Gamepad",
|
||||
.serial = "WiVRn Gamepad",
|
||||
.tracking_origin = &origin,
|
||||
.supported = {
|
||||
.battery_status = cnx.get_info().battery_status,
|
||||
},
|
||||
.update_inputs = method_pointer<&wivrn_gamepad::update_inputs>,
|
||||
.get_tracked_pose = method_pointer<&wivrn_gamepad::get_tracked_pose>,
|
||||
.set_output = method_pointer<&wivrn_gamepad::set_output>,
|
||||
.get_battery_status = method_pointer<&wivrn_gamepad::get_battery_status>,
|
||||
.destroy = [](xrt_device *) {},
|
||||
},
|
||||
origin{
|
||||
@@ -114,34 +110,6 @@ xrt_result_t wivrn_gamepad::get_tracked_pose(xrt_input_name name, int64_t, xrt_s
|
||||
return XRT_ERROR_INPUT_UNSUPPORTED;
|
||||
}
|
||||
|
||||
xrt_result_t wivrn_gamepad::get_battery_status(bool * out_present,
|
||||
bool * out_charging,
|
||||
float * out_charge)
|
||||
{
|
||||
auto bat = battery.lock();
|
||||
|
||||
*out_charging = bat->charging;
|
||||
if (bat->charge)
|
||||
{
|
||||
*out_present = true;
|
||||
*out_charge = *bat->charge;
|
||||
}
|
||||
else
|
||||
{
|
||||
*out_present = false;
|
||||
}
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
void wivrn_gamepad::set_battery(const from_headset::battery & new_battery)
|
||||
{
|
||||
if (new_battery.device == device_id::GAMEPAD)
|
||||
{
|
||||
*battery.lock() = new_battery;
|
||||
}
|
||||
}
|
||||
|
||||
void wivrn_gamepad::set_inputs(const from_headset::inputs & inputs)
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/thread_safe.h"
|
||||
#include "wivrn_packets.h"
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
@@ -44,8 +43,6 @@ class wivrn_gamepad : public xrt_device
|
||||
std::array<xrt_input, 18> inputs_staging; // written from the network thread, published by update_inputs
|
||||
std::array<xrt_output, 4> outputs_array;
|
||||
|
||||
thread_safe<from_headset::battery> battery{};
|
||||
|
||||
wivrn::wivrn_session * cnx;
|
||||
|
||||
public:
|
||||
@@ -54,12 +51,8 @@ public:
|
||||
|
||||
xrt_result_t update_inputs();
|
||||
xrt_result_t get_tracked_pose(xrt_input_name name, int64_t at_timestamp_ns, xrt_space_relation * out_relation);
|
||||
xrt_result_t get_battery_status(bool * out_present,
|
||||
bool * out_charging,
|
||||
float * out_charge);
|
||||
xrt_result_t set_output(xrt_output_name name, const xrt_output_value * value);
|
||||
|
||||
void set_battery(const from_headset::battery &);
|
||||
// Update from a forwarded inputs packet (gamepad device_ids).
|
||||
void set_inputs(const from_headset::inputs &);
|
||||
void set_connected(bool);
|
||||
|
||||
@@ -164,10 +164,8 @@ void wivrn_hmd::update_tracking(const from_headset::tracking & tracking, const c
|
||||
|
||||
void wivrn_hmd::update_battery(const from_headset::battery & new_battery)
|
||||
{
|
||||
if (new_battery.device == device_id::HEAD)
|
||||
{
|
||||
*battery.lock() = new_battery;
|
||||
}
|
||||
// We will only request a new sample if the current one is consumed
|
||||
*battery.lock() = new_battery;
|
||||
}
|
||||
|
||||
xrt_result_t wivrn_hmd::get_view_poses(const xrt_vec3 * default_eye_relation,
|
||||
@@ -216,17 +214,9 @@ xrt_result_t wivrn_hmd::get_battery_status(bool * out_present,
|
||||
float * out_charge)
|
||||
{
|
||||
auto bat = battery.lock();
|
||||
|
||||
*out_present = bat->present;
|
||||
*out_charging = bat->charging;
|
||||
if (bat->charge)
|
||||
{
|
||||
*out_present = true;
|
||||
*out_charge = *bat->charge;
|
||||
}
|
||||
else
|
||||
{
|
||||
*out_present = false;
|
||||
}
|
||||
*out_charge = bat->charge;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -822,12 +822,6 @@ void wivrn_session::operator()(from_headset::feedback && feedback)
|
||||
void wivrn_session::operator()(from_headset::battery && battery)
|
||||
{
|
||||
hmd.update_battery(battery);
|
||||
left_controller.update_battery(battery);
|
||||
left_hand_interaction.update_battery(battery);
|
||||
right_controller.update_battery(battery);
|
||||
right_hand_interaction.update_battery(battery);
|
||||
if (gamepad_device)
|
||||
gamepad_device->set_battery(battery);
|
||||
}
|
||||
|
||||
void wivrn_session::operator()(from_headset::visibility_mask_changed && mask)
|
||||
|
||||
@@ -19,8 +19,35 @@
|
||||
|
||||
#include "xrt_cast.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <cstring>
|
||||
#include <type_traits>
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename Out, typename In>
|
||||
Out do_cast(const In & in)
|
||||
{
|
||||
Out res;
|
||||
static_assert(sizeof(res) == sizeof(in));
|
||||
memcpy(&res, &in, sizeof(res));
|
||||
return res;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#define XRT_CAST(in_type, out_type) \
|
||||
out_type xrt_cast(const in_type & in) \
|
||||
{ \
|
||||
return do_cast<out_type>(in); \
|
||||
}
|
||||
|
||||
XRT_CAST(XrPosef, xrt_pose)
|
||||
XRT_CAST(XrVector3f, xrt_vec3)
|
||||
XRT_CAST(XrQuaternionf, xrt_quat)
|
||||
XRT_CAST(XrFovf, xrt_fov)
|
||||
|
||||
XRT_CAST(xrt_pose, XrPosef)
|
||||
XRT_CAST(xrt_fov, XrFovf)
|
||||
|
||||
xrt_space_relation_flags from_pose_flags(uint8_t in_flags)
|
||||
{
|
||||
std::underlying_type_t<xrt_space_relation_flags> flags{};
|
||||
|
||||
@@ -20,23 +20,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "xrt/xrt_defines.h"
|
||||
#include <bit>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#define XRT_CAST(in_type, out_type) \
|
||||
constexpr out_type xrt_cast(const in_type & in) noexcept \
|
||||
{ \
|
||||
return std::bit_cast<out_type>(in); \
|
||||
}
|
||||
xrt_pose xrt_cast(const XrPosef &);
|
||||
xrt_vec3 xrt_cast(const XrVector3f &);
|
||||
xrt_quat xrt_cast(const XrQuaternionf &);
|
||||
xrt_fov xrt_cast(const XrFovf &);
|
||||
|
||||
XRT_CAST(XrPosef, xrt_pose)
|
||||
XRT_CAST(XrVector3f, xrt_vec3)
|
||||
XRT_CAST(XrQuaternionf, xrt_quat)
|
||||
XRT_CAST(XrFovf, xrt_fov)
|
||||
|
||||
XRT_CAST(xrt_pose, XrPosef)
|
||||
XRT_CAST(xrt_fov, XrFovf)
|
||||
|
||||
#undef XRT_CAST
|
||||
XrPosef xrt_cast(const xrt_pose &);
|
||||
XrFovf xrt_cast(const xrt_fov &);
|
||||
|
||||
xrt_space_relation_flags from_pose_flags(uint8_t in_flags);
|
||||
|
||||
@@ -204,12 +204,8 @@ class prober
|
||||
U_LOG_I("GPU does not support H.265 Vulkan video encode");
|
||||
return res;
|
||||
}
|
||||
case av1: {
|
||||
auto res = vk.has_device_ext(VK_KHR_VIDEO_ENCODE_AV1_EXTENSION_NAME) and flags & vk::VideoCodecOperationFlagBitsKHR::eEncodeAv1;
|
||||
if (not res)
|
||||
U_LOG_I("GPU does not support AV1 Vulkan video encode");
|
||||
return res;
|
||||
}
|
||||
case av1:
|
||||
U_LOG_D("Vulkan video encode for AV1 is not implemented in WiVRn");
|
||||
case raw:
|
||||
return false;
|
||||
}
|
||||
@@ -244,9 +240,6 @@ public:
|
||||
{
|
||||
for (auto codec: codecs)
|
||||
{
|
||||
if (codec == video_codec::av1 and config.name.empty())
|
||||
continue;
|
||||
|
||||
if (has_vk(codec))
|
||||
return {encoder_vulkan, codec};
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "video_encoder_x264.h"
|
||||
#endif
|
||||
#if WIVRN_USE_VULKAN_ENCODE
|
||||
#include "video_encoder_vulkan_av1.h"
|
||||
#include "video_encoder_vulkan_h264.h"
|
||||
#include "video_encoder_vulkan_h265.h"
|
||||
#endif
|
||||
@@ -121,8 +120,7 @@ std::unique_ptr<video_encoder> video_encoder::create(
|
||||
res = video_encoder_vulkan_h265::create(wivrn_vk, settings, stream_idx);
|
||||
break;
|
||||
case video_codec::av1:
|
||||
res = video_encoder_vulkan_av1::create(wivrn_vk, settings, stream_idx);
|
||||
break;
|
||||
throw std::runtime_error("av1 not supported for vulkan video encode");
|
||||
case video_codec::raw:
|
||||
throw std::runtime_error("raw codec only supported on raw encoder");
|
||||
}
|
||||
|
||||
@@ -821,7 +821,7 @@ void wivrn::video_encoder_vulkan::present_image(vk::Image y_cbcr, vk::SemaphoreS
|
||||
}
|
||||
|
||||
video_cmd_buf.beginVideoCodingKHR({
|
||||
.pNext = begin_coding_next((session_initialized and rate_control) ? &rate_control.value() : nullptr),
|
||||
.pNext = (session_initialized and rate_control) ? &rate_control.value() : nullptr,
|
||||
.videoSession = *video_session,
|
||||
.videoSessionParameters = *video_session_parameters,
|
||||
.referenceSlotCount = ref_slot ? 2u : 1u,
|
||||
|
||||
@@ -111,14 +111,6 @@ protected:
|
||||
virtual void * encode_info_next(uint32_t frame_num, size_t slot, std::optional<int32_t> reference_slot) = 0;
|
||||
virtual vk::ExtensionProperties std_header_version() = 0;
|
||||
|
||||
// Codec-specific structures to prepend to the vkCmdBeginVideoCodingKHR pNext chain.
|
||||
// Note that this chain accepts structures the vkCmdControlVideoCodingKHR one does not,
|
||||
// so it must not be reused for rate control updates.
|
||||
virtual const void * begin_coding_next(const void * next)
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
public:
|
||||
void present_image(vk::Image y_cbcr, vk::SemaphoreSubmitInfo, uint8_t slot, uint64_t frame_index) override;
|
||||
std::optional<data> encode(uint8_t slot, uint64_t frame_index) override;
|
||||
|
||||
@@ -1,633 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2026 Philipp Schlegel <dev@phischle.xyz>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "video_encoder_vulkan_av1.h"
|
||||
|
||||
#include "encoder/encoder_settings.h"
|
||||
#include "util/u_logging.h"
|
||||
#include "utils/wivrn_vk_bundle.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
|
||||
namespace
|
||||
{
|
||||
uint32_t align_div(uint32_t value, uint32_t divisor)
|
||||
{
|
||||
return (value + divisor - 1) / divisor;
|
||||
}
|
||||
|
||||
uint8_t bits_for(uint32_t value)
|
||||
{
|
||||
return std::max<uint8_t>(std::bit_width(value), 1);
|
||||
}
|
||||
|
||||
// AV1 spec, annex A.3 "Levels", limited to the levels that are actually defined.
|
||||
// MaxDisplayRate is omitted, it is always smaller than MaxDecodeRate and we never
|
||||
// display more samples than we decode.
|
||||
struct av1_level_limits
|
||||
{
|
||||
StdVideoAV1Level level;
|
||||
uint32_t max_pic_size; // samples
|
||||
uint32_t max_h_size; // samples
|
||||
uint32_t max_v_size; // samples
|
||||
uint64_t max_decode_rate;
|
||||
};
|
||||
|
||||
constexpr av1_level_limits av1_levels[] = {
|
||||
{STD_VIDEO_AV1_LEVEL_2_0, 147456, 2048, 1152, 5529600},
|
||||
{STD_VIDEO_AV1_LEVEL_2_1, 278784, 2816, 1584, 10454400},
|
||||
{STD_VIDEO_AV1_LEVEL_3_0, 665856, 4352, 2448, 24969600},
|
||||
{STD_VIDEO_AV1_LEVEL_3_1, 1065024, 5504, 3096, 39938400},
|
||||
{STD_VIDEO_AV1_LEVEL_4_0, 2359296, 6144, 3456, 77856768},
|
||||
{STD_VIDEO_AV1_LEVEL_4_1, 2359296, 6144, 3456, 155713536},
|
||||
{STD_VIDEO_AV1_LEVEL_5_0, 8912896, 8192, 4352, 273715200},
|
||||
{STD_VIDEO_AV1_LEVEL_5_1, 8912896, 8192, 4352, 547430400},
|
||||
{STD_VIDEO_AV1_LEVEL_5_2, 8912896, 8192, 4352, 1094860800},
|
||||
{STD_VIDEO_AV1_LEVEL_5_3, 8912896, 8192, 4352, 1176502272},
|
||||
{STD_VIDEO_AV1_LEVEL_6_0, 35651584, 16384, 8704, 1176502272},
|
||||
{STD_VIDEO_AV1_LEVEL_6_1, 35651584, 16384, 8704, 2189721600},
|
||||
{STD_VIDEO_AV1_LEVEL_6_2, 35651584, 16384, 8704, 4379443200},
|
||||
{STD_VIDEO_AV1_LEVEL_6_3, 35651584, 16384, 8704, 4706009088},
|
||||
};
|
||||
|
||||
// Smallest level able to carry the stream, clamped to what the encoder supports.
|
||||
// Reporting the driver's maximum instead would make decoders reject or downgrade
|
||||
// the stream for no reason.
|
||||
StdVideoAV1Level select_level(uint32_t width, uint32_t height, float fps, StdVideoAV1Level max_level)
|
||||
{
|
||||
const uint64_t pic_size = uint64_t(width) * height;
|
||||
const uint64_t decode_rate = uint64_t(double(pic_size) * std::max(fps, 1.f));
|
||||
|
||||
for (const auto & l: av1_levels)
|
||||
{
|
||||
if (l.level > max_level)
|
||||
break;
|
||||
if (pic_size <= l.max_pic_size and width <= l.max_h_size and height <= l.max_v_size and decode_rate <= l.max_decode_rate)
|
||||
return l.level;
|
||||
}
|
||||
|
||||
U_LOG_W("AV1: no level supports %ux%u@%.1f, falling back to the encoder maximum", width, height, fps);
|
||||
return max_level;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
wivrn::video_encoder_vulkan_av1::video_encoder_vulkan_av1(
|
||||
wivrn::vk_bundle & vk,
|
||||
const vk::VideoCapabilitiesKHR & video_caps,
|
||||
const vk::VideoEncodeCapabilitiesKHR & encode_caps,
|
||||
const vk::VideoEncodeAV1CapabilitiesKHR & encode_av1_caps,
|
||||
uint8_t stream_idx,
|
||||
const encoder_settings & settings) :
|
||||
video_encoder_vulkan(vk, video_caps, encode_caps, stream_idx, settings)
|
||||
{
|
||||
if (not vk.has_device_ext(VK_KHR_VIDEO_ENCODE_AV1_EXTENSION_NAME))
|
||||
throw std::runtime_error("Vulkan video encode AV1 extension not available");
|
||||
|
||||
if (settings.bit_depth != 8 && settings.bit_depth != 10)
|
||||
throw std::runtime_error("av1 encoder supports 8-bit or 10-bit only");
|
||||
|
||||
configure_from_caps(encode_av1_caps);
|
||||
|
||||
level = select_level(aligned_extent.width, aligned_extent.height, settings.fps, encode_av1_caps.maxLevel);
|
||||
|
||||
color_config = {
|
||||
.flags = {
|
||||
.mono_chrome = 0,
|
||||
.color_range = 1,
|
||||
.separate_uv_delta_q = 0,
|
||||
.color_description_present_flag = 1,
|
||||
},
|
||||
.BitDepth = static_cast<uint8_t>(settings.bit_depth),
|
||||
.subsampling_x = 1,
|
||||
.subsampling_y = 1,
|
||||
.reserved1 = 0,
|
||||
.color_primaries = STD_VIDEO_AV1_COLOR_PRIMARIES_BT_709,
|
||||
.transfer_characteristics = STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_709,
|
||||
.matrix_coefficients = STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_709,
|
||||
.chroma_sample_position = STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_COLOCATED,
|
||||
};
|
||||
|
||||
seq_header = {
|
||||
.flags = {
|
||||
.still_picture = 0,
|
||||
.reduced_still_picture_header = 0,
|
||||
.use_128x128_superblock = superblock_size == 128 ? 1u : 0u,
|
||||
.enable_filter_intra = 0,
|
||||
.enable_intra_edge_filter = 0,
|
||||
.enable_interintra_compound = 0,
|
||||
.enable_masked_compound = 0,
|
||||
.enable_warped_motion = 0,
|
||||
.enable_dual_filter = 0,
|
||||
.enable_order_hint = 1,
|
||||
.enable_jnt_comp = 0,
|
||||
.enable_ref_frame_mvs = 0,
|
||||
.frame_id_numbers_present_flag = 0,
|
||||
.enable_superres = 0,
|
||||
.enable_cdef = 0,
|
||||
.enable_restoration = 0,
|
||||
.film_grain_params_present = 0,
|
||||
.timing_info_present_flag = 0,
|
||||
.initial_display_delay_present_flag = 0,
|
||||
},
|
||||
.seq_profile = STD_VIDEO_AV1_PROFILE_MAIN,
|
||||
.frame_width_bits_minus_1 = static_cast<uint8_t>(bits_for(aligned_extent.width - 1) - 1),
|
||||
.frame_height_bits_minus_1 = static_cast<uint8_t>(bits_for(aligned_extent.height - 1) - 1),
|
||||
.max_frame_width_minus_1 = static_cast<uint16_t>(aligned_extent.width - 1),
|
||||
.max_frame_height_minus_1 = static_cast<uint16_t>(aligned_extent.height - 1),
|
||||
.delta_frame_id_length_minus_2 = 0,
|
||||
.additional_frame_id_length_minus_1 = 0,
|
||||
.order_hint_bits_minus_1 = static_cast<uint8_t>(order_hint_bits - 1),
|
||||
.seq_force_integer_mv = STD_VIDEO_AV1_SELECT_INTEGER_MV,
|
||||
.seq_force_screen_content_tools = STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS,
|
||||
.reserved1 = {},
|
||||
.pColorConfig = &color_config,
|
||||
.pTimingInfo = nullptr,
|
||||
};
|
||||
|
||||
operating_point = {
|
||||
.flags = {
|
||||
.decoder_model_present_for_this_op = 0,
|
||||
.low_delay_mode_flag = 1,
|
||||
.initial_display_delay_present_for_this_op = 0,
|
||||
},
|
||||
.operating_point_idc = 0,
|
||||
.seq_level_idx = static_cast<uint8_t>(level),
|
||||
.seq_tier = 0,
|
||||
.decoder_buffer_delay = 0,
|
||||
.encoder_buffer_delay = 0,
|
||||
.initial_display_delay_minus_1 = 0,
|
||||
};
|
||||
|
||||
const uint32_t sb_cols = align_div(aligned_extent.width, superblock_size);
|
||||
const uint32_t sb_rows = align_div(aligned_extent.height, superblock_size);
|
||||
const uint32_t mi_cols = align_div(aligned_extent.width, 4);
|
||||
const uint32_t mi_rows = align_div(aligned_extent.height, 4);
|
||||
const bool uniform_tile_spacing = bool(std_flags & vk::VideoEncodeAV1StdFlagBitsKHR::eUniformTileSpacingFlagSet);
|
||||
|
||||
// A single tile is enough for the resolutions WiVRn streams, but AV1 caps a tile at 4096
|
||||
// samples wide (annex A.3), a wider stream would not be decodable.
|
||||
if (sb_cols * superblock_size > 4096)
|
||||
throw std::runtime_error("av1 encoder supports at most 4096 samples per tile row");
|
||||
|
||||
mi_col_starts = {0u, static_cast<uint16_t>(mi_cols)};
|
||||
mi_row_starts = {0u, static_cast<uint16_t>(mi_rows)};
|
||||
if (!tile_widths_sb.empty())
|
||||
tile_widths_sb[0] = static_cast<uint16_t>(sb_cols - 1);
|
||||
if (!tile_heights_sb.empty())
|
||||
tile_heights_sb[0] = static_cast<uint16_t>(sb_rows - 1);
|
||||
|
||||
tile_info = {
|
||||
.flags = {
|
||||
.uniform_tile_spacing_flag = uniform_tile_spacing ? 1u : 0u,
|
||||
},
|
||||
.TileCols = 1,
|
||||
.TileRows = 1,
|
||||
.context_update_tile_id = 0,
|
||||
.tile_size_bytes_minus_1 = 0,
|
||||
.reserved1 = {},
|
||||
.pMiColStarts = uniform_tile_spacing ? nullptr : mi_col_starts.data(),
|
||||
.pMiRowStarts = uniform_tile_spacing ? nullptr : mi_row_starts.data(),
|
||||
.pWidthInSbsMinus1 = uniform_tile_spacing ? nullptr : tile_widths_sb.data(),
|
||||
.pHeightInSbsMinus1 = uniform_tile_spacing ? nullptr : tile_heights_sb.data(),
|
||||
};
|
||||
|
||||
quantization = {
|
||||
.flags = {
|
||||
.using_qmatrix = 0,
|
||||
.diff_uv_delta = 0,
|
||||
},
|
||||
.base_q_idx = static_cast<uint8_t>(encode_av1_caps.maxQIndex),
|
||||
.DeltaQYDc = 0,
|
||||
.DeltaQUDc = 0,
|
||||
.DeltaQUAc = 0,
|
||||
.DeltaQVDc = 0,
|
||||
.DeltaQVAc = 0,
|
||||
.qm_y = 0,
|
||||
.qm_u = 0,
|
||||
.qm_v = 0,
|
||||
};
|
||||
|
||||
loop_filter = {
|
||||
.flags = {
|
||||
.loop_filter_delta_enabled = 0,
|
||||
.loop_filter_delta_update = 0,
|
||||
},
|
||||
.loop_filter_level = {},
|
||||
.loop_filter_sharpness = 0,
|
||||
.update_ref_delta = 0,
|
||||
.loop_filter_ref_deltas = {},
|
||||
.update_mode_delta = 0,
|
||||
.loop_filter_mode_deltas = {},
|
||||
};
|
||||
|
||||
cdef = {
|
||||
.cdef_damping_minus_3 = 0,
|
||||
.cdef_bits = 0,
|
||||
.cdef_y_pri_strength = {},
|
||||
.cdef_y_sec_strength = {},
|
||||
.cdef_uv_pri_strength = {},
|
||||
.cdef_uv_sec_strength = {},
|
||||
};
|
||||
|
||||
loop_restoration = {
|
||||
.FrameRestorationType = {STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
|
||||
STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE},
|
||||
.LoopRestorationSize = {0, 0, 0},
|
||||
};
|
||||
|
||||
global_motion = {
|
||||
.GmType = {},
|
||||
.gm_params = {},
|
||||
};
|
||||
|
||||
segmentation = {};
|
||||
|
||||
rate_control_layer.pNext = &rate_control_layer_av1;
|
||||
}
|
||||
|
||||
void wivrn::video_encoder_vulkan_av1::configure_from_caps(const vk::VideoEncodeAV1CapabilitiesKHR & encode_av1_caps)
|
||||
{
|
||||
U_LOG_D("AV1: capabilities: stdSyntaxFlags=0x%x, superblockSizes=0x%x, singleReferenceNameMask=0x%x, maxSingleReferenceCount=%u, maxUnidirectionalCompoundReferenceCount=%u, maxBidirectionalCompoundReferenceCount=%u, maxQIndex=%u, minQIndex=%u, requiresGopRemainingFrames=%u, maxOperatingPoints=%u",
|
||||
static_cast<uint32_t>(encode_av1_caps.stdSyntaxFlags),
|
||||
static_cast<uint32_t>(encode_av1_caps.superblockSizes),
|
||||
encode_av1_caps.singleReferenceNameMask,
|
||||
encode_av1_caps.maxSingleReferenceCount,
|
||||
encode_av1_caps.maxUnidirectionalCompoundReferenceCount,
|
||||
encode_av1_caps.maxBidirectionalCompoundReferenceCount,
|
||||
encode_av1_caps.maxQIndex,
|
||||
encode_av1_caps.minQIndex,
|
||||
encode_av1_caps.requiresGopRemainingFrames,
|
||||
encode_av1_caps.maxOperatingPoints);
|
||||
std_flags = encode_av1_caps.stdSyntaxFlags;
|
||||
if (encode_av1_caps.superblockSizes & vk::VideoEncodeAV1SuperblockSizeFlagBitsKHR::e64)
|
||||
superblock_size = 64;
|
||||
else
|
||||
superblock_size = 128;
|
||||
|
||||
single_reference_name_mask = encode_av1_caps.singleReferenceNameMask;
|
||||
max_single_reference_count = encode_av1_caps.maxSingleReferenceCount;
|
||||
max_q_index = encode_av1_caps.maxQIndex;
|
||||
min_q_index = encode_av1_caps.minQIndex;
|
||||
|
||||
// The single reference of an inter frame must use a reference name the encoder
|
||||
// advertises, bit i standing for LAST_FRAME + i.
|
||||
// VUID-vkCmdEncodeVideoKHR-predictionMode-10329
|
||||
ref_name_index = -1;
|
||||
for (size_t i = 0; i < reference_name_slot_indices.size(); ++i)
|
||||
{
|
||||
if (single_reference_name_mask & (1u << i))
|
||||
{
|
||||
ref_name_index = int32_t(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// WiVRn streams key frame + inter frames referencing a single acknowledged frame, an
|
||||
// encoder that cannot do single reference prediction is of no use to us.
|
||||
if (ref_name_index < 0 or max_single_reference_count == 0)
|
||||
throw std::runtime_error("av1 encoder does not support single reference prediction");
|
||||
if (ref_name_index != 0)
|
||||
U_LOG_W("AV1: LAST_FRAME not supported (mask=0x%x), using reference name index %d", single_reference_name_mask, ref_name_index);
|
||||
|
||||
rate_control_av1 = vk::VideoEncodeAV1RateControlInfoKHR{
|
||||
.flags = vk::VideoEncodeAV1RateControlFlagBitsKHR::eRegularGop,
|
||||
.gopFrameCount = std::numeric_limits<uint32_t>::max(),
|
||||
.keyFramePeriod = std::numeric_limits<uint32_t>::max(),
|
||||
.consecutiveBipredictiveFrameCount = 0,
|
||||
// VUID-VkVideoEncodeAV1RateControlInfoKHR-temporalLayerCount-10299
|
||||
.temporalLayerCount = std::min(1u, encode_av1_caps.maxTemporalLayerCount),
|
||||
};
|
||||
|
||||
rate_control_layer_av1 = vk::VideoEncodeAV1RateControlLayerInfoKHR{
|
||||
.useMinQIndex = VK_FALSE,
|
||||
.minQIndex = {
|
||||
.intraQIndex = encode_av1_caps.minQIndex,
|
||||
.predictiveQIndex = encode_av1_caps.minQIndex,
|
||||
.bipredictiveQIndex = encode_av1_caps.minQIndex,
|
||||
},
|
||||
.useMaxQIndex = VK_FALSE,
|
||||
.maxQIndex = {
|
||||
.intraQIndex = encode_av1_caps.maxQIndex,
|
||||
.predictiveQIndex = encode_av1_caps.maxQIndex,
|
||||
.bipredictiveQIndex = encode_av1_caps.maxQIndex,
|
||||
},
|
||||
.useMaxFrameSize = VK_FALSE,
|
||||
.maxFrameSize = {},
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<void *> wivrn::video_encoder_vulkan_av1::setup_slot_info(size_t dpb_size)
|
||||
{
|
||||
dpb_std_info.resize(dpb_size, {});
|
||||
dpb_std_slots.reserve(dpb_size);
|
||||
std::vector<void *> res;
|
||||
for (size_t i = 0; i < dpb_size; ++i)
|
||||
{
|
||||
dpb_std_slots.push_back({
|
||||
.pStdReferenceInfo = &dpb_std_info[i],
|
||||
});
|
||||
res.push_back(&dpb_std_slots[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static auto get_video_caps(vk::raii::PhysicalDevice & phys_dev, int bit_depth)
|
||||
{
|
||||
if (!(bit_depth == 8 || bit_depth == 10))
|
||||
throw std::runtime_error("av1 encoder supports 8-bit or 10-bit only");
|
||||
|
||||
vk::StructureChain video_profile_info{
|
||||
vk::VideoProfileInfoKHR{
|
||||
.videoCodecOperation = vk::VideoCodecOperationFlagBitsKHR::eEncodeAv1,
|
||||
.chromaSubsampling = vk::VideoChromaSubsamplingFlagBitsKHR::e420,
|
||||
.lumaBitDepth = bit_depth == 10 ? vk::VideoComponentBitDepthFlagBitsKHR::e10 : vk::VideoComponentBitDepthFlagBitsKHR::e8,
|
||||
.chromaBitDepth = bit_depth == 10 ? vk::VideoComponentBitDepthFlagBitsKHR::e10 : vk::VideoComponentBitDepthFlagBitsKHR::e8,
|
||||
},
|
||||
vk::VideoEncodeAV1ProfileInfoKHR{
|
||||
.stdProfile = STD_VIDEO_AV1_PROFILE_MAIN,
|
||||
},
|
||||
vk::VideoEncodeUsageInfoKHR{
|
||||
.videoUsageHints = vk::VideoEncodeUsageFlagBitsKHR::eStreaming,
|
||||
.videoContentHints = vk::VideoEncodeContentFlagBitsKHR::eRendered,
|
||||
.tuningMode = vk::VideoEncodeTuningModeKHR::eUltraLowLatency,
|
||||
}};
|
||||
|
||||
try
|
||||
{
|
||||
auto [video_caps, encode_caps, encode_av1_caps] =
|
||||
phys_dev.getVideoCapabilitiesKHR<
|
||||
vk::VideoCapabilitiesKHR,
|
||||
vk::VideoEncodeCapabilitiesKHR,
|
||||
vk::VideoEncodeAV1CapabilitiesKHR>(video_profile_info.get());
|
||||
|
||||
video_caps.maxDpbSlots = std::min(video_caps.maxDpbSlots, uint32_t(STD_VIDEO_AV1_NUM_REF_FRAMES));
|
||||
return std::make_tuple(video_caps, encode_caps, encode_av1_caps, video_profile_info);
|
||||
}
|
||||
catch (...)
|
||||
{}
|
||||
|
||||
video_profile_info.unlink<vk::VideoEncodeUsageInfoKHR>();
|
||||
auto [video_caps, encode_caps, encode_av1_caps] =
|
||||
phys_dev.getVideoCapabilitiesKHR<
|
||||
vk::VideoCapabilitiesKHR,
|
||||
vk::VideoEncodeCapabilitiesKHR,
|
||||
vk::VideoEncodeAV1CapabilitiesKHR>(video_profile_info.get());
|
||||
video_caps.maxDpbSlots = std::min(video_caps.maxDpbSlots, uint32_t(STD_VIDEO_AV1_NUM_REF_FRAMES));
|
||||
return std::make_tuple(video_caps, encode_caps, encode_av1_caps, video_profile_info);
|
||||
}
|
||||
|
||||
std::unique_ptr<wivrn::video_encoder_vulkan_av1> wivrn::video_encoder_vulkan_av1::create(
|
||||
wivrn::vk_bundle & vk,
|
||||
const encoder_settings & settings,
|
||||
uint8_t stream_idx)
|
||||
{
|
||||
auto [video_caps, encode_caps, encode_av1_caps, video_profile_info] = get_video_caps(vk.physical_device, settings.bit_depth);
|
||||
|
||||
std::unique_ptr<video_encoder_vulkan_av1> self(
|
||||
new video_encoder_vulkan_av1(vk, video_caps, encode_caps, encode_av1_caps, stream_idx, settings));
|
||||
|
||||
vk::VideoEncodeAV1SessionParametersCreateInfoKHR session_params_info{
|
||||
.pStdSequenceHeader = &self->seq_header,
|
||||
.pStdDecoderModelInfo = nullptr,
|
||||
.stdOperatingPointCount = 0,
|
||||
.pStdOperatingPoints = nullptr,
|
||||
};
|
||||
|
||||
self->quality_level_info = vk::VideoEncodeQualityLevelInfoKHR{
|
||||
.qualityLevel = 0, // Use default quality level
|
||||
};
|
||||
session_params_info.pNext = &self->quality_level_info;
|
||||
|
||||
// Let the session be sized for whatever the encoder supports, the level that matters to the
|
||||
// decoder is the one written to the operating point.
|
||||
vk::VideoEncodeAV1SessionCreateInfoKHR session_create_info{
|
||||
.useMaxLevel = false,
|
||||
.maxLevel = encode_av1_caps.maxLevel,
|
||||
};
|
||||
|
||||
// VkVideoEncodeAV1RateControlInfoKHR belongs to the same pNext chain as the generic
|
||||
// rate control info, in both vkCmdBeginVideoCodingKHR and vkCmdControlVideoCodingKHR.
|
||||
if (self->rate_control)
|
||||
{
|
||||
self->rate_control_enabled = true;
|
||||
self->rate_control->pNext = &self->rate_control_av1;
|
||||
}
|
||||
|
||||
// VkVideoEncodeAV1GopRemainingFrameInfoKHR only extends VkVideoBeginCodingInfoKHR, so it
|
||||
// is added by begin_coding_next() rather than chained onto the rate control info, which is
|
||||
// also used for vkCmdControlVideoCodingKHR.
|
||||
// VUID-vkCmdBeginVideoCodingKHR-pBeginInfo-10282
|
||||
if (self->rate_control_enabled and (encode_av1_caps.requiresGopRemainingFrames or encode_av1_caps.prefersGopRemainingFrames))
|
||||
{
|
||||
self->gop_info = vk::VideoEncodeAV1GopRemainingFrameInfoKHR{
|
||||
.useGopRemainingFrames = true,
|
||||
.gopRemainingIntra = 0,
|
||||
.gopRemainingPredictive = std::numeric_limits<uint32_t>::max(),
|
||||
.gopRemainingBipredictive = 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (encode_av1_caps.maxOperatingPoints > 0)
|
||||
{
|
||||
session_params_info.stdOperatingPointCount = 1;
|
||||
session_params_info.pStdOperatingPoints = &self->operating_point;
|
||||
}
|
||||
|
||||
#ifdef VK_KHR_video_encode_intra_refresh
|
||||
vk::VideoEncodeIntraRefreshCapabilitiesKHR intra_caps{};
|
||||
if (std::get<vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>(vk.feat).videoEncodeIntraRefresh)
|
||||
intra_caps = std::get<vk::VideoEncodeIntraRefreshCapabilitiesKHR>(
|
||||
vk.physical_device.getVideoCapabilitiesKHR<vk::VideoCapabilitiesKHR, vk::VideoEncodeCapabilitiesKHR, vk::VideoEncodeAV1CapabilitiesKHR, vk::VideoEncodeIntraRefreshCapabilitiesKHR>(video_profile_info.get()));
|
||||
#endif
|
||||
self->init(video_caps,
|
||||
#ifdef VK_KHR_video_encode_intra_refresh
|
||||
intra_caps,
|
||||
#endif
|
||||
video_profile_info.get(),
|
||||
&session_create_info,
|
||||
&session_params_info);
|
||||
return self;
|
||||
}
|
||||
|
||||
void wivrn::video_encoder_vulkan_av1::send_idr_data()
|
||||
{
|
||||
U_LOG_D("AV1: send_idr_data() called");
|
||||
// Fetch encoded session parameters (sequence header OBU).
|
||||
try
|
||||
{
|
||||
auto data = get_encoded_parameters(nullptr);
|
||||
U_LOG_D("AV1: get_encoded_parameters returned %zu bytes", data.size());
|
||||
if (!data.empty())
|
||||
SendData(data, false, true);
|
||||
else
|
||||
U_LOG_W("AV1: get_encoded_parameters returned empty data");
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
U_LOG_E("AV1: Exception in get_encoded_parameters: %s", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void * wivrn::video_encoder_vulkan_av1::encode_info_next(uint32_t frame_num, size_t slot, std::optional<int32_t> ref_slot)
|
||||
{
|
||||
const bool has_ref = ref_slot.has_value();
|
||||
const bool is_keyframe = not has_ref;
|
||||
|
||||
// Initialize reference name slot indices to -1 (no reference)
|
||||
std::ranges::fill(reference_name_slot_indices, -1);
|
||||
|
||||
if (has_ref)
|
||||
reference_name_slot_indices[ref_name_index] = *ref_slot;
|
||||
|
||||
std_picture_info = {};
|
||||
std_picture_info.flags.error_resilient_mode = is_keyframe ? 1u : 0u;
|
||||
std_picture_info.flags.disable_cdf_update = 0;
|
||||
std_picture_info.flags.use_superres = 0;
|
||||
// The coded frame is always aligned_extent, which is what the sequence header declares as
|
||||
// max_frame_{width,height}, so the frame size is never overridden. Only the render size
|
||||
// differs, when the requested extent needed padding to satisfy the encoder granularity.
|
||||
// VUID-vkCmdEncodeVideoKHR-flags-10322
|
||||
std_picture_info.flags.frame_size_override_flag = 0;
|
||||
std_picture_info.flags.render_and_frame_size_different =
|
||||
(aligned_extent.width != extent.width or aligned_extent.height != extent.height) ? 1u : 0u;
|
||||
std_picture_info.flags.allow_screen_content_tools = 0;
|
||||
std_picture_info.flags.is_filter_switchable = 1;
|
||||
// AV1 spec 5.9.2: both are inferred for intra frames, match what the decoder will derive
|
||||
std_picture_info.flags.force_integer_mv = is_keyframe ? 1u : 0u;
|
||||
std_picture_info.flags.buffer_removal_time_present_flag = 0;
|
||||
std_picture_info.flags.allow_intrabc = 0;
|
||||
std_picture_info.flags.frame_refs_short_signaling = 0;
|
||||
std_picture_info.flags.allow_high_precision_mv = is_keyframe ? 0u : 1u;
|
||||
std_picture_info.flags.is_motion_mode_switchable = 0;
|
||||
std_picture_info.flags.use_ref_frame_mvs = 0;
|
||||
std_picture_info.flags.disable_frame_end_update_cdf = 0;
|
||||
std_picture_info.flags.allow_warped_motion = 0;
|
||||
std_picture_info.flags.reduced_tx_set = 0;
|
||||
std_picture_info.flags.skip_mode_present = 0;
|
||||
std_picture_info.flags.delta_q_present = 0;
|
||||
std_picture_info.flags.delta_lf_present = 0;
|
||||
std_picture_info.flags.delta_lf_multi = 0;
|
||||
std_picture_info.flags.segmentation_enabled = 0;
|
||||
std_picture_info.flags.segmentation_update_map = 0;
|
||||
std_picture_info.flags.segmentation_temporal_update = 0;
|
||||
std_picture_info.flags.segmentation_update_data = 0;
|
||||
std_picture_info.flags.UsesLr = 0;
|
||||
std_picture_info.flags.usesChromaLr = 0;
|
||||
std_picture_info.flags.show_frame = 1;
|
||||
std_picture_info.flags.showable_frame = std_picture_info.flags.show_frame ? (is_keyframe ? 0u : 1u) : 1u;
|
||||
std_picture_info.frame_type = is_keyframe ? STD_VIDEO_AV1_FRAME_TYPE_KEY : STD_VIDEO_AV1_FRAME_TYPE_INTER;
|
||||
// Both are only coded when the decoder model / frame ids are signalled, which the sequence
|
||||
// header disables, and the decoder then infers 0 for them (AV1 spec 5.9.2).
|
||||
std_picture_info.frame_presentation_time = 0;
|
||||
std_picture_info.current_frame_id = 0;
|
||||
std_picture_info.order_hint = static_cast<uint8_t>(frame_num & ((1u << order_hint_bits) - 1));
|
||||
// primary_ref_frame indexes ref_frame_idx[], it selects the reference to load the CDFs and
|
||||
// the loop filter / segmentation state from. Only usable if the encoder supports values
|
||||
// other than PRIMARY_REF_NONE.
|
||||
if (has_ref and (std_flags & vk::VideoEncodeAV1StdFlagBitsKHR::ePrimaryRefFrame))
|
||||
std_picture_info.primary_ref_frame = uint8_t(ref_name_index);
|
||||
else
|
||||
std_picture_info.primary_ref_frame = STD_VIDEO_AV1_PRIMARY_REF_NONE;
|
||||
std_picture_info.refresh_frame_flags = static_cast<uint8_t>(is_keyframe ? 0xFF : (1u << slot));
|
||||
std_picture_info.coded_denom = 0;
|
||||
std_picture_info.render_width_minus_1 = static_cast<uint16_t>(extent.width - 1);
|
||||
std_picture_info.render_height_minus_1 = static_cast<uint16_t>(extent.height - 1);
|
||||
std_picture_info.interpolation_filter = STD_VIDEO_AV1_INTERPOLATION_FILTER_SWITCHABLE;
|
||||
std_picture_info.TxMode = STD_VIDEO_AV1_TX_MODE_SELECT;
|
||||
std_picture_info.delta_q_res = 0;
|
||||
std_picture_info.delta_lf_res = 0;
|
||||
std::fill(std_picture_info.ref_order_hint, std_picture_info.ref_order_hint + STD_VIDEO_AV1_NUM_REF_FRAMES, 0);
|
||||
std::fill(std_picture_info.ref_frame_idx, std_picture_info.ref_frame_idx + STD_VIDEO_AV1_REFS_PER_FRAME, static_cast<int8_t>(-1));
|
||||
std::fill(std_picture_info.delta_frame_id_minus_1, std_picture_info.delta_frame_id_minus_1 + STD_VIDEO_AV1_REFS_PER_FRAME, 0);
|
||||
std_picture_info.pTileInfo = &tile_info;
|
||||
std_picture_info.pQuantization = &quantization;
|
||||
std_picture_info.pSegmentation = (std_picture_info.flags.segmentation_enabled) ? &segmentation : nullptr;
|
||||
std_picture_info.pLoopFilter = &loop_filter;
|
||||
std_picture_info.pCDEF = &cdef;
|
||||
std_picture_info.pLoopRestoration = &loop_restoration;
|
||||
std_picture_info.pGlobalMotion = &global_motion;
|
||||
std_picture_info.pExtensionHeader = nullptr;
|
||||
std_picture_info.pBufferRemovalTimes = nullptr;
|
||||
|
||||
// ref_frame_idx[] maps a reference name to a DPB slot, and must be filled in for the same
|
||||
// reference name that referenceNameSlotIndices uses.
|
||||
if (has_ref)
|
||||
std_picture_info.ref_frame_idx[ref_name_index] = static_cast<int8_t>(*ref_slot);
|
||||
|
||||
const size_t dpb_ref_count = std::min<size_t>(dpb_std_info.size(), STD_VIDEO_AV1_NUM_REF_FRAMES);
|
||||
for (size_t i = 0; i < dpb_ref_count; ++i)
|
||||
std_picture_info.ref_order_hint[i] = dpb_std_info[i].OrderHint;
|
||||
|
||||
picture_info = vk::VideoEncodeAV1PictureInfoKHR{};
|
||||
// WiVRn always predicts from the primary reference, never uses it for CDFs only.
|
||||
// VUID-VkVideoEncodeAV1PictureInfoKHR-flags-10289
|
||||
picture_info.primaryReferenceCdfOnly = VK_FALSE;
|
||||
// Key frames are the only intra frames we produce, everything else predicts from the single
|
||||
// acknowledged reference frame. Encoders without single reference support are rejected in
|
||||
// configure_from_caps().
|
||||
// VUID-vkCmdEncodeVideoKHR-pStdPictureInfo-10327
|
||||
picture_info.predictionMode = is_keyframe ? vk::VideoEncodeAV1PredictionModeKHR::eIntraOnly
|
||||
: vk::VideoEncodeAV1PredictionModeKHR::eSingleReference;
|
||||
|
||||
// Set rate control group based on frame type
|
||||
// Note: WiVRn currently doesn't support B-frames, so only INTRA and PREDICTIVE groups
|
||||
picture_info.rateControlGroup = is_keyframe ? vk::VideoEncodeAV1RateControlGroupKHR::eIntra
|
||||
: vk::VideoEncodeAV1RateControlGroupKHR::ePredictive;
|
||||
// Must be zero while rate control is active, and within the reported range otherwise.
|
||||
// VUID-vkCmdEncodeVideoKHR-constantQIndex-10320, VUID-vkCmdEncodeVideoKHR-constantQIndex-10321
|
||||
picture_info.constantQIndex = rate_control_enabled ? 0 : std::midpoint(min_q_index, max_q_index);
|
||||
picture_info.pStdPictureInfo = &std_picture_info;
|
||||
picture_info.referenceNameSlotIndices = reference_name_slot_indices;
|
||||
picture_info.generateObuExtensionHeader = VK_FALSE;
|
||||
|
||||
auto & i = dpb_std_info[slot];
|
||||
i = {};
|
||||
i.flags.disable_frame_end_update_cdf = 0;
|
||||
i.flags.segmentation_enabled = 0;
|
||||
// Frame ids are not signalled, see current_frame_id above
|
||||
i.RefFrameId = 0;
|
||||
i.frame_type = std_picture_info.frame_type;
|
||||
i.OrderHint = std_picture_info.order_hint;
|
||||
i.pExtensionHeader = nullptr;
|
||||
|
||||
return &picture_info;
|
||||
}
|
||||
|
||||
const void * wivrn::video_encoder_vulkan_av1::begin_coding_next(const void * next)
|
||||
{
|
||||
if (not gop_info)
|
||||
return next;
|
||||
|
||||
gop_info->pNext = next;
|
||||
return &*gop_info;
|
||||
}
|
||||
|
||||
vk::ExtensionProperties wivrn::video_encoder_vulkan_av1::std_header_version()
|
||||
{
|
||||
vk::ExtensionProperties std_header_version{
|
||||
.specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_SPEC_VERSION,
|
||||
};
|
||||
strcpy(std_header_version.extensionName,
|
||||
VK_STD_VULKAN_VIDEO_CODEC_AV1_ENCODE_EXTENSION_NAME);
|
||||
return std_header_version;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* WiVRn VR streaming
|
||||
* Copyright (C) 2024 Patrick Nicolas <patricknicolas@laposte.net>
|
||||
* Copyright (C) 2026 Philipp Schlegel <dev@phischle.xyz>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "video_encoder_vulkan.h"
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#include <vk_video/vulkan_video_codec_av1std.h>
|
||||
#include <vk_video/vulkan_video_codec_av1std_encode.h>
|
||||
|
||||
namespace wivrn
|
||||
{
|
||||
class video_encoder_vulkan_av1 : public video_encoder_vulkan
|
||||
{
|
||||
StdVideoAV1ColorConfig color_config{};
|
||||
StdVideoAV1SequenceHeader seq_header{};
|
||||
|
||||
StdVideoAV1TileInfo tile_info{};
|
||||
StdVideoAV1Quantization quantization{};
|
||||
StdVideoAV1LoopFilter loop_filter{};
|
||||
StdVideoAV1CDEF cdef{};
|
||||
StdVideoAV1LoopRestoration loop_restoration{};
|
||||
StdVideoAV1GlobalMotion global_motion{};
|
||||
StdVideoAV1Segmentation segmentation{};
|
||||
|
||||
StdVideoEncodeAV1PictureInfo std_picture_info{};
|
||||
StdVideoEncodeAV1OperatingPointInfo operating_point{};
|
||||
std::array<int32_t, VK_MAX_VIDEO_AV1_REFERENCES_PER_FRAME_KHR> reference_name_slot_indices{};
|
||||
std::array<uint16_t, 2> mi_col_starts{};
|
||||
std::array<uint16_t, 2> mi_row_starts{};
|
||||
std::array<uint16_t, 1> tile_widths_sb{};
|
||||
std::array<uint16_t, 1> tile_heights_sb{};
|
||||
|
||||
std::vector<StdVideoEncodeAV1ReferenceInfo> dpb_std_info;
|
||||
std::vector<vk::VideoEncodeAV1DpbSlotInfoKHR> dpb_std_slots;
|
||||
|
||||
vk::VideoEncodeAV1PictureInfoKHR picture_info{};
|
||||
|
||||
std::optional<vk::VideoEncodeAV1GopRemainingFrameInfoKHR> gop_info;
|
||||
vk::VideoEncodeQualityLevelInfoKHR quality_level_info{};
|
||||
vk::VideoEncodeAV1RateControlInfoKHR rate_control_av1{};
|
||||
vk::VideoEncodeAV1RateControlLayerInfoKHR rate_control_layer_av1{};
|
||||
|
||||
vk::VideoEncodeAV1StdFlagsKHR std_flags{};
|
||||
uint32_t single_reference_name_mask = 0;
|
||||
uint32_t max_single_reference_count = 0;
|
||||
uint32_t max_q_index = 0;
|
||||
uint32_t min_q_index = 0;
|
||||
uint32_t superblock_size = 64;
|
||||
uint8_t order_hint_bits = 7;
|
||||
// Reference name (LAST_FRAME + index) used for the single reference of inter frames
|
||||
int32_t ref_name_index = 0;
|
||||
bool rate_control_enabled = false;
|
||||
StdVideoAV1Level level = STD_VIDEO_AV1_LEVEL_2_0;
|
||||
|
||||
video_encoder_vulkan_av1(wivrn::vk_bundle & vk,
|
||||
const vk::VideoCapabilitiesKHR & video_caps,
|
||||
const vk::VideoEncodeCapabilitiesKHR & encode_caps,
|
||||
const vk::VideoEncodeAV1CapabilitiesKHR & encode_av1_caps,
|
||||
uint8_t stream_idx,
|
||||
const encoder_settings & settings);
|
||||
|
||||
void configure_from_caps(const vk::VideoEncodeAV1CapabilitiesKHR & encode_av1_caps);
|
||||
|
||||
protected:
|
||||
std::vector<void *> setup_slot_info(size_t dpb_size) override;
|
||||
|
||||
void * encode_info_next(uint32_t frame_num, size_t slot, std::optional<int32_t> ref_slot) override;
|
||||
vk::ExtensionProperties std_header_version() override;
|
||||
const void * begin_coding_next(const void * next) override;
|
||||
|
||||
void send_idr_data() override;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<video_encoder_vulkan_av1> create(wivrn::vk_bundle & vk,
|
||||
const encoder_settings & settings,
|
||||
uint8_t stream_idx);
|
||||
};
|
||||
} // namespace wivrn
|
||||
@@ -100,8 +100,6 @@ int create_listen_socket()
|
||||
sockaddr_un addr{};
|
||||
|
||||
auto sock_file = socket_path();
|
||||
if (sock_file.native().size() >= std::size(addr.sun_path))
|
||||
throw std::runtime_error("Socket file name too long");
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, sock_file.c_str());
|
||||
|
||||
@@ -269,9 +269,6 @@ wivrn::vk_bundle::vk_bundle() :
|
||||
#ifdef VK_KHR_video_encode_h265
|
||||
VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME,
|
||||
#endif
|
||||
#ifdef VK_KHR_video_encode_av1
|
||||
VK_KHR_VIDEO_ENCODE_AV1_EXTENSION_NAME,
|
||||
#endif
|
||||
#ifdef VK_KHR_video_encode_intra_refresh
|
||||
VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME,
|
||||
#endif
|
||||
@@ -337,10 +334,6 @@ wivrn::vk_bundle::vk_bundle() :
|
||||
if (has_device_ext(VK_KHR_VIDEO_ENCODE_INTRA_REFRESH_EXTENSION_NAME))
|
||||
std::get<vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>(feat).videoEncodeIntraRefresh = std::get<vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>(physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR>()).videoEncodeIntraRefresh;
|
||||
#endif
|
||||
#ifdef VK_KHR_video_encode_av1
|
||||
if (has_device_ext(VK_KHR_VIDEO_ENCODE_AV1_EXTENSION_NAME))
|
||||
std::get<vk::PhysicalDeviceVideoEncodeAV1FeaturesKHR>(feat).videoEncodeAV1 = std::get<vk::PhysicalDeviceVideoEncodeAV1FeaturesKHR>(physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceVideoEncodeAV1FeaturesKHR>()).videoEncodeAV1;
|
||||
#endif
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
if (has_device_ext(VK_KHR_UNIFIED_IMAGE_LAYOUTS_EXTENSION_NAME))
|
||||
{
|
||||
|
||||
@@ -131,9 +131,6 @@ struct vk_bundle
|
||||
#ifdef VK_KHR_video_encode_intra_refresh
|
||||
vk::PhysicalDeviceVideoEncodeIntraRefreshFeaturesKHR,
|
||||
#endif
|
||||
#ifdef VK_KHR_video_encode_av1
|
||||
vk::PhysicalDeviceVideoEncodeAV1FeaturesKHR,
|
||||
#endif
|
||||
#ifdef VK_KHR_unified_image_layouts
|
||||
vk::PhysicalDeviceUnifiedImageLayoutsFeaturesKHR,
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user