Compare commits

..
Author SHA1 Message Date
Vindicus999 079d760740 Merge remote-tracking branch 'upstream/master' 2026-01-07 01:59:39 +00:00
Vindicus999 35eb409403 Merge remote-tracking branch 'upstream/master' 2026-01-06 02:00:07 +00:00
Vindicus999 b725f95a55 Merge remote-tracking branch 'upstream/master' 2026-01-04 02:10:02 +00:00
Vindicus999 7e33152f43 Merge remote-tracking branch 'upstream/master' 2026-01-02 02:00:17 +00:00
Vindicus999 c381a0a6d6 Merge remote-tracking branch 'upstream/master' 2026-01-01 02:08:47 +00:00
Vindicus999 633c696a80 Merge remote-tracking branch 'upstream/master' 2025-12-31 01:58:42 +00:00
Vindicus999 ea56845aea Merge remote-tracking branch 'upstream/master' 2025-12-30 01:58:04 +00:00
Vindicus999 331b2e875c Merge remote-tracking branch 'upstream/master' 2025-12-29 02:06:30 +00:00
Vindicus999 36b4da49e8 Merge remote-tracking branch 'upstream/master' 2025-12-27 01:55:04 +00:00
Vindicus999 04507e36f6 Merge remote-tracking branch 'upstream/master' 2025-12-23 01:57:36 +00:00
Vindicus999 3a442d3a87 Merge remote-tracking branch 'upstream/master' 2025-12-22 02:02:10 +00:00
Vindicus999 d9884014e6 Merge remote-tracking branch 'upstream/master' 2025-12-21 02:02:56 +00:00
Vindicus999 5370d24789 Merge remote-tracking branch 'upstream/master' 2025-12-20 01:50:05 +00:00
Vindicus999 83f00ebcf0 Merge remote-tracking branch 'upstream/master' 2025-12-18 01:53:10 +00:00
Vindicus999 d407368f64 Merge remote-tracking branch 'upstream/master' 2025-12-17 01:52:42 +00:00
Vindicus999 4afb3b5786 Merge remote-tracking branch 'upstream/master' 2025-12-16 01:57:09 +00:00
Vindicus999 18457b8e9b Merge remote-tracking branch 'upstream/master' 2025-12-15 02:00:30 +00:00
Vindicus999 3d3b712ba0 Merge remote-tracking branch 'upstream/master' 2025-12-14 02:03:17 +00:00
Vindicus999 67e2627116 Merge remote-tracking branch 'upstream/master' 2025-12-13 01:50:11 +00:00
Vindicus999 06bd4e430a Merge remote-tracking branch 'upstream/master' 2025-12-12 01:56:25 +00:00
Vindicus999 375cced814 Merge remote-tracking branch 'upstream/master' 2025-12-10 01:55:41 +00:00
Vindicus999 46d06413f7 Merge remote-tracking branch 'upstream/master' 2025-12-09 01:53:51 +00:00
Vindicus999 c2c4978275 Merge remote-tracking branch 'upstream/master' 2025-12-08 01:54:49 +00:00
Vindicus999 694def436c Merge remote-tracking branch 'upstream/master' 2025-12-07 02:02:34 +00:00
Vindicus999 e01f5326c4 Merge remote-tracking branch 'upstream/master' 2025-12-06 01:47:37 +00:00
Vindicus999 7a6c53acf0 Merge remote-tracking branch 'upstream/master' 2025-12-05 01:53:53 +00:00
Vindicus999 dd7be5c830 Merge remote-tracking branch 'upstream/master' 2025-12-04 01:53:49 +00:00
Vindicus999 c4d5a235d8 Merge remote-tracking branch 'upstream/master' 2025-12-03 01:52:34 +00:00
Vindicus999 fbfda1fc40 Merge remote-tracking branch 'upstream/master' 2025-12-01 02:09:32 +00:00
Vindicus999 c96d600db2 Merge remote-tracking branch 'upstream/master' 2025-11-30 02:02:06 +00:00
Vindicus999 7dc1daaf73 Merge remote-tracking branch 'upstream/master' 2025-11-26 01:50:49 +00:00
Vindicus999 bd4f21ab67 Merge remote-tracking branch 'upstream/master' 2025-11-24 01:57:13 +00:00
Vindicus999 2e8a83eb5a Merge remote-tracking branch 'upstream/master' 2025-11-23 02:03:00 +00:00
Vindicus999 8d13d910e8 Merge remote-tracking branch 'upstream/master' 2025-11-21 01:48:58 +00:00
Vindicus999 0626bacc10 Merge remote-tracking branch 'upstream/master' 2025-11-20 01:48:03 +00:00
Vindicus999 1755c4de0b Merge remote-tracking branch 'upstream/master' 2025-11-19 01:49:17 +00:00
Vindicus999 7c84b55b6a Merge remote-tracking branch 'upstream/master' 2025-11-18 01:49:53 +00:00
Vindicus999 f5c1f0af1b Merge remote-tracking branch 'upstream/master' 2025-11-17 01:51:16 +00:00
Vindicus999 bc0c7c745c Merge remote-tracking branch 'upstream/master' 2025-11-16 01:55:38 +00:00
Vindicus999 5c4a094357 Merge remote-tracking branch 'upstream/master' 2025-11-15 01:46:08 +00:00
Vindicus999 3133b55edf Merge remote-tracking branch 'upstream/master' 2025-11-14 01:50:30 +00:00
Vindicus999 199d2a15f8 Merge remote-tracking branch 'upstream/master' 2025-11-13 01:51:08 +00:00
Vindicus999 122011e930 Merge remote-tracking branch 'upstream/master' 2025-11-12 01:49:50 +00:00
Vindicus999 f2b5bd506a Merge remote-tracking branch 'upstream/master' 2025-11-11 01:50:44 +00:00
Vindicus999 b8ca0b524f Merge remote-tracking branch 'upstream/master' 2025-11-10 01:54:04 +00:00
Vindicus999 eb156e82a0 Merge remote-tracking branch 'upstream/master' 2025-11-09 01:52:46 +00:00
Vindicus999 9ebac86b75 Merge remote-tracking branch 'upstream/master' 2025-11-08 01:42:51 +00:00
Vindicus999 ffe02e6b46 Merge remote-tracking branch 'upstream/master' 2025-11-07 01:48:41 +00:00
Vindicus999 4b7ebda75d Merge remote-tracking branch 'upstream/master' 2025-11-06 01:49:58 +00:00
Vindicus999 b3fe3b23a3 Merge remote-tracking branch 'upstream/master' 2025-11-05 01:49:29 +00:00
Vindicus999 77b44fb217 Merge remote-tracking branch 'upstream/master' 2025-11-04 01:48:35 +00:00
Vindicus999 c7e2a61cda Merge remote-tracking branch 'upstream/master' 2025-11-03 01:53:00 +00:00
Vindicus999 a0bddec054 Merge remote-tracking branch 'upstream/master' 2025-11-02 01:53:40 +00:00
Vindicus999 2375775a9c Merge remote-tracking branch 'upstream/master' 2025-11-01 01:51:23 +00:00
Vindicus999 c4e6cd623e Merge remote-tracking branch 'upstream/master' 2025-10-31 01:47:49 +00:00
Vindicus999 f77e6e669c Merge remote-tracking branch 'upstream/master' 2025-10-30 01:51:27 +00:00
Vindicus999 c9be142917 Merge remote-tracking branch 'upstream/master' 2025-10-26 20:57:19 +00:00
Vindicus999 f55e52cc69 Update Sync.yml 2025-10-26 15:33:00 -04:00
Vindicus999 7253d4cc9f Update Sync.yml 2025-10-26 15:30:37 -04:00
Vindicus999 54929abae9 Update Sync.yml 2025-10-26 15:28:55 -04:00
Vindicus999 b641c66d25 Update Sync.yml 2025-10-26 15:21:05 -04:00
Vindicus999 0736fc3fc5 Update Sync.yml 2025-10-26 14:57:28 -04:00
Vindicus999 aa4ccfd0b0 Update Sync.yml
Update Sync.yml
2025-10-26 14:52:04 -04:00
Vindicus999 73e86ed096 Configure build actions 2025-10-26 13:56:01 -04:00
217 changed files with 29369 additions and 32515 deletions
+6
View File
@@ -0,0 +1,6 @@
version: "1"
rules:
- base: master
upstream: WiVRn:master
mergeMethod: hardreset
+10 -79
View File
@@ -8,75 +8,6 @@ env:
BUILD_TYPE: RelWithDebInfo
jobs:
build-steam-frame:
name: Steam Frame
runs-on: ubuntu-24.04-arm
if: ${{ vars.APK_ONLY != '' }}
container:
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
volumes:
- ${{github.workspace}}/install:/tmp/install
steps:
- uses: actions/checkout@v6
with:
repository: 'gitea/WiVRn'
ref: ${{ github.sha }}
fetch-depth: 0
fetch-tags: true
- name: Apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
with:
packages: librsvg2-bin npm
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.23
with:
key: steam-frame
job-summary: ""
- uses: actions/cache@v5
with:
key: cmake-frame
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.tgz
${{github.workspace}}/cmake-fetch/*-src/.git
- name: Install dependencies
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
npm install --global @gltf-transform/cli@4.1.1
- name: Configure CMake
run: >
cmake -B "$GITHUB_WORKSPACE/build"
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DWIVRN_CSS=${{env.CSS}}
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_INSTALL_PREFIX=/usr
--preset frame
- name: Build
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE/build"
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
- name: Archive
uses: actions/upload-artifact@v7
with:
name: wivrn-frame-client.zip
path: install/usr
if-no-files-found: error
retention-days: 30
build-android-only:
name: Android
runs-on: ubuntu-24.04
@@ -87,10 +18,10 @@ jobs:
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer']
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
# Checkout from upstream instead of WiVRn-APK to ensure the GIT_DESC variable is set correctly
repository: 'gitea/WiVRn'
repository: 'Vindicus999/WiVRn'
ref: ${{ github.sha }}
fetch-depth: 0
@@ -158,7 +89,7 @@ jobs:
release:
name: Create APK release
runs-on: ubuntu-24.04
needs: [build-android-only, build-steam-frame]
needs: build-android-only
if: ${{ vars.APK_ONLY != '' }}
steps:
@@ -169,12 +100,13 @@ jobs:
pattern: 'apk-*'
merge-multiple: true
- name: Download Steam Frame artifact
uses: actions/download-artifact@v4
with:
path: install/usr
pattern: 'wivrn-frame-client.zip'
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: Download APK debug artifacts
uses: actions/download-artifact@v4
@@ -198,6 +130,5 @@ jobs:
prerelease: false
fail_on_unmatched_files: true
files: |
install/usr/wivrn-frame-client.zip
apk/*.apk
debug-symbols.zip
+93 -117
View File
@@ -6,52 +6,47 @@ on:
env:
BUILD_TYPE: Release
SERVER_DEPS: libx264-dev libavcodec-dev libavutil-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev nlohmann-json3-dev librsvg2-dev libdrm-dev libglib2.0-dev-bin libpipewire-0.3-dev libcli11-dev libnotify-dev libarchive-dev libudev-dev
CSS: images/wivrn-${{(github.ref_type == 'tag' && 'release') || 'nightly'}}.css
SERVER_DEPS: libx264-dev libavcodec-dev libavutil-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev nlohmann-json3-dev librsvg2-dev libdrm-dev libglib2.0-dev-bin libpipewire-0.3-dev libpulse-dev libcli11-dev libnotify-dev libarchive-dev libudev-dev
jobs:
build-linux:
name: Linux
runs-on: ubuntu-26.04
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
strategy:
fail-fast: false
matrix:
config:
- preset: 'client-no-system-boost'
packages: libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev libpipewire-0.3-dev
- preset: 'dashboard'
packages: extra-cmake-modules libarchive-dev libboost-all-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libkirigami-dev librsvg2-dev nlohmann-json3-dev qcoro-qt6-dev qml6-module-org-kde-kirigamiaddons-formcard
- preset: 'client'
packages: libboost-all-dev libharfbuzz-dev libfreetype-dev libavcodec-dev libavutil-dev libswscale-dev librsvg2-bin gettext libcurl4-openssl-dev libfontconfig-dev
# dashboard requires a more recent Ubuntu, have it out of this job
- preset: 'dissector-no-system-boost'
packages: libboost-all-dev wireshark-dev
- preset: 'server'
packages: libboost-all-dev libsystemd-dev
# tracing is opt-in and rarely built; build it here so the instrumentation and the
# Perfetto SDK glue don't bitrot (WIVRN_TRACE_MONADO needs percetto, not packaged in CI)
- preset: 'server-tracing'
packages: libboost-all-dev libsystemd-dev
- preset: 'server-no-systemd'
packages: libboost-all-dev
- preset: 'server-no-system-boost'
packages: libsystemd-dev
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
uses: awalsh128/cache-apt-pkgs-action@v1.6.0
with:
packages: ccache libvulkan-dev glslang-tools spirv-tools libwayland-dev libxrandr-dev ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
packages: ccache ${{matrix.config.packages}} ${{ startsWith(matrix.config.preset, 'server') && env.SERVER_DEPS || ''}}
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.23
uses: hendrikmuhs/ccache-action@v1.2
with:
key: linux-${{matrix.config.preset}}
job-summary: ""
restore-keys: linux-
append-timestamp: false
- uses: actions/cache@v5
- uses: actions/cache@v4
with:
key: cmake-linux-${{matrix.config.preset}}
path: |
@@ -63,23 +58,18 @@ jobs:
restore-keys: cmake-linux-
- name: Install dependencies
if: ${{ startswith(matrix.config.preset, 'client') }}
if: ${{ matrix.config.preset == 'client' }}
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli@4.1.1
- name: Fetch Perfetto SDK
if: ${{ matrix.config.preset == 'server-tracing' }}
# The amalgamated SDK is two files; install them where server/CMakeLists.txt looks.
env:
PERFETTO_TAG: v51.0
run: |
sudo mkdir -p /usr/share/perfetto/sdk
for f in perfetto.h perfetto.cc; do
sudo curl -fsSL -o /usr/share/perfetto/sdk/$f \
https://raw.githubusercontent.com/google/perfetto/${PERFETTO_TAG}/sdk/$f
done
- name: Prepare Vulkan SDK
uses: humbletim/setup-vulkan-sdk@v1.2.1
with:
vulkan-query-version: 1.3.296.0
vulkan-components: Vulkan-Headers, Vulkan-Loader, Glslang, SPIRV-Reflect, SPIRV-Tools
vulkan-use-cache: true
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
@@ -96,7 +86,7 @@ jobs:
- name: Package build dependencies
if: ${{ matrix.config.preset == 'server' }}
# For easier packaging, build dependencies are made available as a separate archive
run: cd ${{github.workspace}}/cmake-fetch ; tar --create --xz --exclude .git --file ${{github.workspace}}/server-build-deps.tar.xz *-src
run: (cd ${{github.workspace}}/cmake-fetch ; tar --create --xz *-src) > ${{github.workspace}}/server-build-deps.tar.xz
- name: Build
# Build your program with the given configuration
@@ -104,7 +94,7 @@ jobs:
- name: Publish build dependencies
if: ${{ matrix.config.preset == 'server' }}
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: server-build-deps
path: server-build-deps.tar.xz
@@ -118,84 +108,55 @@ jobs:
draft: true
files: server-build-deps.tar.xz
build-steam-frame:
name: Steam Frame
runs-on: ubuntu-24.04-arm
build-dashboard:
#FIXME: merge with the matrixed build once Ubuntu gets updated
name: Linux Dashboard
runs-on: ubuntu-24.04
container: ubuntu:plucky
if: ${{ vars.APK_ONLY == '' }}
container:
image: registry.gitlab.steamos.cloud/steamrt/steamrt4/sdk/arm64:4.0.20260805.254769
volumes:
- ${{github.workspace}}/install:/tmp/install
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/checkout@v4
- name: Apt dependencies
uses: awalsh128/cache-apt-pkgs-action@v1.6.1
with:
packages: librsvg2-bin npm
- name: Prepare
run: |
apt-get update
apt-get install --yes curl wget sudo jq cmake gcc g++ git pkgconf libboost-all-dev libkirigami-dev gettext libarchive-dev nlohmann-json3-dev qcoro-qt6-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev libvulkan-dev libssl-dev librsvg2-dev extra-cmake-modules qml6-module-org-kde-kirigamiaddons-formcard
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2.23
- uses: actions/cache@v4
with:
key: steam-frame
job-summary: ""
- uses: actions/cache@v5
with:
key: cmake-frame
key: cmake-linux-dashboard
path: |
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.tar.*
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.tgz
${{github.workspace}}/cmake-fetch/*-src/.git
- name: Install dependencies
run: |
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.4.2/KTX-Software-4.4.2-Linux-arm64.deb
sudo dpkg --install KTX-Software-4.4.2-Linux-arm64.deb
npm install --global @gltf-transform/cli@4.1.1
restore-keys: cmake-linux-
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B "$GITHUB_WORKSPACE/build"
cmake -B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DWIVRN_CSS=${{env.CSS}}
-DFETCHCONTENT_BASE_DIR="$GITHUB_WORKSPACE/cmake-fetch"
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_INSTALL_PREFIX=/usr
--preset frame
-DFETCHCONTENT_BASE_DIR=${{github.workspace}}/cmake-fetch
--preset dashboard
-DWIVRN_USE_SYSTEM_OPENXR=OFF
- name: Build
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
cd "$GITHUB_WORKSPACE/build"
DESTDIR="$GITHUB_WORKSPACE/install" ninja install
- name: Archive
uses: actions/upload-artifact@v7
with:
name: wivrn-frame-client.zip
path: install/usr
if-no-files-found: error
retention-days: 30
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
build-server-flatpak:
name: Linux server (flatpak)
runs-on: ubuntu-24.04
if: ${{ vars.APK_ONLY == '' }}
container:
# Tag matches runtime-version in the manifest.
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.9
options: --privileged
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -206,18 +167,22 @@ jobs:
tools/gen_flatpak_manifest.py --gitlocal --out flatpak
cat flatpak/io.github.wivrn.wivrn.yml
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.7
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6.4
with:
manifest-path: flatpak/io.github.wivrn.wivrn.yml
bundle: wivrn-server.flatpak
# The manifest is regenerated on every commit with the git hash embedded,
# so its default (manifest-hash) cache key never hits. Key on the files
# that actually define the dependency set instead, so the toolchain
# downloads and build cache persist across commits.
cache-key: flatpak-builder-${{ hashFiles('flatpak/io.github.wivrn.wivrn.yml.in', 'flatpak/ct-ng-x86_64.config', 'flatpak/ct-ng-aarch64.config', 'monado-rev', 'CMakeLists.txt') }}
upload-artifact: false
# Upload manually instead of using flatpak/flatpak-github-actions/flatpak-builder because
# it uses upload-artifact@v3
- name: Publish artifact
uses: actions/upload-artifact@v4
with:
name: wivrn-flatpak-x86_64
path: wivrn-server.flatpak
- name: Debug bundle
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
if: failure()
with:
name: flatpak-debug
@@ -231,7 +196,7 @@ jobs:
if: ${{ vars.APK_ONLY == '' }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -249,11 +214,18 @@ jobs:
buildtype: ['Release', 'Debug', 'DebugWithValidationLayer', 'Oculus']
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v5
- name: Prepare Vulkan SDK
uses: humbletim/setup-vulkan-sdk@v1.2.1
with:
vulkan-query-version: 1.3.296.0
vulkan-components: Glslang, SPIRV-Tools
vulkan-use-cache: true
- uses: actions/cache@v4
with:
key: cmake-android-${{matrix.buildtype}}
path: |
@@ -264,18 +236,9 @@ jobs:
${{github.workspace}}/cmake-fetch/*.tgz
restore-keys: cmake-android-
# Gradle distribution and the Android plugin's dependencies.
- uses: actions/cache@v5
with:
key: gradle-android-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'build.gradle') }}
path: |
~/.gradle/caches
~/.gradle/wrapper
restore-keys: gradle-android-
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install glslang-tools spirv-tools librsvg2-bin gettext
sudo apt-get update && sudo apt-get install glslang-tools librsvg2-bin gettext
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli
@@ -316,6 +279,7 @@ jobs:
VERSION_CODE=$(( $VERSION_CODE + 1 ))
fi
CSS=images/wivrn-release.css
APPNAME=WiVRn
else
VERSION_CODE=1
@@ -323,29 +287,31 @@ jobs:
if [ ${{ github.ref_type }} = 'tag' ]
then
SUFFIX=".github"
CSS=images/wivrn-release.css
APPNAME="WiVRn"
else
SUFFIX=".github.testing"
CSS=images/wivrn-nightly.css
APPNAME="WiVRn Testing"
fi
fi
echo Setting version $VERSION and version code $VERSION_CODE in manifest
echo Using stylesheet ${{env.CSS}} and name $APPNAME
echo Using stylesheet $CSS and name $APPNAME
chmod +x gradlew
./gradlew \
-Pwivrn_version=$VERSION \
-Pwivrn_versionCode=$VERSION_CODE \
-Psuffix=$SUFFIX \
-Pwivrn_css=${{env.CSS}} \
-Pwivrn_css=$CSS \
-Pwivrn_app_name="$APPNAME" \
-Pwivrn_compress_glb=ON \
-Pfetchcontent_base_dir=${{github.workspace}}/cmake-fetch \
assemble${{ matrix.buildtype }}
- name: Upload build dir
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
if: failure()
with:
name: android-cxx-debug-${{ matrix.buildtype }}
@@ -362,7 +328,7 @@ jobs:
find debug -name libopenxr_loader.so -delete
- name: Archive APK
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
if: ${{ matrix.buildtype != 'Oculus' }}
with:
name: apk-${{ (steps.secret-check.outputs.available == 'false' && matrix.buildtype == 'Release') && 'Release-unsigned' || matrix.buildtype }}
@@ -370,10 +336,12 @@ jobs:
retention-days: 30
- name: Archive debug symbols
uses: actions/upload-artifact@v7
if: ${{ matrix.buildtype != 'Release' && matrix.buildtype != 'Oculus' }}
uses: actions/upload-artifact@v4
with:
name: symbols-${{ matrix.buildtype }}
path: debug/**/*.so
retention-days: 30
- name: Push to Oculus store
if: ${{ matrix.buildtype == 'Oculus' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') && steps.secret-check.outputs.oculus-token == 'true' }}
@@ -408,13 +376,13 @@ jobs:
- name: Install dependencies
run: |
apt update
apt install --yes libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev pkexec libboost-all-dev librsvg2-bin dpkg-dev pkg-config debhelper-compat build-essential lintian cmake libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git wget libssl-dev qcoro-qt6-dev librsvg2-dev libarchive-dev npm qml6-module-org-kde-kirigamiaddons-formcard
apt install --yes libcjson-dev libx264-dev libavcodec-dev libavutil-dev libswscale-dev libavfilter-dev libbsd-dev libavahi-client-dev libavahi-glib-dev libeigen3-dev glslang-tools libudev-dev libwayland-dev libx11-xcb-dev libxrandr-dev libxcb-randr0-dev libgl-dev libglx-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libsystemd-dev libva-dev nlohmann-json3-dev libpulse-dev xz-utils libpipewire-0.3-dev libcli11-dev qt6-base-dev qt6-tools-dev pkexec libboost-all-dev librsvg2-bin dpkg-dev pkg-config debhelper-compat build-essential lintian cmake libnotify-dev qt6-declarative-dev extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6qqc2desktopstyle-dev libkf6iconthemes-dev jq sudo cmake gcc g++ git wget libssl-dev qcoro-qt6-dev librsvg2-dev libarchive-dev npm
wget https://github.com/KhronosGroup/KTX-Software/releases/download/v4.3.2/KTX-Software-4.3.2-Linux-x86_64.deb
sudo dpkg --install KTX-Software-4.3.2-Linux-x86_64.deb
npm install --global @gltf-transform/cli
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: wivrn
@@ -456,7 +424,7 @@ jobs:
run: dpkg-buildpackage --build=binary --no-sign
- name: Publish package
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v4
with:
name: wivrn-${{ matrix.distro }}
path: |
@@ -474,7 +442,7 @@ jobs:
if: success() && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: wivrn
@@ -489,7 +457,7 @@ jobs:
echo "available=false" >> $GITHUB_OUTPUT;
fi
- uses: actions/checkout@v6
- uses: actions/checkout@v4
if: ${{ steps.flathub-token-check.outputs.available == 'true' }}
with:
fetch-depth: 0
@@ -498,19 +466,20 @@ jobs:
token: ${{ secrets.FLATHUB_TOKEN }}
- name: Download artifacts (APK)
uses: actions/download-artifact@v8
uses: actions/download-artifact@v4
with:
name: apk-Release
path: apk
pattern: '*-Release'
merge-multiple: true
- name: Download artifacts (flatpak)
uses: actions/download-artifact@v8
uses: actions/download-artifact@v4
with:
name: wivrn-server-x86_64.flatpak
name: wivrn-flatpak-x86_64
path: flatpak
- name: Release
uses: softprops/action-gh-release@v3
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.ref }}
generate_release_notes: true
@@ -545,6 +514,13 @@ jobs:
git show
- name: Update release branch
run: |
cd wivrn
if git fetch origin release; then
git push origin HEAD:release
fi
sync_fork_downstream:
name: Sync fork downstream
runs-on: ubuntu-24.04
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.16.0
uses: jidicula/clang-format-action@2c659fea724e981e94741c0e7db663982cd7d3f4
with:
clang-format-version: '21'
check-path: ${{ matrix.path }}
+22 -31
View File
@@ -6,46 +6,37 @@ env:
UPSTREAM_BRANCH: "master"
on:
workflow_dispatch:
schedule:
- cron: '18 2 * * *'
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: GitHub Sync to Upstream Repository
uses: dabreadman/sync-upstream-repo@v1.3.0
with:
upstream_repo: vindicus999/wivrn
fetch-depth: 0
upstream_repo: ${{ env.UPSTREAM_URL }}
upstream_branch: ${{ env.UPSTREAM_BRANCH }}
token: ${{ env.WORKFLOW_TOKEN }}
- name: Add upstream
run: |
git remote add upstream ${{ env.UPSTREAM_URL }}
- name: Checkout stuff
uses: actions/checkout@master
- name: Fetch all
run: |
git fetch origin
git fetch upstream
- name: Merge master -> apk-build
uses: devmasx/merge-branch@master
with:
type: now
from_branch: master
target_branch: apk-build
github_token: ${{ env.WORKFLOW_TOKEN }}
- 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: Merge sneed -> apk-build
uses: devmasx/merge-branch@master
with:
type: now
from_branch: sneed
target_branch: apk-build
github_token: ${{ env.WORKFLOW_TOKEN }}
- 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
+10 -24
View File
@@ -39,12 +39,7 @@ option(WIVRN_BUILD_WIVRNCTL "Build wivrnctl" ON)
option(WIVRN_BUILD_DISSECTOR "Build Wireshark dissector" OFF)
option(WIVRN_BUILD_TEST "Build test binaries" OFF)
option(WIVRN_WERROR "Treat warnings as errors" OFF)
option(WIVRN_OPTIMIZE_SHADERS "Run spirv-opt on compiled shaders" ON)
option(WIVRN_DEBUG_SHADERS "Compile shaders with debug information" OFF)
if(WIVRN_OPTIMIZE_SHADERS AND WIVRN_DEBUG_SHADERS)
message(FATAL_ERROR "WIVRN_OPTIMIZE_SHADERS and WIVRN_DEBUG_SHADERS are incompatible")
endif()
option(WIVRN_OPTIMIZE_SHADERS "Run siprv-opt on compiled shaders" ON)
option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" ON)
option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" ON)
@@ -102,9 +97,9 @@ include(VulkanVersion)
if (WIVRN_USE_SYSTEM_BOOST AND NEED_COMMON)
if (WIVRN_BUILD_DISSECTOR)
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url iostreams)
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url)
else()
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url iostreams)
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url)
endif()
endif()
@@ -177,6 +172,10 @@ if (WIVRN_BUILD_DASHBOARD)
find_package(nlohmann_json REQUIRED)
find_package(QCoro6 REQUIRED COMPONENTS Core Network Qml)
qcoro_enable_coroutines()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
endif()
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
@@ -229,6 +228,8 @@ if (WIVRN_BUILD_WIVRNCTL)
endif()
# Common dependencies
FetchContent_Declare(boostpfr EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/pfr/archive/refs/tags/2.2.0.tar.gz
URL_HASH SHA256=6f490ec1383de5855dcf801c23f0a967f888eb6e1440b6ca0bf36c12d4ae7ac7)
FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.com/boostorg/boost/releases/download/boost-1.89.0/boost-1.89.0-cmake.tar.xz
URL_HASH SHA256=67acec02d0d118b5de9eb441f5fb707b3a1cdd884be00ca24b9a73c995511f74)
@@ -238,7 +239,7 @@ FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.co
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.9.0.tar.gz
URL_HASH SHA256=0bb564e127b14c22f062db50f89381dd2e0a20dbaf4987ca138a4ae8728712f9)
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/releases/download/1.0.2/glm-1.0.2.zip
URL_HASH SHA256=77fff075c5ab0caf076fade41558c5458d9a242aba2b2076bb72008bdb51a35e)
URL_HASH SHA256=203b64abc82e4d8697cc5aeedc93117fc1ee52d36e7cdcfc0854fa2c607edaae)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.54.tar.gz
URL_HASH SHA256=2055688081066e37238be996534f349420ac52ed34f8514836704232121ee7f3)
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz
@@ -278,20 +279,6 @@ FetchContent_Declare(monado
EXCLUDE_FROM_ALL
)
add_custom_target(wivrn-version ALL
COMMAND ${CMAKE_COMMAND}
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/common/version.cpp.in
-D OUTPUT_FILE=${CMAKE_BINARY_DIR}/version.cpp
-D INPUT_FILE_1=${CMAKE_CURRENT_SOURCE_DIR}/server/u_git_tag.cpp.in
-D OUTPUT_FILE_1=${CMAKE_BINARY_DIR}/u_git_tag.cpp
-D GIT_DESC="${GIT_DESC}"
-D GIT_COMMIT="${GIT_COMMIT}"
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
BYPRODUCTS ${CMAKE_BINARY_DIR}/version.cpp ${CMAKE_BINARY_DIR}/u_git_tag.cpp
SOURCES common/version.cpp.in server/u_git_tag.cpp.in
)
add_subdirectory(external)
if (NEED_COMMON)
add_subdirectory(common)
@@ -331,7 +318,6 @@ foreach(TARGET_NAME wivrn wivrn-server wivrn-dashboard wivrn-common wivrn-dissec
if(TARGET ${TARGET_NAME})
target_compile_options(${TARGET_NAME} PRIVATE
-fdiagnostics-color -Wall -Wextra -pedantic
-ffast-math
-Wundef
-Wno-missing-field-initializers
-Wno-unused-parameter
+39 -82
View File
@@ -1,68 +1,33 @@
<h1 align="center"> WiVRn </h1>
# WiVRn
<div align="center">
[![License: GPL v3](images/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ![CI](https://github.com/WiVRn/WiVRn/workflows/Build/badge.svg) ![Format](https://github.com/WiVRn/WiVRn/workflows/Format/badge.svg)
</div>
<p align="center"><img src="images/wivrn.svg" width="180"></p>
<h3 align="center">Fully FOSS PCVR streamer</h3>
# About
WiVRn wirelessly connects a standalone VR headset to a Linux computer. You can then play PCVR games on the headset while processing is done on the computer.
WiVRn is an application that wirelessly streams a virtual reality game to a standalone VR headset from a <b>Linux</b> computer.
WiVRn support a wide range of VR devices:
| Headset | Supported | Notes |
|:--------:|:--------:|:--------:|
| Quest 1 | ✓ | |
| Quest 2 | ✓ | |
| Quest 3 | ✓ | |
| Quest 3s | ✓ | |
| Quest Pro | ✓ | |
| Pico Neo 3 | ✓ | |
| Pico 4 | ✓ | |
| HTC Vive Focus 3 | ✓ | Laggy |
| HTC Vive XR Elite | ✓ | Laggy |
| Samsung Galaxy XR | ✓ | |
| Other Android VR | ? | Cannot know |
| Play for Dream | ✖ | https://github.com/WiVRn/WiVRn/issues/465 |
| Non-Android VR | ✖ | Not Android |
| Non-VR Android | ✖ | VR required |
<sup>A Linux client does exist, only for debugging. It has no audio or hardware decoding.</sup>
It supports a wide range of headsets such as Quest 1 / 2 / Pro / 3 / 3S, Pico Neo 3, Pico 4, HTC Vive Focus 3, HTC Vive XR elite and most other Android based headsets.
# Getting started
## PC Server/Dashboard
## Server and dashboard
We recommend using native packages if available for your distribution:
- [Arch User Repository](https://aur.archlinux.org/packages/wivrn-dashboard)
- [Fedora](https://packages.fedoraproject.org/pkgs/wivrn/wivrn/)
- [Gentoo Guru](https://gitweb.gentoo.org/repo/proj/guru.git/tree/media-libs/wivrn)
- [NixOS](https://search.nixos.org/packages?channel=25.11&show=wivrn)
For OpenVR and Steam compatibility, you also need a [compatibility library](#openvr-and-steam-games) such as xrizer or OpenComposite.
A flatpak is available on Flathub for all distributions:
We recommend using the flatpak package from Flathub:
[![Flathub](https://flathub.org/api/badge)](https://flathub.org/apps/io.github.wivrn.wivrn)
Note that due to flatpak sandboxing some features may not be available such as Lighthouse tracked devices.
Alternatively, packages are available:
- [AUR for Arch](https://aur.archlinux.org/packages/wivrn-dashboard)
- [Fedora](https://packages.fedoraproject.org/pkgs/wivrn/wivrn/)
- [Guru for Gentoo](https://gitweb.gentoo.org/repo/proj/guru.git/tree/media-libs/wivrn).
## Headset Client/App
Follow the wizard in the PC dashboard to install the client on your VR headset.
## Headset app
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).
Follow the wizard in the dashboard to install the client app on the headset: it will either lead you to the [Meta Store](https://www.meta.com/experiences/7959676140827574/) or download the correct APK.
> [!WARNING]
> 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).
⚠️ You will need to have a compatible version: if the headset fails to connect to your computer, see [troubleshooting](#troubleshooting).
@@ -76,19 +41,19 @@ Avahi must be running:
systemctl enable --now avahi-daemon
```
- If a firewall is installed, open port 5353/UDP for Avahi and ports 9757/UDP+TCP for WiVRn.
- For example, if using UFW run `ufw allow 5353/udp` and `ufw allow 9757`.
- If a firewall is installed, open port 5353/UDP for avahi and ports 9757/UDP+TCP for WiVRn itself.
- In the case of ufw, use `ufw allow 5353/udp` and `ufw allow 9757`.
### Running
- On your computer, run "WiVRn server" application, or `wivrn-dashboard` from the command line. It will show the setup wizard the first time you launch it.
- On your headset, run WiVRn from the App Library. If you are using a Meta Quest and you have installed it from an APK instead of the Meta Store, it should be in the "unknown sources" section.
- You should now see your computer in the list: click connect, the screen will show "Connection ready. Start a VR application on <i>\[your computer's name\]</i>".
- On your computer, run "WiVRn server" application, or `wivrn-dashboard` from the command line, it will show the connection wizard the first time you launch it.
- On your headset, run WiVRn from the App Library. If you are using a Quest and you have installed it from an APK instead of the Meta Store, it will be in the "unknown sources" section.
- You should now see your computer in the list: click connect, the screen will show "Connection ready. Start a VR application on **your computer's name**".
You can now stream an OpenXR application from your computer to your headset. For Steam games, you may also need to set the launch options to be able to use WiVRn. The server/dashboard will tell you how to do this if required.
You can now start an OpenXR application on your computer. For Steam games, you may also need to set the launch options to be able to use WiVRn. If nothing related to Steam is displayed in the dashboard or wivrn-server output, then your system does not require it.
- Right-click on the game you want to play in VR in Steam and click "Properties".
- In the "General" tab, enter the launch options that the WiVRn server/dashboard gave you inside the "Launch Options" setting.
- In the "General" tab, set the launch options to the value given in the dashboard.
You can set an application to be started automatically when your headset is connected, in the dashboard settings or [manually](docs/configuration.md#application).
You can set an application to be started automatically when you connect your headset in the dashboard settings or [manually](docs/configuration.md#application)
### Application list
When the headset is connected and no XR application is running, it will show an application launcher. Applications in that list are sourced from:
@@ -97,13 +62,14 @@ When the headset is connected and no XR application is running, it will show an
### OpenVR and Steam games
The flatpak includes [OpenComposite](https://gitlab.com/znixian/OpenOVR/) and [xrizer](https://github.com/Supreeeme/xrizer/), used to translate the OpenVR API to OpenXR. see [SteamVR](docs/steamvr.md) for details.
The flatpak also includes [OpenComposite](https://gitlab.com/znixian/OpenOVR/) and [xrizer](https://github.com/Supreeeme/xrizer/), used to translate the OpenVR API used by SteamVR to OpenXR used by WiVRn, see [SteamVR](docs/steamvr.md) for details.
If using Wine/Proton, it will probe for OpenVR at startup, This means even for OpenXR applications, OpenComposite or xrizer is required.
If using Wine/Proton, it will probe for OpenVR at startup, so even for OpenXR applications, OpenComposite or xrizer is required.
When a headset connects, wivrn-server sets the OpenVR runtime to xrizer unless manually configured differently.
When you start the server through flatpak, it will automatically configure the current OpenVR to use xrizer.
### Steam Flatpak
If you're using the Steam Flatpak, you'll need to grant read only access to the following paths:
```bash
@@ -116,12 +82,12 @@ flatpak override \
com.valvesoftware.Steam
```
When using a user installation of flatpak Steam, use `override --user` instead of `override`.
When using a user installation of flatpak Steam, user `override --user` instead of `override`.
### Audio
When the headset is connected, WiVRn will create a virtual output device simply named "WiVRn. You must manually set this audio output to enabled/default. Please note that in `pavucontrol` it will appear as a virtual device.
When the headset is connected, WiVRn will create a virtual output device named WiVRn. It is not selected as default and you should either assign the application to the device when it is running, or mark it as default. To do so you can use `pavucontrol` or your desktop environment's configuration panel. Please note that in `pavucontrol` it will appear as a virtual device.
To enable microphone, you first have to enable it on the settings tab on the VR headset (and give permission when prompted). It should appear as a virtual input device named "WiVRn(microphone)", and needs to be assigned as the input device (same way as output device).
For microphone, you first have to enable it on the settings tabs on the headset (and give permission when prompted). It will then appear as a virtual input device named WiVRn(microphone) and also needs to be assigned like for output device.
# Building
@@ -135,19 +101,19 @@ Configuration can be done from the dashboard.
See [configuration](docs/configuration.md) for editing the configuration manually.
# Troubleshooting
<details><summary>My computer is not seen by the headset</summary>
## My computer is not seen by the headset
If the server list is empty in the headset app:
- Make sure your computer is connected on the same network as your headset
- Check that avahi is running with `systemctl status avahi-daemon`, if it is not, enable it with `systemctl enable --now avahi-daemon`
- If you have a firewall, check that port 5353 (UDP) is open</details>
- If you have a firewall, check that port 5353 (UDP) is open
<details><summary>My headset does not connect to my computer</summary>
## My headset does not connect to my computer
- If you have a firewall, check that port 9757 (UDP and TCP) is open
- The server and client must be the same version.</details>
- The server and client must be compatible.
<details><summary>How do I use a wired connection?</summary>
## How do I use a wired connection?
- Make sure the WiVRn Server is installed and running on your computer
- Make sure you have the WiVRn app installed on your headset
@@ -161,15 +127,15 @@ If the server list is empty in the headset app:
- `org.meumeu.wivrn.github.nighly` for Github nightlies (wirvn-apk [repository](https://github.com/WiVRn/WiVRn-APK/releases))
- `org.meumeu.wivrn.github.testing` for Github CI builds
- `org.meumeu.wivrn.local` for developer builds
- You can now continue the pairing process as documented in the running section.</details>
- You can now continue the pairing process as documented in the running section.
<details><summary>How do I see server logs when using the dashboard?</summary>
## How do I see server logs when using the dashboard?
- Click Troubleshoot > Open server logs, or
- Navigate to `${XDG_STATE_HOME}/wivrn/wivrn-dashboard` (with fallback to `${HOME}/.local/state` for `${XDG_STATE_HOME}`, or
- For flatpak, navigate to `${HOME}/.var/app/io.github.wivrn.wivrn/.local/state/wivrn/wivrn-dashboard`.</details>
- For flatpak, navigate to `${HOME}/.var/app/io.github.wivrn.wivrn/.local/state/wivrn/wivrn-dashboard`.
<details><summary>I have high motion latency, black borders following my view, hear corrupted audio or see a corrupted, pixelated image</summary>
## I have high motion latency, black borders following my view, hear corrupted audio or see a corrupted, pixelated image
- When connecting through USB, make sure the headset isn't connected through WiFi (switch off WiFi)
- Reset the settings using the button at the bottom of the settings tab
@@ -178,16 +144,7 @@ If the server list is empty in the headset app:
- Decrease the resolution in the WiVRn app
- Connect through USB or use a better WiFi router.
Note: WiVRn isn't properly optimized for NVIDIA GPUs due to the lack of developers with NVIDIA hardware. Motion latency may be significantly worse at rendering resolutions higher than default.</details>
# Community Support
We are available on either **Discord** or **Matrix space**:
[![LVRA Discord](https://img.shields.io/discord/1065291958328758352?style=for-the-badge&logo=discord)](https://discord.gg/EHAYe3tTYa) [![LVRA Matrix](https://img.shields.io/matrix/linux-vr-adventures:matrix.org?logo=matrix&style=for-the-badge)](https://matrix.to/#/#linux-vr-adventures:matrix.org)
Please use the `wivrn` chat room for questions or issues specific to WiVRn.
Note: WiVRn isn't properly optimized for NVIDIA GPUs due to the lack of developers with NVIDIA hardware. Motion latency may be significantly worse at rendering resolutions higher than default.
# Contributing
Binary file not shown.
BIN
View File
Binary file not shown.
+2 -15
View File
@@ -127,6 +127,7 @@ android {
'-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DCMAKE_ANDROID_ASSETS_DIRECTORIES=' + layout.buildDirectory.dir("assets").get().asFile,
'-DCMAKE_ANDROID_LIB_DIRECTORIES=' + layout.buildDirectory.dir("libs").get().asFile,
'-DWIVRN_USE_SYSTEM_BOOST=OFF',
'-DWIVRN_USE_SYSTEM_FREETYPE=OFF',
'-DWIVRN_USE_ANDROID_BIN_LIBKTX=ON',
@@ -201,26 +202,12 @@ android {
initWith debug
externalNativeBuild {
cmake {
arguments '-DWIVRN_USE_ANDROID_VALIDATION_LAYER=ON'
arguments '-DUSE_ANDROID_VALIDATION_LAYER=ON'
}
}
}
}
buildTypes.all { variant ->
sourceSets {
"${variant.name}" {
jniLibs.srcDirs layout.buildDirectory.dir("libs${variant.name.capitalize()}")
}
}
externalNativeBuild{
cmake {
arguments '-DANDROID_LIB_DIRECTORIES=' + layout.buildDirectory.dir("libs${variant.name.capitalize()}").get().asFile
}
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
+3 -3
View File
@@ -194,7 +194,7 @@ khronos_validation.enables = VK_VALIDATION_FEATURE_ENABLE_THREAD_SAFETY_EXT
")
endif()
if(WIVRN_USE_ANDROID_VALIDATION_LAYER)
if(USE_ANDROID_VALIDATION_LAYER)
set(VVL_VERSION "1.4.321.0")
if(NOT EXISTS ${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayers-${VVL_VERSION}.zip)
@@ -213,10 +213,10 @@ if(WIVRN_USE_ANDROID_VALIDATION_LAYER)
file(COPY
${FETCHCONTENT_BASE_DIR}/Vulkan-ValidationLayer/android-binaries-${VVL_VERSION}/${CMAKE_ANDROID_ARCH_ABI}
DESTINATION ${ANDROID_LIB_DIRECTORIES})
DESTINATION ${CMAKE_ANDROID_LIB_DIRECTORIES})
else()
# silence "Manually-specified variables were not used by the project" warning
set(_unused ${ANDROID_LIB_DIRECTORIES})
set(_unused ${CMAKE_ANDROID_LIB_DIRECTORIES})
endif()
+5 -3
View File
@@ -722,13 +722,11 @@ void application::initialize_vulkan()
}
}
#ifndef NDEBUG
#ifdef __ANDROID__
if (validation_layer_found)
{
spdlog::info("Using Vulkan validation layer");
layers.push_back("VK_LAYER_KHRONOS_validation");
}
#endif
bool debug_report_found = false;
bool debug_utils_found = false;
#endif
@@ -1243,6 +1241,10 @@ void application::initialize()
XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME,
XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME,
XR_FB_FACE_TRACKING2_EXTENSION_NAME,
// Disable foveation, doesn't seem useful
// XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME,
// XR_FB_FOVEATION_EXTENSION_NAME,
// XR_FB_FOVEATION_VULKAN_EXTENSION_NAME,
XR_FB_PASSTHROUGH_EXTENSION_NAME,
XR_FB_SWAPCHAIN_UPDATE_STATE_EXTENSION_NAME,
@@ -1336,7 +1338,7 @@ 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);
config.emplace(xr_system_id, xr_session);
config.emplace(xr_system_id);
// HTC face tracker fails if created later
// we can destroy it right away, it actually stores static handles
+4 -20
View File
@@ -19,7 +19,6 @@
#include "configuration.h"
#include "application.h"
#include "utils/contains.h"
#include "utils/json_string.h"
#include "wivrn_packets.h"
@@ -30,9 +29,6 @@
#include "android/permissions.h"
#endif
// If no refresh rate is configured, don't select a too high one
static const float max_default_rate = 100;
bool configuration::check_feature(feature f) const
{
{
@@ -99,7 +95,7 @@ void configuration::set_feature(feature f, bool state)
save();
}
configuration::configuration(xr::system & system, xr::session & session)
configuration::configuration(xr::system & system)
{
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
features[feature::hand_tracking] = system.hand_tracking_supported();
@@ -126,15 +122,6 @@ configuration::configuration(xr::system & system, xr::session & session)
high_power_mode = true;
break;
}
const auto & rates = session.get_refresh_rates();
for (auto rate: rates)
{
if (rate >= max_default_rate)
break;
preferred_refresh_rate = rate;
}
try
{
simdjson::dom::parser parser;
@@ -158,11 +145,7 @@ configuration::configuration(xr::system & system, xr::session & session)
}
if (auto val = root["preferred_refresh_rate"]; val.is_double())
{
float f = val.get_double();
if (f == 0 or utils::contains(rates, f))
preferred_refresh_rate = f;
}
preferred_refresh_rate = val.get_double();
if (auto val = root["minimum_refresh_rate"]; val.is_double())
minimum_refresh_rate = val.get_double();
@@ -302,7 +285,8 @@ void configuration::save()
std::ofstream json(application::get_config_path() / "client.json");
json << "{\"servers\":[" << servers_str << "]";
json << ",\"preferred_refresh_rate\":" << preferred_refresh_rate;
if (preferred_refresh_rate)
json << ",\"preferred_refresh_rate\":" << *preferred_refresh_rate;
if (minimum_refresh_rate)
json << ",\"minimum_refresh_rate\":" << *minimum_refresh_rate;
json << ",\"resolution_scale\":" << resolution_scale;
+4 -5
View File
@@ -31,9 +31,8 @@
namespace xr
{
class session;
class system;
} // namespace xr
}
class configuration
{
@@ -49,7 +48,7 @@ public:
};
std::map<std::string, server_data> servers;
float preferred_refresh_rate = 0;
std::optional<float> preferred_refresh_rate;
std::optional<float> minimum_refresh_rate;
float resolution_scale = 1.0;
std::optional<wivrn::video_codec> codec;
@@ -77,7 +76,7 @@ public:
std::string environment_model = "assets://ground.glb";
bool override_foveation_enable = false;
float override_foveation_pitch = -10 * M_PI / 180;
float override_foveation_pitch = 10 * M_PI / 180;
float override_foveation_distance = 3;
bool high_power_mode;
@@ -100,7 +99,7 @@ private:
void parse_openxr_post_processing_options(simdjson::simdjson_result<simdjson::dom::object> root);
public:
configuration(xr::system &, xr::session &);
configuration(xr::system &);
configuration() = default;
void save();
+8 -10
View File
@@ -40,7 +40,7 @@ constexpr int font_size_large = 75;
constexpr float scroll_ratio = 10;
// Threshold on the trigger value to register a click
constexpr float trigger_click_thd = 0.7;
constexpr float trigger_click_thd = 0.8;
// Thresholds on the distance between the fingertip and GUI layers (positive: in front of the GUI, negative: behind the GUI)
constexpr float palm_distance_close_thd_lo = 0.18; // Distance to switch between touch and aim interaction
@@ -53,8 +53,9 @@ constexpr float fingertip_distance_stick_thd = -0.02; // Max distance wher
constexpr float scroll_value_thd = 0.01;
// Pointer radius
constexpr float pointer_thickness = 2;
constexpr float pointer_radius_in = 6;
constexpr float pointer_radius_in = 10;
constexpr float pointer_radius_out = 12;
constexpr float pointer_thickness = 4;
// Pointer transparency
constexpr float pointer_alpha = 0.8;
@@ -62,7 +63,8 @@ constexpr float pointer_alpha_disabled = 0.25;
constexpr float pointer_fading_distance = 40;
// Pointer color
constexpr uint32_t pointer_color = 0x40ffffff;
constexpr uint32_t pointer_color_pressed = 0xffff3300;
constexpr uint32_t pointer_color_unpressed = 0xffffffff;
constexpr uint32_t pointer_color_border = 0xff000000;
} // namespace constants::gui
@@ -108,8 +110,7 @@ constexpr int zindex_passthrough = -2;
constexpr int zindex_lobby = -1;
constexpr int zindex_gui = 0;
constexpr int zindex_controllers = 1;
constexpr int zindex_tooltip = 2;
constexpr int zindex_recenter_tip = 3;
constexpr int zindex_recenter_tip = 2;
} // namespace constants::lobby
namespace constants::stream
@@ -117,9 +118,6 @@ namespace constants::stream
constexpr float fade_delay = 3;
constexpr float fade_duration = 0.25;
constexpr float urgent_fade_delay = 5;
constexpr ImVec4 urgent_border_color = {8.f, .6f, 0.f, .8f};
// Dimming for the streamed video when the GUI is interactable
constexpr float dimming_scale = 0.4;
constexpr float dimming_bias = 0.01;
@@ -133,7 +131,7 @@ constexpr float window_rounding = 10;
constexpr ImVec2 tooltip_padding = {5, 5};
constexpr float tooltip_rounding = 0;
constexpr glm::vec3 tooltip_distance = {0, 0.004, 0.005};
constexpr float tooltip_distance = 10;
constexpr ImVec2 button_size = {220, 80};
constexpr ImVec2 icon_button_size = {80, 80};
+4 -10
View File
@@ -71,20 +71,14 @@ std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
__builtin_unreachable();
}
static std::vector<wivrn::video_codec> supported_codecs_()
std::vector<wivrn::video_codec> wivrn::decoder::supported_codecs()
{
std::vector<wivrn::video_codec> res;
#ifdef __ANDROID__
wivrn::android::decoder::supported_codecs(res);
android::decoder::supported_codecs(res);
#else
wivrn::ffmpeg::decoder::supported_codecs(res);
ffmpeg::decoder::supported_codecs(res);
#endif
res.push_back(wivrn::video_codec::raw);
return res;
}
const std::vector<wivrn::video_codec> & wivrn::decoder::supported_codecs()
{
static std::vector<wivrn::video_codec> res = supported_codecs_();
res.push_back(video_codec::raw);
return res;
}
+1 -1
View File
@@ -66,6 +66,6 @@ public:
virtual vk::Sampler sampler() = 0;
static const std::vector<wivrn::video_codec> & supported_codecs();
static std::vector<wivrn::video_codec> supported_codecs();
};
} // namespace wivrn
+1 -1
View File
@@ -281,7 +281,7 @@ void raw_decoder::frame_completed(
input[0],
item->image,
item->current_layout,
stream_index < 2 ? 2 : 1,
stream_index ? 2 : 1,
regions.data());
vk::ImageMemoryBarrier barrier{
+2 -6
View File
@@ -376,10 +376,10 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
return {{0, -0.006, -0.025}, glm::angleAxis(glm::radians(-15.f), glm::vec3{1, 0, 0})};
case xr::spaces::aim_left:
return {{-0.010, 0, 0.02}, {1, 0, 0, 0}};
return {{-0.010, 0, 0.025}, {1, 0, 0, 0}};
case xr::spaces::aim_right:
return {{0.010, 0, 0.02}, {1, 0, 0, 0}};
return {{0.010, 0, 0.025}, {1, 0, 0, 0}};
default:
break;
@@ -392,10 +392,6 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
case xr::spaces::grip_right:
return {{0, -0.010, -0.025}, glm::angleAxis(glm::radians(-12.f), glm::vec3{1, 0, 0})};
case xr::spaces::aim_left:
case xr::spaces::aim_right:
return {{0, 0, -0.03}, {1, 0, 0, 0}};
default:
break;
}
+63 -95
View File
@@ -37,7 +37,6 @@
#include <cmath>
#include <cstddef>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/quaternion.hpp>
#include <imgui.h>
#include <imgui_internal.h>
#include <limits>
@@ -158,7 +157,7 @@ static bool window_intersects_viewport(ImGuiWindow * window, const imgui_context
static float distance_to_window(ImGuiWindow * window, ImVec2 position)
{
if (window->Hidden or not window->Active)
return std::numeric_limits<float>::max();
return std::numeric_limits<float>::infinity();
float dx;
if (position.x < window->Pos.x)
@@ -209,18 +208,13 @@ imgui_textures::imgui_textures(
this->image_cache = std::make_shared<image_cache_type>(device, physical_device, queue, queue_family_index);
}
imgui_textures::~imgui_textures()
{
device.waitIdle();
}
std::vector<std::pair<ImVec2, float>> imgui_context::ray_plane_intersection(const imgui_context::controller_state & in) const
{
std::vector<std::pair<ImVec2, float>> intersections;
for (const auto & i: layers_)
{
if (i.space != xr::spaces::world or i.tooltip_viewport)
if (i.space != xr::spaces::world)
continue;
auto M = glm::transpose(glm::mat3_cast(i.orientation)); // world-to-plane transform
@@ -570,9 +564,9 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
for (const auto & [controller, state, current_aim_interaction]: std::ranges::zip_view(controllers, new_states, aim_interaction))
{
const auto & ctrl = controller.first;
std::pair<std::optional<ImVec2>, float> index_tip_position{{}, std::numeric_limits<float>::max()};
std::pair<std::optional<ImVec2>, float> palm_position{{}, std::numeric_limits<float>::max()};
std::pair<std::optional<ImVec2>, float> controller_position{{}, std::numeric_limits<float>::max()};
std::pair<std::optional<ImVec2>, float> index_tip_position{{}, std::numeric_limits<float>::infinity()};
std::pair<std::optional<ImVec2>, float> palm_position{{}, std::numeric_limits<float>::infinity()};
std::pair<std::optional<ImVec2>, float> controller_position{{}, std::numeric_limits<float>::infinity()};
// First hands, so we can set aim_interaction
current_aim_interaction = 1;
@@ -639,6 +633,10 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
auto trigger = application::read_action_float(ctrl.trigger).value_or(std::pair{0, 0});
state.trigger_value = trigger.second;
// TODO tunable
/*if (new_state.trigger_value < 0.5)
new_state.trigger_clicked = false;
else */
if (state.trigger_value > constants::gui::trigger_click_thd)
state.trigger_clicked = true;
}
@@ -678,7 +676,7 @@ std::pair<std::optional<ImVec2>, float> imgui_context::compute_pointer_position(
auto intersections = ray_plane_intersection(state);
if (intersections.empty())
return {std::nullopt, std::numeric_limits<float>::max()};
return {std::nullopt, std::numeric_limits<float>::infinity()};
if (ImGuiWindow * modal_popup = ImGui::GetTopMostAndVisiblePopupModal())
{
@@ -698,7 +696,7 @@ std::pair<std::optional<ImVec2>, float> imgui_context::compute_pointer_position(
}
}
return {std::nullopt, std::numeric_limits<float>::max()};
return {std::nullopt, std::numeric_limits<float>::infinity()};
}
else
{
@@ -845,7 +843,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
application::haptic_start(haptic_output, XR_NULL_PATH, 10'000'000, 1000, 1);
}
vk::Image destination = swapchain.image(image_index);
vk::Image destination = swapchain.images()[image_index].image;
ImGui::SetCurrentContext(context);
ImPlot::SetCurrentContext(plot_context);
@@ -909,7 +907,7 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
}
// Compute the distance to the closest window
float distance = std::numeric_limits<float>::max();
float distance = std::numeric_limits<float>::infinity();
for (ImGuiWindow * window: context->Windows)
{
distance = std::min(distance, distance_to_window(window, *position));
@@ -917,18 +915,20 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
float alpha = std::clamp<float>(1 - distance / constants::gui::pointer_fading_distance, 0, 1);
if (focused_controller != (size_t)-1 and &controller == &controllers[focused_controller])
if (&controller == &controllers[focused_controller])
alpha *= constants::gui::pointer_alpha;
else
alpha *= constants::gui::pointer_alpha_disabled;
float radius_in = constants::gui::pointer_radius_in;
float radius_out = radius_in + constants::gui::pointer_thickness * 0.5;
ImU32 color_pressed = ImGui::GetColorU32(constants::gui::pointer_color_pressed, alpha);
ImU32 color_unpressed = ImGui::GetColorU32(constants::gui::pointer_color_unpressed, alpha);
bool pressed = controller.second.trigger_clicked || controller.second.fingertip_touching;
ImDrawList * draw_list = ImGui::GetForegroundDrawList();
draw_list->PushClipRect(clip_rect_min, clip_rect_max);
draw_list->AddCircleFilled(*position, radius_in, ImGui::GetColorU32(constants::gui::pointer_color, alpha));
draw_list->AddCircle(*position, radius_out, ImGui::GetColorU32(constants::gui::pointer_color_border, alpha), 0, constants::gui::pointer_thickness);
draw_list->AddCircleFilled(*position, constants::gui::pointer_radius_in, pressed ? color_pressed : color_unpressed);
draw_list->AddCircle(*position, constants::gui::pointer_radius_out, ImGui::GetColorU32(constants::gui::pointer_color_border, alpha), 0, constants::gui::pointer_thickness);
draw_list->PopClipRect();
}
}
@@ -983,47 +983,15 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
for (auto & i: layers_)
{
bool visible = false;
ImRect layer_rect(
i.vp_origin.x,
i.vp_origin.y,
i.vp_origin.x + i.vp_size.x,
i.vp_origin.y + i.vp_size.y);
ImRect all_windows_rect{
std::numeric_limits<float>::max(),
std::numeric_limits<float>::max(),
std::numeric_limits<float>::lowest(),
std::numeric_limits<float>::lowest(),
};
for (ImGuiWindow * window: context->Windows)
{
ImRect window_rect{
window->Pos.x,
window->Pos.y,
window->Pos.x + window->Size.x,
window->Pos.y + window->Size.y};
if (window->Active and not window->Hidden and layer_rect.Overlaps(window_rect))
if (window->Active and not window->Hidden and window_intersects_viewport(window, i))
{
visible = true;
// Take the union of all visible windows in this layer
all_windows_rect.Add(window_rect);
break;
}
}
// Take the intersection with the layer
all_windows_rect.ClipWithFull(layer_rect);
glm::vec2 pixel_size = i.size / glm::vec2(i.vp_size);
glm::vec2 all_windows_center(all_windows_rect.GetCenter().x, all_windows_rect.GetCenter().y);
glm::vec2 layer_center(layer_rect.GetCenter().x, layer_rect.GetCenter().y);
glm::vec3 new_position = i.position + i.orientation * glm::vec3((all_windows_center - layer_center) * pixel_size, 0);
glm::vec2 new_size = glm::vec2(all_windows_rect.GetWidth(), all_windows_rect.GetHeight()) * pixel_size;
if (not visible)
continue;
@@ -1038,12 +1006,12 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
.swapchain = swapchain,
.imageRect = {
.offset = {
.x = int(all_windows_rect.Min.x),
.y = int(all_windows_rect.Min.y),
.x = i.vp_origin.x,
.y = i.vp_origin.y,
},
.extent = {
.width = int(all_windows_rect.Max.x - all_windows_rect.Min.x),
.height = int(all_windows_rect.Max.y - all_windows_rect.Min.y),
.width = i.vp_size.x,
.height = i.vp_size.y,
}},
},
.pose = {
@@ -1054,14 +1022,14 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
.w = i.orientation.w,
},
.position = {
.x = new_position.x,
.y = new_position.y,
.z = new_position.z,
.x = i.position.x,
.y = i.position.y,
.z = i.position.z,
},
},
.size = {
.width = new_size.x,
.height = new_size.y,
.width = i.size.x,
.height = i.size.y,
},
});
}
@@ -1069,9 +1037,11 @@ std::vector<std::pair<int, XrCompositionLayerQuad>> imgui_context::end_frame()
return quads;
}
std::vector<imgui_context::window_viewport> imgui_context::windows()
std::vector<imgui_context::viewport> imgui_context::windows()
{
std::vector<imgui_context::window_viewport> w;
std::vector<imgui_context::viewport> w;
ImGuiWindow * modal_popup = ImGui::GetTopMostAndVisiblePopupModal();
for (const imgui_context::viewport & layer: layers_)
{
@@ -1082,7 +1052,10 @@ std::vector<imgui_context::window_viewport> imgui_context::windows()
for (ImGuiWindow * window: context->Windows)
{
if (not window->Active or window->Hidden or (window->Flags & ImGuiWindowFlags_ChildWindow))
if (not window->Active or window->Hidden /*or window->ParentWindowInBeginStack != nullptr*/)
continue;
if (modal_popup != nullptr and window != modal_popup and not layer.always_show_cursor)
continue;
if (not window_intersects_viewport(window, layer))
@@ -1093,7 +1066,7 @@ std::vector<imgui_context::window_viewport> imgui_context::windows()
ImVec2 min = ImMax(v.Min, window->Pos);
ImVec2 center = (min + max) / 2;
w.push_back(window_viewport{
w.push_back(viewport{
.space = layer.space,
.position = layer.position +
glm::mat3_cast(layer.orientation) *
@@ -1106,6 +1079,9 @@ std::vector<imgui_context::window_viewport> imgui_context::windows()
(max.x - min.x) * layer.size.x / layer.vp_size.x,
(max.y - min.y) * layer.size.y / layer.vp_size.y,
},
.vp_origin = {min.x, min.y},
.vp_size = {max.x - min.x, max.y - min.y},
.always_show_cursor = layer.always_show_cursor,
});
}
}
@@ -1265,32 +1241,34 @@ void imgui_context::tooltip(std::string_view text)
// FIXME: this is incorrect if we use the docking branch of imgui
ImGuiViewport * viewport = ImGui::GetMainViewport();
auto & current_layer = layer(ImGui::GetMousePos());
assert(std::ranges::contains(layers_, true, &viewport::tooltip_viewport));
auto & tooltip_layer = *std::ranges::find(layers_, true, &viewport::tooltip_viewport);
// Get the item position before drawing the tooltip (top center)
ImVec2 item_position{
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
ImGui::GetItemRectMin().y,
};
auto pos_backup = viewport->Pos;
auto size_backup = viewport->Size;
viewport->Pos = ImVec2(tooltip_layer.vp_origin.x, tooltip_layer.vp_origin.y);
viewport->Size = ImVec2(tooltip_layer.vp_size.x, tooltip_layer.vp_size.y);
viewport->Pos = ImVec2(current_layer.vp_origin.x, current_layer.vp_origin.y);
viewport->Size = ImVec2(current_layer.vp_size.x, current_layer.vp_size.y);
ImVec2 pos{
(ImGui::GetItemRectMin().x + ImGui::GetItemRectMax().x) / 2,
ImGui::GetItemRectMin().y - constants::style::tooltip_distance,
};
// Draw the tooltip in the tooltip layer
// Clamp position to avoid overflowing on the left or the right
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, constants::style::tooltip_padding);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, constants::style::tooltip_rounding);
// Clamp position to avoid overflowing on the left or the right
auto & style = ImGui::GetStyle();
const ImVec2 text_size = ImGui::CalcTextSize(text.data(), text.data() + text.size(), true);
const ImVec2 tooltip_size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
const ImVec2 size = {text_size.x + style.WindowPadding.x * 2.0f, text_size.y + style.WindowPadding.y * 2.0f};
pos.x = std::clamp<float>(pos.x, viewport->Pos.x + size.x / 2, viewport->Pos.x + viewport->Size.x - size.x / 2);
ImVec2 pivot = {0.5, 1};
ImGui::SetNextWindowPos(viewport->Pos + viewport->Size * 0.5, ImGuiCond_Always, {0.5, 0.5});
ImGui::SetNextWindowSizeConstraints({0, 0}, viewport->Size);
// Move tooltip below the item if it overflows on the top
if (pos.y - size.y <= viewport->Pos.y)
{
pos.y = ImGui::GetItemRectMax().y + constants::style::tooltip_distance;
pivot.y = 0;
}
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
if (ImGui::BeginTooltip())
{
ImGui::PushStyleColor(ImGuiCol_Text, 0xffffffff);
@@ -1298,21 +1276,11 @@ void imgui_context::tooltip(std::string_view text)
ImGui::PopStyleColor();
ImGui::EndTooltip();
}
ImGui::PopStyleVar(2);
viewport->Pos = pos_backup;
viewport->Size = size_backup;
// Compute the tooltip position
glm::quat tooltip_orientation = current_layer.orientation;
auto M = glm::mat3_cast(tooltip_orientation);
float pixel_size = current_layer.size.y / current_layer.vp_size.y;
glm::vec3 tooltip_position_centre = rw_from_vp(item_position) + M * (glm::vec3(0, tooltip_size.y / 2, 0) * pixel_size + constants::style::tooltip_distance);
// Position the tooltip layer
tooltip_layer.position = tooltip_position_centre;
tooltip_layer.orientation = tooltip_orientation;
}
// https://github.com/ocornut/imgui/issues/3379#issuecomment-2943903877
+1 -12
View File
@@ -68,7 +68,6 @@ public:
uint32_t queue_family_index,
thread_safe<vk::raii::Queue> & queue,
std::shared_ptr<image_cache_type> image_cache = {});
~imgui_textures();
ImTextureID load_texture(const std::string & filename, vk::raii::Sampler && sampler);
ImTextureID load_texture(const std::string & filename);
ImTextureID load_texture(const std::span<const std::byte> & bytes, vk::raii::Sampler && sampler, const std::string & name = "");
@@ -137,7 +136,6 @@ public:
glm::ivec2 vp_size;
bool always_show_cursor = false; // Show the cursor in this viewport even if there is a modal popup elsewhere (eg. this is a virtual keyboard)
bool tooltip_viewport = false; // Choose this viewport to display the tooltip, ignore mouse events
int z_index = 0;
@@ -147,15 +145,6 @@ public:
}
};
struct window_viewport
{
// Position of this window in the world
xr::spaces space;
glm::vec3 position;
glm::quat orientation;
glm::vec2 size;
};
private:
uint32_t queue_family_index;
@@ -226,7 +215,7 @@ public:
return layers_;
}
std::vector<window_viewport> windows();
std::vector<viewport> windows();
viewport & layer(ImVec2 position);
+4 -18
View File
@@ -19,7 +19,6 @@
#pragma once
#include <array>
#include <inplace_vector.hpp>
#include <memory>
#include <type_traits>
#include <utility>
@@ -101,7 +100,7 @@ struct material
size_t offset;
std::string name;
std::string fragment_shader = "lit.frag";
std::string fragment_shader_name = "lit.frag";
};
struct primitive
@@ -111,7 +110,7 @@ struct primitive
uint32_t vertex_count;
vk::IndexType index_type;
vk::DeviceSize index_offset;
beman::inplace_vector::inplace_vector<vk::DeviceSize, 8> vertex_offset; // See VkPhysicalDeviceLimits::maxVertexInputBindings
std::vector<vk::DeviceSize> vertex_offset; // TODO: inplace_vector
vertex_layout layout;
glm::vec3 obb_min;
@@ -156,24 +155,11 @@ struct node
bool visible = true;
uint32_t layer_mask = -1;
std::array<glm::vec4, 4> clipping_planes;
// TODO: separate component?
std::vector<std::pair<entt::entity, glm::mat4>> joints; // Node index, inverse bind matrix of each joint
std::vector<std::byte> extra_shader_data;
template <typename T>
void set_extra_shader_data(const T & data)
{
extra_shader_data.resize(sizeof(std::decay_t<T>));
memcpy(extra_shader_data.data(), &data, sizeof(std::decay_t<T>));
}
template <typename T>
T & get_extra_shader_data()
{
assert(extra_shader_data.size() == sizeof(std::decay_t<T>));
return *reinterpret_cast<T *>(extra_shader_data.data());
}
// For internal use by the renderer
glm::mat4 transform_to_root;
bool global_visible;
+12 -40
View File
@@ -45,9 +45,6 @@
#include <limits>
#include <ranges>
#include <simdjson/dom.h>
#include <simdjson/dom/element.h>
#include <simdjson/dom/object.h>
#include <simdjson/error.h>
#include <spdlog/spdlog.h>
#include <string>
#include <vulkan/vulkan_format_traits.hpp>
@@ -516,7 +513,7 @@ struct : std::error_category
} fastgltf_error_category;
// END
fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::filesystem::path & directory, std::function<void(simdjson::dom::object &, std::size_t, fastgltf::Category)> extra_callback)
fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::filesystem::path & directory)
{
fastgltf::Parser parser(
fastgltf::Extensions::KHR_texture_basisu |
@@ -527,12 +524,6 @@ fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::fi
fastgltf::Options::AllowDouble |
fastgltf::Options::DecomposeNodeMatrices;
parser.setUserPointer(&extra_callback);
parser.setExtrasParseCallback([](simdjson::dom::object * extras, std::size_t object_index, fastgltf::Category category, void * user_pointer) {
auto f = reinterpret_cast<std::function<void(simdjson::dom::object &, std::size_t, fastgltf::Category)> *>(user_pointer);
(*f)(*extras, object_index, category);
});
auto expected_asset = parser.loadGltf(buffer, directory, gltf_options);
if (auto error = expected_asset.error(); error != fastgltf::Error::None)
@@ -549,8 +540,7 @@ class loader_context
vk::raii::PhysicalDevice physical_device;
vk::raii::Device & device;
thread_safe<vk::raii::Queue> & queue;
image_loader loader;
const std::map<std::tuple<fastgltf::Category, size_t, std::string>, std::string> & extras;
image_loader & loader;
std::vector<utils::mapped_file> loaded_assets;
utils::mapped_file & load_from_asset(const std::filesystem::path & path)
@@ -573,16 +563,14 @@ public:
vk::raii::PhysicalDevice physical_device,
vk::raii::Device & device,
thread_safe<vk::raii::Queue> & queue,
uint32_t queue_family_index,
std::map<std::tuple<fastgltf::Category, size_t, std::string>, std::string> & extras) :
image_loader & loader) :
base_directory(std::move(base_directory)),
name(std::move(name)),
gltf(gltf),
physical_device(physical_device),
device(device),
queue(queue),
loader(device, physical_device, queue, queue_family_index),
extras(extras)
loader(loader)
{
}
@@ -805,8 +793,6 @@ public:
materials.reserve(gltf.materials.size());
for (const fastgltf::Material & gltf_material: gltf.materials)
{
size_t material_id = materials.size();
// Copy the default material, without references to its buffer or descriptor set
auto & material = *materials.emplace_back(std::make_shared<renderer::material>(default_material));
material.name = gltf_material.name;
@@ -817,24 +803,21 @@ public:
switch (gltf_material.alphaMode)
{
case fastgltf::AlphaMode::Opaque:
material.fragment_shader = "lit.frag";
material.fragment_shader_name = "lit.frag";
material.blend_enable = false;
break;
case fastgltf::AlphaMode::Mask:
material.fragment_shader = "lit_mask.frag";
material.fragment_shader_name = "lit_mask.frag";
material.blend_enable = false;
break;
case fastgltf::AlphaMode::Blend:
material.fragment_shader = "lit.frag";
material.fragment_shader_name = "lit.frag";
material.blend_enable = true;
break;
}
if (auto it = extras.find({fastgltf::Category::Materials, material_id, "fragment_shader"}); it != extras.end())
material.fragment_shader = it->second;
renderer::material::gpu_data & material_data = material.staging;
material_data.base_color_factor = convert(gltf_material.pbrData.baseColorFactor);
@@ -887,7 +870,6 @@ public:
meshes.reserve(gltf.meshes.size());
for (const fastgltf::Mesh & gltf_mesh: gltf.meshes)
{
size_t mesh_id = meshes.size();
std::shared_ptr<renderer::mesh> & mesh_ref = meshes.emplace_back();
mesh_ref = std::make_shared<renderer::mesh>();
@@ -910,9 +892,7 @@ public:
renderer::vertex_layout & layout = primitive_ref.layout;
if (auto it = extras.find({fastgltf::Category::Meshes, mesh_id, "vertex_shader"}); it != extras.end())
primitive_ref.vertex_shader = it->second;
else if (gltf_primitive.findAttribute("JOINTS_0") == gltf_primitive.attributes.cend())
if (gltf_primitive.findAttribute("JOINTS_0") == gltf_primitive.attributes.cend())
primitive_ref.vertex_shader = "lit.vert";
else
primitive_ref.vertex_shader = "lit_skinned.vert";
@@ -1027,6 +1007,7 @@ public:
node.orientation = glm::make_quat(TRS.rotation.data());
node.scale = glm::make_vec3(TRS.scale.data());
node.visible = true;
std::ranges::fill(node.clipping_planes, glm::vec4{0, 0, 0, 1});
}
return entities;
@@ -1167,19 +1148,10 @@ std::shared_ptr<entt::registry> scene_loader::operator()(
if (auto error = data_buffer.error(); error != fastgltf::Error::None)
throw std::system_error((int)error, fastgltf_error_category);
std::map<std::tuple<fastgltf::Category, size_t, std::string>, std::string> gltf_extras;
fastgltf::Asset asset = load_gltf_asset(data_buffer.get(), parent_path);
fastgltf::Asset asset = load_gltf_asset(data_buffer.get(), parent_path, [&](simdjson::dom::object & extras, std::size_t object_index, fastgltf::Category category) {
std::string_view value;
for (const auto & kv: extras)
{
if (kv.value.get_string().get(value) == simdjson::SUCCESS)
gltf_extras.emplace(std::tuple{category, object_index, kv.key}, value);
}
});
loader_context ctx{parent_path, name, asset, physical_device, device, queue, queue_family_index, gltf_extras};
image_loader loader{device, physical_device, queue, queue_family_index};
loader_context ctx{parent_path, name, asset, physical_device, device, queue, loader};
#ifndef NDEBUG
if (auto error = fastgltf::validate(asset); error != fastgltf::Error::None)
+58 -13
View File
@@ -29,7 +29,6 @@
#include "vk/pipeline.h"
#include "vk/shader.h"
#include "vk/specialization_constants.h"
#include <algorithm>
#include <boost/pfr/core.hpp>
#include <entt/entity/entity.hpp>
#include <entt/entt.hpp>
@@ -340,7 +339,7 @@ scene_renderer::renderpass & scene_renderer::get_renderpass(const renderpass_inf
scene_renderer::renderpass scene_renderer::create_renderpass(const renderpass_info & info_)
{
vk::StructureChain<vk::RenderPassCreateInfo, vk::RenderPassMultiviewCreateInfo> info;
vk::StructureChain<vk::RenderPassCreateInfo, vk::RenderPassFragmentDensityMapCreateInfoEXT, vk::RenderPassMultiviewCreateInfo> info;
scene_renderer::renderpass rp;
std::vector<vk::AttachmentDescription> attachments;
@@ -392,6 +391,29 @@ scene_renderer::renderpass scene_renderer::create_renderpass(const renderpass_in
});
}
if (info_.fragment_density_map)
{
vk::RenderPassFragmentDensityMapCreateInfoEXT & fragment_density_info = info.get<vk::RenderPassFragmentDensityMapCreateInfoEXT>();
rp.fragment_density_attachment = {
.attachment = (uint32_t)attachments.size(),
.layout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
};
fragment_density_info.fragmentDensityMapAttachment = {
.attachment = (uint32_t)attachments.size(),
.layout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
};
attachments.push_back(vk::AttachmentDescription{
.format = vk::Format::eR8G8Unorm,
.samples = vk::SampleCountFlagBits::e1,
.loadOp = vk::AttachmentLoadOp::eLoad,
.storeOp = vk::AttachmentStoreOp::eDontCare,
.initialLayout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
.finalLayout = vk::ImageLayout::eFragmentDensityMapOptimalEXT,
});
}
else
info.unlink<vk::RenderPassFragmentDensityMapCreateInfoEXT>();
info.get().setAttachments(attachments);
vk::SubpassDescription subpasses{
@@ -550,6 +572,27 @@ scene_renderer::output_image scene_renderer::create_output_image_data(const outp
});
}
if (info.renderpass.fragment_density_map)
{
assert(info.foveation != VK_NULL_HANDLE);
out.foveation_view = vk::raii::ImageView(
device,
vk::ImageViewCreateInfo{
.image = info.foveation,
.viewType = vk::ImageViewType::e2DArray,
.format = vk::Format::eR8G8Unorm,
.components{},
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = info.renderpass.multiview_count,
},
});
}
vk::FramebufferCreateInfo fb_info{
.renderPass = *get_renderpass(info.renderpass).renderpass,
.width = info.output_size.width,
@@ -574,6 +617,9 @@ scene_renderer::output_image scene_renderer::create_output_image_data(const outp
attachments[rp.depth_attachment.attachment] = vk::ImageView{*out.depth_view};
if (rp.fragment_density_attachment)
attachments[rp.fragment_density_attachment->attachment] = vk::ImageView{*out.foveation_view};
fb_info.setAttachments(attachments);
out.framebuffer = vk::raii::Framebuffer(device, fb_info);
return out;
@@ -629,8 +675,8 @@ vk::raii::Pipeline scene_renderer::create_pipeline(const pipeline_info & info)
{
spdlog::debug("Creating pipeline");
auto vertex_shader = load_shader(device, info.vertex_shader_name);
auto fragment_shader = load_shader(device, info.fragment_shader_name);
auto vertex_shader = shader_loader{device}(info.vertex_shader_name);
auto fragment_shader = shader_loader{device}(info.fragment_shader_name);
auto specialization = make_specialization_constants(
int32_t(info.nb_texcoords),
@@ -686,7 +732,7 @@ vk::raii::Pipeline scene_renderer::create_pipeline(const pipeline_info & info)
.ColorBlendState = {vk::PipelineColorBlendStateCreateInfo{}},
.ColorBlendAttachments = {vk::PipelineColorBlendAttachmentState{
.blendEnable = info.blend_enable,
.srcColorBlendFactor = vk::BlendFactor::eOne,
.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha,
.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha,
.colorBlendOp = vk::BlendOp::eAdd,
.srcAlphaBlendFactor = vk::BlendFactor::eOne,
@@ -864,6 +910,7 @@ void scene_renderer::render(
vk::Format depth_format,
vk::Image color_buffer,
vk::Image depth_buffer,
vk::Image foveation_image,
std::span<frame_info> frames,
bool render_debug_draws)
{
@@ -916,6 +963,7 @@ void scene_renderer::render(
.keep_depth_buffer = depth_buffer != vk::Image{},
.msaa_samples = vk::SampleCountFlagBits::e1,
// .msaa_samples = vk::SampleCountFlagBits::e4, // FIXME: MSAA does not work
.fragment_density_map = foveation_image != vk::Image{},
.multiview_count = (uint32_t)frames.size(),
};
vk::raii::RenderPass & renderpass = get_renderpass(rp_info).renderpass;
@@ -1011,6 +1059,7 @@ void scene_renderer::render(
.output_size = output_size,
.color = color_buffer,
.depth = depth_buffer,
.foveation = foveation_image,
});
vk::DeviceSize frame_ubo_offset = resources.uniform_buffer_offset;
@@ -1057,12 +1106,8 @@ void scene_renderer::render(
// TODO: reuse the UBO if another primitive of the same mesh has already been drawn
vk::DeviceSize instance_ubo_offset = resources.uniform_buffer_offset;
vk::DeviceSize instance_ubo_size = sizeof(instance_gpu_data) + node.extra_shader_data.size();
instance_gpu_data & object_ubo = *reinterpret_cast<instance_gpu_data *>(ubo + resources.uniform_buffer_offset);
std::span<std::byte> extra_shader_data{reinterpret_cast<std::byte *>(ubo + resources.uniform_buffer_offset + sizeof(instance_gpu_data)), node.extra_shader_data.size()};
resources.uniform_buffer_offset += utils::align_up(buffer_alignment, sizeof(instance_gpu_data) + node.extra_shader_data.size());
resources.uniform_buffer_offset += utils::align_up(buffer_alignment, sizeof(instance_gpu_data));
vk::DeviceSize joints_ubo_offset = 0;
if (!node.joints.empty())
@@ -1085,7 +1130,7 @@ void scene_renderer::render(
object_ubo.modelview[frame_index] = frame.view * transform;
object_ubo.modelviewproj[frame_index] = viewproj[frame_index] * transform;
}
std::ranges::copy(node.extra_shader_data, extra_shader_data.begin());
object_ubo.clipping_planes = node.clipping_planes;
// Get the material
std::shared_ptr<renderer::material> material = primitive.material_ ? primitive.material_ : default_material;
@@ -1094,7 +1139,7 @@ void scene_renderer::render(
pipeline_info info{
.renderpass = rp_info,
.vertex_shader_name = primitive.vertex_shader,
.fragment_shader_name = material->fragment_shader,
.fragment_shader_name = material->fragment_shader_name,
.vertex_layout = primitive.layout,
.cull_mode = primitive.cull_mode,
.front_face = primitive.front_face,
@@ -1142,7 +1187,7 @@ void scene_renderer::render(
vk::DescriptorBufferInfo buffer_info_2{
.buffer = resources.uniform_buffer,
.offset = instance_ubo_offset,
.range = instance_ubo_size,
.range = sizeof(instance_gpu_data),
};
vk::DescriptorBufferInfo buffer_info_3{
.buffer = resources.uniform_buffer,
+6
View File
@@ -44,6 +44,7 @@ struct renderpass_info
vk::Format depth_format;
bool keep_depth_buffer;
vk::SampleCountFlagBits msaa_samples = vk::SampleCountFlagBits::e1;
bool fragment_density_map;
uint32_t multiview_count;
bool operator==(const renderpass_info & other) const noexcept = default;
@@ -80,6 +81,7 @@ struct output_image_info
vk::Extent2D output_size;
VkImage color;
VkImage depth;
VkImage foveation;
bool operator==(const output_image_info & other) const noexcept = default;
};
@@ -125,6 +127,8 @@ class scene_renderer
image_allocation multisample_image;
vk::raii::ImageView multisample_view = nullptr;
vk::raii::ImageView foveation_view = nullptr;
};
struct renderpass
@@ -195,6 +199,7 @@ class scene_renderer
glm::mat4 model;
std::array<glm::mat4, 2> modelview;
std::array<glm::mat4, 2> modelviewproj;
std::array<glm::vec4, 4> clipping_planes;
};
struct debug_draw_vertex
@@ -275,6 +280,7 @@ public:
vk::Format depth_format,
vk::Image color_buffer,
vk::Image depth_buffer,
vk::Image foveation_image,
std::span<frame_info> info,
bool render_debug_draws = false);
void end_frame();
+68 -19
View File
@@ -155,20 +155,28 @@ void scene::render_world(
bool keep_depth_buffer,
uint32_t layer_mask,
XrColor4f clear_color,
const std::optional<xr::foveation_profile> & foveation,
bool render_debug_draws)
{
assert(views.size() <= layer::max_views);
beman::inplace_vector::inplace_vector<scene_renderer::frame_info, layer::max_views> frames;
beman::inplace_vector::inplace_vector<XrCompositionLayerProjectionView, layer::max_views> composition_layer_color;
beman::inplace_vector::inplace_vector<XrCompositionLayerDepthInfoKHR, layer::max_views> composition_layer_depth;
std::vector<scene_renderer::frame_info> frames;
frames.reserve(views.size());
auto [color_swapchain, color_image] = [&]() -> std::tuple<XrSwapchain, vk::Image> {
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size());
// TODO inplace vector
std::vector<XrCompositionLayerProjectionView> composition_layer_color;
std::vector<XrCompositionLayerDepthInfoKHR> composition_layer_depth;
composition_layer_color.reserve(views.size());
if (keep_depth_buffer)
composition_layer_depth.reserve(views.size());
auto [color_swapchain, color_image, foveation_image] = [&]() -> std::tuple<XrSwapchain, vk::Image, vk::Image> {
xr::swapchain & color_swapchain = get_swapchain(swapchain_format, width, height, 1, views.size(), foveation);
int color_image_index = color_swapchain.acquire();
vk::Image color_image = color_swapchain.image(color_image_index);
vk::Image color_image = color_swapchain.images()[color_image_index].image;
vk::Image foveation_image = color_swapchain.images()[color_image_index].foveation;
color_swapchain.wait();
return {color_swapchain, color_image};
return {color_swapchain, color_image, foveation_image};
}();
auto [depth_swapchain, depth_image] = [&]() -> std::pair<XrSwapchain, vk::Image> {
@@ -177,7 +185,7 @@ void scene::render_world(
xr::swapchain & depth_swapchain = get_swapchain(depth_format, width, height, 1, views.size());
int depth_image_index = depth_swapchain.acquire();
vk::Image depth_image = depth_swapchain.image(depth_image_index);
vk::Image depth_image = depth_swapchain.images()[depth_image_index].image;
depth_swapchain.wait();
return {depth_swapchain, depth_image};
}
@@ -220,10 +228,9 @@ void scene::render_world(
},
.minDepth = 0,
.maxDepth = 1,
.nearZ = std::bit_cast<float>(0x7f800000), // infinity
.nearZ = std::numeric_limits<float>::infinity(),
.farZ = constants::lobby::near_plane,
});
static_assert(std::numeric_limits<float>::is_iec559);
}
}
@@ -238,20 +245,52 @@ void scene::render_world(
depth_format,
color_image,
depth_image,
foveation_image,
frames,
render_debug_draws);
add_projection_layer(
XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
space,
composition_layer_color,
composition_layer_depth);
std::move(composition_layer_color),
std::move(composition_layer_depth));
}
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size)
xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size, const std::optional<xr::foveation_profile> & foveation)
{
XrFoveationProfileFB foveation_profile = XR_NULL_HANDLE;
XrFoveationLevelFB foveation_level = XR_FOVEATION_LEVEL_NONE_FB;
float foveation_vertical_offset_degrees = 0;
bool foveation_dynamic = false;
if (foveation)
{
foveation_profile = *foveation;
foveation_level = foveation->level();
foveation_vertical_offset_degrees = foveation->vertical_offset_degrees();
foveation_dynamic = foveation->dynamic();
}
// Look for an exact match
for (swapchain_entry & entry: swapchains)
{
if (not entry.used and
entry.format == format and
entry.width == width and
entry.height == height and
entry.sample_count == sample_count and
entry.array_size == array_size and
entry.foveation_level == foveation_level and
entry.foveation_vertical_offset_degrees == foveation_vertical_offset_degrees and
entry.foveation_dynamic == foveation_dynamic)
{
entry.used = true;
return entry.swapchain;
}
}
// Look for a swapchain with a different foveation profile
for (swapchain_entry & entry: swapchains)
{
if (not entry.used and
entry.format == format and
@@ -260,7 +299,13 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
entry.sample_count == sample_count and
entry.array_size == array_size)
{
spdlog::info("Updating swapchain foveation profile to {}, {:.1f} deg", magic_enum::enum_name(foveation_level), foveation_vertical_offset_degrees);
entry.foveation_level = foveation_level;
entry.foveation_vertical_offset_degrees = foveation_vertical_offset_degrees;
entry.foveation_dynamic = foveation_dynamic;
entry.used = true;
entry.swapchain.update_foveation(*foveation);
return entry.swapchain;
}
}
@@ -272,6 +317,9 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
.height = height,
.sample_count = sample_count,
.array_size = array_size,
.foveation_level = foveation_level,
.foveation_vertical_offset_degrees = foveation_vertical_offset_degrees,
.foveation_dynamic = foveation_dynamic,
.used = true,
.swapchain = xr::swapchain(
instance,
@@ -281,7 +329,8 @@ xr::swapchain & scene::get_swapchain(vk::Format format, int32_t width, int32_t h
width,
height,
sample_count,
array_size)};
array_size,
foveation_profile)};
spdlog::info("Created swapchain");
return swapchains.emplace_back(std::move(new_swapchain)).swapchain;
@@ -327,8 +376,8 @@ void scene::render_start(bool passthrough, XrTime predicted_display_time_)
void scene::add_projection_layer(
XrCompositionLayerFlags flags,
XrSpace space,
std::span<XrCompositionLayerProjectionView> color_views,
std::span<XrCompositionLayerDepthInfoKHR> depth_views)
std::vector<XrCompositionLayerProjectionView> && color_views,
std::vector<XrCompositionLayerDepthInfoKHR> && depth_views)
{
layers.push_back(layer{
.composition_layer = XrCompositionLayerProjection{
@@ -339,8 +388,8 @@ void scene::add_projection_layer(
.viewCount = (uint32_t)color_views.size(),
.views = nullptr,
},
.color_views{color_views.begin(), color_views.end()},
.depth_views{depth_views.begin(), depth_views.end()},
.color_views = std::move(color_views),
.depth_views = std::move(depth_views),
});
}
+12 -8
View File
@@ -24,11 +24,11 @@
#include "render/scene_renderer.h"
#include "utils/cache.h"
#include "xr/actionset.h"
#include "xr/foveation_profile.h"
#include "xr/instance.h"
#include "xr/session.h"
#include "xr/swapchain.h"
#include "xr/system.h"
#include <inplace_vector.hpp>
#include <cstdint>
#include <entt/entity/registry.hpp>
@@ -132,12 +132,11 @@ protected:
struct layer
{
static const int max_views = 2;
std::variant<XrCompositionLayerProjection, XrCompositionLayerQuad, XrCompositionLayerBaseHeader *> composition_layer;
beman::inplace_vector::inplace_vector<XrCompositionLayerProjectionView, max_views> color_views; // Used by XrCompositionLayerProjection
beman::inplace_vector::inplace_vector<XrCompositionLayerDepthInfoKHR, max_views> depth_views; // Used by XrCompositionLayerProjection
// TODO in place vectors
std::vector<XrCompositionLayerProjectionView> color_views; // Used by XrCompositionLayerProjection
std::vector<XrCompositionLayerDepthInfoKHR> depth_views; // Used by XrCompositionLayerProjection
std::optional<XrCompositionLayerColorScaleBiasKHR> color_scale_bias;
std::optional<XrCompositionLayerDepthTestFB> depth_test;
@@ -155,13 +154,17 @@ protected:
int sample_count;
uint32_t array_size;
XrFoveationLevelFB foveation_level;
float foveation_vertical_offset_degrees;
bool foveation_dynamic;
bool used;
xr::swapchain swapchain;
};
std::vector<swapchain_entry> swapchains;
// The returned reference is valid until the next call to get_swapchain
xr::swapchain & get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size);
xr::swapchain & get_swapchain(vk::Format format, int32_t width, int32_t height, int sample_count, uint32_t array_size, const std::optional<xr::foveation_profile> & foveation = std::nullopt);
void clear_swapchains();
void render_start(bool passthrough, XrTime predicted_display_time);
@@ -169,8 +172,8 @@ protected:
void add_projection_layer(
XrCompositionLayerFlags flags,
XrSpace space,
std::span<XrCompositionLayerProjectionView> color_views,
std::span<XrCompositionLayerDepthInfoKHR> depth_views = {});
std::vector<XrCompositionLayerProjectionView> && color_views,
std::vector<XrCompositionLayerDepthInfoKHR> && depth_views = {});
void add_quad_layer(
XrCompositionLayerFlags flags,
@@ -189,6 +192,7 @@ protected:
bool keep_depth_buffer,
uint32_t layer_mask,
XrColor4f clear_color,
const std::optional<xr::foveation_profile> & foveation = std::nullopt,
bool render_debug_draws = false);
void set_color_scale_bias(XrColor4f scale, XrColor4f bias);
+10 -1
View File
@@ -103,12 +103,21 @@ app_launcher::app_launcher(
default_icon = textures.load_texture("assets://default_icon.ktx2");
}
app_launcher::~app_launcher()
{
stream.device.waitIdle();
for (const auto & [app_id, app_icon]: app_icons)
textures.free_texture(app_icon);
textures.free_texture(default_icon);
}
app_launcher::clicked app_launcher::draw_gui(imgui_context & imgui_ctx, const std::string & cancel)
{
auto res = clicked::None;
auto t0 = std::chrono::steady_clock::now();
bool app_starting = start_time != std::chrono::steady_clock::time_point{} and
t0 - start_time < 10s;
t0 - start_time < 10s and
stream.current_state() != scenes::stream::state::streaming;
auto cancel_size = ImGui::CalcTextSize(cancel.c_str());
+1 -5
View File
@@ -50,6 +50,7 @@ class app_launcher
public:
app_launcher(scenes::stream &, std::string server_name);
~app_launcher();
enum clicked
{
None,
@@ -59,11 +60,6 @@ public:
// cancel: text to display on the quit/disconnect/cancel button
clicked draw_gui(imgui_context &, const std::string & cancel);
void reset()
{
start_time = {};
}
void operator()(wivrn::to_headset::application_list && apps);
void operator()(wivrn::to_headset::application_icon && icon);
};
+54 -86
View File
@@ -23,8 +23,6 @@
#include "render/scene_components.h"
#include "utils/mapped_file.h"
#include "xr/space.h"
#include <array>
#include <entt/entity/fwd.hpp>
#include <entt/entt.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/quaternion.hpp>
@@ -35,7 +33,6 @@
#include <string>
#include <unordered_map>
#include <variant>
#include <openxr/openxr.h>
namespace components
{
@@ -65,27 +62,17 @@ struct visual_response
details::node_state state;
};
} // namespace components
namespace
{
// Component added to nodes bound to an action space
struct bound_space
{
xr::spaces space;
XrDuration Δt;
};
// Component added to node clipped by the GUI
struct clipped_by_gui
{
};
struct emissive_trigger
{
XrAction action;
};
} // namespace components
namespace
{
// clang-format off
const std::unordered_map<std::string, std::string> input_mappings = {
{"xr-standard-squeeze" , "/input/squeeze/value" },
@@ -184,21 +171,9 @@ struct json_visual_response
// OpenXR component path
std::string component_subpath;
};
struct ray_extra_shader_data
{
std::array<glm::mat4, 4> window_to_world;
float emissive_factor;
};
void setup_ray_shader(entt::registry & scene, entt::entity entity, const ray_extra_shader_data & initial_data = {})
{
auto & node = scene.get<components::node>(entity);
node.set_extra_shader_data(initial_data);
}
} // namespace
input_profile::input_profile(scene & scene, const std::filesystem::path & json_profile, uint32_t layer_mask_controller, uint32_t layer_mask_ray, XrAction left_trigger, XrAction right_trigger)
input_profile::input_profile(scene & scene, const std::filesystem::path & json_profile, uint32_t layer_mask_controller, uint32_t layer_mask_ray)
{
utils::mapped_file json{json_profile};
@@ -291,7 +266,7 @@ input_profile::input_profile(scene & scene, const std::filesystem::path & json_p
auto [e, node] = scene.add_gltf(model, layer_mask_controller);
node.name = layout;
entity = e;
scene.world.emplace<components::bound_space>(e, space, 0);
scene.world.emplace<bound_space>(e, space);
spdlog::debug("Created entity {}", layout);
}
@@ -306,32 +281,16 @@ input_profile::input_profile(scene & scene, const std::filesystem::path & json_p
else
continue;
auto && [ray_entity, ray_node] = scene.add_gltf(controller_ray_model_name(), layer_mask_ray);
auto && [entity, node] = scene.add_gltf(controller_ray_model_name(), layer_mask_ray);
node.name = (std::string)layout.key + "_ray";
spdlog::debug("Created entity {}", node.name);
ray_node.name = (std::string)layout.key + "_ray";
spdlog::debug("Created entity {}", ray_node.name);
scene.world.emplace<bound_space>(entity, space);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Ray", ray_entity), space, 0);
scene.world.emplace<components::clipped_by_gui>(find_node_by_name(scene.world, "Ray", ray_entity));
scene.world.emplace<components::emissive_trigger>(find_node_by_name(scene.world, "Ray", ray_entity), layout.key == "left" ? left_trigger : right_trigger);
setup_ray_shader(scene.world, find_node_by_name(scene.world, "Ray", ray_entity));
try
{
// These nodes don't exist in the HTC version
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail", ray_entity), space, 0);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail now", ray_entity), space, 0);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail -10ms", ray_entity), space, -10'000'000);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail -20ms", ray_entity), space, -20'000'000);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail -30ms", ray_entity), space, -30'000'000);
scene.world.emplace<components::bound_space>(find_node_by_name(scene.world, "Trail -40ms", ray_entity), space, -40'000'000);
scene.world.emplace<components::clipped_by_gui>(find_node_by_name(scene.world, "Trail", ray_entity));
scene.world.emplace<components::emissive_trigger>(find_node_by_name(scene.world, "Trail", ray_entity), layout.key == "left" ? left_trigger : right_trigger);
setup_ray_shader(scene.world, find_node_by_name(scene.world, "Trail", ray_entity));
}
catch (...)
{
}
if (layout.key == "left")
left_ray = entity;
else if (layout.key == "right")
right_ray = entity;
}
for (auto & json_response: json_responses)
@@ -403,6 +362,41 @@ static void apply_visual_response(components::node & node, components::details::
node.visible = value > 0.5;
}
static void set_clipping_planes(entt::registry & scene, entt::entity entity, std::span<glm::vec4> clipping_planes)
{
// If the ray starts on the wrong side of the GUI, hide it entirely
// This assumes the node is a child of the root node
components::node & node = scene.get<components::node>(entity);
for (glm::vec4 & plane: clipping_planes)
{
if (glm::dot(plane, glm::vec4(node.position, 1)) < 0)
{
scene.get<components::node>(entity).visible = false;
return;
}
}
// Apply the clipping planes on direct children of the target entity
for (auto && [child_entity, child_node]: scene.view<components::node>().each())
{
if (child_node.parent == entity)
{
size_t nb_clipping_planes = std::min(child_node.clipping_planes.size(), clipping_planes.size());
auto copy_results = std::ranges::copy_n(
clipping_planes.begin(),
nb_clipping_planes,
child_node.clipping_planes.begin());
// Disable the remaining clipping planes
std::ranges::fill_n(
copy_results.out,
child_node.clipping_planes.size() - nb_clipping_planes,
glm::vec4(0, 0, 0, 1));
}
}
}
void input_profile::apply(
entt::registry & scene,
XrSpace world_space,
@@ -411,9 +405,9 @@ void input_profile::apply(
bool hide_left_ray,
bool hide_right_controller,
bool hide_right_ray,
std::span<glm::mat4> world_to_window)
std::span<glm::vec4> pointer_limits)
{
for (auto && [entity, node, space]: scene.view<components::node, components::bound_space>().each())
for (auto && [entity, node, space]: scene.view<components::node, bound_space>().each())
{
if ((space.space == xr::spaces::grip_left and hide_left_controller) or
(space.space == xr::spaces::aim_left and hide_left_ray) or
@@ -422,7 +416,7 @@ void input_profile::apply(
{
node.visible = false;
}
else if (auto location = application::locate_controller(application::space(space.space), world_space, predicted_display_time + space.Δt); location)
else if (auto location = application::locate_controller(application::space(space.space), world_space, predicted_display_time); location)
{
node.visible = true;
@@ -501,32 +495,6 @@ void input_profile::apply(
}
}
for (auto && [entity, node, response]: scene.view<components::node, components::emissive_trigger>().each())
{
if (not response.action)
continue;
if (auto opt_value = application::read_action_float(response.action))
{
float value = opt_value->second * 0.9 + 0.1;
node.set_extra_shader_data(ray_extra_shader_data{{}, value});
}
}
for (auto && [entity, node]: scene.view<components::node, components::clipped_by_gui>().each())
{
auto & data = node.get_extra_shader_data<ray_extra_shader_data>();
size_t nb_windows = std::min(data.window_to_world.size(), world_to_window.size());
auto copy_results = std::ranges::copy_n(
world_to_window.begin(),
nb_windows,
data.window_to_world.begin());
// Disable the remaining clipping planes
std::ranges::fill_n(
copy_results.out,
data.window_to_world.size() - nb_windows,
glm::mat4{/* TODO */});
}
set_clipping_planes(scene, left_ray, pointer_limits);
set_clipping_planes(scene, right_ray, pointer_limits);
}
+2 -2
View File
@@ -37,7 +37,7 @@ struct input_profile
magic_enum::containers::array<xr::spaces, std::pair<glm::vec3, glm::quat>> offset;
input_profile(scene & scene, const std::filesystem::path & json_profile, uint32_t layer_mask_controller, uint32_t layer_mask_ray, XrAction left_trigger = XR_NULL_HANDLE, XrAction right_trigger = XR_NULL_HANDLE);
input_profile(scene & scene, const std::filesystem::path & json_profile, uint32_t layer_mask_controller, uint32_t layer_mask_ray);
// application::poll_actions() must have been called before
void apply(
@@ -48,5 +48,5 @@ struct input_profile
bool hide_left_ray,
bool hide_right_controller,
bool hide_right_ray,
std::span<glm::mat4> world_to_window);
std::span<glm::vec4> pointer_limits);
};
+61 -39
View File
@@ -157,6 +157,15 @@ scenes::lobby::lobby() :
else
spdlog::info("Composition layer color scale/bias NOT supported");
if (instance.has_extension(XR_FB_FOVEATION_VULKAN_EXTENSION_NAME) and
instance.has_extension(XR_FB_FOVEATION_CONFIGURATION_EXTENSION_NAME))
{
spdlog::info("Foveation image supported");
foveation = xr::foveation_profile(instance, session, XR_FOVEATION_LEVEL_NONE_FB, -10, false);
}
else
spdlog::info("Foveation image NOT supported");
if (std::getenv("WIVRN_AUTOCONNECT"))
force_autoconnect = true;
@@ -341,7 +350,12 @@ std::unique_ptr<wivrn_session> scenes::lobby::connect_to_session(wivrn_discover:
void scenes::lobby::update_server_list()
{
if (not discover)
if (application::is_focused() && !discover)
discover.emplace();
else if (!application::is_focused() && discover)
discover.reset();
if (!discover)
return;
std::vector<wivrn_discover::service> discovered_services = discover->get_services();
@@ -612,7 +626,28 @@ std::optional<glm::vec3> scenes::lobby::check_recenter_gui(glm::vec3 head_positi
return std::nullopt;
}
static void stick_finger_to_gui(std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> & hand, const std::vector<imgui_context::window_viewport> & layers)
// Return the vector v such that dot(v, x) > 0 iff x is on the side where the composition layer is visible
static glm::vec4 compute_ray_limits(const XrPosef & pose, float margin = 0)
{
glm::quat q{
pose.orientation.w,
pose.orientation.x,
pose.orientation.y,
pose.orientation.z,
};
glm::vec3 p{
pose.position.x,
pose.position.y,
pose.position.z,
};
glm::vec3 normal = glm::column(glm::mat3_cast(q), 2);
return glm::vec4(normal, -glm::dot(p, normal) - margin);
}
static void stick_finger_to_gui(std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> & hand, const std::vector<imgui_context::viewport> & layers)
{
// Move XR_HAND_JOINT_INDEX_{TIP,DISTAL,INTERMEDIATE,PROXIMAL}_EXT so that:
// - Only the X rotation changes for distal and intermediate (relative to the parent bone)
@@ -632,7 +667,7 @@ static void stick_finger_to_gui(std::array<xr::hand_tracker::joint, XR_HAND_JOIN
// Compute the target position of the tip
std::vector<std::pair<glm::vec3, float>> intersections; // Target position of the finger tip, distance to the GUI plane
for (const imgui_context::window_viewport & layer: layers)
for (const imgui_context::viewport & layer: layers)
{
// Ignore layers that are not absolutely positionned
if (layer.space != xr::spaces::world)
@@ -868,18 +903,12 @@ void scenes::lobby::render(const XrFrameState & frame_state)
if (next_scene)
{
switch (next_scene->current_state())
if (!next_scene->alive())
next_scene.reset();
else if (next_scene->current_state() == scenes::stream::state::streaming)
{
case scenes::stream::state::streaming:
application::push_scene(next_scene);
break;
case scenes::stream::state::shutdown:
current_tab = tab::server_list;
break;
default:
break;
autoconnect_enabled = true;
application::push_scene(next_scene);
}
}
@@ -947,14 +976,14 @@ void scenes::lobby::render(const XrFrameState & frame_state)
auto windows = imgui_ctx->windows();
auto left = left_hand->locate(world_space, frame_state.predictedDisplayTime);
if (left)
if (left and xr::hand_tracker::check_flags(*left, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
{
stick_finger_to_gui(*left, windows);
hide_left_controller = true;
}
auto right = right_hand->locate(world_space, frame_state.predictedDisplayTime);
if (right)
if (right and xr::hand_tracker::check_flags(*right, XR_SPACE_LOCATION_POSITION_TRACKED_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT, 0))
{
stick_finger_to_gui(*right, windows);
hide_right_controller = true;
@@ -1028,11 +1057,11 @@ void scenes::lobby::render(const XrFrameState & frame_state)
#endif
// Get the planes that limit the ray size from the composition layers
std::vector<glm::mat4> world_to_window;
for (auto & window: imgui_ctx->windows())
std::vector<glm::vec4> ray_limits;
for (auto & [z_index, layer]: imgui_layers)
{
if (window.space == xr::spaces::world)
world_to_window.push_back(glm::inverse(glm::translate(window.position) * glm::mat4(glm::mat3_cast(window.orientation)) * glm::scale(glm::vec3(window.size, 1))));
if (z_index != constants::lobby::zindex_recenter_tip)
ray_limits.push_back(compute_ray_limits(layer.pose));
}
input->apply(world,
@@ -1042,7 +1071,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
not imgui_ctx->is_aim_interaction()[0],
hide_right_controller,
not imgui_ctx->is_aim_interaction()[1],
world_to_window);
ray_limits);
renderer::animate(world, frame_state.predictedDisplayPeriod * 1.0e-9);
@@ -1060,6 +1089,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
composition_layer_depth_test_supported,
composition_layer_depth_test_supported ? layer_lobby | layer_controllers : layer_lobby,
clear_color,
foveation,
true);
if (composition_layer_depth_test_supported)
@@ -1090,7 +1120,8 @@ void scenes::lobby::render(const XrFrameState & frame_state)
height,
composition_layer_depth_test_supported,
composition_layer_depth_test_supported ? layer_rays : layer_rays | layer_controllers,
{0, 0, 0, 0});
{0, 0, 0, 0},
foveation);
if (composition_layer_depth_test_supported)
set_depth_test(true, XR_COMPARE_OP_LESS_OR_EQUAL_FB);
@@ -1140,9 +1171,7 @@ void scenes::lobby::on_focused()
*this,
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
get_action("right_trigger").first);
layer_rays);
spdlog::info("Loaded input profile {}", input->id);
@@ -1238,17 +1267,7 @@ void scenes::lobby::on_focused()
.vp_origin = {0, 1000},
.vp_size = {1500, 300},
.z_index = constants::lobby::zindex_recenter_tip,
},
{
// Tooltip
.space = xr::spaces::world,
.size = {0.6, 0.08},
.vp_origin = {0, 1300},
.vp_size = {1500, 200},
.tooltip_viewport = true,
.z_index = constants::lobby::zindex_tooltip,
},
};
}};
xr::swapchain swapchain_imgui(instance, session, device, swapchain_format, 3000, 1500);
@@ -1262,6 +1281,8 @@ void scenes::lobby::on_focused()
vps,
image_cache);
supported_codecs = wivrn::decoder::supported_codecs();
auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auto tm = std::localtime(&t);
switch (tm->tm_mon)
@@ -1320,8 +1341,8 @@ void scenes::lobby::on_focused()
std::ranges::sort(local_environments, std::less{});
setup_passthrough();
session.set_refresh_rate(application::get_config().preferred_refresh_rate.value_or(0));
multicast = application::get_wifi_lock().get_multicast_lock();
discover.emplace();
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT);
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_GPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT);
@@ -1353,6 +1374,7 @@ void scenes::lobby::on_unfocused()
right_hand.reset();
face_tracker.emplace<std::monostate>();
clear_swapchains();
multicast.reset();
}
@@ -1361,8 +1383,8 @@ void scenes::lobby::on_xr_event(const xr::event & event)
switch (event.header.type)
{
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED:
if (event.state_changed.state == XR_SESSION_STATE_FOCUSED)
autoconnect_enabled = true;
if (event.state_changed.state == XR_SESSION_STATE_STOPPING)
discover.reset();
recenter_gui = true;
break;
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING:
+5 -1
View File
@@ -31,6 +31,7 @@
#include "wivrn_config.h"
#include "wivrn_discover.h"
#include "xr/face_tracker.h"
#include "xr/foveation_profile.h"
#include <vulkan/vulkan_raii.hpp>
#include <openxr/openxr.h>
@@ -78,6 +79,8 @@ class lobby : public scene_impl<lobby>
xr::face_tracker face_tracker;
std::optional<xr::foveation_profile> foveation;
std::string selected_item;
std::unique_ptr<utils::mapped_file> license;
@@ -132,6 +135,8 @@ class lobby : public scene_impl<lobby>
tab last_current_tab = tab::server_list;
int optional_feature_index = 0; // Which step of the first run screen are we in
std::vector<wivrn::video_codec> supported_codecs;
ImTextureID about_picture;
virtual_keyboard keyboard;
@@ -219,7 +224,6 @@ class lobby : public scene_impl<lobby>
void gui_connecting(locked_notifiable<pin_request_data> & request);
void gui_enter_pin(locked_notifiable<pin_request_data> & request);
void gui_connected(XrTime predicted_display_time);
void gui_disconnected();
void gui_server_list();
void gui_new_server();
void gui_settings();
+43 -62
View File
@@ -249,51 +249,19 @@ void scenes::lobby::gui_enter_pin(locked_notifiable<pin_request_data> & pin_requ
void scenes::lobby::gui_connected(XrTime predicted_display_time)
{
assert(next_scene);
if (not next_scene)
{
current_tab = tab::server_list;
return;
}
if (next_scene->apps.draw_gui(*imgui_ctx, _("Disconnect")) == app_launcher::Cancel)
{
next_scene->exit();
next_scene.reset();
current_tab = tab::server_list;
}
}
void scenes::lobby::gui_disconnected()
{
using constants::style::button_size;
std::string close_button_label = _("Close");
if (!async_error)
{
async_error = next_scene->pop_stream_error();
if (!async_error)
{
next_scene.reset();
ImGui::CloseCurrentPopup();
return;
}
}
ImGui::Dummy({1000, 1});
ImGui::PushFont(nullptr, constants::gui::font_size_large);
if (server_name == "")
CenterTextH(fmt::format(_F("Disconnected")));
else
CenterTextH(fmt::format(_F("Disconnected from {}"), server_name));
ImGui::PopFont();
ImGui::Text("%s", async_error->c_str());
ImGui::SetCursorPosX(ImGui::GetWindowContentRegionMax().x - button_size.x - ImGui::GetStyle().WindowPadding.x);
if (ImGui::Button(close_button_label.c_str(), button_size))
{
async_error.reset();
}
imgui_ctx->vibrate_on_hover();
}
void scenes::lobby::gui_new_server()
{
using constants::style::button_size;
@@ -528,12 +496,8 @@ void scenes::lobby::gui_server_list()
config.save();
}
// Check if we need to report errors after a disconnect
if (next_scene and next_scene->current_state() == scenes::stream::state::shutdown and not ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup))
ImGui::OpenPopup("disconnected");
// Check if an automatic connection has started
if ((async_session.valid() || next_scene) and not ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup))
if ((async_session.valid() || next_scene) and not ImGui::IsPopupOpen("connecting"))
ImGui::OpenPopup("connecting");
const auto & popup_layer = imgui_ctx->layers()[1];
@@ -552,13 +516,6 @@ void scenes::lobby::gui_server_list()
ImGui::EndPopup();
}
ImGui::SetNextWindowPos({popup_layer_center.x, popup_layer_center.y}, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopupModal("disconnected", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize))
{
gui_disconnected();
ImGui::EndPopup();
}
ImGui::SetNextWindowSize({800, 0});
ImGui::SetNextWindowPos({popup_layer_center.x, popup_layer_center.y}, ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopupModal("add or edit server", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize))
@@ -619,10 +576,10 @@ void scenes::lobby::gui_settings()
const auto & refresh_rates = session.get_refresh_rates();
if (not refresh_rates.empty())
{
float active_rate = config.preferred_refresh_rate;
float active_rate = config.preferred_refresh_rate.value_or(refresh_rates.back());
if (ImGui::BeginCombo(_S("Refresh rate"), active_rate ? fmt::format("{}", active_rate).c_str() : _cS("automatic refresh rate", "Automatic")))
{
if (ImGui::Selectable(_cS("automatic refresh rate", "Automatic"), active_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
if (ImGui::Selectable(_cS("automatic refresh rate", "Automatic"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
{
session.set_refresh_rate(0);
config.preferred_refresh_rate = 0;
@@ -632,7 +589,7 @@ void scenes::lobby::gui_settings()
imgui_ctx->tooltip(_("Select refresh rate based on measured application performance.\nMay cause flicker when a change happens."));
for (float rate: refresh_rates)
{
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == active_rate, ImGuiSelectableFlags_SelectOnRelease))
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.preferred_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
{
session.set_refresh_rate(rate);
config.preferred_refresh_rate = rate;
@@ -643,7 +600,7 @@ void scenes::lobby::gui_settings()
}
imgui_ctx->vibrate_on_hover();
if (active_rate == 0 and refresh_rates.size() > 2)
if (config.preferred_refresh_rate == 0 and refresh_rates.size() > 2)
{
float min_rate = config.minimum_refresh_rate.value_or(refresh_rates.front());
if (ImGui::BeginCombo(_S("Minimum refresh rate"), fmt::format("{}", min_rate).c_str()))
@@ -663,6 +620,31 @@ void scenes::lobby::gui_settings()
}
}
if (foveation)
{
std::array<const char *, 4> foveation_levels = {
gettext_noop_context("Foveation level", "None"),
gettext_noop_context("Foveation level", "Low"),
gettext_noop_context("Foveation level", "Medium"),
gettext_noop_context("Foveation level", "High"),
};
if (ImGui::BeginCombo(_S("Foveation level"), _cS("Foveation level", foveation_levels[(int)foveation->level()])))
{
for (int level = 0; level < foveation_levels.size(); level++)
{
if (ImGui::Selectable(_cS("Foveation level", foveation_levels[level]), (int)foveation->level() == level))
{
foveation = xr::foveation_profile{instance, session, (XrFoveationLevelFB)level, -10, false};
// TODO save in configuration
}
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
}
// Render resolution
{
const auto current = config.resolution_scale;
@@ -691,7 +673,7 @@ void scenes::lobby::gui_settings()
// foveation
{
const int step = 5;
const int step = 10;
const auto current = config.get_stream_scale();
int intval = round((1 - current) * 100 / step);
const auto slider = ImGui::SliderInt(
@@ -747,7 +729,7 @@ void scenes::lobby::gui_settings()
config.codec = std::nullopt;
config.save();
}
for (auto codec: decoder::supported_codecs())
for (auto codec: supported_codecs)
{
// don't show raw in GUI
if (codec == wivrn::raw)
@@ -779,19 +761,18 @@ void scenes::lobby::gui_settings()
// Bitrate
{
const int step = 5;
const int mb = 1'000'000;
const auto current = config.bitrate_bps;
auto val = int(current / mb / step);
auto val = int(current / mb);
const auto slider = ImGui::SliderInt(
_("Bitrate").append("##bitrate").c_str(),
&val,
1,
config.max_bitrate() / mb / step,
fmt::format(_F("{}Mbit/s"), val * step).c_str());
config.max_bitrate() / mb,
fmt::format(_F("{}Mbit/s"), val).c_str());
if (slider)
{
config.bitrate_bps = val * mb * step;
config.bitrate_bps = val * mb;
config.save();
}
imgui_ctx->vibrate_on_hover();
@@ -1052,7 +1033,7 @@ void scenes::lobby::gui_debug_node_hierarchy(entt::entity root)
primitive.vertex_count,
primitive.material_->name,
primitive.vertex_shader,
primitive.material_->fragment_shader);
primitive.material_->fragment_shader_name);
imgui_ctx->tooltip(tooltip);
}
+1
View File
@@ -283,6 +283,7 @@ void scenes::lobby::update_file_picker()
vk::Format::eD32Sfloat, // Depth format
output, // Output image
vk::Image{}, // Depth image
vk::Image{}, // Foveation image
{&frame, 1}, // View info
false);
local_renderer.end_frame();
+1 -1
View File
@@ -199,7 +199,7 @@ virtual_keyboard::layout symbols = {
}, // 12
{
{1.5},
{1, "."},
{1}, // {1, "", ImGuiKey_None, "1/2", virtual_keyboard::key_flag_hidden},
{1, "\""},
{1, "<"},
{1, ">"},
+114 -149
View File
@@ -34,8 +34,8 @@
#include "boost/pfr/core.hpp"
#include "decoder/shard_accumulator.h"
#include "hardware.h"
#include "inplace_vector.hpp"
#include "spdlog/spdlog.h"
#include "utils/contains.h"
#include "utils/named_thread.h"
#include "utils/ranges.h"
#include "wivrn_packets.h"
@@ -51,7 +51,6 @@
#endif
using namespace wivrn;
using namespace beman::inplace_vector;
// clang-format off
static const std::unordered_map<std::string, device_id> device_ids = {
@@ -232,8 +231,20 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (self->instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
info.available_refresh_rates = self->session.get_refresh_rates();
info.settings.preferred_refresh_rate = config.preferred_refresh_rate;
info.settings.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
// I can't find anything in specification the ensures it won't be empty
if (not info.available_refresh_rates.empty())
{
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(info.available_refresh_rates, *config.preferred_refresh_rate)))
{
info.settings.preferred_refresh_rate = *config.preferred_refresh_rate;
info.settings.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
}
else
{
// Default to highest refresh rate
info.settings.preferred_refresh_rate = info.available_refresh_rates.back();
}
}
}
if (info.available_refresh_rates.empty())
@@ -248,11 +259,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
info.hand_tracking = config.check_feature(feature::hand_tracking);
info.eye_gaze = config.check_feature(feature::eye_gaze);
if (self->instance.has_extension(XR_EXT_USER_PRESENCE_EXTENSION_NAME))
{
info.user_presence = self->system.user_presence_properties().supportsUserPresence;
}
if (config.check_feature(feature::face_tracking))
{
switch (self->system.face_tracker_supported())
@@ -322,9 +328,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
self->network_session->send_control(from_headset::session_state_changed{
.state = application::get_session_state(),
});
self->network_session->send_control(from_headset::stream_tab_changed{
.tab = self->gui_status,
});
if (self->instance.has_extension(XR_KHR_VISIBILITY_MASK_EXTENSION_NAME))
{
@@ -425,9 +428,7 @@ void scenes::stream::on_focused()
*this,
"assets://controllers/" + profile + "/profile.json",
layer_controllers,
layer_rays,
get_action("left_trigger").first,
get_action("right_trigger").first);
layer_rays);
spdlog::info("Loaded input profile {}", input->id);
@@ -471,23 +472,14 @@ void scenes::stream::on_focused()
device,
swapchain_format,
1800,
1200);
1000);
std::vector<imgui_context::viewport> vps{
{
.space = xr::spaces::world,
// Position and orientation are set at each frame
.size = {1.2, 0.6666},
.vp_origin = {0, 0},
.vp_size = {1800, 1000},
},
{
.space = xr::spaces::world,
.size = {1.2, 0.1333},
.vp_origin = {0, 1000},
.vp_size = {1800, 200},
.tooltip_viewport = true,
},
imgui_context::viewport vp{
.space = xr::spaces::world,
// Position and orientation are set at each frame
.size = {1.2, 0.6666},
.vp_origin = {0, 0},
.vp_size = {1800, 1000},
};
imgui_ctx.emplace(physical_device,
@@ -496,7 +488,7 @@ void scenes::stream::on_focused()
queue,
imgui_inputs,
std::move(swapchain_imgui),
std::move(vps),
std::vector{vp},
image_cache);
if (application::get_config().enable_stream_gui)
@@ -511,6 +503,9 @@ void scenes::stream::on_focused()
foveation_ok = get_action("foveation_ok").first;
foveation_cancel = get_action("foveation_cancel").first;
assert(video_stream_description);
std::unique_lock lock(decoder_mutex);
if (application::get_config().high_power_mode)
{
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT);
@@ -528,9 +523,9 @@ void scenes::stream::on_unfocused()
renderer->wait_idle(); // Must be before the scene data because the renderer uses its descriptor sets;
world.clear();
input.reset();
clear_swapchains();
left_hand.reset();
right_hand.reset();
apps.reset();
imgui_ctx.reset();
}
@@ -566,7 +561,7 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
if (state_ != state::streaming and not(decoders[0].empty() and decoders[1].empty()))
{
set_state(state::streaming);
state_ = state::streaming;
spdlog::info("Stream scene ready at t={}", instance.now());
}
}
@@ -592,7 +587,8 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
if (decoders.empty())
return {};
std::unique_lock lock(frames_mutex);
inplace_vector<shard_accumulator::blit_handle *, decoder_count> common_frames;
thread_local std::vector<shard_accumulator::blit_handle *> common_frames;
common_frames.clear();
const bool alpha = decoders[0].latest_frames[0] and decoders[0].latest_frames[0]->view_info.alpha;
for (size_t i = 0; i < view_count + alpha; ++i)
{
@@ -605,7 +601,7 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
else
{
// clang-format off
erase_if(common_frames,
std::erase_if(common_frames,
[this, i](auto & left)
{
return std::ranges::none_of(
@@ -618,7 +614,7 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
// clang-format on
}
}
std::array<std::shared_ptr<shard_accumulator::blit_handle>, decoder_count> result;
std::array<std::shared_ptr<shard_accumulator::blit_handle>, view_count + 1> result;
if (not common_frames.empty())
{
auto min = std::ranges::min_element(common_frames,
@@ -673,51 +669,28 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
std::shared_ptr<shard_accumulator::blit_handle> scenes::stream::accumulator_images::frame(uint64_t id) const
{
auto & frame = latest_frames[id % latest_frames.size()];
if (frame and frame->feedback.frame_index != id)
return nullptr;
return frame;
for (auto it = latest_frames.rbegin(); it != latest_frames.rend(); ++it)
{
if (not *it)
continue;
if ((*it)->feedback.frame_index != id)
continue;
return *it;
}
return nullptr;
}
void scenes::stream::update_gui_position(xr::spaces controller)
{
std::optional<std::pair<glm::vec3, glm::quat>> aim;
auto aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
switch (guess_model())
{
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico fails to find its controllers within view space, so use the head position in
// world space as a reference
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::world),
predicted_display_time);
auto head_position = application::locate_controller(application::space(xr::spaces::view),
application::space(xr::spaces::world),
predicted_display_time);
if (not aim || not head_position)
return;
aim->first = glm::conjugate(head_position->second) * (aim->first - head_position->first);
aim->second = glm::conjugate(head_position->second) * aim->second;
break;
}
default:
aim = application::locate_controller(
application::space(controller),
application::space(xr::spaces::view),
predicted_display_time);
if (not aim)
return;
break;
}
if (not aim)
return;
auto [offset_position, offset_orientation] = input->offset[controller];
@@ -762,44 +735,40 @@ void scenes::stream::update_gui_position(xr::spaces controller)
}
}
bool scenes::stream::is_interactable(stream_tab tab)
{
switch (tab)
{
case stream_tab::stats:
case stream_tab::settings:
case stream_tab::bitrate_settings:
case stream_tab::foveation_settings:
case stream_tab::applications:
case stream_tab::application_launcher:
return true;
case stream_tab::hidden:
case stream_tab::overlay_only:
case stream_tab::compact:
return false;
}
spdlog::warn("Invalid tab value {}", int(tab));
return false;
}
bool scenes::stream::is_gui_interactable() const
{
return is_interactable(gui_status);
switch (gui_status)
{
case gui_status::stats:
case gui_status::settings:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
case gui_status::applications:
case gui_status::application_launcher:
return true;
case gui_status::hidden:
case gui_status::overlay_only:
case gui_status::compact:
return false;
}
assert(false);
__builtin_unreachable();
}
void scenes::stream::render(const XrFrameState & frame_state)
{
if (state_ == state::shutdown)
if (exiting)
application::pop_scene();
display_time_phase = frame_state.predictedDisplayPeriod ? frame_state.predictedDisplayTime % frame_state.predictedDisplayPeriod : 0;
display_time_phase = frame_state.predictedDisplayTime % frame_state.predictedDisplayPeriod;
display_time_period = frame_state.predictedDisplayPeriod;
real_display_period = last_display_time ? frame_state.predictedDisplayTime - last_display_time : frame_state.predictedDisplayPeriod;
last_display_time = frame_state.predictedDisplayTime;
std::shared_lock lock(decoder_mutex);
if (not frame_state.shouldRender or (decoders[0].empty() and decoders[1].empty()) or state_ == state::shutdown)
if (not frame_state.shouldRender or (decoders[0].empty() and decoders[1].empty()))
{
// TODO: stop/restart video stream
session.begin_frame();
@@ -815,7 +784,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
.variant = application::get_messages_info().variant,
});
next_gui_status = stream_tab::hidden;
gui_status = stream::gui_status::hidden;
application::pop_scene();
}
@@ -879,7 +848,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
blit_handle->feedback.blitted = instance.now();
if (blit_handle->feedback.blitted - blit_handle->feedback.received_from_decoder > 1'000'000'000)
set_state(state::stalled);
state_ = stream::state::stalled;
++blit_handle->feedback.times_displayed;
blit_handle->feedback.displayed = frame_state.predictedDisplayTime;
@@ -947,7 +916,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
int32_t max_height = 0;
for (size_t i = 0; i < view_count; ++i)
{
extents[i] = stream_defoveator::defoveated_size(foveation[i]);
extents[i] = defoveator->defoveated_size(foveation[i]);
max_width = std::max(max_width, extents[i].width);
max_height = std::max(max_height, extents[i].height);
}
@@ -988,9 +957,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
vk::SubmitInfo submit_info;
submit_info.setCommandBuffers(*command_buffer);
inplace_vector<vk::Semaphore, decoder_count> semaphores;
inplace_vector<uint64_t, decoder_count> semaphore_vals;
inplace_vector<vk::PipelineStageFlags, decoder_count> wait_stages;
std::vector<vk::Semaphore> semaphores;
std::vector<uint64_t> semaphore_vals;
std::vector<vk::PipelineStageFlags> wait_stages;
for (auto b: current_blit_handles)
{
if (b and b->semaphore)
@@ -1015,6 +984,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
#endif
swapchain.release();
std::vector<XrCompositionLayerProjectionView> layer_view(view_count);
if (use_alpha)
session.enable_passthrough(system);
else
@@ -1023,7 +994,6 @@ void scenes::stream::render(const XrFrameState & frame_state)
render_start(use_alpha, frame_state.predictedDisplayTime);
// Add the layer with the streamed content
std::array<XrCompositionLayerProjectionView, view_count> layer_view;
for (uint32_t view = 0; view < view_count; view++)
{
layer_view[view] =
@@ -1045,23 +1015,23 @@ void scenes::stream::render(const XrFrameState & frame_state)
add_projection_layer(
XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
application::space(xr::spaces::world),
layer_view);
std::move(layer_view));
if (composition_layer_color_scale_bias_supported)
{
switch (gui_status)
{
case stream_tab::hidden:
case stream_tab::bitrate_settings:
case stream_tab::foveation_settings:
case stream_tab::compact:
case stream_tab::overlay_only:
case gui_status::hidden:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
case gui_status::compact:
case gui_status::overlay_only:
dimming = dimming - frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
break;
case stream_tab::stats:
case stream_tab::settings:
case stream_tab::applications:
case stream_tab::application_launcher:
case gui_status::stats:
case gui_status::settings:
case gui_status::applications:
case gui_status::application_launcher:
dimming = dimming + frame_state.predictedDisplayPeriod / (1e9 * constants::stream::fade_duration);
break;
}
@@ -1098,8 +1068,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
// Network operations may be blocking, do them once everything was submitted
{
// Keep a copy of the feedback packets as they can be modified if they're encrypted
inplace_vector<from_headset::feedback, decoder_count> feedbacks;
inplace_vector<serialization_packet, decoder_count> packets;
std::vector<from_headset::feedback> feedbacks;
std::vector<serialization_packet> packets;
feedbacks.reserve(current_blit_handles.size());
packets.reserve(current_blit_handles.size());
@@ -1142,14 +1112,23 @@ void scenes::stream::render(const XrFrameState & frame_state)
if (state_1.currentState and state_2.currentState and (state_1.changedSinceLastSync or state_2.changedSinceLastSync))
{
// Arbitraty transitions can happen from network commands
// Ensure we can't have a set of 2 non interactable states
if (is_gui_interactable())
next_gui_status = stream_tab::hidden;
else if (is_interactable(stored_gui_status))
next_gui_status = stored_gui_status;
else
next_gui_status = stream_tab::applications;
switch (gui_status)
{
case gui_status::hidden:
case gui_status::compact:
case gui_status::overlay_only:
gui_status = next_gui_status;
break;
case gui_status::stats:
case gui_status::settings:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
case gui_status::applications:
case gui_status::application_launcher:
gui_status = gui_status::hidden;
break;
}
}
}
@@ -1158,17 +1137,15 @@ void scenes::stream::render(const XrFrameState & frame_state)
void scenes::stream::exit()
{
state_ = state::shutdown;
exiting = true;
}
void scenes::stream::setup(const to_headset::video_stream_description & description)
{
session.set_refresh_rate(description.fps);
std::unique_lock lock(decoder_mutex);
if (video_stream_description == description)
return;
spdlog::info("Creating decoders, size {}x{}", description.width, description.height);
std::unique_lock lock(decoder_mutex);
video_stream_description = description;
for (const auto & [stream_index, item]: utils::enumerate(decoders))
@@ -1177,9 +1154,6 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, description, shared_from_this(), stream_index),
};
}
if (defoveator)
defoveator->reset_pipelines();
}
void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint32_t swapchain_height)
@@ -1201,11 +1175,14 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint
spdlog::info("Initializing reprojector");
vk::Extent2D extent = {(uint32_t)swapchain.width(), (uint32_t)swapchain.height()};
std::vector<vk::Image> swapchain_images;
for (auto & image: swapchain.images())
swapchain_images.push_back(image.image);
defoveator.emplace(
device,
physical_device,
swapchain.images(),
swapchain_images,
extent,
swapchain.format());
}
@@ -1285,18 +1262,6 @@ scene::meta & scenes::stream::get_meta_scene()
return m;
}
std::optional<std::string> scenes::stream::pop_stream_error()
{
auto queue = stream_error_queue.lock();
if (queue->empty())
return std::nullopt;
auto err = std::make_optional(queue->front());
queue->pop();
return err;
}
void scenes::stream::on_xr_event(const xr::event & event)
{
switch (event.header.type)
+27 -41
View File
@@ -32,7 +32,6 @@
#include "wivrn_packets.h"
#include "xr/space.h"
#include <mutex>
#include <queue>
#include <shared_mutex>
#include <thread>
#include <vulkan/vulkan_core.h>
@@ -46,8 +45,7 @@ public:
{
initializing,
streaming,
stalled,
shutdown,
stalled
};
static const size_t image_buffer_size = 3;
@@ -55,7 +53,6 @@ public:
private:
static const size_t view_count = 2;
static const size_t decoder_count = view_count + 1;
struct accumulator_images
{
@@ -71,14 +68,14 @@ private:
// for frames inside accumulator images
std::mutex frames_mutex;
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> common_frame(XrTime display_time);
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> common_frame(XrTime display_time);
std::unique_ptr<wivrn_session> network_session;
std::atomic<bool> exiting = false;
std::thread network_thread;
thread_safe<to_headset::tracking_control> tracking_control{};
std::array<std::atomic<interaction_profile>, 2> interaction_profiles; // left and right hand
std::atomic<bool> interaction_profile_changed = false;
std::atomic<XrTime> scheduled_derived_pose = 0; // Tracking thread will compute derived pose when time is reached
std::atomic<bool> recenter_requested = false;
std::atomic<bool> hid_forwarding = false;
std::atomic<XrDuration> display_time_phase = 0;
@@ -89,7 +86,7 @@ private:
std::shared_mutex decoder_mutex;
std::optional<to_headset::video_stream_description> video_stream_description;
std::array<accumulator_images, decoder_count> decoders; // Locked by decoder_mutex
std::array<accumulator_images, view_count + 1> decoders; // Locked by decoder_mutex
std::optional<stream_defoveator> defoveator;
@@ -105,16 +102,7 @@ private:
std::unordered_multimap<device_id, haptics_action> haptics_actions;
std::vector<std::tuple<device_id, XrAction, XrActionType>> input_actions;
std::atomic<state> state_ = state::initializing;
void set_state(state new_state)
{
state prev = state_;
if (prev == state::shutdown)
return;
state_.compare_exchange_strong(prev, new_state);
}
state state_ = state::initializing;
xr::swapchain swapchain;
@@ -131,28 +119,27 @@ private:
uint32_t height;
std::optional<imgui_context> imgui_ctx;
struct gui_toast
enum class gui_status
{
std::string content;
bool is_urgent = false;
hidden,
overlay_only,
compact,
stats,
settings,
bitrate_settings,
foveation_settings,
applications,
application_launcher,
};
static bool is_interactable(stream_tab);
bool is_gui_interactable() const;
// Tab currently being displayed
stream_tab gui_status = stream_tab::hidden;
// Tab that we will switch to if button is pressed
stream_tab stored_gui_status = stream_tab::applications;
// Tab that will be displayed on next render()
std::atomic<stream_tab> next_gui_status = stream_tab::hidden;
std::atomic<gui_status> gui_status = gui_status::hidden;
enum gui_status last_gui_status = gui_status::hidden;
enum gui_status next_gui_status = gui_status::applications;
XrTime gui_status_last_change;
float dimming = 0;
thread_safe<std::optional<gui_toast>> gui_toast;
std::atomic<XrTime> gui_status_last_change;
thread_safe<std::queue<std::string>> stream_error_queue;
XrAction plots_toggle_1 = XR_NULL_HANDLE;
XrAction plots_toggle_2 = XR_NULL_HANDLE;
XrAction recenter_left = XR_NULL_HANDLE;
@@ -175,7 +162,7 @@ private:
void update_gui_position(xr::spaces controller);
// Keep a reference to the resources needed to blit the images until vkWaitForFences
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> current_blit_handles;
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> current_blit_handles;
XrTime running_application_req = 0;
thread_safe<to_headset::running_applications> running_applications;
@@ -209,16 +196,13 @@ public:
void operator()(to_headset::pin_check_2 &&) {};
void operator()(to_headset::pin_check_4 &&) {};
void operator()(to_headset::handshake &&) {};
void operator()(to_headset::server_message &&);
void operator()(to_headset::video_stream_data_shard &&);
void operator()(to_headset::haptics &&);
void operator()(to_headset::timesync_query &&);
void operator()(to_headset::tracking_control &&);
void operator()(to_headset::feature_control &&);
void operator()(to_headset::audio_stream_description &&);
void operator()(to_headset::video_stream_description &&);
void operator()(to_headset::refresh_rate_change &&);
void operator()(to_headset::stream_tab_change &&);
void operator()(to_headset::application_list &&);
void operator()(to_headset::application_icon &&);
void operator()(to_headset::running_applications &&);
@@ -233,11 +217,14 @@ public:
return state_;
}
void exit();
bool alive() const
{
return !exiting;
}
void start_application(std::string appid);
static meta & get_meta_scene();
std::optional<std::string> pop_stream_error();
private:
void process_packets();
@@ -245,10 +232,10 @@ private:
void read_actions();
void on_interaction_profile_changed(const XrEventDataInteractionProfileChanged &);
void send_derived_pose();
void setup(const to_headset::video_stream_description &);
void setup_reprojection_swapchain(uint32_t width, uint32_t height);
void exit();
vk::raii::QueryPool query_pool = nullptr;
bool query_pool_filled = false;
@@ -314,14 +301,13 @@ private:
float compact_cpu_time = 0;
float compact_gpu_time = 0;
void accumulate_metrics(XrTime predicted_display_time, const std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> & blit_handles, const gpu_timestamps & timestamps);
void accumulate_metrics(XrTime predicted_display_time, const std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> & blit_handles, const gpu_timestamps & timestamps);
void gui_performance_metrics();
void gui_compact_view();
void gui_settings(float predicted_display_period);
void gui_bitrate_settings(float predicted_display_period);
void gui_foveation_settings(float predicted_display_period);
void gui_applications();
void gui_toasts();
void draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period);
};
} // namespace scenes
+1 -9
View File
@@ -283,14 +283,6 @@ stream_defoveator::stream_defoveator(
}
}
void stream_defoveator::reset_pipelines()
{
for (auto & p: pipeline_rgb)
p = {};
for (auto & p: pipeline_a)
p = {};
}
static size_t required_vertices(const wivrn::to_headset::foveation_parameter & p)
{
// strips are constructed like this:
@@ -451,7 +443,7 @@ static uint16_t count_pixels(const std::vector<uint16_t> & param)
return res;
}
XrExtent2Di stream_defoveator::defoveated_size(const wivrn::to_headset::foveation_parameter & view)
XrExtent2Di stream_defoveator::defoveated_size(const wivrn::to_headset::foveation_parameter & view) const
{
return {
count_pixels(view.x),
+1 -3
View File
@@ -81,13 +81,11 @@ public:
stream_defoveator(const stream_defoveator &) = delete;
void reset_pipelines();
void defoveate(
vk::raii::CommandBuffer & command_buffer,
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
const std::array<input, 2> & inputs,
int destination);
static XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &);
XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &) const;
};
+171 -186
View File
@@ -26,13 +26,12 @@
#include "imgui.h"
#include "imgui_internal.h"
#include "implot.h"
#include "utils/contains.h"
#include "utils/i18n.h"
#include "utils/ranges.h"
#include <IconsFontAwesome6.h>
#include <chrono>
#include <cmath>
#include <glm/ext.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <limits>
#include <ranges>
@@ -339,10 +338,13 @@ void scenes::stream::gui_performance_metrics()
ImPlot::PopStyleColor(5);
{
ImGui::TextUnformatted(
ImGui::Text(
"%s",
fmt::format(
_F("Estimated motion to photons latency: {}ms"),
tracking_control.lock()->motions_to_photons / 1'000'000)
std::chrono::duration_cast<std::chrono::milliseconds>(
tracking_control.lock()->max_offset)
.count())
.c_str());
if (is_gui_interactable())
@@ -371,7 +373,10 @@ void scenes::stream::gui_compact_view()
f(_S("CPU time"), compact_cpu_time * 1000, "ms");
f(_S("GPU time"), compact_gpu_time * 1000, "ms");
f(_S("Motion to photon latency"),
tracking_control.lock()->motions_to_photons / 1'000'000.f,
std::chrono::duration_cast<std::chrono::microseconds>(
tracking_control.lock()->max_offset)
.count() *
1e-3f,
"ms");
ImGui::EndTable();
}
@@ -383,9 +388,9 @@ static void send_settings_changed_packet(xr::session & session, wivrn_session *
from_headset::settings_changed packet{
.bitrate_bps = config.bitrate_bps,
};
if (not refresh_rates.empty())
if (config.preferred_refresh_rate and (config.preferred_refresh_rate == 0 or utils::contains(refresh_rates, *config.preferred_refresh_rate)))
{
packet.preferred_refresh_rate = config.preferred_refresh_rate;
packet.preferred_refresh_rate = *config.preferred_refresh_rate;
packet.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
}
else
@@ -408,11 +413,12 @@ void scenes::stream::gui_settings(float predicted_display_period)
const auto & refresh_rates = session.get_refresh_rates();
if (not refresh_rates.empty())
{
float active_rate = config.preferred_refresh_rate;
float active_rate = config.preferred_refresh_rate.value_or(refresh_rates.back());
if (ImGui::BeginCombo(_S("Refresh rate"), active_rate ? fmt::format("{}", active_rate).c_str() : _cS("automatic refresh rate", "Automatic")))
{
if (ImGui::Selectable(_cS("automatic refresh rate", "Automatic"), active_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
if (ImGui::Selectable(_cS("automatic refresh rate", "Automatic"), config.preferred_refresh_rate == 0, ImGuiSelectableFlags_SelectOnRelease))
{
session.set_refresh_rate(0);
config.preferred_refresh_rate = 0;
send_settings_changed_packet(session, network_session.get(), config, predicted_display_period);
config.save();
@@ -421,7 +427,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
imgui_ctx->tooltip(_("Select refresh rate based on measured application performance.\nMay cause flicker when a change happens."));
for (float rate: refresh_rates)
{
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == active_rate, ImGuiSelectableFlags_SelectOnRelease))
if (ImGui::Selectable(fmt::format("{}", rate).c_str(), rate == config.preferred_refresh_rate, ImGuiSelectableFlags_SelectOnRelease))
{
session.set_refresh_rate(rate);
config.preferred_refresh_rate = rate;
@@ -433,7 +439,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
}
imgui_ctx->vibrate_on_hover();
if (active_rate == 0 and refresh_rates.size() > 2)
if (config.preferred_refresh_rate == 0 and refresh_rates.size() > 2)
{
float min_rate = config.minimum_refresh_rate.value_or(refresh_rates.front());
if (ImGui::BeginCombo(_S("Minimum refresh rate"), fmt::format("{}", min_rate).c_str()))
@@ -462,7 +468,7 @@ void scenes::stream::gui_settings(float predicted_display_period)
ImGui::SameLine(0.f, 10.f);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (size.y / 4.f) - style.FramePadding.y * 3.f);
if (ImGui::Button(fmt::format("{}Mbit/s", config.bitrate_bps / 1'000'000).c_str()))
next_gui_status = stream_tab::bitrate_settings;
gui_status = gui_status::bitrate_settings;
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Click to adjust bitrate"));
@@ -525,58 +531,58 @@ void scenes::stream::gui_settings(float predicted_display_period)
}
}
ImGui::Unindent();
}
bool send_packet = false;
bool save_config = false;
ImGui::Text("%s", _S("Foveation center override"));
ImGui::Indent();
{
if (ImGui::Checkbox(_S("Enable"), &override_foveation_enable))
bool send_packet = false;
bool save_config = false;
ImGui::Text("%s", _S("Foveation center override"));
ImGui::Indent();
{
send_packet = true;
save_config = true;
}
imgui_ctx->vibrate_on_hover();
if (ImGui::Checkbox(_S("Enable"), &override_foveation_enable))
{
send_packet = true;
save_config = true;
}
imgui_ctx->vibrate_on_hover();
ImGui::BeginDisabled(!override_foveation_enable);
ImGui::Text("%s", fmt::format(_F("Height {:.1f} deg"), -override_foveation_pitch * 180 / M_PI).c_str());
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override_foveation_distance).c_str());
if (ImGui::Button(_S("Default")))
ImGui::BeginDisabled(!override_foveation_enable);
ImGui::Text("%s", fmt::format(_F("Height {:.1f} deg"), -override_foveation_pitch * 180 / M_PI).c_str());
ImGui::Text("%s", fmt::format(_F("Distance {:.2f} m"), override_foveation_distance).c_str());
if (ImGui::Button(_S("Default")))
{
override_foveation_distance = configuration{}.override_foveation_distance;
override_foveation_pitch = configuration{}.override_foveation_pitch;
send_packet = true;
save_config = true;
}
imgui_ctx->vibrate_on_hover();
ImGui::SameLine();
if (ImGui::Button(_S("Change")))
gui_status = gui_status::foveation_settings;
imgui_ctx->vibrate_on_hover();
ImGui::EndDisabled();
}
ImGui::Unindent();
if (send_packet)
{
override_foveation_distance = configuration{}.override_foveation_distance;
override_foveation_pitch = configuration{}.override_foveation_pitch;
send_packet = true;
save_config = true;
network_session->send_control(from_headset::override_foveation_center{
.enabled = override_foveation_enable,
.pitch = override_foveation_pitch,
.distance = override_foveation_distance,
});
}
imgui_ctx->vibrate_on_hover();
ImGui::SameLine();
if (ImGui::Button(_S("Change")))
next_gui_status = stream_tab::foveation_settings;
imgui_ctx->vibrate_on_hover();
ImGui::EndDisabled();
}
ImGui::Unindent();
if (send_packet)
{
network_session->send_control(from_headset::override_foveation_center{
.enabled = override_foveation_enable,
.pitch = override_foveation_pitch,
.distance = override_foveation_distance,
});
}
if (save_config)
{
auto & config = application::get_config();
config.override_foveation_enable = override_foveation_enable;
config.override_foveation_pitch = override_foveation_pitch;
config.override_foveation_distance = override_foveation_distance;
config.save();
if (save_config)
{
auto & config = application::get_config();
config.override_foveation_enable = override_foveation_enable;
config.override_foveation_pitch = override_foveation_pitch;
config.override_foveation_distance = override_foveation_distance;
config.save();
}
}
ImGui::PopStyleVar();
}
@@ -600,7 +606,7 @@ void scenes::stream::gui_bitrate_settings(float predicted_display_period)
if (ok)
{
config.save();
next_gui_status = stream_tab::settings;
gui_status = gui_status::settings;
}
send_settings_changed_packet(session, network_session.get(), application::get_config(), predicted_display_period);
@@ -629,7 +635,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
if (ok)
{
next_gui_status = stream_tab::settings;
gui_status = gui_status::settings;
// Save settings
auto & config = application::get_config();
@@ -640,7 +646,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
}
else if (cancel)
{
next_gui_status = stream_tab::settings;
gui_status = gui_status::settings;
// Restore settings
const auto & config = application::get_config();
@@ -729,26 +735,70 @@ void scenes::stream::gui_applications()
ImGui::PopStyleVar(3);
}
void scenes::stream::gui_toasts()
// Return the vector v such that dot(v, x) > 0 iff x is on the side where the composition layer is visible
static glm::vec4 compute_ray_limits(const XrPosef & pose, float margin = 0)
{
auto toast = gui_toast.lock();
glm::quat q{
pose.orientation.w,
pose.orientation.x,
pose.orientation.y,
pose.orientation.z,
};
if (!toast->has_value())
{
ImGui::Text("%s", _S("Press both thumbsticks to display the WiVRn window"));
return;
}
glm::vec3 p{
pose.position.x,
pose.position.y,
pose.position.z,
};
ImGui::Text("%s", (*toast)->content.c_str());
glm::vec3 normal = glm::column(glm::mat3_cast(q), 2);
return glm::vec4(normal, -glm::dot(p, normal) - margin);
}
void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicted_display_period)
{
if (auto new_status = next_gui_status.load(); new_status != gui_status)
if (not(plots_toggle_1 and plots_toggle_2))
return;
bool interactable = true;
XrSpace world_space = application::space(xr::spaces::world);
auto views = session.locate_views(viewconfig, predicted_display_time, world_space).second;
switch (gui_status)
{
spdlog::info("Switch tab from {} to {}", magic_enum::enum_name(gui_status), magic_enum::enum_name(new_status));
stored_gui_status = gui_status;
gui_status = new_status;
case gui_status::hidden:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
case gui_status::overlay_only:
case gui_status::compact:
interactable = false;
break;
case gui_status::stats:
case gui_status::settings:
case gui_status::applications:
case gui_status::application_launcher:
break;
}
imgui_ctx->set_controllers_enabled(interactable);
if (interactable)
{
if (system.hand_tracking_supported())
{
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
}
}
else
{
left_hand.reset();
right_hand.reset();
}
if (gui_status != last_gui_status)
{
last_gui_status = gui_status;
if (is_gui_interactable())
next_gui_status = gui_status;
gui_status_last_change = predicted_display_time;
// Override session state if the GUI is interactable
@@ -760,64 +810,17 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
network_session->send_control(from_headset::session_state_changed{
.state = XR_SESSION_STATE_VISIBLE,
});
network_session->send_control(from_headset::stream_tab_changed{.tab = new_status});
}
bool interactable = true;
XrSpace world_space = application::space(xr::spaces::world);
auto views = session.locate_views(viewconfig, predicted_display_time, world_space).second;
switch (gui_status)
{
case stream_tab::hidden:
case stream_tab::bitrate_settings:
case stream_tab::foveation_settings:
case stream_tab::overlay_only:
case stream_tab::compact:
interactable = false;
break;
case stream_tab::stats:
case stream_tab::settings:
case stream_tab::applications:
case stream_tab::application_launcher:
break;
}
imgui_ctx->set_controllers_enabled(interactable);
if (interactable)
{
if (system.hand_tracking_supported())
{
if (not left_hand)
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
if (not right_hand)
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
}
}
else
{
left_hand.reset();
right_hand.reset();
}
float alpha = 1;
bool is_urgent = false;
if (gui_status == stream_tab::hidden)
if (gui_status == gui_status::hidden)
{
auto toast = gui_toast.lock();
if (toast->has_value())
is_urgent = (*toast)->is_urgent;
float t = (predicted_display_time - gui_status_last_change) * 1.e-9f;
float delay = is_urgent ? constants::stream::urgent_fade_delay : constants::stream::fade_delay;
alpha = std::clamp<float>(1 - (t - delay) / constants::stream::fade_duration, 0, 1);
alpha = std::clamp<float>(1 - (t - constants::stream::fade_delay) / constants::stream::fade_duration, 0, 1);
if (alpha == 0)
{
toast->reset();
return;
}
}
// Lock the GUI position to the head, do it before displaying the GUI to avoid being off by one frame when gui_status changes
@@ -827,24 +830,24 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
glm::mat3 M = glm::mat3_cast(head_position->second);
switch (gui_status)
{
case stream_tab::bitrate_settings:
case stream_tab::foveation_settings:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
imgui_ctx->layers()[0].orientation = head_position->second;
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0, -override_foveation_distance * sin(override_foveation_pitch), -override_foveation_distance};
break;
case stream_tab::hidden:
case gui_status::hidden:
// Always use the same position for the GUI shortcut tip
imgui_ctx->layers()[0].orientation = head_position->second;
imgui_ctx->layers()[0].position = head_position->first + M * glm::vec3{0.0, -0.4, -1.0};
break;
case stream_tab::overlay_only:
case stream_tab::compact:
case stream_tab::stats:
case stream_tab::settings:
case stream_tab::applications:
case stream_tab::application_launcher:
case gui_status::overlay_only:
case gui_status::compact:
case gui_status::stats:
case gui_status::settings:
case gui_status::applications:
case gui_status::application_launcher:
imgui_ctx->layers()[0].orientation = head_position->second * head_gui_orientation;
imgui_ctx->layers()[0].position = head_position->first + M * head_gui_position;
break;
@@ -857,56 +860,49 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
const ImGuiStyle & style = ImGui::GetStyle();
imgui_ctx->new_frame(predicted_display_time);
ImVec2 viewport_size(imgui_ctx->layers()[0].vp_size.x, imgui_ctx->layers()[0].vp_size.y);
ImVec2 content_size{viewport_size - ImVec2{tab_width, 0} - margin_around_window * 2};
ImVec2 content_size{ImGui::GetMainViewport()->Size - ImVec2{tab_width, 0} - margin_around_window * 2};
ImVec2 content_center = margin_around_window + content_size / 2 + ImVec2{tab_width, 0};
bool display_tabs, always_auto_resize;
switch (gui_status)
{
case stream_tab::overlay_only:
case gui_status::overlay_only:
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::SetNextWindowSize(content_size);
always_auto_resize = false;
display_tabs = false;
break;
case stream_tab::hidden:
case stream_tab::bitrate_settings:
case stream_tab::foveation_settings:
ImGui::SetNextWindowPos(viewport_size / 2, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
case gui_status::hidden:
case gui_status::bitrate_settings:
case gui_status::foveation_settings:
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->Size / 2, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
always_auto_resize = true;
display_tabs = false;
break;
case stream_tab::compact:
case gui_status::compact:
ImGui::SetNextWindowPos(content_center, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
always_auto_resize = true;
display_tabs = false;
break;
case stream_tab::stats:
case stream_tab::settings:
case stream_tab::applications:
case gui_status::stats:
case gui_status::settings:
case gui_status::applications:
ImGui::SetNextWindowPos(margin_around_window);
ImGui::SetNextWindowSize(viewport_size - margin_around_window * 2);
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - margin_around_window * 2);
always_auto_resize = false;
display_tabs = true;
break;
case stream_tab::application_launcher:
case gui_status::application_launcher:
ImGui::SetNextWindowPos(margin_around_window);
ImGui::SetNextWindowSize(viewport_size - margin_around_window * 2);
ImGui::SetNextWindowSize(ImGui::GetMainViewport()->Size - margin_around_window * 2);
always_auto_resize = false;
display_tabs = false;
break;
}
if (is_urgent)
{
ImGui::PushStyleColor(ImGuiCol_Border, constants::stream::urgent_border_color);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 4);
}
ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0);
if (always_auto_resize)
{
@@ -919,64 +915,58 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
ImGui::Begin("Stream settings", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
}
if (is_urgent)
{
ImGui::PopStyleColor(1);
ImGui::PopStyleVar(1);
}
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, {8, 8});
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10);
switch (gui_status)
{
case stream_tab::hidden:
gui_toasts();
case gui_status::hidden:
ImGui::Text("%s", _S("Press both thumbsticks to display the WiVRn window"));
break;
case stream_tab::overlay_only:
case gui_status::overlay_only:
ImGui::SetCursorPos({20, 20});
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
gui_performance_metrics();
ImGui::EndChild();
break;
case stream_tab::compact:
case gui_status::compact:
gui_compact_view();
break;
case stream_tab::stats:
case gui_status::stats:
ImGui::SetCursorPos({tab_width + 20, 20});
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
gui_performance_metrics();
ImGui::EndChild();
break;
case stream_tab::settings:
case gui_status::settings:
ImGui::SetCursorPos({tab_width + 20, 20});
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
gui_settings(predicted_display_period * 1.e-9f);
ImGui::EndChild();
break;
case stream_tab::bitrate_settings:
case gui_status::bitrate_settings:
gui_bitrate_settings(predicted_display_period * 1.e-9f);
break;
case stream_tab::foveation_settings:
case gui_status::foveation_settings:
gui_foveation_settings(predicted_display_period * 1.e-9f);
break;
case stream_tab::applications:
case gui_status::applications:
ImGui::SetCursorPos({tab_width + 20, 20});
ImGui::BeginChild("Main", ImVec2(ImGui::GetWindowSize().x - ImGui::GetCursorPosX(), 0));
gui_applications();
ImGui::EndChild();
break;
case stream_tab::application_launcher:
case gui_status::application_launcher:
if (apps.draw_gui(*imgui_ctx, _("Cancel")) != app_launcher::None)
next_gui_status = stream_tab::applications;
gui_status = gui_status::applications;
}
ImGui::PopStyleVar(2); // ImGuiStyleVar_WindowPadding, ImGuiStyleVar_FrameRounding
@@ -990,13 +980,11 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
auto target = next_gui_status.load();
RadioButtonWithoutCheckBox(ICON_FA_LIST " " + _("Applications"), target, stream_tab::applications, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_LIST " " + _("Applications"), gui_status, gui_status::applications, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
if (RadioButtonWithoutCheckBox(ICON_FA_ROCKET " " + _("Start"), target, stream_tab::application_launcher, {tab_width, 0}))
if (RadioButtonWithoutCheckBox(ICON_FA_ROCKET " " + _("Start"), gui_status, gui_status::application_launcher, {tab_width, 0}))
{
apps.reset();
network_session->send_control(from_headset::get_application_list{
.language = application::get_messages_info().language,
.country = application::get_messages_info().country,
@@ -1005,22 +993,22 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
}
imgui_ctx->vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), target, stream_tab::settings, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_GEARS " " + _("Settings"), gui_status, gui_status::settings, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), target, stream_tab::stats, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_COMPUTER " " + _("Stats"), gui_status, gui_status::stats, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
int n_items_at_end = 4;
ImGui::SetCursorPosY(ImGui::GetContentRegionMax().y - n_items_at_end * ImGui::GetCurrentContext()->FontSize - (n_items_at_end * 2) * style.FramePadding.y - (n_items_at_end - 1) * style.ItemSpacing.y - style.WindowPadding.y);
RadioButtonWithoutCheckBox(ICON_FA_CHART_LINE " " + _("Statistics overlay"), target, stream_tab::overlay_only, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_CHART_LINE " " + _("Statistics overlay"), gui_status, gui_status::overlay_only, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_MINIMIZE " " + _("Compact view"), target, stream_tab::compact, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_MINIMIZE " " + _("Compact view"), gui_status, gui_status::compact, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
RadioButtonWithoutCheckBox(ICON_FA_XMARK " " + _("Close"), target, stream_tab::hidden, {tab_width, 0});
RadioButtonWithoutCheckBox(ICON_FA_XMARK " " + _("Close"), gui_status, gui_status::hidden, {tab_width, 0});
imgui_ctx->vibrate_on_hover();
bool dummy = false;
@@ -1030,7 +1018,6 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
ImGui::PopStyleVar(); // ImGuiStyleVar_FramePadding
ImGui::EndChild();
next_gui_status = target;
}
ImGui::PopStyleColor(); // ImGuiCol_ChildBg
}
@@ -1071,12 +1058,10 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
else
recentering_context.reset();
std::vector<glm::mat4> world_to_window;
for (auto & window: imgui_ctx->windows())
{
if (window.space == xr::spaces::world)
world_to_window.push_back(glm::inverse(glm::translate(window.position) * glm::mat4(glm::mat3_cast(window.orientation)) * glm::scale(glm::vec3(window.size, 1))));
}
std::vector<glm::vec4> ray_limits;
for (auto [_, layer]: layers)
ray_limits.push_back(compute_ray_limits(layer.pose));
bool hide_left_controller = false;
bool hide_right_controller = false;
@@ -1100,7 +1085,7 @@ void scenes::stream::draw_gui(XrTime predicted_display_time, XrDuration predicte
hide_left_controller,
hide_right_controller,
hide_right_controller,
world_to_window);
ray_limits);
// Add the layer with the controllers
if (composition_layer_depth_test_supported)
+1 -41
View File
@@ -33,7 +33,7 @@ void scenes::stream::process_packets()
#ifdef __ANDROID__
application::instance().setup_jni();
#endif
while (state_ != state::shutdown)
while (not exiting)
{
try
{
@@ -47,28 +47,6 @@ void scenes::stream::process_packets()
}
}
void scenes::stream::operator()(to_headset::server_message && message)
{
switch (message.kind)
{
case to_headset::server_message::kind::toast:
case to_headset::server_message::kind::toast_urgent: {
auto toast = gui_toast.lock();
toast->emplace(message.msg, message.kind == to_headset::server_message::kind::toast_urgent);
gui_status_last_change = instance.now();
break;
}
case to_headset::server_message::kind::error: {
auto queue = stream_error_queue.lock();
queue->emplace(std::move(message.msg));
break;
}
}
}
void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
{
std::shared_lock lock(decoder_mutex);
@@ -81,19 +59,6 @@ void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
decoders[idx].decoder->push_shard(std::move(shard));
}
void scenes::stream::operator()(to_headset::feature_control && control)
{
switch (control.f)
{
case wivrn::to_headset::feature_control::hid_input:
hid_forwarding = control.state;
return;
case wivrn::to_headset::feature_control::microphone:
if (audio_handle)
audio_handle->set_mic_state(control.state);
return;
}
}
void scenes::stream::operator()(to_headset::audio_stream_description && desc)
{
audio_handle.emplace(desc, *network_session, instance);
@@ -117,11 +82,6 @@ void scenes::stream::operator()(to_headset::refresh_rate_change && rate)
video_stream_description->fps = rate.fps;
}
void scenes::stream::operator()(to_headset::stream_tab_change && tab)
{
next_gui_status = tab.tab;
}
void scenes::stream::operator()(to_headset::timesync_query && query)
{
network_session->send_stream(from_headset::timesync_response{
+281 -259
View File
@@ -26,7 +26,6 @@
#include "xr/fb_body_tracker.h"
#include "xr/to_string.h"
#include <magic_enum.hpp>
#include <magic_enum_containers.hpp>
#include <ranges>
#include <spdlog/spdlog.h>
#include <thread>
@@ -35,6 +34,11 @@
#include "android/battery.h"
#endif
using tid = to_headset::tracking_control::id;
static const XrDuration min_tracking_period = 2'000'000;
static const XrDuration max_tracking_period = 5'000'000;
static uint8_t cast_flags(XrSpaceLocationFlags location, XrSpaceVelocityFlags velocity)
{
uint8_t flags = 0;
@@ -61,6 +65,19 @@ static uint8_t cast_flags(XrSpaceLocationFlags location, XrSpaceVelocityFlags ve
namespace
{
class timer
{
xr::instance & instance;
XrTime start = instance.now();
public:
timer(xr::instance & instance) :
instance(instance) {}
XrDuration count()
{
return instance.now() - start;
}
};
from_headset::tracking::pose locate_space(device_id device, XrSpace space, XrSpace reference, XrTime time)
{
@@ -84,7 +101,7 @@ from_headset::tracking::pose locate_space(device_id device, XrSpace space, XrSpa
.flags = cast_flags(location.locationFlags, velocity.velocityFlags),
};
spdlog::warn("xrLocateSpace failed for {}: {}", magic_enum::enum_name(device), xr::to_string(res));
return {.device = device};
return {};
}
class locate_spaces_functor
@@ -131,8 +148,6 @@ public:
std::vector<from_headset::tracking::pose> & out)
{
assert(devices.size() == spaces.size());
if (devices.empty())
return;
if (locate_spaces)
{
locations.resize(spaces.size());
@@ -192,8 +207,7 @@ static std::optional<std::array<from_headset::hand_tracking::pose, XR_HAND_JOINT
for (int i = 0; i < XR_HAND_JOINT_COUNT_EXT; i++)
{
poses[i] = {
.position = (*joints)[i].first.pose.position,
.orientation = pack((*joints)[i].first.pose.orientation),
.pose = (*joints)[i].first.pose,
.linear_velocity = (*joints)[i].second.linearVelocity,
.angular_velocity = (*joints)[i].second.angularVelocity,
.radius = uint16_t((*joints)[i].first.radius * 10'000),
@@ -278,9 +292,7 @@ void scenes::stream::tracking()
const XrDuration battery_check_interval = 30'000'000'000; // 30s
#endif
magic_enum::containers::array<device_id, XrSpace> spaces{};
const auto & config = application::get_config();
std::vector<std::pair<device_id, XrSpace>> spaces;
{
std::vector ids{
@@ -298,27 +310,80 @@ void scenes::stream::tracking()
ids.insert(ids.end(), {device_id::LEFT_PINCH_POSE, device_id::LEFT_POKE, device_id::RIGHT_PINCH_POSE, device_id::RIGHT_POKE});
}
if (config.check_feature(feature::eye_gaze))
ids.emplace_back(device_id::EYE_GAZE);
for (auto id: ids)
{
if (XrSpace space = application::space(device_to_space(id)))
spaces[id] = space;
spaces.emplace_back(id, space);
else
spdlog::warn("Missing space for device {}", magic_enum::enum_name(id));
}
}
auto enabled = [&](const to_headset::tracking_control & control, device_id id) -> bool {
if (is_gui_interactable())
{
switch (id)
{
case device_id::HEAD:
case device_id::EYE_GAZE:
return true;
default:
return false;
}
}
switch (id)
{
case device_id::HEAD:
case device_id::EYE_GAZE:
return true;
case device_id::LEFT_AIM:
return control.enabled[size_t(tid::left_aim)];
case device_id::LEFT_GRIP:
return control.enabled[size_t(tid::left_grip)];
case device_id::LEFT_PALM:
return control.enabled[size_t(tid::left_palm)];
case device_id::LEFT_PINCH_POSE:
return control.enabled[size_t(tid::left_pinch)];
case device_id::LEFT_POKE:
return control.enabled[size_t(tid::left_poke)];
case device_id::RIGHT_AIM:
return control.enabled[size_t(tid::right_aim)];
case device_id::RIGHT_GRIP:
return control.enabled[size_t(tid::right_grip)];
case device_id::RIGHT_PALM:
return control.enabled[size_t(tid::right_palm)];
case device_id::RIGHT_PINCH_POSE:
return control.enabled[size_t(tid::right_pinch)];
case device_id::RIGHT_POKE:
return control.enabled[size_t(tid::right_poke)];
default:
break;
}
throw std::runtime_error("enabled called on unhandled device " + std::string(magic_enum::enum_name(id)));
};
const auto & config = application::get_config();
if (config.check_feature(feature::eye_gaze))
spaces.push_back({device_id::EYE_GAZE, application::space(xr::spaces::eye_gaze)});
XrSpace view_space = application::space(xr::spaces::view);
XrSpace world_space = application::space(xr::spaces::world);
XrDuration tracking_period = min_tracking_period; // target period for 20% busy time
XrDuration current_tracking_period = tracking_period; // divider of frame period
int period_adjust = 0;
XrTime t0 = instance.now();
from_headset::tracking tracking;
XrTime last_hand_sample = t0;
XrTime last_body_sample = t0;
std::vector<from_headset::tracking> tracking;
std::vector<from_headset::tracking> tracking_pool; // pre-allocated objects
std::vector<from_headset::hand_tracking> hands;
std::vector<from_headset::body_tracking> body;
std::vector<XrView> views;
std::vector<from_headset::trackings> merged_tracking;
std::vector<serialization_packet> packets;
const bool hand_tracking = config.check_feature(feature::hand_tracking);
@@ -335,255 +400,173 @@ void scenes::stream::tracking()
on_interaction_profile_changed({});
decltype(to_headset::tracking_control::pattern) pattern;
size_t pattern_position = 0;
XrDuration frame_duration;
XrTime pattern_begin = instance.now();
while (state_ != state::shutdown)
while (not exiting)
{
try
{
if (pattern_position == pattern.size())
{
// Upper limit to 200FPS
frame_duration = std::max<XrDuration>(5'000'000, display_time_period);
// Wait for next frame
XrTime now = instance.now();
pattern_begin = display_time_phase + (std::max(pattern_begin + frame_duration, now) / frame_duration) * frame_duration;
std::this_thread::sleep_for(std::chrono::nanoseconds(pattern_begin - now));
pattern_position = 0;
// Check if a new pattern has been received
if (auto locked = tracking_control.lock(); pattern.empty() or not locked->pattern.empty())
{
pattern.clear();
std::swap(pattern, locked->pattern);
pattern_position = 0;
// Ensure head tracking is always done
if (not std::ranges::contains(pattern, device_id::HEAD, &to_headset::tracking_control::sample::device))
pattern.push_back({.device = device_id::HEAD});
if (hand_tracking)
{
if (std::ranges::contains(pattern, device_id::LEFT_HAND, &to_headset::tracking_control::sample::device))
{
if (not left_hand)
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
}
else
left_hand.reset();
if (std::ranges::contains(pattern, device_id::RIGHT_HAND, &to_headset::tracking_control::sample::device))
{
if (not right_hand)
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
}
else
right_hand.reset();
}
if (face_tracking)
{
if (std::ranges::contains(pattern, device_id::FACE, &to_headset::tracking_control::sample::device))
{
if (std::holds_alternative<std::monostate>(face_tracker))
face_tracker = xr::make_face_tracker(instance, system, session);
}
else
face_tracker.emplace<std::monostate>();
}
if (body_tracking)
{
if (std::ranges::contains(pattern, device_id::BODY, &to_headset::tracking_control::sample::device))
{
if (std::holds_alternative<std::monostate>(body_tracker))
body_tracker = xr::make_body_tracker(
instance,
system,
session,
application::get_generic_trackers(),
config.fb_lower_body,
config.fb_hip);
}
else
body_tracker.emplace<std::monostate>();
}
std::ranges::sort(pattern, std::less{}, [frame_duration](const auto & i) { return -i.prediction_ns % frame_duration; });
spdlog::info("Tracking pattern ({}µs):", frame_duration / 1'000);
for (const auto & [device, pred]: pattern)
{
spdlog::info("\tt+{}µs {} ({}µs)",
(frame_duration - (pred % frame_duration)) / 1'000,
magic_enum::enum_name(device),
pred / 1'000);
}
}
}
tracking.clear();
hands.clear();
body.clear();
XrTime now = instance.now();
XrTime t0 = pattern_begin + frame_duration - (pattern[pattern_position].prediction_ns % frame_duration);
if (t0 > now + 500)
if (now < t0)
std::this_thread::sleep_for(std::chrono::nanoseconds(t0 - now));
// If thread can't keep up, skip timestamps
t0 = std::max(t0, now);
timer t(instance);
int samples = 0;
auto control = *tracking_control.lock();
bool interaction_profile_changed = this->interaction_profile_changed.exchange(false);
if (control.enabled[size_t(tid::left_hand)])
{
if (not left_hand and system.hand_tracking_supported())
left_hand = session.create_hand_tracker(XR_HAND_LEFT_EXT);
}
else
left_hand.reset();
if (control.enabled[size_t(tid::right_hand)])
{
if (not right_hand and system.hand_tracking_supported())
right_hand = session.create_hand_tracker(XR_HAND_RIGHT_EXT);
}
else
right_hand.reset();
if (face_tracking and control.enabled[size_t(tid::face)])
{
if (std::holds_alternative<std::monostate>(face_tracker))
face_tracker = xr::make_face_tracker(instance, system, session);
}
else
face_tracker.emplace<std::monostate>();
if (body_tracking and control.enabled[size_t(tid::generic_tracker)])
{
if (std::holds_alternative<std::monostate>(body_tracker))
body_tracker = xr::make_body_tracker(
instance,
system,
session,
application::get_generic_trackers(),
config.fb_lower_body,
config.fb_hip);
}
else
body_tracker.emplace<std::monostate>();
if (interaction_profile_changed)
if (auto htc = std::get_if<xr::htc_body_tracker>(&body_tracker))
htc->update_active();
tracking.interaction_profiles = {
interaction_profiles[0].load(),
interaction_profiles[1].load(),
};
tracking.production_timestamp = t0;
tracking.timestamp = t0 + pattern[pattern_position].prediction_ns;
tracking.view_flags = {};
tracking.state_flags = {};
tracking.views = {};
tracking.device_poses.clear();
tracking.face = {};
if (recenter_requested.exchange(false))
tracking.state_flags = wivrn::from_headset::tracking::recentered;
try
XrDuration prediction = std::clamp<XrDuration>(control.max_offset.count(), 0, 80'000'000);
auto period = std::max<XrDuration>(display_time_period.load(), 1'000'000);
for (XrDuration Δt = display_time_phase - t0 % period + (control.min_offset.count() / period) * period;
Δt <= prediction + period / 2;
Δt += period, ++samples)
{
for (; pattern_position < pattern.size(); ++pattern_position)
auto & packet = from_pool(tracking, tracking_pool);
packet.production_timestamp = t0;
packet.timestamp = t0 + Δt;
try
{
const auto & item = pattern[pattern_position];
auto at_time = t0 + item.prediction_ns;
packet.view_flags = session.locate_views(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, t0 + Δt, view_space, views);
assert(views.size() == packet.views.size());
// Don't merge items that are too far from the current one
if (std::abs(tracking.timestamp - at_time) > 1'000'000)
break;
switch (item.device)
for (auto [i, j]: std::views::zip(views, packet.views))
{
case device_id::HEAD:
tracking.view_flags = session.locate_views(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, tracking.timestamp, view_space, views);
assert(views.size() == tracking.views.size());
for (auto [i, j]: std::views::zip(views, tracking.views))
{
j.pose = i.pose;
j.fov = i.fov;
}
locate_spaces.add_space(item.device, view_space, tracking.timestamp, tracking.device_poses);
break;
case wivrn::device_id::LEFT_GRIP:
case wivrn::device_id::LEFT_AIM:
case wivrn::device_id::LEFT_PALM:
case wivrn::device_id::RIGHT_GRIP:
case wivrn::device_id::RIGHT_AIM:
case wivrn::device_id::RIGHT_PALM:
case wivrn::device_id::LEFT_PINCH_POSE:
case wivrn::device_id::LEFT_POKE:
case wivrn::device_id::RIGHT_PINCH_POSE:
case wivrn::device_id::RIGHT_POKE:
locate_spaces.add_space(item.device, spaces[item.device], tracking.timestamp, tracking.device_poses);
break;
case wivrn::device_id::EYE_GAZE:
// Eye gaze uses view pose as the origin
switch (guess_model())
{
case model::pico_4_pro:
case model::pico_4_enterprise: {
// Pico headsets fail to locate gaze relative to view
auto gaze = locate_space(item.device, spaces[item.device], world_space, tracking.timestamp);
auto view_pose = locate_space(item.device, view_space, world_space, tracking.timestamp);
glm::quat gaze_quat(gaze.pose.orientation.w, gaze.pose.orientation.x, gaze.pose.orientation.y, gaze.pose.orientation.z);
glm::quat view_quat(view_pose.pose.orientation.w, view_pose.pose.orientation.x, view_pose.pose.orientation.y, view_pose.pose.orientation.z);
gaze_quat = glm::conjugate(view_quat) * gaze_quat;
using flags = from_headset::tracking::flags;
tracking.device_poses.push_back(
from_headset::tracking::pose{
// Zero position and velocities
.pose = {
.orientation = {
.x = gaze_quat.x,
.y = gaze_quat.y,
.z = gaze_quat.z,
.w = gaze_quat.w,
},
},
.device = item.device,
.flags = uint8_t(gaze.flags & view_pose.flags & ~(flags::linear_velocity_valid | flags::angular_velocity_valid)),
});
}
break;
default:
tracking.device_poses.push_back(locate_space(item.device, spaces[item.device], spaces[wivrn::device_id::HEAD], tracking.timestamp));
break;
}
break;
case wivrn::device_id::FACE:
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](auto & ft) {
ft.get_weights(at_time, tracking.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
},
},
face_tracker);
break;
case wivrn::device_id::LEFT_HAND:
if (left_hand)
{
hands.emplace_back(
t0,
at_time,
from_headset::hand_tracking::left,
locate_hands(*left_hand, world_space, tracking.timestamp));
}
break;
case wivrn::device_id::RIGHT_HAND:
if (right_hand)
{
hands.emplace_back(
t0,
at_time,
from_headset::hand_tracking::right,
locate_hands(*right_hand, world_space, tracking.timestamp));
}
break;
case wivrn::device_id::BODY:
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](auto & b) {
body.push_back(from_headset::body_tracking{
.production_timestamp = tracking.production_timestamp,
.timestamp = at_time,
.poses = b.locate_spaces(at_time, world_space),
});
},
},
body_tracker);
break;
default:
break;
j.pose = i.pose;
j.fov = i.fov;
}
packet.state_flags = 0;
if (recenter_requested.exchange(false))
packet.state_flags = wivrn::from_headset::tracking::recentered;
// Hand tracking data are very large, send fewer samples than other items
if (hand_tracking and t0 >= last_hand_sample + period and
(Δt == 0 or Δt >= prediction - 2 * period))
{
last_hand_sample = t0;
if (left_hand)
{
auto joints = locate_hands(*left_hand, world_space, t0 + Δt);
hands.emplace_back(
t0,
t0 + Δt,
from_headset::hand_tracking::left,
joints);
}
if (right_hand)
{
auto joints = locate_hands(*right_hand, world_space, t0 + Δt);
hands.emplace_back(
t0,
t0 + Δt,
from_headset::hand_tracking::right,
joints);
}
}
packet.device_poses.clear();
for (auto [device, space]: spaces)
{
if (enabled(control, device))
locate_spaces.add_space(device, space, t0 + Δt, packet.device_poses);
}
locate_spaces.resolve(session, t0 + Δt, packet.device_poses);
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](auto & b) {
if (t0 >= last_body_sample + period and
(Δt == 0 or Δt >= prediction - 2 * period))
{
last_body_sample = t0;
if (control.enabled[size_t(tid::generic_tracker)])
{
body.push_back(from_headset::body_tracking{
.production_timestamp = t0,
.timestamp = t0 + Δt,
.poses = b.locate_spaces(t0 + Δt, world_space),
});
}
}
},
},
body_tracker);
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](auto & ft) {
ft.get_weights(t0 + Δt, packet.face.emplace<typename std::remove_reference_t<decltype(ft)>::packet_type>());
},
},
face_tracker);
}
locate_spaces.resolve(session, tracking.timestamp, tracking.device_poses);
}
catch (const std::system_error & e)
{
if (e.code().category() != xr::error_category() or
e.code().value() != XR_ERROR_TIME_INVALID)
throw;
}
catch (const std::system_error & e)
{
if (e.code().category() != xr::error_category() or
e.code().value() != XR_ERROR_TIME_INVALID)
throw;
}
} // end prediction loop
XrDuration busy_time = t.count();
// Target: polling between 1 and 5ms, with 20% busy time
tracking_period = std::clamp<XrDuration>(std::lerp(tracking_period, busy_time * 5, 0.1), min_tracking_period, max_tracking_period);
#ifdef __ANDROID__
// FIXME: switch to event based
if (next_battery_check < now)
if (next_battery_check < now and control.enabled[size_t(tid::battery)])
{
timer t2(instance);
auto status = get_battery_status();
network_session->send_stream(from_headset::battery{
.charge = status.charge.value_or(-1),
@@ -592,25 +575,46 @@ void scenes::stream::tracking()
});
next_battery_check = now + battery_check_interval;
XrDuration battery_dur = t2.count();
spdlog::info("Battery check took: {}", battery_dur);
}
#endif
packets.resize(std::max(packets.size(), 1 + hands.size() + body.size()));
size_t packet_count = 0;
if (not(tracking.device_poses.empty() and std::holds_alternative<std::monostate>(tracking.face)))
merged_tracking.clear();
size_t current_size = 1400;
for (auto & item: tracking)
{
auto & packet = packets[packet_count++];
packet.clear();
wivrn_session::stream_socket_t::serialize(packet, tracking);
size_t size = serialized_size(item);
if (size + current_size > 1400)
{
merged_tracking.emplace_back().interaction_profiles = {
interaction_profiles[0].load(),
interaction_profiles[1].load(),
};
current_size = 0;
}
current_size += size;
merged_tracking.back().items.emplace_back(std::move(item));
}
for (const auto & i: hands)
packets.resize(std::max(packets.size(), merged_tracking.size() + hands.size() + body.size()));
size_t packet_count = 0;
for (const auto & i: merged_tracking)
{
auto & packet = packets[packet_count++];
packet.clear();
wivrn_session::stream_socket_t::serialize(packet, i);
}
for (const auto & i: hands)
{
if (i.joints)
{
auto & packet = packets[packet_count++];
packet.clear();
wivrn_session::stream_socket_t::serialize(packet, i);
}
}
for (const auto & i: body)
{
if (i.poses)
@@ -623,12 +627,21 @@ void scenes::stream::tracking()
network_session->send_stream(std::span(packets.data(), packet_count));
XrTime old = scheduled_derived_pose;
if (old and now > old)
for (auto & item: merged_tracking)
std::ranges::move(item.items, std::back_inserter(tracking_pool));
if (period_adjust == 0)
{
send_derived_pose();
scheduled_derived_pose.compare_exchange_strong(old, 0);
if (auto p = real_display_period.load())
{
period_adjust = (p / tracking_period);
current_tracking_period = p / period_adjust;
}
}
else
--period_adjust;
t0 += current_tracking_period;
}
catch (std::exception & e)
{
@@ -640,7 +653,16 @@ void scenes::stream::tracking()
void scenes::stream::operator()(to_headset::tracking_control && packet)
{
*tracking_control.lock() = std::move(packet);
auto locked = tracking_control.lock();
auto m = size_t(to_headset::tracking_control::id::microphone);
if (audio_handle)
audio_handle->set_mic_state(packet.enabled[m]);
auto n = size_t(wivrn::to_headset::tracking_control::id::hid_input);
hid_forwarding = packet.enabled[n];
*locked = packet;
locked->min_offset = std::min(locked->min_offset, locked->max_offset);
}
static device_id derived_from(device_id target)
@@ -728,12 +750,6 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
interaction_profiles[i] = interaction_profile::none;
}
// Wait for runtime to know about the controllers before sending data
scheduled_derived_pose = instance.now() + 1'000'000'000;
}
void scenes::stream::send_derived_pose()
{
auto now = instance.now();
for (device_id target: {
device_id::LEFT_AIM,
@@ -748,8 +764,14 @@ void scenes::stream::send_derived_pose()
{
// don't do derived poses for hand interaction
const bool right = (target >= device_id::RIGHT_GRIP && target <= device_id::RIGHT_PALM) || target == device_id::RIGHT_PINCH_POSE || target == device_id::RIGHT_POKE;
if (interaction_profiles[right] == interaction_profile::ext_hand_interaction_ext)
if (interaction_profiles[right].load() == interaction_profile::ext_hand_interaction_ext)
{
network_session->send_control(from_headset::derived_pose{
.source = target,
.target = target,
});
continue;
}
auto source = derived_from(target);
auto source_space = application::space(device_to_space(source));
+2
View File
@@ -1,6 +1,7 @@
// kate: hl glsl
const int nb_views = 2;
const int nb_clipping = 4;
const int nb_texcoords = 2;
const bool use_pbr = false;
@@ -19,6 +20,7 @@ layout(set = 0, binding = 1) uniform mesh_ubo
mat4 model;
mat4 modelview[nb_views];
mat4 modelviewproj[nb_views];
vec4 clipping_plane[nb_clipping];
} mesh;
layout(set = 0, binding = 2) uniform joints_ubo
+2
View File
@@ -27,6 +27,7 @@ layout (constant_id = 2) const bool alpha_cutout = false;
layout (constant_id = 3) const bool skinning = false;
const int nb_views = 2;
const int nb_clipping = 4;
layout(set = 0, binding = 0) uniform scene_ubo
{
@@ -41,6 +42,7 @@ layout(set = 0, binding = 1) uniform mesh_ubo
mat4 model;
mat4 modelview[nb_views];
mat4 modelviewproj[nb_views];
vec4 clipping_plane[nb_clipping];
} mesh;
layout(set = 0, binding = 2) uniform joints_ubo
+6
View File
@@ -34,6 +34,7 @@ layout(location = 5) in vec4 in_color;
out gl_PerVertex
{
vec4 gl_Position;
float gl_ClipDistance[nb_clipping];
};
void main()
@@ -58,4 +59,9 @@ void main()
frag_pos = mesh.modelview[gl_ViewIndex] * vec4(in_position, 1.0);
light_pos = scene.view[gl_ViewIndex] * scene.light_position;
vertex_color = in_color;
for (int i = 0; i < nb_clipping; i++)
{
gl_ClipDistance[i] = dot(mesh.clipping_plane[i], mesh.model * vec4(in_position, 1.0));
}
}
+10 -3
View File
@@ -36,6 +36,7 @@ layout(location = 7) in vec4 in_weights;
out gl_PerVertex
{
vec4 gl_Position;
float gl_ClipDistance[nb_clipping];
};
void main()
@@ -52,8 +53,8 @@ void main()
in_weights.z * joints.joint_matrices[int(in_joints.z)] +
in_weights.w * joints.joint_matrices[int(in_joints.w)];
mat3 mv = inverse(transpose(mat3(mesh.modelview[gl_ViewIndex] * skinMatrix)));
// TODO on CPU?
mat3 mv = inverse(transpose(mat3(mesh.modelview[gl_ViewIndex])));
tangent = vec4(normalize(mv * in_tangent.xyz), in_tangent.w);
if (any(isnan(tangent))) // avoid NaNs if no tangent data is provided
@@ -61,9 +62,15 @@ void main()
normal = normalize(mv * in_normal);
normal = vec3(mesh.modelview[gl_ViewIndex] * skinMatrix * vec4(in_normal, 0.0));
gl_Position = mesh.modelviewproj[gl_ViewIndex] * skinMatrix * vec4(in_position, 1.0);
frag_pos = mesh.modelview[gl_ViewIndex] * skinMatrix * vec4(in_position, 1.0);
frag_pos = mesh.modelview[gl_ViewIndex] * vec4(in_position, 1.0);
light_pos = scene.view[gl_ViewIndex] * scene.light_position;
vertex_color = in_color;
for(int i = 0; i < nb_clipping; i++)
{
gl_ClipDistance[i] = dot(mesh.clipping_plane[i], mesh.model * vec4(in_position, 1.0));
}
}
-23
View File
@@ -1,23 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_GOOGLE_include_directive : require
#include "ray_common.glsl.inc"
-25
View File
@@ -1,25 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_EXT_multiview : require
#extension GL_GOOGLE_include_directive : require
#define SKINNED 0
#include "ray_common.glsl.inc"
-140
View File
@@ -1,140 +0,0 @@
// kate: hl glsl
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const int nb_views = 2;
const int nb_windows = 4;
layout(set = 0, binding = 1) uniform mesh_ubo
{
mat4 model;
mat4 modelview[nb_views];
mat4 modelviewproj[nb_views];
// Extra data
mat4 world_to_window[nb_windows];
float emissive_factor;
} mesh;
layout(set = 0, binding = 2) uniform joints_ubo
{
mat4 joint_matrices[32];
} joints;
layout(set = 0, binding = 6) uniform sampler2D emissive_texture;
#ifdef VERT_SHADER
// Vertex input
layout(location = 0) in vec3 in_position;
layout(location = 1) in vec2 in_texcoord;
#if SKINNED
layout(location = 2) in vec4 in_joints;
layout(location = 3) in vec4 in_weights;
#endif
#endif
#ifdef FRAG_SHADER
#define VS_TO_FS in
#else
#define VS_TO_FS out
#endif
// Vertex-to-fragment
layout(location = 0) VS_TO_FS vec2 texcoord;
#ifndef HTC_WORKAROUND
layout(location = 1) VS_TO_FS vec4 position_wrt_window[nb_windows];
layout(location = 1 + nb_windows) VS_TO_FS vec4 base_wrt_window[nb_windows];
#endif // HTC_WORKAROUND
#ifdef VERT_SHADER
out gl_PerVertex
{
vec4 gl_Position;
#ifdef HTC_WORKAROUND
float gl_ClipDistance[nb_windows];
#endif
};
void main()
{
texcoord = in_texcoord;
#if SKINNED
mat4 skinMatrix =
in_weights.x * joints.joint_matrices[int(in_joints.x)] +
in_weights.y * joints.joint_matrices[int(in_joints.y)] +
in_weights.z * joints.joint_matrices[int(in_joints.z)] +
in_weights.w * joints.joint_matrices[int(in_joints.w)];
gl_Position = mesh.modelviewproj[gl_ViewIndex] * skinMatrix * vec4(in_position, 1.0);
vec4 world_position = mesh.model * skinMatrix * vec4(in_position, 1.0);
vec4 base_position = mesh.model * skinMatrix * vec4(in_position.xy, 0.0, 1.0);
#else // SKINNED
gl_Position = mesh.modelviewproj[gl_ViewIndex] * vec4(in_position, 1.0);
vec4 world_position = mesh.model * vec4(in_position, 1.0);
vec4 base_position = mesh.model * vec4(in_position.xy, 0.0, 1.0);
#endif // SKINNED
for(uint i = 0; i < nb_windows; i++)
{
#ifdef HTC_WORKAROUND
vec4 tmp = mesh.world_to_window[i] * world_position;
gl_ClipDistance[i] = tmp.z;
#else // HTC_WORKAROUND
position_wrt_window[i] = mesh.world_to_window[i] * world_position;
base_wrt_window[i] = mesh.world_to_window[i] * base_position;
#endif // HTC_WORKAROUND
}
}
#endif // VERT_SHADER
#ifdef FRAG_SHADER
// Fragment output
layout(location = 0) out vec4 out_color;
void main()
{
#ifdef HTC_WORKAROUND
out_color = vec4(mesh.emissive_factor * texture(emissive_texture, texcoord).rgb, 1.0 / 255.0);
#else // HTC_WORKAROUND
for (uint i = 0; i < nb_windows; i++)
{
if (position_wrt_window[i].w < 0.5)
continue;
// TODO check NaN
float lambda = -base_wrt_window[i].z / (position_wrt_window[i].z - base_wrt_window[i].z);
if (lambda < 0 || lambda > 1)
continue;
vec2 intersection = base_wrt_window[i].xy + lambda * (position_wrt_window[i].xy - base_wrt_window[i].xy);
if (abs(intersection.x) < 0.5 && abs(intersection.y) < 0.5)
discard;
}
out_color = vec4(mesh.emissive_factor * texture(emissive_texture, texcoord).rgb, 0);
#endif // HTC_WORKAROUND
}
#endif // FRAG_SHADER
-25
View File
@@ -1,25 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_GOOGLE_include_directive : require
#define HTC_WORKAROUND
#include "ray_common.glsl.inc"
-26
View File
@@ -1,26 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_EXT_multiview : require
#extension GL_GOOGLE_include_directive : require
#define SKINNED 0
#define HTC_WORKAROUND
#include "ray_common.glsl.inc"
-25
View File
@@ -1,25 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_EXT_multiview : require
#extension GL_GOOGLE_include_directive : require
#define SKINNED 1
#include "ray_common.glsl.inc"
-26
View File
@@ -1,26 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#version 450
#extension GL_EXT_multiview : require
#extension GL_GOOGLE_include_directive : require
#define SKINNED 1
#define HTC_WORKAROUND
#include "ray_common.glsl.inc"
+6
View File
@@ -18,6 +18,7 @@
*/
#include "shader.h"
#include "utils/cache.h"
#include "wivrn_shaders.h"
#include <magic_enum.hpp>
#include <spdlog/spdlog.h>
@@ -103,3 +104,8 @@ std::shared_ptr<shader> shader_loader::operator()(const std::string & name)
return (*this)(shaders.at(name));
}
std::shared_ptr<shader> load_shader(vk::raii::Device & device, const std::string & name)
{
return shader_loader{device}(name);
}
+1 -4
View File
@@ -64,7 +64,4 @@ struct shader_loader
std::shared_ptr<shader> operator()(const std::string & name);
};
inline std::shared_ptr<shader> load_shader(vk::raii::Device & device, const std::string & name)
{
return shader_loader{device}(name);
}
std::shared_ptr<shader> load_shader(vk::raii::Device & device, const std::string & name);
+41
View File
@@ -0,0 +1,41 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 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 "foveation_profile.h"
#include "xr/instance.h"
#include "xr/session.h"
xr::foveation_profile::foveation_profile(instance & inst, session & s, XrFoveationLevelFB level, float vertical_offset_degrees, bool dynamic) :
handle(inst.get_proc<PFN_xrDestroyFoveationProfileFB>("xrDestroyFoveationProfileFB")),
level_(level),
vertical_offset_degrees_(vertical_offset_degrees),
dynamic_(dynamic)
{
auto create = inst.get_proc<PFN_xrCreateFoveationProfileFB>("xrCreateFoveationProfileFB");
XrFoveationLevelProfileCreateInfoFB level_info{
.type = XR_TYPE_FOVEATION_LEVEL_PROFILE_CREATE_INFO_FB,
.level = level,
.verticalOffset = vertical_offset_degrees,
.dynamic = dynamic ? XR_FOVEATION_DYNAMIC_LEVEL_ENABLED_FB : XR_FOVEATION_DYNAMIC_DISABLED_FB,
};
XrFoveationProfileCreateInfoFB info{
.type = XR_TYPE_FOVEATION_PROFILE_CREATE_INFO_FB,
.next = &level_info,
};
create(s, &info, &id);
}
+57
View File
@@ -0,0 +1,57 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 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/handle.h"
#include <openxr/openxr.h>
namespace xr
{
class instance;
class session;
class foveation_profile : public utils::handle<XrFoveationProfileFB>
{
XrFoveationLevelFB level_;
float vertical_offset_degrees_;
bool dynamic_;
public:
foveation_profile(instance & inst, session & s, XrFoveationLevelFB level, float vertical_offset_degrees, bool dynamic);
bool operator==(const foveation_profile & other) const
{
return level_ == other.level_ and vertical_offset_degrees_ == other.vertical_offset_degrees_ and dynamic_ == other.dynamic_;
}
XrFoveationLevelFB level() const
{
return level_;
}
float vertical_offset_degrees() const
{
return vertical_offset_degrees_;
}
bool dynamic() const
{
return dynamic_;
}
};
} // namespace xr
+2 -2
View File
@@ -74,8 +74,8 @@ std::optional<std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT>> xr::
if (!locations.isActive)
return std::nullopt;
// bail if any of the joint is invalid
if (std::ranges::any_of(joints_pos, [](const auto & loc) { return loc.locationFlags == 0; }))
// bail if none of the joints are valid/tracked
if (!std::ranges::any_of(joints_pos, [](const auto & loc) { return loc.locationFlags != 0; }))
return std::nullopt;
std::array<xr::hand_tracker::joint, XR_HAND_JOINT_COUNT_EXT> joints;
-1
View File
@@ -69,7 +69,6 @@ struct xr::pico_face_tracker::impl
if (face_tracking.time == 0)
return;
out_expressions.time = face_tracking.time;
#define MAP_EXPRESSION(fb, pico) \
out_expressions.weights[fb] = face_tracking.blendShapeWeight[pico];
+41 -5
View File
@@ -30,13 +30,16 @@ xr::swapchain::swapchain(
int32_t width,
int32_t height,
int sample_count,
uint32_t array_size) :
uint32_t array_size,
XrFoveationProfileFB foveated) :
width_(width),
height_(height),
sample_count_(sample_count),
format_(format)
{
assert(sample_count == 1);
if (foveated)
update = inst.get_proc<PFN_xrUpdateSwapchainFB>("xrUpdateSwapchainFB");
XrSwapchainUsageFlags usage_flags;
@@ -55,8 +58,14 @@ xr::swapchain::swapchain(
break;
}
XrSwapchainCreateInfoFoveationFB foveation_info{
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO_FOVEATION_FB,
.flags = XR_SWAPCHAIN_CREATE_FOVEATION_FRAGMENT_DENSITY_MAP_BIT_FB,
};
XrSwapchainCreateInfo create_info{
.type = XR_TYPE_SWAPCHAIN_CREATE_INFO,
.next = foveated ? &foveation_info : nullptr,
.createFlags = 0,
.usageFlags = usage_flags,
.format = static_cast<VkFormat>(format),
@@ -70,11 +79,29 @@ xr::swapchain::swapchain(
CHECK_XR(xrCreateSwapchain(s, &create_info, &id));
auto images = details::enumerate<XrSwapchainImageVulkanKHR>(xrEnumerateSwapchainImages, id);
std::tuple<std::vector<XrSwapchainImageVulkanKHR>, std::vector<XrSwapchainImageFoveationVulkanFB>> array;
auto & images = std::get<0>(array);
auto & foveation = std::get<1>(array);
if (foveated)
{
update_foveation(foveated);
details::enumerate2(xrEnumerateSwapchainImages, array, id);
assert(images.size() == foveation.size());
}
else
{
details::enumerate(xrEnumerateSwapchainImages, images, id);
}
images_.reserve(images.size());
for (auto & image: images)
images_.push_back(image.image);
images_.resize(images.size());
for (uint32_t i = 0; i < images.size(); i++)
{
images_[i].image = images[i].image;
if (foveated)
{
images_[i].foveation = foveation[i].image;
}
}
}
int xr::swapchain::acquire()
@@ -112,3 +139,12 @@ void xr::swapchain::release()
auto lock = application::get_queue().lock();
CHECK_XR(xrReleaseSwapchainImage(id, &release_info));
}
void xr::swapchain::update_foveation(XrFoveationProfileFB foveation)
{
XrSwapchainStateFoveationFB update_info{
.type = XR_TYPE_SWAPCHAIN_STATE_FOVEATION_FB,
.profile = foveation,
};
CHECK_XR(update(id, (XrSwapchainStateBaseHeaderFB *)&update_info));
}
+16 -5
View File
@@ -35,13 +35,21 @@ class session;
class swapchain : public utils::handle<XrSwapchain, xrDestroySwapchain>
{
public:
struct image
{
vk::Image image{};
vk::Image foveation{};
};
private:
PFN_xrUpdateSwapchainFB update;
int32_t width_;
int32_t height_;
int sample_count_;
vk::Format format_;
std::vector<vk::Image> images_;
std::vector<image> images_;
public:
swapchain() = default;
@@ -53,7 +61,8 @@ public:
int32_t width,
int32_t height,
int sample_count = 1,
uint32_t array_size = 1);
uint32_t array_size = 1,
XrFoveationProfileFB foveation = XR_NULL_HANDLE);
int32_t width() const
{
@@ -71,13 +80,13 @@ public:
{
return sample_count_;
}
const std::vector<vk::Image> & images() const
const std::vector<image> & images() const
{
return images_;
}
vk::Image image(size_t i) const
std::vector<image> & images()
{
return images_[i];
return images_;
}
vk::Format format() const
{
@@ -87,5 +96,7 @@ public:
int acquire();
bool wait(XrDuration timeout = XR_INFINITE_DURATION);
void release();
void update_foveation(XrFoveationProfileFB foveation);
};
} // namespace xr
+1 -8
View File
@@ -13,20 +13,13 @@ function(compile_glsl_aux shader_stage shader_name glsl_filename output target_e
}},
")
if (WIVRN_DEBUG_SHADERS)
set(SHADER_FLAGS -gVS)
else()
set(SHADER_FLAGS )
endif()
add_custom_command(
OUTPUT "${SPV_FILE}-nopt"
COMMAND Vulkan::glslangValidator -V --target-env ${target_env} -S ${shader_stage} -D${shader_stage_upper}_SHADER ${glsl_filename} ${SHADER_FLAGS} -o "${SPV_FILE}-nopt" --depfile "${SPV_FILE}.d"
COMMAND Vulkan::glslangValidator -V --target-env ${target_env} -S ${shader_stage} -D${shader_stage_upper}_SHADER ${in_file} -o "${SPV_FILE}-nopt" --depfile "${SPV_FILE}.d"
DEPENDS "${glsl_filename}"
DEPFILE "${SPV_FILE}.d"
VERBATIM
)
if (WIVRN_OPTIMIZE_SHADERS)
add_custom_command(
OUTPUT "${SPV_FILE}-opt"
+1 -2
View File
@@ -1,6 +1,5 @@
function(add_file_to_target TARGET OUTPUT_FILE)
file(RELATIVE_PATH TARGET_SUFFIX "${CMAKE_SOURCE_DIR}" "${OUTPUT_FILE}")
string(REPLACE "/" "_" TARGET_SUFFIX "${TARGET_SUFFIX}")
string(REPLACE "/" "_" TARGET_SUFFIX ${OUTPUT_FILE})
add_custom_target(${TARGET}-${TARGET_SUFFIX} ALL DEPENDS ${OUTPUT_FILE})
add_dependencies(${TARGET} ${TARGET}-${TARGET_SUFFIX})
+20 -23
View File
@@ -1,33 +1,30 @@
if (NOT GIT_DESC)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
OUTPUT_VARIABLE GIT_DESC
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(STRIP "${GIT_DESC}" GIT_DESC)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always
OUTPUT_VARIABLE GIT_DESC
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if (GIT_DESC)
string(STRIP ${GIT_DESC} GIT_DESC)
message(STATUS "Setting version to ${GIT_DESC} from git")
else()
message(STATUS "Setting version to ${GIT_DESC} from parameters")
endif()
if (NOT GIT_COMMIT)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT
ERROR_QUIET
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(STRIP "${GIT_COMMIT}" GIT_COMMIT)
endif()
if (NOT GIT_DESC)
message(FATAL_ERROR "GIT_DESC cannot be inferred from .git and was not provided at build time")
set(GIT_DESC v${CMAKE_PROJECT_VERSION})
message(STATUS "Setting version to ${GIT_DESC} from CMakeLists")
endif()
if (GIT_COMMIT)
string(STRIP ${GIT_COMMIT} GIT_COMMIT)
message(STATUS "Setting commit to ${GIT_COMMIT}")
else()
message(FATAL_ERROR "GIT_COMMIT cannot be inferred from .git and was not provided at build time")
set(GIT_COMMIT "")
message(STATUS "Not setting commit")
endif()
configure_file(${INPUT_FILE} ${OUTPUT_FILE})
configure_file(${INPUT_FILE_1} ${OUTPUT_FILE_1})
+24 -15
View File
@@ -1,8 +1,25 @@
if (WIVRN_USE_SYSTEM_BOOST)
add_library(Boost::pfr ALIAS Boost::headers)
else()
set(BOOST_INCLUDE_LIBRARIES locale url pfr iostreams)
elseif (WIVRN_BUILD_CLIENT)
set(BOOST_INCLUDE_LIBRARIES locale url pfr)
FetchContent_MakeAvailable(boost)
else()
FetchContent_MakeAvailable(boostpfr)
endif()
if (GIT_DESC)
configure_file(version.cpp.in version.cpp)
else ()
add_custom_target(wivrn-version ALL
COMMAND ${CMAKE_COMMAND}
-D GIT_EXECUTABLE=${GIT_EXECUTABLE}
-D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
-D OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.cpp
-D CMAKE_PROJECT_VERSION=${CMAKE_PROJECT_VERSION}
-P ${CMAKE_SOURCE_DIR}/cmake/GitVersion.cmake
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp.in
)
endif()
configure_file(wivrn_config.h.in wivrn_config.h)
@@ -10,9 +27,8 @@ configure_file(wivrn_config.h.in wivrn_config.h)
add_library(wivrn-common-base STATIC EXCLUDE_FROM_ALL
utils/strings.cpp
utils/xdg_base_directory.cpp
${CMAKE_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
)
add_dependencies(wivrn-common-base wivrn-version)
add_library(wivrn-common STATIC EXCLUDE_FROM_ALL
crypto.cpp
@@ -28,17 +44,14 @@ add_library(wivrn-common STATIC EXCLUDE_FROM_ALL
if (WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_SERVER)
add_library(wivrn-common-server STATIC EXCLUDE_FROM_ALL
application.cpp
utils/flatpak.cpp
utils/xdg_icon_lookup.cpp
utils/steam_app_info.cpp
utils/load_icon.cpp
utils/ini.cpp
utils/steam_info.cpp
utils/vdf.cpp
utils/xdg_icon_lookup.cpp
application.cpp
)
target_link_libraries(wivrn-common-server
PRIVATE nlohmann_json::nlohmann_json PNG::PNG PkgConfig::librsvg-2.0 LibArchive::LibArchive Boost::iostreams
PUBLIC wivrn-common-base)
target_link_libraries(wivrn-common-server PRIVATE nlohmann_json::nlohmann_json PNG::PNG PkgConfig::librsvg-2.0 LibArchive::LibArchive PUBLIC wivrn-common-base)
if (WIVRN_BUILD_TEST)
add_executable(list-apps
@@ -46,10 +59,6 @@ if (WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_SERVER)
)
target_link_libraries(list-apps wivrn-common-server)
add_executable(vdf utils/vdf.cpp)
target_compile_definitions(vdf PRIVATE WIVRN_BUILD_TEST)
target_link_libraries(vdf Boost::iostreams)
endif()
endif()
+171 -35
View File
@@ -20,12 +20,13 @@
#include "application.h"
#include "utils/flatpak.h"
#include "utils/steam_info.h"
#include "utils/steam_app_info.h"
#include "utils/xdg_base_directory.h"
#include "utils/xdg_icon_lookup.h"
#include <filesystem>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
namespace wivrn
@@ -41,6 +42,156 @@ std::string read_file(const std::filesystem::path & path)
return {begin, end};
}
std::filesystem::path home()
{
auto home = std::getenv("HOME");
return home ? home : "";
}
std::pair<std::string, std::optional<std::filesystem::path>> find_steam()
{
auto h = home();
// Flatpak Steam
if (std::filesystem::exists(h / ".var/app/com.valvesoftware.Steam/.steam/steam"))
return {"flatpak run com.valvesoftware.Steam", h / ".var/app/com.valvesoftware.Steam/.steam/steam"};
// Debian Steam (accessed from flatpak)
if (std::filesystem::exists(h / ".steam/debian-installation"))
return {"steam", h / ".steam/debian-installation"};
// system Steam
if (std::filesystem::exists(xdg_data_home() / "Steam"))
return {"steam", xdg_data_home() / "Steam"};
// system Steam (accessed from flatpak)
if (std::filesystem::exists(h / ".local/share/Steam"))
return {"steam", h / ".local/share/Steam"};
return {};
}
std::string read_vr_manifest(const std::filesystem::path & root)
{
return read_file(root / "config/steamapps.vrmanifest");
}
steam_app_info read_steam_app_info(const std::filesystem::path & root)
{
try
{
return steam_app_info{root / "appcache/appinfo.vdf"};
}
catch (...)
{}
return {};
}
std::optional<std::filesystem::path> find_steam_icon(const std::filesystem::path & root, int app_id, const steam_app_info & info)
{
const auto & app_info = info.get(app_id);
try
{
std::string icon{std::get<std::string_view>(app_info.at("common.clienticon"))};
auto icon_path = root / "steam/games" / (icon + ".ico");
if (std::filesystem::exists(icon_path))
return icon_path;
}
catch (...)
{
}
try
{
std::string icon{std::get<std::string_view>(app_info.at("common.linuxclienticon"))};
auto icon_path = root / "steam/games" / (icon + ".zip");
if (std::filesystem::exists(icon_path))
return icon_path;
}
catch (...)
{
}
return std::nullopt;
}
void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
{
auto [command, root] = find_steam();
if (not root)
return;
auto manifest = read_vr_manifest(*root);
auto info = read_steam_app_info(*root);
if (manifest.empty())
return;
nlohmann::json json = nlohmann::json::parse(manifest);
for (auto & i: json["applications"])
{
try
{
application app;
std::string app_key = i["app_key"];
for (auto [locale, items]: i["strings"].items())
{
if (auto it = items.find("name"); it != items.end())
app.name[locale] = *it;
}
if (not app.name.contains(""))
{
auto it = app.name.find("en_us");
if (it == app.name.end())
it = app.name.begin();
if (it != app.name.end())
app.name[""] = it->second;
}
if (i["launch_type"] == "url")
{
app.exec = command + " " + (std::string)i["url"];
}
else if (i["launch_type"] == "binary")
{
const char prefix[] = "steam.app.";
if (app_key.starts_with(prefix))
{
// ¯\_(ツ)_/¯
uint64_t appkey = stoll(app_key.substr(strlen(prefix)));
app.exec = command + " steam://rungameid/" + std::to_string((appkey << 32) + 0x2000000);
}
}
try
{
const char prefix[] = "steam.app.";
if (app_key.starts_with(prefix))
{
uint32_t app_id = stoll(app_key.substr(strlen(prefix)));
app.icon_path = find_steam_icon(*root, app_id, info);
}
}
catch (...)
{
}
if (not app.exec.empty())
res[app_key] = std::move(app);
}
catch (std::exception & e)
{
std::cerr << "Failed to parse Steam VR manifest: " << e.what() << std::endl;
}
}
}
std::string unescape(std::string_view in)
{
std::string out;
@@ -194,33 +345,28 @@ void do_data_dir(std::filesystem::path dir, std::unordered_map<std::string, appl
dir = dir / "applications";
if (not std::filesystem::is_directory(dir))
return;
try
for (const auto & entry: std::filesystem::recursive_directory_iterator(dir))
{
for (const auto & entry: std::filesystem::recursive_directory_iterator(dir, std::filesystem::directory_options::skip_permission_denied))
{
if (entry.is_directory())
continue;
if (entry.is_directory())
continue;
if (entry.path().extension() != ".desktop")
continue;
if (entry.path().extension() != ".desktop")
continue;
// https://specifications.freedesktop.org/desktop-entry-spec/latest/file-naming.html#desktop-file-id
auto file_id = entry.path()
.lexically_relative(dir)
.replace_extension("")
.string();
std::ranges::replace(file_id, '/', '-');
// https://specifications.freedesktop.org/desktop-entry-spec/latest/file-naming.html#desktop-file-id
auto file_id = entry.path()
.lexically_relative(dir)
.replace_extension("")
.string();
std::ranges::replace(file_id, '/', '-');
if (res.contains(file_id))
continue;
if (res.contains(file_id))
continue;
auto app = do_desktop_entry(entry.path());
if (app)
res.emplace(std::move(file_id), std::move(*app));
}
auto app = do_desktop_entry(entry.path());
if (app)
res.emplace(std::move(file_id), std::move(*app));
}
catch (std::exception & ex)
{}
}
} // namespace
@@ -228,19 +374,9 @@ std::unordered_map<std::string, application> list_applications()
{
std::unordered_map<std::string, application> res;
for (auto & steam: steam::find_installations())
{
auto cmd = steam.get_steam_command() + " ";
for (auto && app: steam.list_applications())
{
res.emplace(std::to_string(app.appid),
application{
.name = std::move(app.name),
.exec = cmd + app.url,
.icon_path = steam.get_icon(app.appid),
});
}
}
read_steam_vr_apps(res);
do_data_dir(xdg_data_home(), res);
for (auto && dir: xdg_data_dirs())
do_data_dir(std::move(dir), res);
-105
View File
@@ -1,105 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <openxr/openxr.h>
struct packed_quaternion
{
uint32_t value;
static packed_quaternion from_quaternion(const XrQuaternionf & q)
{
assert(std::abs(q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z - 1) < 0.01);
float abs_w = std::abs(q.w);
float abs_x = std::abs(q.x);
float abs_y = std::abs(q.y);
float abs_z = std::abs(q.z);
const float scale_factor = 511 * std::sqrt(2);
if (abs_x > std::max({abs_y, abs_z, abs_w}))
{
uint32_t q1 = q.y * std::copysign(scale_factor, q.x) + 512.5;
uint32_t q2 = q.z * std::copysign(scale_factor, q.x) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.x) + 512.5;
return {(0 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else if (abs_y > std::max({abs_x, abs_z, abs_w}))
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.y) + 512.5;
uint32_t q2 = q.z * std::copysign(scale_factor, q.y) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.y) + 512.5;
return {(1 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else if (abs_z > std::max({abs_x, abs_y, abs_w}))
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.z) + 512.5;
uint32_t q2 = q.y * std::copysign(scale_factor, q.z) + 512.5;
uint32_t q3 = q.w * std::copysign(scale_factor, q.z) + 512.5;
return {(2 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
else
{
uint32_t q1 = q.x * std::copysign(scale_factor, q.w) + 512.5;
uint32_t q2 = q.y * std::copysign(scale_factor, q.w) + 512.5;
uint32_t q3 = q.z * std::copysign(scale_factor, q.w) + 512.5;
return {(3 << 30) | (q1 << 20) | (q2 << 10) | q3};
}
}
operator XrQuaternionf() const
{
const float scale_factor = 1. / (511 * std::sqrt(2));
float q1 = (int((value >> 20) & 0x3ff) - 512) * scale_factor;
float q2 = (int((value >> 10) & 0x3ff) - 512) * scale_factor;
float q3 = (int((value >> 0) & 0x3ff) - 512) * scale_factor;
float q0 = std::sqrt(1 - q1 * q1 - q2 * q2 - q3 * q3);
switch (value >> 30)
{
case 0:
return {q0, q1, q2, q3};
case 1:
return {q1, q0, q2, q3};
case 2:
return {q1, q2, q0, q3};
case 3:
return {q1, q2, q3, q0};
}
__builtin_unreachable();
}
};
inline packed_quaternion pack(const XrQuaternionf & q)
{
return packed_quaternion::from_quaternion(q);
}
-130
View File
@@ -1,130 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <boost/pfr.hpp>
#include <concepts>
#include <fstream>
#include <string>
#include <type_traits>
#if __has_include(<boost/pfr/core_name.hpp>)
#define BOOST_HAS_CORE_NAME
#endif
namespace details
{
template <class>
struct is_stdarray : public std::false_type
{};
template <class T, size_t N>
struct is_stdarray<std::array<T, N>> : public std::true_type
{};
template <typename T>
inline constexpr bool is_stdarray_v = is_stdarray<T>::value;
template <typename T, typename Enable = void>
struct csv_logger_traits;
template <typename T>
struct csv_logger_traits<T, std::enable_if_t<std::is_aggregate_v<T> && !is_stdarray_v<T>>>
{
#ifdef BOOST_HAS_CORE_NAME
static void write_header(std::ostream & out, const std::string & name, bool first = true)
{
boost::pfr::for_each_field_with_name(T{}, [&](std::string_view member_name, const auto & value) {
csv_logger_traits<std::remove_cvref_t<decltype(value)>>::write_header(out, name + "." + (std::string)member_name, first);
first = false;
});
}
#endif
static void write_line(std::ostream & out, const T & value, bool first = true)
{
boost::pfr::for_each_field(value, [&](const auto & member) {
csv_logger_traits<std::remove_cvref_t<decltype(member)>>::write_line(out, member, first);
first = false;
});
}
};
template <typename T>
struct csv_logger_traits<T, std::enable_if_t<is_stdarray_v<T>>>
{
static void write_header(std::ostream & out, const std::string & name, bool first = true)
{
for (int i = 0; i < std::tuple_size_v<T>; i++)
{
csv_logger_traits<std::tuple_element_t<0, T>>::write_header(out, name + "[" + std::to_string(i) + "]", first and i == 0);
}
}
static void write_line(std::ostream & out, const T & value, bool first = true)
{
for (int i = 0; i < std::tuple_size_v<T>; i++)
{
csv_logger_traits<std::tuple_element_t<0, T>>::write_line(out, value[i], first and i == 0);
}
}
};
template <typename T>
struct csv_logger_traits<T, std::enable_if_t<!std::is_aggregate_v<T>>>
{
static void write_header(std::ostream & out, std::string_view name, bool first = true)
{
if (not first)
out << ",";
out << name.substr(1);
}
static void write_line(std::ostream & out, const T & value, bool first = true)
{
if (not first)
out << ",";
out << value;
}
};
} // namespace details
template <typename T, typename Stream = std::ofstream>
requires std::derived_from<Stream, std::ostream>
class csv_logger
{
Stream stream;
public:
template <typename... Args>
csv_logger(Args &&... args) : stream(std::forward<Args>(args)...)
{
#ifdef BOOST_HAS_CORE_NAME
details::csv_logger_traits<T>::write_header(stream, "");
stream << std::endl;
#endif
}
void write(const T & data)
{
details::csv_logger_traits<T>::write_line(stream, data);
stream << std::endl;
}
};
+186
View File
@@ -0,0 +1,186 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "steam_app_info.h"
#include <bit>
#include <cctype>
#include <cstring>
#include <fstream>
#include <span>
#include <string_view>
namespace
{
template <typename T>
T read(std::span<char> & buffer);
template <typename T>
requires std::is_integral_v<T>
T read(std::span<char> & buffer)
{
if (sizeof(T) > buffer.size())
throw std::runtime_error{"File truncated"};
T value;
memcpy(&value, buffer.data(), sizeof(T));
buffer = buffer.subspan(sizeof(T));
static_assert(std::endian::native == std::endian::big or std::endian::native == std::endian::little);
if constexpr (std::endian::native == std::endian::big)
return std::byteswap(value);
else
return value;
}
template <>
std::string_view read<std::string_view>(std::span<char> & buffer)
{
size_t size = strnlen((char *)buffer.data(), buffer.size());
if (size == buffer.size())
throw std::runtime_error{"File truncated"};
char * str = buffer.data();
buffer = buffer.subspan(size + 1);
return {str, size};
}
std::span<char> read(std::span<char> & buffer, size_t size)
{
if (size > buffer.size())
throw std::runtime_error{"File truncated"};
std::span<char> value{buffer.data(), size};
buffer = buffer.subspan(size);
return value;
}
std::vector<std::string_view> read_string_table(std::span<char> buffer)
{
std::vector<std::string_view> string_table;
uint32_t count = read<uint32_t>(buffer);
string_table.reserve(count);
for (size_t i = 0; i < count; i++)
string_table.emplace_back(read<std::string_view>(buffer));
return string_table;
}
void read_vdf(wivrn::steam_app_info::info & info, const std::string & prefix, std::span<char> & bindata, const std::vector<std::string_view> & string_table)
{
int type = read<uint8_t>(bindata);
while (type != 8)
{
std::string name{string_table.at(read<uint32_t>(bindata))};
for (char & c: name)
c = std::tolower(c);
// https://github.com/ValveResourceFormat/ValveKeyValue/blob/master/ValveKeyValue/ValveKeyValue/KeyValues1/KV1BinaryNodeType.cs
switch (type)
{
case 0: // Dictionary
read_vdf(info, prefix + name + ".", bindata, string_table);
break;
case 1: // UTF-8 string
info.emplace(prefix + name, read<std::string_view>(bindata));
break;
case 2: // uint32_t
info.emplace(prefix + name, read<uint32_t>(bindata));
break;
// case 3: // float
// break;
default:
throw std::runtime_error{"Unknown object type " + std::to_string(type)};
}
type = read<uint8_t>(bindata);
}
}
} // namespace
wivrn::steam_app_info::steam_app_info(std::filesystem::path path)
{
std::vector<std::string_view> string_table;
{
std::ifstream f{path};
data = std::vector<char>{std::istreambuf_iterator{f}, {}};
}
std::span<char> buffer = data;
// See https://github.com/SteamDatabase/SteamAppInfo/blob/master/README.md#file-header
uint32_t magic = read<uint32_t>(buffer);
if ((magic & 0xff'ff'ff'00) != 0x07'56'44'00)
throw std::runtime_error{"Wrong magic number"};
int version = magic & 0xff;
if (version < 41)
throw std::runtime_error{"Unsupported version"};
int universe = read<uint32_t>(buffer);
if (version >= 41)
{
size_t string_offset = read<uint64_t>(buffer);
string_table = read_string_table(std::span<char>{data}.subspan(string_offset));
}
else
throw std::runtime_error{"Unsupported version"};
while (true)
{
// See https://github.com/SteamDatabase/SteamAppInfo/blob/master/README.md#app-entry-repeated
auto app_id = read<uint32_t>(buffer);
if (app_id == 0)
break;
auto size_data = read<uint32_t>(buffer);
char * current_offset = buffer.data();
read<uint32_t>(buffer); // info_state
read<uint32_t>(buffer); // last_updated
read<uint64_t>(buffer); // pics_token
read(buffer, 20); // SHA1 of the app info
read<uint32_t>(buffer); // change number
// if (version < 38)
// read<uint8_t>(buffer); // section type
read(buffer, 20); // SHA1 of the bin data
auto bindata = read(buffer, size_data - (buffer.data() - current_offset));
try
{
bindata = bindata.subspan(4 + 1); // Skip the checksum + type (must be 0)
info app_info;
read_vdf(app_info, "", bindata, string_table);
app_data.emplace(app_id, app_info);
}
catch (...)
{
// Ignore errors
}
}
}
@@ -1,6 +1,6 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 Patrick Nicolas <patricknicolas@laposte.net>
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,37 +18,34 @@
#pragma once
#include <any>
#include <filesystem>
#include <string_view>
#include <unordered_map>
#include <variant>
#include <vector>
namespace wivrn
{
namespace vdf
class steam_app_info
{
struct string
{
std::string_view data;
bool operator==(const char *) const;
};
struct keyvalue
{
string key;
std::variant<string, std::vector<keyvalue>> value;
};
struct root : public keyvalue
{
root(const std::filesystem::path &);
public:
using info = std::unordered_map<std::string, std::variant<uint32_t, std::string_view>>;
private:
std::any opaque;
};
} // namespace vdf
std::vector<char> data;
std::unordered_map<int, info> app_data;
public:
steam_app_info(std::filesystem::path path);
steam_app_info() = default;
steam_app_info(const steam_app_info &) = delete;
steam_app_info(steam_app_info &&) = default;
steam_app_info & operator=(const steam_app_info &) = delete;
steam_app_info & operator=(steam_app_info &&) = default;
const auto & get(int appid) const
{
return app_data.at(appid);
}
};
} // namespace wivrn
-495
View File
@@ -1,495 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2026 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 "steam_info.h"
#include "vdf.h"
#include "xdg_base_directory.h"
#include <bit>
#include <charconv>
#include <cstring>
#include <format>
#include <fstream>
#include <iostream>
#include <nlohmann/json.hpp>
namespace
{
class binary_reader
{
std::ifstream in;
public:
binary_reader(std::ifstream && in) : in{std::move(in)} {}
void discard(size_t bytes)
{
in.seekg(bytes, std::ios_base::cur);
}
template <typename T>
T read();
template <typename T>
requires std::is_integral_v<T>
T read()
{
T res;
in.read((char *)&res, sizeof(T));
if (not in)
throw std::runtime_error{"File truncated"};
static_assert(std::endian::native == std::endian::big or std::endian::native == std::endian::little);
if constexpr (std::endian::native == std::endian::big)
return std::byteswap(res);
else
return res;
}
std::vector<std::string> string_table();
auto tellg()
{
return in.tellg();
}
void seekg(size_t pos)
{
in.seekg(pos);
}
};
template <>
std::string binary_reader::read()
{
std::string res;
std::getline(in, res, '\0');
if (not in)
throw std::runtime_error{"File truncated"};
return res;
}
std::vector<std::string> binary_reader::string_table()
{
std::vector<std::string> res;
size_t string_offset = read<uint64_t>();
auto pos = in.tellg();
in.seekg(string_offset);
auto count = read<uint32_t>();
res.reserve(count);
for (size_t i = 0; i < count; ++i)
res.emplace_back(read<std::string>());
in.seekg(pos);
return res;
}
template <typename T>
void read_dict(binary_reader & in, T & visitor, const std::vector<std::string> * string_table = nullptr)
{
while (true)
{
auto type = in.read<uint8_t>();
if (type == 8)
{
visitor.end_dict();
return;
}
// Key
const std::string & key = string_table ? string_table->at(in.read<uint32_t>()) : in.read<std::string>();
// Value
switch (type)
{
case 0: // Dictionary
visitor.begin_dict(key);
read_dict(in, visitor, string_table);
break;
case 1: // UTF-8 string
visitor.on_string(key, in.read<std::string>());
break;
case 2: // uint32_t
visitor.on_uint32_t(key, in.read<uint32_t>());
break;
// case 3: // float
default:
throw std::runtime_error{"Unknown object type " + std::to_string(type)};
}
}
}
std::filesystem::path home()
{
auto home = std::getenv("HOME");
return home ? home : "";
}
std::optional<uint32_t> guess_steam_userid(const std::filesystem::path & root)
{
auto localconfig = root / "config/loginusers.vdf";
if (not std::filesystem::exists(localconfig))
return {};
try
{
wivrn::vdf::root loginusers(localconfig);
if (loginusers.key != "users")
return {};
std::optional<uint32_t> res;
for (const auto & [userid, entries]: std::get<std::vector<wivrn::vdf::keyvalue>>(loginusers.value))
{
uint64_t v;
if (std::from_chars(userid.data.begin(), userid.data.end(), v).ec != std::errc{})
continue;
res = v; // truncate to 32 bits
for (const auto & [key, value]: std::get<std::vector<wivrn::vdf::keyvalue>>(entries))
{
if (key == "MostRecent" and std::get<wivrn::vdf::string>(value) == "1")
return res;
}
}
return res;
}
catch (std::exception & e)
{
return {};
}
}
} // namespace
void read_steam_icons(std::filesystem::path path, std::unordered_map<uint32_t, wivrn::steam::icon> & icons)
{
binary_reader in{std::ifstream{path}};
uint32_t magic = in.read<uint32_t>();
if ((magic & 0xff'ff'ff'00) != 0x07'56'44'00)
throw std::runtime_error{"Wrong magic number"};
auto universe = in.read<uint32_t>();
int version = magic & 0xff;
std::vector<std::string> string_table;
std::vector<std::string> * string_table_ptr = nullptr;
if (version >= 41)
{
string_table = in.string_table();
string_table_ptr = &string_table;
}
struct V
{
wivrn::steam::icon current{};
void begin_dict(const std::string & key)
{
}
void end_dict()
{
}
void on_string(const std::string & key, std::string && val)
{
if (strcasecmp(key.c_str(), "clienticon") == 0)
current.clienticon = std::move(val);
else if (strcasecmp(key.c_str(), "linuxclienticon") == 0)
current.linuxclienticon = std::move(val);
}
void on_uint32_t(const std::string & key, uint32_t val)
{
}
};
while (true)
{
// See https://github.com/SteamDatabase/SteamAppInfo/blob/master/README.md#app-entry-repeated
auto app_id = in.read<uint32_t>();
if (app_id == 0)
break;
size_t size_data = in.read<uint32_t>();
size_t pos = in.tellg();
in.discard(
4 // info_state
+ 4 // last_updated
+ 8 // pics_token
+ 20 // SHA1 of the app info
+ 4 // change number
+ 20 // SHA1 of the bin data
+ 4 // checksum
+ 1 // type
);
try
{
V v;
read_dict(in, v, string_table_ptr);
if (not(v.current.clienticon.empty() and v.current.linuxclienticon.empty()))
icons.emplace(app_id, std::move(v.current));
}
catch (...)
{
// Ignore errors
}
in.seekg(pos + size_data);
}
}
void read_steam_shortcuts(
const std::filesystem::path & path,
std::vector<wivrn::steam::application> & apps,
std::unordered_map<uint32_t, std::filesystem::path> & icons)
{
if (not std::filesystem::exists(path))
return;
binary_reader in{std::ifstream{path}};
auto type = in.read<uint8_t>();
auto name = in.read<std::string>();
if (type != 0 or name != "shortcuts")
throw std::runtime_error{"Invalid type for shortcuts file"};
std::vector<wivrn::steam_shortcut> res;
struct V
{
std::vector<wivrn::steam::application> & apps;
std::unordered_map<uint32_t, std::filesystem::path> & icons;
int depth = 0;
wivrn::steam::application current{};
std::filesystem::path icon;
bool VR = false;
void begin_dict(const std::string & key)
{
++depth;
if (depth == 1)
{
current = decltype(current){};
icon.clear();
VR = false;
}
}
void end_dict()
{
--depth;
if (depth == 0)
{
if (VR)
{
if (not icon.empty())
icons[current.appid] = std::move(icon);
// ¯\_(ツ)_/¯
current.appid = (current.appid << 32) | 0x02000000;
current.url = std::format("steam://rungameid/{}", current.appid);
apps.push_back(std::move(current));
}
}
}
void on_string(const std::string & key, std::string && val)
{
if (depth == 1)
{
if (strcasecmp(key.c_str(), "AppName") == 0)
current.name[""] = std::move(val);
else if (strcasecmp(key.c_str(), "icon") == 0 and not val.empty())
icon = std::move(val);
}
}
void on_uint32_t(const std::string & key, uint32_t val)
{
if (depth == 1)
{
if (strcasecmp(key.c_str(), "appid") == 0)
current.appid = val;
else if (strcasecmp(key.c_str(), "OpenVR") == 0)
VR = val;
}
}
} v{apps, icons};
read_dict(in, v);
}
wivrn::steam::steam(std::filesystem::path root, bool flatpak) :
root(std::move(root)),
flatpak(flatpak),
default_userid(guess_steam_userid(this->root))
{
}
std::vector<wivrn::steam> wivrn::steam::find_installations()
{
std::vector<wivrn::steam> res;
auto h = home();
auto try_construct = [&res](std::filesystem::path root, bool flatpak = false) {
try
{
if (std::filesystem::exists(root))
{
res.push_back(wivrn::steam(std::move(root), flatpak));
return true;
}
}
catch (std::exception &)
{
}
return false;
};
// Flatpak Steam
try_construct(h / ".var/app/com.valvesoftware.Steam/.steam/steam", true);
// Debian Steam (accessed from flatpak)
try_construct(h / ".steam/debian-installation")
// system Steam
or try_construct(xdg_data_home() / "Steam")
// system Steam (accessed from flatpak)
or try_construct(h / ".local/share/Steam");
return res;
}
std::vector<wivrn::steam::application> wivrn::steam::list_applications()
{
std::vector<wivrn::steam::application> res;
// Steam games, from VR manifest
try
{
std::ifstream manifest(root / "config/steamapps.vrmanifest");
nlohmann::json json = nlohmann::json::parse(manifest);
for (auto & i: json["applications"])
{
try
{
// Steam games have an url launch
// shortcuts may be in this file, or may not...
if (i["launch_type"] != "url")
continue;
std::string app_key = i["app_key"];
const char prefix[] = "steam.app.";
if (not app_key.starts_with(prefix))
continue;
application app{
.appid = stoul(app_key.substr(strlen(prefix))),
.url = i["url"],
};
for (auto [locale, items]: i["strings"].items())
{
if (auto it = items.find("name"); it != items.end())
app.name[locale] = *it;
}
if (not app.name.contains(""))
{
auto it = app.name.find("en_us");
if (it == app.name.end())
it = app.name.begin();
if (it != app.name.end())
app.name[""] = it->second;
else
continue; // skip unnamed app
}
res.push_back(std::move(app));
}
catch (std::exception & e)
{
std::cerr << "Failed to parse Steam VR manifest: " << e.what() << std::endl;
}
}
}
catch (std::exception & e)
{
}
// Shortcuts
if (default_userid)
{
try
{
read_steam_shortcuts(root / "userdata" / std::to_string(*default_userid) / "config/shortcuts.vdf", res, shortcut_icons);
}
catch (std::exception & e)
{
}
}
else
{
// Is it a good idea to just iterate over all users?
for (auto const & entry: std::filesystem::directory_iterator{root / "userdata"})
try
{
read_steam_shortcuts(entry.path() / "config/shortcuts.vdf", res, shortcut_icons);
}
catch (std::exception & e)
{
}
}
return res;
}
std::optional<std::filesystem::path> wivrn::steam::get_icon(uint64_t appid)
{
if (appid & 0x02000000)
{
// Shortcut
auto it = shortcut_icons.find(appid >> 32);
if (it != shortcut_icons.end())
return it->second;
return {};
}
if (not icons)
{
icons.emplace();
try
{
read_steam_icons(root / "appcache/appinfo.vdf", *icons);
}
catch (...)
{}
}
auto it = icons->find(appid);
if (it == icons->end())
return {};
auto icon_path = root / "steam/games" / (it->second.clienticon + ".ico");
if (std::filesystem::exists(icon_path))
return icon_path;
icon_path = root / "steam/games" / (it->second.linuxclienticon + ".zip");
if (std::filesystem::exists(icon_path))
return icon_path;
return {};
}
std::string wivrn::steam::get_steam_command() const
{
if (flatpak)
return "flatpak run com.valvesoftware.Steam";
return "steam";
}
-69
View File
@@ -1,69 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <filesystem>
#include <optional>
#include <unordered_map>
#include <vector>
namespace wivrn
{
class steam
{
public:
struct application
{
uint64_t appid;
// localised names, with empty locale for default
std::unordered_map<std::string, std::string> name;
std::string url;
};
struct icon
{
std::string clienticon;
std::string linuxclienticon;
};
private:
std::filesystem::path root;
bool flatpak;
std::optional<uint32_t> default_userid;
std::optional<std::unordered_map<uint32_t, icon>> icons;
std::unordered_map<uint32_t, std::filesystem::path> shortcut_icons;
steam(std::filesystem::path root, bool flatpak);
public:
static std::vector<steam> find_installations();
std::vector<application> list_applications();
std::optional<std::filesystem::path> get_icon(uint64_t app_id);
std::string get_steam_command() const;
};
struct steam_shortcut
{
uint32_t appid;
std::string name;
std::optional<std::filesystem::path> icon;
};
} // namespace wivrn
-191
View File
@@ -1,191 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2026 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 "vdf.h"
#include <boost/iostreams/device/mapped_file.hpp>
#include <iostream>
namespace
{
void consume_whitespace(const char *& pos, const char * end)
{
for (; pos != end; ++pos)
{
if (not std::isspace(*pos))
return;
}
throw std::runtime_error("malformed VDF file");
}
wivrn::vdf::string read_string(const char *& pos, const char * end)
{
consume_whitespace(pos, end);
const bool quoted = *pos == '"';
if (quoted)
++pos;
const char * begin = pos;
for (; pos != end; ++pos)
{
if (*pos == '\\')
{
++pos;
if (pos == end)
break;
continue;
}
if (quoted)
{
if (*pos == '"')
return {std::string_view(begin, pos++)};
}
else
{
if (std::isspace(*pos) or *pos == '{' or *pos == '}')
return {std::string_view(begin, pos)};
}
}
throw std::runtime_error("malformed string in VDF file");
}
std::variant<wivrn::vdf::string, std::vector<wivrn::vdf::keyvalue>> read_value(const char *& pos, const char * end);
wivrn::vdf::keyvalue read_key_value(const char *& pos, const char * end)
{
return wivrn::vdf::keyvalue{
.key = read_string(pos, end),
.value = read_value(pos, end),
};
}
std::vector<wivrn::vdf::keyvalue> read_dict(const char *& pos, const char * end)
{
consume_whitespace(pos, end);
if (*pos != '{')
throw std::runtime_error("malformed VDF file");
++pos;
std::vector<wivrn::vdf::keyvalue> res;
while (true)
{
consume_whitespace(pos, end);
if (*pos == '}')
{
++pos;
return res;
}
res.push_back(read_key_value(pos, end));
}
throw std::runtime_error("malformed dict in VDF file");
}
std::variant<wivrn::vdf::string, std::vector<wivrn::vdf::keyvalue>> read_value(const char *& pos, const char * end)
{
consume_whitespace(pos, end);
if (*pos == '{')
return read_dict(pos, end);
else
return read_string(pos, end);
}
} // namespace
bool wivrn::vdf::string::operator==(const char * b) const
{
const char * a = data.begin();
for (; a != data.end(); ++a, ++b)
{
if (*b == '\0')
return false;
if (*a == '\\')
{
++a;
// This should be taken care of by the parser
assert(a != data.end());
}
if (std::tolower(*b) != std::tolower(*a))
return false;
}
return *b == '\0';
}
wivrn::vdf::root::root(const std::filesystem::path & file)
{
boost::iostreams::mapped_file in{file};
opaque = in;
const char * pos = in.begin();
key = read_string(pos, in.end());
value = read_value(pos, in.end());
}
void dump(const wivrn::vdf::keyvalue & kv, int depth)
{
for (int i = 0; i < depth; ++i)
std::cout << '\t';
std::cout << '"' << kv.key.data << "\": ";
struct V
{
int depth;
void operator()(const wivrn::vdf::string & s)
{
std::cout << '"' << s.data << '"';
}
void operator()(const std::vector<wivrn::vdf::keyvalue> & kv)
{
std::cout << '{' << std::endl;
for (const auto & i: kv)
{
dump(i, depth + 1);
if (&i != &kv.back())
std::cout << ',';
std::cout << std::endl;
}
for (int i = 0; i < depth; ++i)
std::cout << '\t';
std::cout << "}";
}
};
std::visit(V{depth}, kv.value);
}
#ifdef WIVRN_BUILD_TEST
void dump(const wivrn::vdf::root & kv)
{
std::cout << '{';
dump(kv, 0);
std::cout << '}';
}
int main(int argc, char ** argv)
{
for (int i = 1; i < argc; ++i)
{
wivrn::vdf::root doc{argv[i]};
dump(doc);
}
}
#endif
+2 -4
View File
@@ -45,7 +45,7 @@ std::filesystem::path xdg_cache_home()
std::filesystem::path xdg_data_home()
{
if (const char * xdg_data_home = std::getenv("XDG_DATA_HOME"); xdg_data_home and *xdg_data_home)
if (const char * xdg_data_home = std::getenv("XDG_DATA_HOME"))
return xdg_data_home;
if (const char * home = std::getenv("HOME"))
@@ -71,11 +71,9 @@ std::vector<std::filesystem::path> xdg_config_dirs()
return paths;
}
std::vector<std::filesystem::path> xdg_data_dirs(bool include_data_home)
std::vector<std::filesystem::path> xdg_data_dirs()
{
std::vector<std::filesystem::path> paths;
if (include_data_home)
paths.push_back(xdg_data_home());
if (const char * xdg_config_dirs = std::getenv("XDG_DATA_DIRS"))
{
+1 -1
View File
@@ -26,4 +26,4 @@ std::filesystem::path xdg_config_home();
std::filesystem::path xdg_cache_home();
std::filesystem::path xdg_data_home();
std::vector<std::filesystem::path> xdg_config_dirs();
std::vector<std::filesystem::path> xdg_data_dirs(bool include_data_home = true);
std::vector<std::filesystem::path> xdg_data_dirs();
+38 -63
View File
@@ -25,7 +25,6 @@
#include <algorithm>
#include <filesystem>
#include <format>
#include <fstream>
#include <limits>
#include <optional>
@@ -108,75 +107,51 @@ void find_icon_theme_dirs_helper(const std::vector<std::filesystem::path> & base
const auto theme_dir = base_dir / "icons" / theme;
const auto index_theme = theme_dir / "index.theme";
if (std::filesystem::exists(index_theme))
if (not std::filesystem::exists(index_theme))
continue;
try
{
try
std::ifstream file{index_theme};
wivrn::ini index{file};
for (const auto & inherited_theme: utils::split(index.get<std::string>("Icon Theme", "Inherits", ""), ","))
{
std::ifstream file{index_theme};
wivrn::ini index{file};
for (const auto & inherited_theme: utils::split(index.get<std::string>("Icon Theme", "Inherits", ""), ","))
{
if (inherited_theme != "" and not std::ranges::contains(themes, inherited_theme))
themes.push_back(inherited_theme);
}
for (auto directory: utils::split(index.get<std::string>("Icon Theme", "Directories", ""), ","))
{
int size = index.get<int>(directory, "Size");
int scale = index.get<int>(directory, "Scale", 1);
int min_size = index.get<int>(directory, "MinSize", size);
int max_size = index.get<int>(directory, "MaxSize", size);
int threshold = index.get<int>(directory, "Threshold", 2);
std::string type_str = index.get<std::string>(directory, "Type", "Threshold");
icon_theme_type type = icon_theme_type::threshold;
if (type_str == "Fixed")
type = icon_theme_type::fixed;
else if (type_str == "Scalable")
type = icon_theme_type::scalable;
else if (type_str == "Threshold")
type = icon_theme_type::threshold;
dirs.push_back(icon_theme_dir{
.path = theme_dir / directory,
.size = size,
.scale = scale,
.type = type,
.min_size = min_size,
.max_size = max_size,
.threshold = threshold,
});
}
if (inherited_theme != "" and not std::ranges::contains(themes, inherited_theme))
themes.push_back(inherited_theme);
}
catch (std::exception & e)
for (auto directory: utils::split(index.get<std::string>("Icon Theme", "Directories", ""), ","))
{
int size = index.get<int>(directory, "Size");
int scale = index.get<int>(directory, "Scale", 1);
int min_size = index.get<int>(directory, "MinSize", size);
int max_size = index.get<int>(directory, "MaxSize", size);
int threshold = index.get<int>(directory, "Threshold", 2);
std::string type_str = index.get<std::string>(directory, "Type", "Threshold");
icon_theme_type type = icon_theme_type::threshold;
if (type_str == "Fixed")
type = icon_theme_type::fixed;
else if (type_str == "Scalable")
type = icon_theme_type::scalable;
else if (type_str == "Threshold")
type = icon_theme_type::threshold;
dirs.push_back(icon_theme_dir{
.path = theme_dir / directory,
.size = size,
.scale = scale,
.type = type,
.min_size = min_size,
.max_size = max_size,
.threshold = threshold,
});
}
}
else if (theme == "hicolor")
catch (std::exception & e)
{
// FIXME: full theme support
for (int size: {256})
dirs.push_back(icon_theme_dir{
.path = theme_dir / std::format("{}x{}/apps", size, size),
.size = size,
.scale = 1,
.type = icon_theme_type::threshold,
.min_size = size,
.max_size = size,
.threshold = 2,
});
dirs.push_back(icon_theme_dir{
.path = theme_dir / "scalable/apps",
.size = 128,
.scale = 1,
.type = icon_theme_type::scalable,
.min_size = 1,
.max_size = 256,
.threshold = 2,
});
}
}
}
-3
View File
@@ -19,13 +19,10 @@
#pragma once
#include <cstdint>
namespace wivrn
{
// Default port for server to listen, both TCP and UDP
static const int default_port = 9757;
static const int64_t max_extrapolation_ns = 80'000'000;
} // namespace wivrn
#cmakedefine01 WIVRN_USE_NVENC
+32 -72
View File
@@ -32,14 +32,13 @@
#include <vulkan/vulkan_core.h>
#include <openxr/openxr.h>
#include "packed_quaternion.h"
#include "smp.h"
#include "wivrn_serialization_types.h"
namespace wivrn
{
static constexpr int protocol_revision = 1;
static constexpr int protocol_revision = 0;
enum class device_id : uint8_t
{
@@ -129,10 +128,6 @@ 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_HAND, // identify hand tracking
RIGHT_HAND, // identify hand tracking
BODY, // identify body tracking
FACE, // identify face tracking
};
enum class interaction_profile : uint8_t
@@ -173,19 +168,6 @@ enum video_codec
raw,
};
enum class stream_tab : uint8_t
{
hidden,
overlay_only,
compact,
stats,
settings,
bitrate_settings,
foveation_settings,
applications,
application_launcher,
};
struct audio_data
{
XrTime timestamp;
@@ -317,9 +299,6 @@ struct tracking
XrFovf fov;
};
// /user/hand/left and /user/hand/right
std::array<interaction_profile, 2> interaction_profiles;
XrTime production_timestamp;
XrTime timestamp;
XrViewStateFlags view_flags;
@@ -341,11 +320,11 @@ struct tracking
struct fb_face2
{
XrTime time;
std::array<float, XR_FACE_EXPRESSION2_COUNT_FB> weights;
std::array<float, XR_FACE_CONFIDENCE2_COUNT_FB> confidences;
bool is_valid;
bool is_eye_following_blendshapes_valid;
XrTime time;
};
struct htc_face
@@ -361,6 +340,13 @@ struct tracking
std::variant<std::monostate, android_face, fb_face2, htc_face> face;
};
struct trackings
{
// /user/hand/left and /user/hand/right
std::array<interaction_profile, 2> interaction_profiles;
std::vector<tracking> items;
};
struct derived_pose
{
device_id source;
@@ -386,8 +372,7 @@ struct hand_tracking
};
struct pose
{
XrVector3f position;
packed_quaternion orientation;
XrPosef pose;
XrVector3f linear_velocity;
XrVector3f angular_velocity;
// In order to avoid packet fragmentation
@@ -525,11 +510,6 @@ struct user_presence_changed
bool present;
};
struct stream_tab_changed
{
stream_tab tab;
};
struct override_foveation_center
{
bool enabled;
@@ -573,6 +553,7 @@ using packets = std::variant<
audio_data,
handshake,
tracking,
trackings,
derived_pose,
hand_tracking,
body_tracking,
@@ -583,7 +564,6 @@ using packets = std::variant<
refresh_rate_changed,
session_state_changed,
user_presence_changed,
stream_tab_changed,
override_foveation_center,
get_application_list,
start_app,
@@ -627,22 +607,6 @@ struct handshake
int stream_port;
};
struct server_message
{
enum class kind : uint8_t
{
// in-stream toasts (not buffered)
toast,
toast_urgent,
// displayed in lobby after disconnect (buffered)
error,
};
kind kind;
std::string msg;
};
struct foveation_parameter
{
// The number of source pixels for each ratio,
@@ -678,8 +642,6 @@ struct video_stream_description
uint16_t height;
std::array<video_codec, 3> codec; // left, right, alpha
float fps;
bool operator==(const video_stream_description &) const = default;
};
class video_stream_data_shard
@@ -741,25 +703,31 @@ struct timesync_query
struct tracking_control
{
struct sample
{
device_id device;
XrDuration prediction_ns;
};
std::vector<sample> pattern;
XrDuration motions_to_photons;
};
struct feature_control
{
enum feature
enum class id
{
left_aim,
left_grip,
left_palm,
left_pinch,
left_poke,
right_aim,
right_grip,
right_palm,
right_pinch,
right_poke,
left_hand,
right_hand,
face,
generic_tracker,
hid_input,
battery,
microphone,
last = microphone,
};
feature f;
bool state;
std::chrono::nanoseconds min_offset;
std::chrono::nanoseconds max_offset;
std::array<bool, size_t(id::last) + 1> enabled;
};
struct refresh_rate_change
@@ -767,11 +735,6 @@ struct refresh_rate_change
float fps;
};
struct stream_tab_change
{
stream_tab tab;
};
struct application_list
{
std::string language;
@@ -808,7 +771,6 @@ using packets = std::variant<
pin_check_2,
pin_check_4,
handshake,
server_message,
audio_stream_description,
video_stream_description,
audio_data,
@@ -816,9 +778,7 @@ using packets = std::variant<
haptics,
timesync_query,
tracking_control,
feature_control,
refresh_rate_change,
stream_tab_change,
application_list,
application_icon,
running_applications>;
+15 -15
View File
@@ -308,29 +308,29 @@ wivrn::deserialization_packet wivrn::UDP::receive_raw()
static const size_t message_size = 2048;
static const size_t num_messages = 20;
if ((not buffer) or buffer.use_count() > 1)
{
#if defined(__cpp_lib_smart_ptr_for_overwrite) && __cpp_lib_smart_ptr_for_overwrite >= 202002L
buffer = std::make_shared_for_overwrite<uint8_t[]>(message_size * num_messages);
buffer = std::make_shared_for_overwrite<uint8_t[]>(message_size * num_messages);
#else
buffer.reset(new uint8_t[message_size * num_messages]);
buffer.reset(new uint8_t[message_size * num_messages]);
#endif
}
std::array<iovec, num_messages> iovecs;
std::array<mmsghdr, num_messages> mmsgs;
std::vector<iovec> iovecs;
std::vector<mmsghdr> mmsgs;
iovecs.reserve(num_messages);
mmsgs.reserve(num_messages);
for (size_t i = 0; i < num_messages; ++i)
{
iovecs[i] = {
iovecs.push_back({
.iov_base = buffer.get() + message_size * i,
.iov_len = message_size,
};
});
mmsgs[i] = {
.msg_hdr = {
.msg_iov = &iovecs[i],
.msg_iovlen = 1,
},
};
mmsgs.push_back(
{
.msg_hdr = {
.msg_iov = &iovecs.back(),
.msg_iovlen = 1,
},
});
}
int received = recvmmsg(fd, mmsgs.data(), num_messages, MSG_DONTWAIT, nullptr);
-4
View File
@@ -7,10 +7,6 @@ include(I18n)
ecm_find_qmlmodule(org.kde.kirigami REQUIRED)
ecm_find_qmlmodule(org.kde.kirigamiaddons.formcard REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
add_executable(wivrn-dashboard
avahi.cpp
main.cpp
+1 -11
View File
@@ -28,7 +28,7 @@
<li>Samsung Galaxy XR</li>
</ul>
<p>For desktop streaming, check out WayVR.</p>
<p>For desktop streaming, check out wlx-overlay-s.</p>
</description>
<developer id="io.github.wivrn.wivrn">
<name>Guillaume Meunier, Patrick Nicolas et al</name>
@@ -68,16 +68,6 @@
<content_rating type="oars-1.1" />
<releases>
<release version="26.2" date="2026-02-08">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v26.2</url>
<description>
<ul>
<li>Added support for SlimeVR trackers</li>
<li>Unsafe configuration values can now be used on headset</li>
<li>Improved head and controller tracking</li>
</ul>
</description>
</release>
<release version="25.12" date="2025-12-19">
<url type="details">https://github.com/WiVRn/WiVRn/releases/tag/v25.12</url>
<description>
+6 -3
View File
@@ -20,6 +20,12 @@ int main(int argc, char * argv[])
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("wivrn-dashboard");
app.setOrganizationName(QStringLiteral("wivrn"));
app.setOrganizationDomain(QStringLiteral("wivrn.github.io"));
app.setApplicationName(QStringLiteral("wivrn-dashboard"));
app.setDesktopFileName(QStringLiteral("io.github.wivrn.wivrn"));
app.setApplicationVersion(QString(wivrn::git_version));
app.setApplicationDisplayName(i18n("WiVRn dashboard"));
KAboutData aboutData(
QStringLiteral("wivrn-dashboard"),
@@ -29,9 +35,6 @@ int main(int argc, char * argv[])
KAboutLicense::GPL_V3,
i18n("(c) 2022-2026 WiVRn development team"));
aboutData.setDesktopFileName(QStringLiteral("io.github.wivrn.wivrn"));
aboutData.setOrganizationDomain("wivrn.github.io");
aboutData.setHomepage("https://github.com/WiVRn/WiVRn");
aboutData.setBugAddress("https://github.com/WiVRn/WiVRn/issues");
aboutData.setProgramLogo(QIcon(":/qml/wivrn.svg"));
+4 -30
View File
@@ -36,25 +36,7 @@ Kirigami.ApplicationWindow {
}
}
onClosing: (close) => {
if (WivrnServer.ownServer && WivrnServer.sessionRunning)
{
close.accepted = false;
confirm_close.open();
} else {
Qt.quit();
}
}
Kirigami.PromptDialog {
id: confirm_close
title: i18n("Quit WiVRn")
subtitle: i18n("The WiVRn server is active.\nClosing the window will terminate it.")
iconName: "dialog-warning"
popupType: Controls.Popup.Native
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
onAccepted: Qt.quit()
}
onClosing: Qt.quit()
width: 900
height: 800
@@ -165,7 +147,7 @@ Kirigami.ApplicationWindow {
text: i18n("Firewall may not allow port 9757")
type: Kirigami.MessageType.Warning
showCloseButton: true
visible: DashboardSettings.show_system_checks && Firewall.needSetup && Settings.port == Settings.default_port
visible: DashboardSettings.show_system_checks && Firewall.needSetup
actions: [
Kirigami.Action {
text: i18n("Fix it")
@@ -188,14 +170,6 @@ Kirigami.ApplicationWindow {
]
}
Kirigami.InlineMessage {
Layout.fillWidth: true
text: Settings.flatpak ? i18n("Vulkan drivers cannot be found, you may need to run \"flatpak update\"") : i18n("Vulkan drivers cannot be found")
type: Kirigami.MessageType.Warning
showCloseButton: true
visible: DashboardSettings.show_system_checks && (VulkanInfo.type == VulkanInfo.SoftGPU || VulkanInfo.type == VulkanInfo.NoGPU)
}
Kirigami.InlineMessage {
Layout.fillWidth: true
text: i18n("Use the Mesa (radv) driver for AMD GPUs\nHardware encoding with vaapi does not work with AMDVLK and AMDGPU-PRO")
@@ -371,14 +345,14 @@ Kirigami.ApplicationWindow {
Controls.Label {
Kirigami.FormData.label: i18nc("label for USB status or connect button", "USB")
visible: !Adb.adbInstalled && !WivrnServer.headsetConnected
visible: !Adb.adbInstalled
enabled: root.server_started
text: i18n("ADB is not installed")
}
Controls.Label {
Kirigami.FormData.label: i18nc("label for USB status or connect button", "USB")
visible: Adb.adbInstalled && select_usb_device.connected_headset_count == 0 && !WivrnServer.headsetConnected
visible: Adb.adbInstalled && select_usb_device.connected_headset_count == 0
enabled: root.server_started
text: i18n("No headset is connected or your headset is not in developer mode");
Layout.fillWidth: true
+20 -3
View File
@@ -7,6 +7,8 @@ import io.github.wivrn.wivrn
ColumnLayout {
id: select_game
property bool json_loaded: false
Component.onCompleted: {
apps.append({
"name": i18nc("don't start an application automatically", "None"),
@@ -73,8 +75,13 @@ ColumnLayout {
}
}
function reload() {
select_game.json_loaded = false;
load();
}
function load() {
if (WivrnServer.jsonConfiguration == "")
if (select_game.json_loaded || WivrnServer.serverStatus != WivrnServer.Started || WivrnServer.jsonConfiguration == "")
return;
Settings.load(WivrnServer);
@@ -96,12 +103,22 @@ ColumnLayout {
app_text.text = Settings.application;
app_combobox.currentIndex = custom_idx;
}
select_game.json_loaded = true;
}
function save() {
var new_application;
if (apps.get(app_combobox.currentIndex).is_custom)
Settings.application = app_text.text;
new_application = app_text.text;
else
Settings.application = apps.get(app_combobox.currentIndex).command;
new_application = apps.get(app_combobox.currentIndex).command;
Settings.load(WivrnServer);
if (Settings.application != new_application) {
Settings.application = new_application;
Settings.save(WivrnServer);
}
}
}
+1 -46
View File
@@ -21,7 +21,6 @@
#include "escape_string.h"
#include "gui_config.h"
#include "utils/flatpak.h"
#include "wivrn_config.h"
#include "wivrn_server.h"
#include <QList>
#include <QObject>
@@ -29,7 +28,6 @@
#include <fcntl.h>
#include <nlohmann/json.hpp>
#include <qqmlintegration.h>
#include <unistd.h>
namespace
{
@@ -122,8 +120,6 @@ void Settings::emitAllChanged()
debugGuiChanged();
steamVrLhChanged();
hidForwardingChanged();
portChanged();
hostnameChanged();
}
void Settings::load(const wivrn_server * server)
@@ -432,40 +428,6 @@ void Settings::set_tcpOnly(const bool & value)
tcpOnlyChanged();
}
int Settings::port() const
{
auto it = m_jsonSettings.find("port");
if (it != m_jsonSettings.end() and it->is_number_integer())
return *it;
return wivrn::default_port;
}
void Settings::set_port(const int & value)
{
auto old = port();
m_jsonSettings["port"] = value;
if (old != value)
portChanged();
}
QString Settings::hostname() const
{
if (auto it = m_jsonSettings.find("hostname"); it != m_jsonSettings.end() and it->is_string())
return QString::fromStdString(*it);
return "";
}
void Settings::set_hostname(const QString & value)
{
auto old = hostname();
if (value == "")
m_jsonSettings.erase("hostname");
else
m_jsonSettings["hostname"] = value.toStdString();
if (old != value)
hostnameChanged();
}
QString Settings::openvr() const
{
// OpenVR compat library
@@ -489,7 +451,7 @@ void Settings::set_openvr(const QString & value)
else
m_jsonSettings["openvr-compat-path"] = value.toStdString();
if (old != value)
openvrChanged();
tcpOnlyChanged();
}
QList<Settings::video_codec> Settings::allowedCodecs() const
@@ -541,8 +503,6 @@ void Settings::restore_defaults()
m_jsonSettings.erase("use-steamvr-lh");
m_jsonSettings.erase("tcp-only");
m_jsonSettings.erase("application");
m_jsonSettings.erase("port");
m_jsonSettings.erase("hostname");
emitAllChanged();
}
@@ -551,11 +511,6 @@ bool Settings::flatpak() const
return wivrn::is_flatpak();
}
int Settings::default_port() const
{
return wivrn::default_port;
}
bool Settings::debug_gui() const
{
#if WIVRN_FEATURE_DEBUG_GUI
-6
View File
@@ -68,8 +68,6 @@ public:
Q_PROPERTY(bool tenbit READ tenbit WRITE set_tenbit NOTIFY tenbitChanged)
Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged)
Q_PROPERTY(int port READ port WRITE set_port NOTIFY portChanged)
Q_PROPERTY(QString hostname READ hostname WRITE set_hostname NOTIFY hostnameChanged)
Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged)
Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged)
@@ -78,7 +76,6 @@ public:
Q_PROPERTY(bool steamVrLh READ steamVrLh WRITE set_steamVrLh NOTIFY steamVrLhChanged)
Q_PROPERTY(bool flatpak READ flatpak CONSTANT)
Q_PROPERTY(int default_port READ default_port CONSTANT)
Q_PROPERTY(bool hid_forwarding_supported READ hid_forwarding CONSTANT)
Q_PROPERTY(bool debug_gui_supported READ debug_gui CONSTANT)
Q_PROPERTY(bool steamvr_lh_supported READ steamvr_lh CONSTANT)
@@ -92,8 +89,6 @@ public:
SETTER_GETTER_NOTIFY(bool, debugGui)
SETTER_GETTER_NOTIFY(bool, steamVrLh)
SETTER_GETTER_NOTIFY(bool, tcpOnly)
SETTER_GETTER_NOTIFY(int, port)
SETTER_GETTER_NOTIFY(QString, hostname)
SETTER_GETTER_NOTIFY(QString, openvr)
private:
nlohmann::json m_jsonSettings = nlohmann::json::object();
@@ -112,7 +107,6 @@ public:
bool can10bit() const;
bool flatpak() const;
int default_port() const;
bool debug_gui() const;
bool steamvr_lh() const;
bool hid_forwarding() const;
+6 -34
View File
@@ -24,40 +24,14 @@
vulkan_info::vulkan_info()
{
try
{
vk::raii::Context context;
vk::raii::Context context;
vk::ApplicationInfo app_info{"WiVRn dashboard", 1, "No engine", 1, VK_API_VERSION_1_1};
vk::InstanceCreateInfo instance_info{vk::InstanceCreateFlags{0}, &app_info};
vk::raii::Instance vulkan{context, instance_info};
vk::ApplicationInfo app_info{"WiVRn dashboard", 1, "No engine", 1, VK_API_VERSION_1_1};
vk::InstanceCreateInfo instance_info{vk::InstanceCreateFlags{0}, &app_info};
vk::raii::Instance vulkan{context, instance_info};
auto devices = vulkan.enumeratePhysicalDevices();
set_info(choose_device(devices));
}
catch (std::runtime_error & e)
{
qCritical() << "Failed to get vulkan info: " << e.what();
}
}
static vulkan_info::gpu_type cast_type(vk::PhysicalDeviceType type)
{
switch (type)
{
case vk::PhysicalDeviceType::eOther:
return vulkan_info::OtherGPU;
case vk::PhysicalDeviceType::eIntegratedGpu:
return vulkan_info::IGPU;
case vk::PhysicalDeviceType::eDiscreteGpu:
return vulkan_info::DGPU;
case vk::PhysicalDeviceType::eVirtualGpu:
return vulkan_info::VirtGPU;
case vk::PhysicalDeviceType::eCpu:
return vulkan_info::SoftGPU;
}
qCritical() << "invalid GPU type enum " << int(type);
return vulkan_info::OtherGPU;
auto devices = vulkan.enumeratePhysicalDevices();
set_info(choose_device(devices));
}
vk::raii::PhysicalDevice & vulkan_info::choose_device(std::vector<vk::raii::PhysicalDevice> & devices)
@@ -96,7 +70,5 @@ void vulkan_info::set_info(vk::raii::PhysicalDevice & device)
break;
}
m_type = cast_type(prop.properties.deviceType);
qDebug() << "Driver" << m_driverId << m_driverVersion;
}
+1 -19
View File
@@ -33,27 +33,14 @@ class vulkan_info : public QObject
Q_OBJECT
QML_NAMED_ELEMENT(VulkanInfo)
QML_SINGLETON
public:
enum gpu_type
{
DGPU,
IGPU,
SoftGPU,
VirtGPU,
OtherGPU,
NoGPU,
};
Q_ENUM(gpu_type)
Q_PROPERTY(QString driverId READ driverId CONSTANT)
Q_PROPERTY(QString driverVersion READ driverVersion CONSTANT)
Q_PROPERTY(uint32_t driverVersionCode READ driverVersionCode CONSTANT)
Q_PROPERTY(gpu_type type READ type CONSTANT)
QString m_driverId;
QString m_driverVersion;
uint32_t m_driverVersionCode{};
gpu_type m_type = NoGPU;
uint32_t m_driverVersionCode;
vk::raii::PhysicalDevice & choose_device(std::vector<vk::raii::PhysicalDevice> & devices);
void set_info(vk::raii::PhysicalDevice & device);
@@ -75,9 +62,4 @@ public:
{
return m_driverVersionCode;
}
gpu_type type() const
{
return m_type;
}
};
-2
View File
@@ -137,12 +137,10 @@ void wivrn_server::start_server()
qDebug() << "Server finished before registering on dbus";
serverStatusChanged(m_serverStatus = Status::FailedToStart);
}
ownServerChanged();
}
});
server_process->start(server_path(), QApplication::arguments().mid(1));
ownServerChanged();
}
break;
-7
View File
@@ -172,7 +172,6 @@ public:
// Server information
Q_PROPERTY(Status serverStatus READ serverStatus NOTIFY serverStatusChanged)
Q_PROPERTY(bool ownServer READ ownServer NOTIFY ownServerChanged)
Q_PROPERTY(bool headsetConnected READ isHeadsetConnected NOTIFY headsetConnectedChanged)
Q_PROPERTY(bool sessionRunning READ isSessionRunning NOTIFY sessionRunningChanged)
Q_PROPERTY(QString jsonConfiguration READ jsonConfiguration WRITE setJsonConfiguration NOTIFY jsonConfigurationChanged)
@@ -222,11 +221,6 @@ public:
return m_serverStatus;
}
bool ownServer() const
{
return server_process;
}
bool isHeadsetConnected() const
{
return m_headsetConnected;
@@ -385,7 +379,6 @@ private:
Q_SIGNALS:
void serverStatusChanged(Status);
void ownServerChanged();
void headsetConnectedChanged(bool);
void sessionRunningChanged(bool);
void jsonConfigurationChanged(QString);
-5
View File
@@ -73,11 +73,6 @@
<property name="PairingEnabled" type="b" access="read"/>
<property name="EncryptionEnabled" type="b" access="read"/>
<property name="ClientTab" type="s" access="read"/>
<method name="SetClientTab">
<arg type="s" name="Tab"/>
</method>
<signal name="ServerError">
<arg type="s" name="where"/>
<arg type="s" name="message"/>
+7 -10
View File
@@ -22,6 +22,7 @@ The encoder to use, either a single string or object applied to all streams, or
When a string it is used, it is equivalent to the `encoder` item of the object.
WiVRn encodes each eye separately, and the alpha channel as one for both eyes. Each stream is processed independently, this may use resources more effectively and reduce latency.
All the provided encoders are put into groups, groups are executed concurrently and items within a group are processed sequentially.
### `encoder`
Default value: `nvenc` if Nvidia GPU and compiled with nvenc, `vaapi` for all other GPU when compiled with ffmpeg, else `x264`.
@@ -45,6 +46,12 @@ Not all encoders support every codec:
If `nvenc` encoder is in use, you can refer to [nvidia website](https://developer.nvidia.com/video-encode-decode-support-matrix) to make sure that your GPU supports encoding with the desired codec.
### `group` (advanced)
Default value: One value for each encoder type (nvenc, vaapi, vulkan, x264).
Identifier (number) of the encoder group. Encoders with the same identifier are executed sequentially, in the order they are defined in the configuration. Encoders with different identifiers are executed concurrently.
Default setting will have all encoders of a given type execute sequentially, and different types in parallel.
### Examples
1. Simple configuration
```json
@@ -151,13 +158,3 @@ Default value: `false`
Only available when built with `WIVRN_FEATURE_STEAMVR_LIGHTHOUSE`
Enables the driver to load SteamVR Lighthouse devices.
## `port`
Default value: `9757`
Change the TCP/UDP port used for the connection.
## `hostname`
Default value: unset
If set, overrides the name displayed in the server list.
-509
View File
@@ -1,509 +0,0 @@
# Debugging WiVRn
This guide covers debugging techniques for WiVRn, including log collection, crash analysis, performance profiling, and common troubleshooting scenarios.
## Table of Contents
- [Prerequisites](#prerequisites)
- [Collecting Logs](#collecting-logs)
- [HMD Client Logs](#hmd-client-logs)
- [Server Logs](#server-logs)
- [Starting Components for Debugging](#starting-components-for-debugging)
- [HMD Client](#hmd-client)
- [Server](#server)
- [XR Applications](#xr-applications)
- [Crash Debugging](#crash-debugging)
- [Server Crashes](#server-crashes)
- [HMD Client Crashes](#hmd-client-crashes)
- [Performance Debugging](#performance-debugging)
- [Timing Analysis](#timing-analysis)
- [Perfetto Profiling](#perfetto-profiling)
- [USB Tunneling](#usb-tunneling)
- [Game Debugging](#game-debugging)
- [Environment Variables Reference](#environment-variables-reference)
- [Configuration Files](#configuration-files)
- [External Resources](#external-resources)
- [Remote Native Debugging (Advanced)](#remote-native-debugging-advanced)
---
## Prerequisites
### ADB Setup
The Android Debug Bridge ([ADB](https://developer.android.com/tools/adb)) is required for debugging the HMD client. Connect your headset to your PC via a USB data cable and authorize the connection when prompted in the HMD.
### Clean Installation
When debugging, ensure the HMD client matches the server version. Perform a clean reinstall:
```bash
# Find and uninstall existing installation
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb uninstall ${WIVRN_PKG}
# Install the debug APK
adb install /path/to/wivrn-standard-debug.apk
```
---
## Collecting Logs
### HMD Client Logs
The primary method to collect logs from the HMD is through [ADB logcat](https://developer.android.com/tools/logcat).
Watch for crashes (FATAL priority):
```bash
adb logcat '*:F'
```
Record ERROR and above:
```bash
adb logcat '*:E' | tee -a errors-$(date "+%Y-%m-%d-%H").log
```
WiVRn-only logs (verbose):
```bash
adb logcat '*:S' WiVRn:V
```
Watch WiVRn client logs:
```bash
adb logcat | grep WiVRn
```
Watch Android system logs related to WiVRn:
```bash
adb logcat | grep wivrn
```
### Server Logs
Start the server with debug logging enabled:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug wivrn-server
```
To also dump video frames for analysis:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug WIVRN_DUMP_VIDEO=/tmp/video-dump wivrn-server
```
The video dump can be played back with `mpv` or other media players to verify what video was being sent to the HMD.
There will be multiple files in the directory, one for each video stream per codec. For example, `/tmp/video-dump-0.h264`.
---
## Starting Components for Debugging
### HMD Client
The package name varies by build variant:
- `org.meumeu.wivrn` - for app store builds
- `org.meumeu.wivrn.github` - for GitHub release builds
- `org.meumeu.wivrn.local` - for locally built APK
- `org.meumeu.wivrn.github.testing` - for CI runs
- `org.meumeu.wivrn.github.nightly` - for APK repo
Find your installed package with:
```bash
adb shell pm list packages | grep wivrn
```
Start via ADB:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am start ${WIVRN_PKG}/org.meumeu.wivrn.MainActivity
```
Connect to a specific server:
Replace `ADDRESS=localhost` with the address of the server you want to connect to.
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
ADDRESS=localhost
adb shell am start -a android.intent.action.VIEW -d "wivrn://${ADDRESS}" ${WIVRN_PKG}
```
Stop the client:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am force-stop ${WIVRN_PKG}
```
### Server
Start the server with debug logging:
```bash
XRT_LOG=debug XRT_COMPOSITOR_LOG=debug wivrn-server
```
The server will publish itself on the network via mDNS/Zeroconf for discovery by the HMD client.
### XR Applications
Basic OpenXR application:
```bash
xrgears
```
To run Steam games via OpenVR, make sure to add the Steam launch options presented by the server output or in the dashboard. This is required to configure the OpenVR runtime correctly.
Some games have options to control window behavior. Try adding `-windowed` or `-window -w 1280 -h 1024` to the game launch options to allow moving/resizing the local render window. Each game may have different options, check the game's documentation.
> Note: Games linked to OpenVR require [OpenComposite](https://gitlab.com/znixian/OpenOVR) or [xrizer](https://github.com/Supreeeme/xrizer) to translate calls to OpenXR.
---
## Crash Debugging
### Server Crashes
#### Systemd
Core dumps are managed by [systemd-coredump](https://www.freedesktop.org/software/systemd/man/latest/coredumpctl.html).
View the most recent crash:
```bash
coredumpctl info
```
Start a debugger on the most recent crash:
```bash
coredumpctl -1 debug
```
Inside GDB/LLDB:
```
# Select frame 2
f 2
# View local variables
info locals
# Print backtrace
bt
```
#### Non-Systemd Systems
On systems without systemd-coredump, core dumps are handled by the kernel directly.
Check where core dumps are written:
```bash
cat /proc/sys/kernel/core_pattern
```
To set a simple core pattern:
```bash
sudo sysctl -w kernel.core_pattern=/tmp/core.%e.%p.%t
```
This writes cores to `/tmp/` with the format `core.<executable>.<pid>.<timestamp>`.
Analyze a core dump with GDB:
```bash
gdb /usr/bin/wivrn-server /tmp/core.wivrn-server.12345.1706234567
```
Inside GDB:
```
# Print backtrace
bt
# View all threads
info threads
# Switch to thread 2
thread 2
# Print backtrace for all threads
thread apply all bt
```
### HMD Client Crashes
Copy the traceback from the HMD logs using logcat:
```bash
adb logcat '*:F' | grep -A 50 wivrn
```
---
## Performance Debugging
### Timing Analysis
WiVRn can record detailed timing information for analysis.
Capture timing data:
```bash
WIVRN_DUMP_TIMINGS=/tmp/wivrn-timings.csv wivrn-server
```
### Perfetto Profiling
[Perfetto](https://perfetto.dev/) provides detailed system-wide profiling.
#### HMD Profiling
Enable persistent tracing on Android:
```bash
adb shell setprop persist.traced.enable 1
```
Open the [Perfetto UI](https://ui.perfetto.dev/), connect to your device, and configure tracing as needed.
See the [Android tracing quickstart](https://perfetto.dev/docs/quickstart/android-tracing) for detailed instructions.
#### Server Profiling
Ensure WiVRn is built with `XRT_FEATURE_TRACING=ON` to enable [Monado tracing with Perfetto](https://monado.pages.freedesktop.org/monado/tracing-perfetto.html).
Start with tracing enabled:
```bash
XRT_TRACING=true wivrn-server
```
---
## USB Tunneling
For debugging network issues or testing with a wired connection, you can tunnel WiVRn over USB.
Set up the tunnel and connect:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb reverse tcp:9757 tcp:9757
adb shell am start -a android.intent.action.VIEW -d "wivrn+tcp://localhost:9757" ${WIVRN_PKG}
```
You are also able to make this connection through the dashboard.
---
## Game Debugging
### Proton/Wine Games
Enable additional logging for Windows compatibility layers:
```
PROTON_LOG=1 WINEDEBUG=vrclient,openxr,steam %command%
```
### OpenComposite
For games using OpenVR, and you are using [OpenComposite](https://gitlab.com/znixian/OpenOVR) to translate calls to OpenXR.
The OpenComposite log can be found at `$HOME/.local/state/OpenComposite/logs/opencomposite.log`.
### XRizer
To debug [xrizer](https://github.com/Supreeeme/xrizer), you can set the `RUST_LOG` environment variable to control the log level.
| Variable | Description | Default |
|------------|-----------------------------------------------------------------------------|---------|
| `RUST_LOG` | Configures the logging level for Rust applications. Accepts a comma-separated list of directives in the format `module::path=level`, where `level` can be `error`, `warn`, `info`, `debug`, or `trace`. For example, `RUST_LOG=info,my_crate=debug` sets the global level to `info` and the `my_crate` module to `debug`. | `warn` |
In xrizer, `RUST_LOG` follows the standard [`env_logger` semantics](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) described above. In addition, xrizer defines the following useful nonstandard logging targets:
| Logging Target | Description |
|-----------------|-------------|
| `openvr_calls` | Logs the name of each OpenVR function as they are called |
| `tracked_property` | Logs the name and device index of each requested tracked device property |
The log is located at `$XDG_STATE_HOME/xrizer/xrizer.txt`, or `$HOME/.local/state/xrizer/xrizer.txt` if `$XDG_STATE_HOME` is not set.
---
## Environment Variables Reference
### Compositor Settings
| Variable | Description | Default |
|----------|-------------|---------|
| `XRT_LOG` | Log level (`trace`, `debug`, `info`, `warn`, `error`) | `warn` |
| `XRT_COMPOSITOR_LOG` | Compositor log level (`trace`, `debug`, `info`, `warn`, `error`) | `info` |
| `OXR_VIEWPORT_SCALE_PERCENTAGE` | Per-application viewport scale (set on application, not server) | `100` |
### Debugging
| Variable | Description |
|----------|-------------|
| `WIVRN_DUMP_VIDEO` | Path to dump video frames (e.g., `/tmp/video-dump`) |
| `WIVRN_DUMP_TIMINGS` | Path to dump timing CSV (e.g., `/tmp/wivrn-timings.csv`) |
| `WIVRN_LOGLEVEL` | Log level for the native client |
| `WIVRN_AUTOCONNECT` | Auto-connect to the first discovered server |
| `XRT_TRACING` | Enable Perfetto tracing (`true`/`false`) |
### Vulkan
| Variable | Description |
|----------|-------------|
| `VK_INSTANCE_LAYERS` | Vulkan validation layers (e.g., `VK_LAYER_KHRONOS_validation`) |
### OpenXR
| Variable | Description |
|----------|-------------|
| `XR_RUNTIME_JSON` | Path to OpenXR runtime configuration |
See also the [Monado compositor documentation](https://monado.freedesktop.org/getting-started.html#compositor) for additional options.
---
## Configuration Files
### OpenXR Runtime Configuration
Active runtime symlink:
```bash
ls -la $HOME/.config/openxr/1/active_runtime.json
```
Should point to `/usr/share/openxr/1/openxr_wivrn.json` or similar.
Check runtime configuration:
```bash
cat /usr/share/openxr/1/openxr_wivrn.json
```
Example output:
```json
{
"file_format_version": "1.0.0",
"runtime": {
"name": "Monado",
"library_path": "../../../lib64/wivrn/libopenxr_wivrn.so",
"MND_libmonado_path": "../../../lib64/wivrn/libmonado_wivrn.so"
}
}
```
Verify library dependencies:
```bash
pushd /usr/share/openxr/1/
ldd ../../../lib64/wivrn/libopenxr_wivrn.so
popd
```
### WiVRn Server Configuration
See [docs/configuration.md](configuration.md).
---
## External Resources
### Tools and Documentation
- [ADB Documentation](https://developer.android.com/tools/adb) - Android Debug Bridge
- [ADB Logcat](https://developer.android.com/tools/logcat) - Log filtering and analysis
- [coredumpctl](https://www.freedesktop.org/software/systemd/man/latest/coredumpctl.html) - Core dump management
- [Perfetto](https://perfetto.dev/docs/) - System profiling and tracing
- [Perfetto UI](https://ui.perfetto.dev/) - Web-based trace viewer
### Monado/OpenXR
- [Monado Getting Started](https://monado.freedesktop.org/getting-started.html) - Compositor configuration
- [Monado Tracing with Perfetto](https://monado.pages.freedesktop.org/monado/tracing-perfetto.html) - Server-side tracing
- [OpenXR](https://www.khronos.org/openxr/) - Khronos OpenXR standard
- [xrgears](https://github.com/ila-embsys/monado_demo_xrgears) - OpenXR test application
### Gaming
- [OpenComposite](https://gitlab.com/znixian/OpenOVR) - OpenVR to OpenXR translation
- [xrizer](https://github.com/Supreeeme/xrizer) - OpenVR to OpenXR translation layer (Rust)
### Rust
- [env_logger](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) - Rust logging configuration via RUST_LOG
### Android Debugging
- [Android NDK Debugging](https://developer.android.com/ndk/guides/ndk-gdb) - Native debugging with ndk-gdb
- [Android Tracing Quickstart](https://perfetto.dev/docs/quickstart/android-tracing) - Perfetto on Android
---
## Remote Native Debugging (Advanced)
This section covers attaching a native debugger to the HMD client remotely. This requires the Android NDK and familiarity with LLDB/GDB.
Start the client with debugging enabled:
```bash
WIVRN_PKG=$(adb shell pm list packages | grep wivrn | cut -d: -f2)
adb shell am start -D ${WIVRN_PKG}/org.meumeu.wivrn.MainActivity
```
Set up LLDB debugging:
1. Push the LLDB server to the device:
```bash
adb shell "mkdir -p /data/local/tmp/tools"
adb push "$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/*/lib/linux/aarch64/lldb-server" /data/local/tmp/tools/
```
2. Start the LLDB server on the device:
```bash
adb shell /data/local/tmp/tools/lldb-server platform --server --listen '*:5039'
```
3. Forward the port:
```bash
adb forward tcp:5039 tcp:5039
```
4. Connect from your host:
```bash
lldb
(lldb) platform select remote-android
(lldb) platform connect connect://localhost:5039
```
Resume the app (required for `-D` flag):
```bash
adb forward tcp:12345 jdwp:$(adb shell pidof ${WIVRN_PKG})
jdb -attach localhost:12345
```
See the [Android NDK debugging guide](https://developer.android.com/ndk/guides/ndk-gdb) for more details.
-956
View File
@@ -1,956 +0,0 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
#define BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
#if !defined(__has_include) || __has_include(<beman/inplace_vector/config.hpp>)
#include <beman/inplace_vector/config.hpp>
#endif
#include <algorithm> // for rotate...
#include <array>
#include <compare>
#include <concepts> // for lots...
#include <cstddef> // for size_t
#include <cstdint> // for fixed-width integer types
#include <iterator> // for reverse_iterator and iterator traits
#include <limits> // for numeric_limits
#include <memory> // for destroy
#include <ranges>
#include <type_traits> // for aligned_storage and all meta-functions
// Artifact from previous implementation, can be used as hints for optimizer
#define IV_EXPECT(EXPR)
#ifndef BEMAN_IV_THROW_OR_ABORT
#ifndef BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS
#define BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS() 0
#endif
#if BEMAN_INPLACE_VECTOR_NO_EXCEPTIONS()
#include <cstdlib> // for abort
#define BEMAN_IV_THROW_OR_ABORT(x) abort()
#else
#include <stdexcept> // for length_error
#define BEMAN_IV_THROW_OR_ABORT(x) throw x
#endif
#endif
// Private utilities
namespace beman::inplace_vector::details {
struct from_range_t {};
inline constexpr from_range_t from_range;
// clang-format off
// Smallest unsigned integer that can represent values in [0, N].
template <size_t N>
using smallest_size_t
= std::conditional_t<(N < std::numeric_limits<uint8_t>::max()), uint8_t,
std::conditional_t<(N < std::numeric_limits<uint16_t>::max()), uint16_t,
std::conditional_t<(N < std::numeric_limits<uint32_t>::max()), uint32_t,
std::conditional_t<(N < std::numeric_limits<uint64_t>::max()), uint64_t,
size_t>>>>;
// clang-format on
// Index a random-access and sized range doing bound checks in debug builds
template <std::ranges::random_access_range Rng, std::integral Index>
static constexpr decltype(auto) index(Rng &&rng, Index i) noexcept
requires(std::ranges::sized_range<Rng>)
{
IV_EXPECT(static_cast<ptrdiff_t>(i) < std::ranges::size(rng));
return std::begin(std::forward<Rng>(rng))[std::forward<Index>(i)];
}
// http://eel.is/c++draft/container.requirements.general#container.intro.reqmts-2
template <class Rng, class T>
concept container_compatible_range =
std::ranges::input_range<Rng> &&
std::convertible_to<std::ranges::range_reference_t<Rng>, T>;
template <typename T>
concept satisfy_triviality = std::is_trivially_copyable_v<T> &&
std::is_trivially_default_constructible_v<T> &&
std::is_trivially_destructible_v<T>;
template <typename T, std::size_t N>
concept satisfy_constexpr = N == 0 || satisfy_triviality<T>;
template <typename T>
concept lessthan_comparable = requires(const T &a, const T &b) {
{ a < b } -> std::convertible_to<bool>;
};
// Types implementing the `inplace_vector`'s storage
namespace storage {
// Storage for zero elements.
template <class T> struct zero_sized {
protected:
using size_type = uint8_t;
static constexpr T *storage_data() noexcept { return nullptr; }
static constexpr size_type storage_size() noexcept { return 0; }
static constexpr void
unsafe_set_size([[maybe_unused]] size_t new_size) noexcept {
IV_EXPECT(new_size == 0 &&
"tried to change size of empty storage to non-zero value");
}
public:
constexpr zero_sized() = default;
constexpr zero_sized(zero_sized const &) = default;
constexpr zero_sized &operator=(zero_sized const &) = default;
constexpr zero_sized(zero_sized &&) = default;
constexpr zero_sized &operator=(zero_sized &&) = default;
constexpr ~zero_sized() = default;
};
// Storage for trivial types.
template <class T, size_t N> struct trivial {
static_assert(satisfy_triviality<T>,
"storage::trivial<T, C> requires Trivial<T>");
static_assert(N != size_t{0}, "N == 0, use zero_sized");
protected:
using size_type = smallest_size_t<N>;
private:
using array_based_storage = std::array<std::remove_const_t<T>, N>;
alignas(alignof(T)) array_based_storage storage_data_{};
size_type storage_size_ = 0;
protected:
constexpr const T *storage_data() const noexcept {
return storage_data_.data();
}
constexpr auto storage_data() noexcept { return storage_data_.data(); }
constexpr size_type storage_size() const noexcept { return storage_size_; }
constexpr void unsafe_set_size(size_t new_size) noexcept {
IV_EXPECT(size_type(new_size) <= N && "new_size out-of-bounds [0, N]");
storage_size_ = size_type(new_size);
}
public:
constexpr trivial() noexcept = default;
constexpr trivial(trivial const &) noexcept = default;
constexpr trivial &operator=(trivial const &) noexcept = default;
constexpr trivial(trivial &&) noexcept = default;
constexpr trivial &operator=(trivial &&) noexcept = default;
constexpr ~trivial() = default;
};
// This is the base storage for non-trivial types.
// In this storage solution, elements are stored in type-erased byte storage,
// thus, reinterpret_cast must be used,
// which makes inplace_vector of non-trivial types non-constexpr-friendly.
//
// Note: This is not used if trivial union is supported.
template <class T, size_t N> struct raw_byte_based_storage {
alignas(T) std::byte _d[sizeof(T) * N];
T *storage_data(size_t i) noexcept {
IV_EXPECT(i < N);
return reinterpret_cast<T *>(_d) + i;
}
const T *storage_data(size_t i) const noexcept {
IV_EXPECT(i < N);
return reinterpret_cast<const T *>(_d) + i;
}
};
/// Storage for non-trivial elements.
template <class T, size_t N> struct non_trivial {
static_assert(!satisfy_triviality<T>,
"use storage::trivial for Trivial<T> elements");
static_assert(N != size_t{0}, "use storage::zero for N==0");
protected:
using size_type = smallest_size_t<N>;
private:
using byte_based_storage = raw_byte_based_storage<std::remove_const_t<T>, N>;
byte_based_storage storage_data_{}; // BUGBUG: test SIMD types
size_type storage_size_ = 0;
protected:
constexpr const T *storage_data() const noexcept {
return storage_data_.storage_data(0);
}
constexpr auto storage_data() noexcept {
return storage_data_.storage_data(0);
}
constexpr size_type storage_size() const noexcept { return storage_size_; }
constexpr void unsafe_set_size(size_t new_size) noexcept {
IV_EXPECT(size_type(new_size) <= N && "new_size out-of-bounds [0, N)");
storage_size_ = size_type(new_size);
}
public:
constexpr non_trivial() noexcept = default;
constexpr non_trivial(non_trivial const &) noexcept = default;
constexpr non_trivial &operator=(non_trivial const &) noexcept = default;
constexpr non_trivial(non_trivial &&) noexcept = default;
constexpr non_trivial &operator=(non_trivial &&) noexcept = default;
constexpr ~non_trivial()
requires(std::is_trivially_destructible_v<T>)
= default;
constexpr ~non_trivial() {
std::destroy(storage_data(), storage_data() + storage_size());
}
};
// Selects the vector storage.
template <class T, size_t N>
using storage_for = std::conditional_t<
!satisfy_constexpr<T, N>, non_trivial<T, N>,
std::conditional_t<N == 0, zero_sized<T>, trivial<T, N>>>;
} // namespace storage
template <class T, size_t N>
struct inplace_vector_base : private storage::storage_for<T, N> {
protected:
static_assert(std::is_nothrow_destructible_v<T>,
"T must be nothrow destructible");
using base_t = storage::storage_for<T, N>;
using base_t::storage_data;
using base_t::storage_size;
using base_t::unsafe_set_size;
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = value_type &;
using const_reference = const value_type &;
using size_type = size_t;
using difference_type = std::ptrdiff_t;
using iterator = pointer;
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// iterators
constexpr iterator begin() noexcept { return storage_data(); }
constexpr const_iterator begin() const noexcept { return storage_data(); }
constexpr iterator end() noexcept { return begin() + size(); }
constexpr const_iterator end() const noexcept { return begin() + size(); }
constexpr reverse_iterator rbegin() noexcept {
return reverse_iterator(end());
}
constexpr const_reverse_iterator rbegin() const noexcept {
return const_reverse_iterator(end());
}
constexpr reverse_iterator rend() noexcept {
return reverse_iterator(begin());
}
constexpr const_reverse_iterator rend() const noexcept {
return const_reverse_iterator(begin());
}
constexpr const_iterator cbegin() const noexcept { return storage_data(); }
constexpr const_iterator cend() const noexcept { return cbegin() + size(); }
constexpr const_reverse_iterator crbegin() const noexcept {
return const_reverse_iterator(cend());
}
constexpr const_reverse_iterator crend() const noexcept {
return const_reverse_iterator(cbegin());
}
// [inplace.vector.capacity], size/capacity
[[nodiscard]] constexpr bool empty() const noexcept {
return storage_size() == 0;
};
constexpr size_type size() const noexcept { return storage_size(); }
constexpr void shrink_to_fit() {}
static constexpr size_type max_size() noexcept { return N; }
static constexpr size_type capacity() noexcept { return N; }
// element access
constexpr reference operator[](size_type n) {
return details::index(*this, n);
}
constexpr const_reference operator[](size_type n) const {
return details::index(*this, n);
}
constexpr reference front() { return details::index(*this, size_type(0)); }
constexpr const_reference front() const {
return details::index(*this, size_type(0));
}
constexpr reference back() {
return details::index(*this, size() - size_type(1));
}
constexpr const_reference back() const {
return details::index(*this, size() - size_type(1));
}
// [containers.sequences.inplace_vector.data], data access
constexpr T *data() noexcept { return storage_data(); }
constexpr const T *data() const noexcept { return storage_data(); }
protected: // Utilities
constexpr void
assert_iterator_in_range([[maybe_unused]] const_iterator it) noexcept {
IV_EXPECT(begin() <= it && "iterator not in range");
IV_EXPECT(it <= end() && "iterator not in range");
}
constexpr void
assert_valid_iterator_pair([[maybe_unused]] const_iterator first,
[[maybe_unused]] const_iterator last) noexcept {
IV_EXPECT(first <= last && "invalid iterator pair");
}
constexpr void assert_iterator_pair_in_range(const_iterator first,
const_iterator last) noexcept {
assert_iterator_in_range(first);
assert_iterator_in_range(last);
assert_valid_iterator_pair(first, last);
}
constexpr void
unsafe_destroy(T *first,
T *last) noexcept(std::is_nothrow_destructible_v<T>) {
assert_iterator_pair_in_range(first, last);
if constexpr (N > 0 && !std::is_trivially_destructible_v<T>) {
for (; first != last; ++first)
first->~T();
}
}
public:
// [inplace.vector.modifiers], modifiers
template <class... Args>
constexpr T &unchecked_emplace_back(Args &&...args)
requires(std::constructible_from<T, Args...>)
{
IV_EXPECT(size() < capacity() && "inplace_vector out-of-memory");
std::construct_at(storage_data() + size(), std::forward<Args>(args)...);
unsafe_set_size(size() + size_type(1));
return this->back();
}
template <class... Args> constexpr T *try_emplace_back(Args &&...args) {
if (size() == capacity()) [[unlikely]]
return nullptr;
return &unchecked_emplace_back(std::forward<Args>(args)...);
}
constexpr T *try_push_back(const T &x)
requires(std::constructible_from<T, const T &>)
{
return try_emplace_back(x);
}
constexpr T *try_push_back(T &&x)
requires(std::constructible_from<T, T &&>)
{
return try_emplace_back(std::forward<T &&>(x));
}
constexpr T &unchecked_push_back(const T &x)
requires(std::constructible_from<T, const T &>)
{
return unchecked_emplace_back(x);
}
constexpr T &unchecked_push_back(T &&x)
requires(std::constructible_from<T, T &&>)
{
return unchecked_emplace_back(std::forward<T &&>(x));
}
template <details::container_compatible_range<T> R>
constexpr std::ranges::borrowed_iterator_t<R> try_append_range(R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
{
auto it = std::ranges::begin(rg);
const auto end = std::ranges::end(rg);
for (; size() != capacity() && it != end; ++it) {
unchecked_emplace_back(*it);
}
return it;
}
constexpr iterator erase(const_iterator first, const_iterator last)
requires(std::movable<T>)
{
assert_iterator_pair_in_range(first, last);
iterator f = begin() + (first - begin());
if (first != last) {
unsafe_destroy(std::move(f + (last - first), end(), f), end());
unsafe_set_size(size() - static_cast<size_type>(last - first));
}
return f;
}
constexpr iterator erase(const_iterator position)
requires(std::movable<T>)
{
return erase(position, position + 1);
}
constexpr void clear() noexcept {
unsafe_destroy(begin(), end());
unsafe_set_size(0);
}
constexpr void pop_back() {
IV_EXPECT(size() > 0 && "pop_back from empty inplace_vector!");
if (size() > 0) { // UB fail-safe
unsafe_destroy(end() - 1, end());
unsafe_set_size(size() - 1);
}
}
constexpr friend bool operator==(const inplace_vector_base &x,
const inplace_vector_base &y) {
return x.size() == y.size() && std::ranges::equal(x, y);
}
constexpr void swap(inplace_vector_base &x) noexcept(
N == 0 || (std::is_nothrow_swappable_v<T> &&
std::is_nothrow_move_constructible_v<T>))
requires(std::movable<T>)
{
auto tmp = std::move(x);
x = std::move(*this);
(*this) = std::move(tmp);
}
constexpr friend void
swap(inplace_vector_base &x, inplace_vector_base &y) noexcept(
N == 0 || (std::is_nothrow_swappable_v<T> &&
std::is_nothrow_move_constructible_v<T>)) {
x.swap(y);
}
constexpr friend auto operator<=>(const inplace_vector_base &x,
const inplace_vector_base &y)
requires(details::lessthan_comparable<T>)
{
if constexpr (std::three_way_comparable<T>) {
return std::lexicographical_compare_three_way(x.begin(), x.end(),
y.begin(), y.end());
} else {
const auto sz = std::min(x.size(), y.size());
for (std::size_t i = 0; i < sz; ++i) {
if (x[i] < y[i])
return std::strong_ordering::less;
if (y[i] < x[i])
return std::strong_ordering::greater;
// [container.opt.reqmts] < must be total ordering relationship
}
return x.size() <=> y.size();
}
}
// [containers.sequences.inplace_vector.cons], construct/copy/destroy
constexpr inplace_vector_base() noexcept = default;
constexpr inplace_vector_base(const inplace_vector_base &x)
requires(N == 0 || std::is_trivially_copy_constructible_v<T>)
= default;
constexpr inplace_vector_base(const inplace_vector_base &x)
requires(N != 0 && !std::is_trivially_copy_constructible_v<T> &&
std::copyable<T>)
{
for (auto &&e : x)
unchecked_emplace_back(e);
}
constexpr inplace_vector_base(inplace_vector_base &&x)
requires(N == 0 || std::is_trivially_move_constructible_v<T>)
= default;
constexpr inplace_vector_base(inplace_vector_base &&x)
requires(N != 0 && !std::is_trivially_move_constructible_v<T> &&
std::movable<T>)
{
for (auto &&e : x)
unchecked_emplace_back(std::move(e));
}
constexpr inplace_vector_base &operator=(const inplace_vector_base &x)
requires(N == 0 || (std::is_trivially_destructible_v<T> &&
std::is_trivially_copy_constructible_v<T> &&
std::is_trivially_copy_assignable_v<T>))
= default;
constexpr inplace_vector_base &operator=(const inplace_vector_base &x)
requires(N != 0 &&
!(std::is_trivially_destructible_v<T> &&
std::is_trivially_copy_constructible_v<T> &&
std::is_trivially_copy_assignable_v<T>) &&
std::copyable<T>)
{
clear();
for (auto &&e : x)
unchecked_emplace_back(e);
return *this;
}
constexpr inplace_vector_base &operator=(inplace_vector_base &&x)
requires(N == 0 || (std::is_trivially_destructible_v<T> &&
std::is_trivially_move_constructible_v<T> &&
std::is_trivially_move_assignable_v<T>))
= default;
constexpr inplace_vector_base &operator=(inplace_vector_base &&x)
requires(N != 0 &&
!(std::is_trivially_destructible_v<T> &&
std::is_trivially_move_constructible_v<T> &&
std::is_trivially_move_assignable_v<T>) &&
std::movable<T>)
{
clear();
for (auto &&e : x)
unchecked_emplace_back(std::move(e));
return *this;
}
};
} // namespace beman::inplace_vector::details
namespace beman::inplace_vector {
template <typename IV>
concept has_constexpr_support =
details::satisfy_constexpr<typename IV::value_type, IV::capacity()>;
/// Dynamically-resizable fixed-N vector with inplace storage.
template <class T, size_t N>
struct inplace_vector : public details::inplace_vector_base<T, N> {
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = value_type &;
using const_reference = const value_type &;
using size_type = size_t;
using difference_type = std::ptrdiff_t;
using iterator = pointer;
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// [containers.sequences.inplace_vector.modifiers], modifiers
template <class... Args>
constexpr T &emplace_back(Args &&...args)
requires(std::constructible_from<T, Args...>)
{
if (!this->try_emplace_back(std::forward<Args>(args)...)) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
}
return this->back();
}
constexpr T &push_back(const T &x)
requires(std::constructible_from<T, const T &>)
{
emplace_back(x);
return this->back();
}
constexpr T &push_back(T &&x)
requires(std::constructible_from<T, T &&>)
{
emplace_back(std::forward<T &&>(x));
return this->back();
}
template <details::container_compatible_range<T> R>
constexpr void append_range(R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
{
if constexpr (std::ranges::sized_range<R>) {
if (this->size() + std::ranges::size(rg) > this->capacity())
[[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
}
}
for (auto &&e : rg) {
if (this->size() == this->capacity()) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
}
emplace_back(std::forward<decltype(e)>(e));
}
}
template <class... Args>
constexpr iterator emplace(const_iterator position, Args &&...args)
requires(std::constructible_from<T, Args...> && std::movable<T>)
{
this->assert_iterator_in_range(position);
auto b = this->end();
emplace_back(std::forward<Args>(args)...);
auto pos = this->begin() + (position - this->begin());
std::rotate(pos, b, this->end());
return pos;
}
template <class InputIterator>
constexpr iterator insert(const_iterator position, InputIterator first,
InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
{
this->assert_iterator_in_range(position);
if constexpr (std::random_access_iterator<InputIterator>) {
if (this->size() + static_cast<size_type>(std::distance(first, last)) >
this->capacity()) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
}
}
auto b = this->end();
for (; first != last; ++first)
emplace_back(*first);
auto pos = this->begin() + (position - this->begin());
std::rotate(pos, b, this->end());
return pos;
}
template <details::container_compatible_range<T> R>
constexpr iterator insert_range(const_iterator position, R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
{
return insert(position, std::begin(rg), std::end(rg));
}
constexpr iterator insert(const_iterator position,
std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
{
return insert_range(position, il);
}
constexpr iterator insert(const_iterator position, size_type n, const T &x)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
{
this->assert_iterator_in_range(position);
auto b = this->end();
for (size_type i = 0; i < n; ++i)
emplace_back(x);
auto pos = this->begin() + (position - this->begin());
std::rotate(pos, b, this->end());
return pos;
}
constexpr iterator insert(const_iterator position, const T &x)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
{
return insert(position, 1, x);
}
constexpr iterator insert(const_iterator position, T &&x)
requires(std::constructible_from<T, T &&> && std::movable<T>)
{
return emplace(position, std::move(x));
}
constexpr inplace_vector &operator=(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
{
assign_range(il);
return *this;
}
template <class InputIterator>
constexpr void assign(InputIterator first, InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
{
this->clear();
insert(this->begin(), first, last);
}
template <details::container_compatible_range<T> R>
constexpr void assign_range(R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
{
assign(std::begin(rg), std::end(rg));
}
constexpr void assign(size_type n, const T &u)
requires(std::constructible_from<T, const T &> && std::movable<T>)
{
this->clear();
insert(this->begin(), n, u);
}
constexpr void assign(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
{
this->clear();
insert_range(this->begin(), il);
}
// [inplace.vector.capacity], size/capacity
constexpr void reserve(size_type n) {
if (n > N) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
}
}
constexpr void resize(size_type sz, const T &c)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
{
if (sz == this->size())
return;
else if (sz > N) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
} else if (sz > this->size())
insert(this->end(), sz - this->size(), c);
else {
this->unsafe_destroy(this->begin() + sz, this->end());
this->unsafe_set_size(sz);
}
}
constexpr void resize(size_type sz)
requires(std::constructible_from<T, T &&> && std::default_initializable<T>)
{
if (sz == this->size())
return;
else if (sz > N) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::bad_alloc());
} else if (sz > this->size()) {
while (this->size() != sz)
emplace_back(T{});
} else {
this->unsafe_destroy(this->begin() + sz, this->end());
this->unsafe_set_size(sz);
}
}
// element access
constexpr reference at(size_type pos) {
if (pos >= this->size()) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::out_of_range("inplace_vector::at"));
}
return details::index(*this, pos);
}
constexpr const_reference at(size_type pos) const {
if (pos >= this->size()) [[unlikely]] {
BEMAN_IV_THROW_OR_ABORT(std::out_of_range("inplace_vector::at"));
}
return details::index(*this, pos);
}
// [containers.sequences.inplace_vector.cons], construct/copy/destroy
constexpr inplace_vector() noexcept = default;
constexpr inplace_vector(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
{
insert(this->begin(), il);
}
constexpr inplace_vector(size_type n, const T &value)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
{
insert(this->begin(), n, value);
}
constexpr explicit inplace_vector(size_type n)
requires(std::constructible_from<T, T &&> && std::default_initializable<T>)
{
for (size_type i = 0; i < n; ++i)
emplace_back(T{});
}
template <class InputIterator> // BUGBUG: why not std::ranges::input_iterator?
constexpr inplace_vector(InputIterator first, InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
{
insert(this->begin(), first, last);
}
template <details::container_compatible_range<T> R>
constexpr inplace_vector(details::from_range_t, R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
{
insert_range(this->begin(), std::forward<R &&>(rg));
}
};
namespace freestanding {
template <class T, size_t N>
struct inplace_vector : public details::inplace_vector_base<T, N> {
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = value_type &;
using const_reference = const value_type &;
using size_type = size_t;
using difference_type = std::ptrdiff_t;
using iterator = pointer;
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
// [containers.sequences.inplace_vector.modifiers], modifiers
template <class... Args>
constexpr T &emplace_back(Args &&...args)
requires(std::constructible_from<T, Args...>)
= delete;
constexpr T &push_back(const T &x)
requires(std::constructible_from<T, const T &>)
= delete;
constexpr T &push_back(T &&x)
requires(std::constructible_from<T, T &&>)
= delete;
template <details::container_compatible_range<T> R>
constexpr void append_range(R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>>)
= delete;
template <class... Args>
constexpr iterator emplace(const_iterator position, Args &&...args)
requires(std::constructible_from<T, Args...> && std::movable<T>)
= delete;
template <class InputIterator>
constexpr iterator insert(const_iterator position, InputIterator first,
InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
= delete;
template <details::container_compatible_range<T> R>
constexpr iterator insert_range(const_iterator position, R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
= delete;
constexpr iterator insert(const_iterator position,
std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
= delete;
constexpr iterator insert(const_iterator position, size_type n, const T &x)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
= delete;
constexpr iterator insert(const_iterator position, const T &x)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
= delete;
constexpr iterator insert(const_iterator position, T &&x)
requires(std::constructible_from<T, T &&> && std::movable<T>)
= delete;
constexpr inplace_vector &operator=(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
= delete;
template <class InputIterator>
constexpr void assign(InputIterator first, InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
= delete;
template <details::container_compatible_range<T> R>
constexpr void assign_range(R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
= delete;
constexpr void assign(size_type n, const T &u)
requires(std::constructible_from<T, const T &> && std::movable<T>)
= delete;
constexpr void assign(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
= delete;
// [inplace.vector.capacity], size/capacity
constexpr void reserve(size_type n) = delete;
constexpr void resize(size_type sz, const T &c)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
= delete;
constexpr void resize(size_type sz)
requires(std::constructible_from<T, T &&> && std::default_initializable<T>)
= delete;
// element access
constexpr reference at(size_type pos) = delete;
constexpr const_reference at(size_type pos) const = delete;
// [containers.sequences.inplace_vector.cons], construct/copy/destroy
constexpr inplace_vector() noexcept = default;
constexpr inplace_vector(std::initializer_list<T> il)
requires(std::constructible_from<
T, std::ranges::range_reference_t<std::initializer_list<T>>> &&
std::movable<T>)
= delete;
constexpr inplace_vector(size_type n, const T &value)
requires(std::constructible_from<T, const T &> && std::copyable<T>)
= delete;
constexpr explicit inplace_vector(size_type n)
requires(std::constructible_from<T, T &&> && std::default_initializable<T>)
= delete;
template <class InputIterator> // BUGBUG: why not std::ranges::input_iterator?
constexpr inplace_vector(InputIterator first, InputIterator last)
requires(std::constructible_from<T, std::iter_reference_t<InputIterator>> &&
std::movable<T>)
= delete;
template <details::container_compatible_range<T> R>
constexpr inplace_vector(beman::inplace_vector::details::from_range_t, R &&rg)
requires(std::constructible_from<T, std::ranges::range_reference_t<R>> &&
std::movable<T>)
= delete;
};
} // namespace freestanding
template <typename T, std::size_t N, typename U = T>
constexpr std::size_t erase(details::inplace_vector_base<T, N> &c,
const U &value) {
auto it = std::remove(c.begin(), c.end(), value);
auto r = std::distance(it, c.end());
c.erase(it, c.end());
return r;
}
template <typename T, std::size_t N, typename Predicate>
constexpr std::size_t erase_if(details::inplace_vector_base<T, N> &c,
Predicate pred) {
auto it = std::remove_if(c.begin(), c.end(), pred);
auto r = std::distance(it, c.end());
c.erase(it, c.end());
return r;
}
} // namespace beman::inplace_vector
#undef IV_EXPECT
#endif // BEMAN_INPLACE_VECTOR_INPLACE_VECTOR_HPP
+19558 -19530
View File
File diff suppressed because it is too large Load Diff
Generated
+9 -9
View File
@@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1768135262,
"narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=",
"lastModified": 1756770412,
"narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac",
"rev": "4524271976b625a4a605beefd893f270620fd751",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1767892417,
"narHash": "sha256-dhhvQY67aboBk8b0/u0XB6vwHdgbROZT3fJAjyNh5Ww=",
"lastModified": 1758690382,
"narHash": "sha256-NY3kSorgqE5LMm1LqNwGne3ZLMF2/ILgLpFr1fS4X3o=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba",
"rev": "e643668fd71b949c53f8626614b21ff71a07379d",
"type": "github"
},
"original": {
@@ -36,11 +36,11 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1765674936,
"narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=",
"lastModified": 1754788789,
"narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85",
"rev": "a73b9c743612e4244d865a2fdee11865283c04e6",
"type": "github"
},
"original": {
+3 -7
View File
@@ -52,22 +52,18 @@
monado = pkgs.applyPatches {
inherit (oldAttrs.monado) patches postPatch;
# Force a refetch when the monado rev changes.
src = pkgs.testers.invalidateFetcherByDrvHash pkgs.fetchFromGitLab {
src = pkgs.invalidateFetcherByDrvHash pkgs.fetchFromGitLab {
inherit (oldAttrs.monado.src) owner repo;
domain = "gitlab.freedesktop.org";
# Keep in sync with CMakeLists.txt monado rev
rev = lib.strings.trim (builtins.readFile ./monado-rev);
rev = builtins.readFile ./monado-rev;
# Nix will output the correct hash when it doesn't match
hash = "sha256-M0SQMu1rgY++a+4r0DK//ralFEO5w7I3UrgLecoLO+A=";
hash = "sha256-nlfrx6NRYV9eMs+Rb9JBh+mwucL6v+bB3jBrPsSxh+Q=";
};
};
buildInputs = oldAttrs.buildInputs ++ extraBuildInputs;
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ extraNativeBuildInputs;
cmakeFlags = (oldAttrs.cmakeFlags or []) ++ [
(lib.cmakeFeature "GIT_DESC" "nightly")
(lib.cmakeFeature "GIT_COMMIT" "nightly")
];
}));
in {
packages = {
+24 -15
View File
@@ -72,19 +72,11 @@ modules:
sources:
- type: git
url: https://github.com/crosstool-ng/crosstool-ng.git
tag: 620b909cd0713f68084378b63cf61b5232757b90
tag: 70c2b00ad79a0a21a48e5a0eedc9f91c374af21d
- type: shell
commands:
# Make the build lighter:
# don't generate debug symbols at all
- sed -i 's/-O2 -g/-O2/' scripts/crosstool-NG.sh
- sed -i 's/-g -O2/-O2/' scripts/build/cc/gcc.sh
# Delete extracted sources when no longer needed
- sed -i '/# Cleanup/a rm -r "$(readlink "${kernel_path}")"' scripts/build/kernel/linux.sh
# Delete tarballs once extracted
- sed -i '2228i CT_DoExecLog FILE rm "$(readlink -f "${file}")"' scripts/functions
# Delete big test files
- sed -i '/CT_ExtractPatch GCC/a CT_Pushd "${CT_SRC_DIR}/gcc/gcc/testsuite/";CT_DoExecLog ALL rm -rf $(ls -1 | grep -v selftests);CT_Popd' scripts/build/cc/gcc.sh
cleanup:
- '*'
@@ -229,7 +221,7 @@ modules:
sources:
- type: git
url: https://gitlab.com/libeigen/eigen.git
tag: 5.0.1
tag: 3.4.0
cleanup:
- '*'
@@ -256,6 +248,23 @@ modules:
cleanup:
- '*'
- name: libnotify
buildsystem: meson
config-opts:
- -Dtests=false
- -Dintrospection=disabled
- -Dman=false
- -Dgtk_doc=false
- -Ddocbook_docs=disabled
sources:
- type: archive
url: https://download.gnome.org/sources/libnotify/0.8/libnotify-0.8.7.tar.xz
sha256: 4be15202ec4184fce1ac15997ece5530d2be32fe9573875aeb10e3b573858748
x-checker-data:
type: gnome
name: libnotify
stable-only: true
- name: qcoro
buildsystem: cmake-ninja
config-opts:
@@ -319,7 +328,7 @@ modules:
sources:
- type: git
url: https://github.com/Supreeeme/xrizer.git
tag: be664bb93eebdd82336d00230154bacc6f8b9765
tag: 01ab72809f2bd5c6494fa77fb08e4229c886da7a
- xrizer-gen-src.json
- name: wivrn-library
@@ -376,7 +385,6 @@ modules:
- -DWIVRN_BUILD_SERVER=ON
- -DWIVRN_BUILD_SERVER_LIBRARY=OFF
- -DWIVRN_BUILD_DASHBOARD=ON
- -DWIVRN_OPTIMIZE_SHADERS=OFF
- -DWIVRN_USE_VAAPI=ON
- -DWIVRN_USE_X264=ON
- -DWIVRN_USE_NVENC=ON
@@ -397,9 +405,9 @@ modules:
WIVRN_SRC2
WIVRN_SRC3
- type: archive
url: BOOST_URL
dest: deps/boost-src
sha256: BOOST_SHA256
url: BOOSTPFR_URL
dest: deps/boostpfr-src
sha256: BOOSTPFR_SHA256
- type: git
url: https://gitlab.freedesktop.org/monado/monado
tag: MONADO_COMMIT
@@ -407,3 +415,4 @@ modules:
- type: shell
commands:
- cd deps/monado-src && ../../patches/apply.sh ../../patches/monado/*
- cd deps/boostpfr-src && ../../patches/apply.sh ../../flatpak/boostpfr-gcc-12-internal-compiler-error.patch
+69 -164
View File
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WiVRn-dashboard\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-02-26 15:00+0100\n"
"POT-Creation-Date: 2025-12-13 11:28+0100\n"
"PO-Revision-Date: 2025-11-19 20:20+0100\n"
"Last-Translator: Álvaro De Quinta <blackcherry@danwin1210.de>\n"
"Language-Team: Spanish <>\n"
@@ -15,7 +15,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Qt Linguist 6.10.2\n"
"X-Generator: Lokalize 25.08.3\n"
"X-Language: es_ES\n"
"X-Source-Language: en_US\n"
@@ -69,39 +69,10 @@ msgstr "El comando 'adb install' falló: código de salida %1"
msgid "Installation successful"
msgstr "Instalación completada con éxito"
#: dashboard/main.cpp:26
#: dashboard/main.cpp:27 dashboard/qml/Main.qml:12
#, kde-format
msgctxt "@title"
msgid "WiVRn"
msgstr "WiVRn"
#: dashboard/main.cpp:28
#, kde-format
msgid "WiVRn server"
msgstr "Servidor WiVRn"
#: dashboard/main.cpp:30
#, kde-format
msgid "(c) 2022-2026 WiVRn development team"
msgstr "(c) 2022-2026 Equipo de desarrollo de WiVRn"
#: dashboard/main.cpp:40
#, kde-format
msgid "Monado"
msgstr "Monado"
#: dashboard/main.cpp:41
#, kde-format
msgid "OpenXR runtime"
msgstr "Motor de OpenXR"
#: dashboard/qml/About.qml:17 dashboard/qml/ApkInstallPage.qml:65
#: dashboard/qml/HeadsetsPage.qml:183 dashboard/qml/HeadsetStatsPage.qml:36
#: dashboard/qml/TroubleshootPage.qml:71
#, kde-format
msgctxt "go back to the home page"
msgid "Back"
msgstr "Volver"
msgid "WiVRn dashboard"
msgstr "Panel de control de WiVRn"
#: dashboard/qml/ApkInstallPage.qml:12 dashboard/qml/WizardPage.qml:137
#, kde-format
@@ -119,8 +90,8 @@ msgstr "Comprobando la última versión..."
msgid "No APK is available for this version"
msgstr "No hay ningún APK disponible para esta versión"
#: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:376
#: dashboard/qml/Main.qml:434 dashboard/qml/WizardPage.qml:211
#: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:321
#: dashboard/qml/Main.qml:386 dashboard/qml/WizardPage.qml:211
#: dashboard/qml/WizardPage.qml:337
#, kde-format
msgid "ADB is not installed"
@@ -135,13 +106,20 @@ msgstr ""
#: dashboard/qml/ApkInstallPage.qml:51 dashboard/qml/WizardPage.qml:204
#, kde-format
msgid ""
"Follow the instructions in the <a href=\"https://github.com/WiVRn/WiVRn/blob/"
"master/docs/building.md#client-headset\">documentation</a> to build your own "
"client."
"Follow the instructions in the <a "
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-headset\">documentation</a> "
"to build your own client."
msgstr ""
"Sigue las instrucciones en la <a href=\"https://github.com/WiVRn/WiVRn/blob/"
"master/docs/building.md#client-headset\">documentación</a> para compilar tu "
"propio cliente."
"Sigue las instrucciones en la <a "
"href=\"https://github.com/WiVRn/WiVRn/blob/master/docs/building.md#client-headset\">documentación</a> "
"para compilar tu propio cliente."
#: dashboard/qml/ApkInstallPage.qml:65 dashboard/qml/HeadsetsPage.qml:183
#: dashboard/qml/HeadsetStatsPage.qml:36 dashboard/qml/TroubleshootPage.qml:71
#, kde-format
msgctxt "go back to the home page"
msgid "Back"
msgstr "Volver"
#: dashboard/qml/ConnectUsbDialog.qml:11
#, kde-format
@@ -163,7 +141,7 @@ msgstr "Reinstalar WiVRn"
msgid "Install WiVRn"
msgstr "Instalar WiVRn"
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:439
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:391
#, kde-format
msgid "Headsets"
msgstr "Visores"
@@ -260,47 +238,28 @@ msgstr "Emparejar un nuevo visor"
msgid "Headset statistics"
msgstr "Estadísticas del visor"
#: dashboard/qml/Main.qml:12
#, kde-format
msgid "WiVRn dashboard"
msgstr "Panel de control de WiVRn"
#: dashboard/qml/Main.qml:51
#, kde-format
msgid "Quit WiVRn"
msgstr "Salir de WiVRn"
#: dashboard/qml/Main.qml:52
#, kde-format
msgid ""
"The WiVRn server is active.\n"
"Closing the window will terminate it."
msgstr ""
"El servidor de WiVRn está activo.\n"
"Cerrar la ventana parará el servidor."
#: dashboard/qml/Main.qml:142
#: dashboard/qml/Main.qml:120
#, kde-format
msgid "Avahi daemon is not installed"
msgstr "El servicio Avahi no está instalado"
#: dashboard/qml/Main.qml:150
#: dashboard/qml/Main.qml:128
#, kde-format
msgid "Avahi daemon is not started"
msgstr "El servicio Avahi no está iniciado"
#: dashboard/qml/Main.qml:157 dashboard/qml/Main.qml:171
#: dashboard/qml/Main.qml:231
#: dashboard/qml/Main.qml:135 dashboard/qml/Main.qml:149
#: dashboard/qml/Main.qml:201
#, kde-format
msgid "Fix it"
msgstr "Arreglarlo"
#: dashboard/qml/Main.qml:165
#: dashboard/qml/Main.qml:143
#, kde-format
msgid "Firewall may not allow port 9757"
msgstr "El firewall podría no permitir el puerto 9757"
#: dashboard/qml/Main.qml:179
#: dashboard/qml/Main.qml:157
#, kde-format
msgid ""
"NVIDIA GPUs require at least driver version 565.77, current version is %1"
@@ -308,24 +267,12 @@ msgstr ""
"Las GPU NVIDIA requieren al menos la versión 565.77 del controlador, la "
"versión actual es %1"
#: dashboard/qml/Main.qml:185
#: dashboard/qml/Main.qml:163
#, kde-format
msgid "More info"
msgstr "Más información"
#: dashboard/qml/Main.qml:193
#, kde-format
msgid "Vulkan drivers cannot be found, you may need to run \"flatpak update\""
msgstr ""
"Los drivers Vulkan no se han encontrado, puede ser que necesite ejecutar "
"\"flatpak update\""
#: dashboard/qml/Main.qml:193
#, kde-format
msgid "Vulkan drivers cannot be found"
msgstr "Los drivers Vulkan no se han encontrado"
#: dashboard/qml/Main.qml:201
#: dashboard/qml/Main.qml:171
#, kde-format
msgid ""
"Use the Mesa (radv) driver for AMD GPUs\n"
@@ -334,7 +281,7 @@ msgstr ""
"Usa el controlador Mesa (radv) para las GPU AMD\n"
"La codificación por hardware con vaapi no funciona con AMDVLK y AMDGPU-PRO"
#: dashboard/qml/Main.qml:209
#: dashboard/qml/Main.qml:179
#, kde-format
msgid ""
"No OpenVR compatibility detected, Steam games won't be able to load VR.\n"
@@ -344,144 +291,110 @@ msgstr ""
"en VR.\n"
"Instala xrizer o OpenComposite."
#: dashboard/qml/Main.qml:217
#: dashboard/qml/Main.qml:187
#, kde-format
msgid "Steam is installed as a snap. Snaps are not compatible with WiVRn."
msgstr ""
"Steam está instalado mediante snap. Los Snaps no son compatibles con WiVRn."
#: dashboard/qml/Main.qml:225
#: dashboard/qml/Main.qml:195
#, kde-format
msgid ""
"Steam is installed as a flatpak but does not have sufficient permissions."
msgstr ""
"Steam está instalado con flatpak, pero no tiene los suficientes permisos."
#: dashboard/qml/Main.qml:240
#: dashboard/qml/Main.qml:210
#, kde-format
msgid "Restart the server for configuration changes to take effect"
msgstr "Reinicia el servidor para que los cambios surtan efecto"
#: dashboard/qml/Main.qml:246
#: dashboard/qml/Main.qml:216
#, kde-format
msgctxt "restart the server"
msgid "Restart now"
msgstr "Reiniciar ahora"
#: dashboard/qml/Main.qml:271
#: dashboard/qml/Main.qml:241
#, kde-format
msgid "Server failed to start"
msgstr "El servidor no pudo iniciar"
#: dashboard/qml/Main.qml:277 dashboard/qml/TroubleshootPage.qml:89
#: dashboard/qml/Main.qml:247 dashboard/qml/TroubleshootPage.qml:89
#, kde-format
msgid "Open server logs"
msgstr "Abrir registros del servidor"
#: dashboard/qml/Main.qml:303
#, kde-format
msgid "Server status"
msgstr "Estado del servidor"
#: dashboard/qml/Main.qml:309
#: dashboard/qml/Main.qml:276
#, kde-format
msgctxt "whether the server is running, displayed in front of a checkbox"
msgid "Running"
msgstr "En ejecución"
#: dashboard/qml/Main.qml:322
#: dashboard/qml/Main.qml:291
#, kde-format
msgctxt "whether pairing is enabled, displayed in front of a checkbox"
msgid "Pairing"
msgstr "Emparejando"
#: dashboard/qml/Main.qml:342
#: dashboard/qml/Main.qml:304
#, kde-format
msgid "Headset status"
msgstr "Estado del visor"
msgid "PIN: %1"
msgstr "PIN: %1"
#: dashboard/qml/Main.qml:349
#: dashboard/qml/Main.qml:312 dashboard/qml/WizardPage.qml:329
#, kde-format
msgctxt "label for headset name/status under server running switch"
msgid "Headset"
msgstr "Visor"
msgid "Connect by USB"
msgstr "Conectar por USB"
#: dashboard/qml/Main.qml:352
#, kde-format
msgid "Not connected"
msgstr "No conectado"
#: dashboard/qml/Main.qml:356
#, kde-format
msgid "Disconnect"
msgstr "Desconectar"
#: dashboard/qml/Main.qml:365 dashboard/qml/Main.qml:373
#: dashboard/qml/Main.qml:380
#, kde-format
msgctxt "label for USB status or connect button"
msgid "USB"
msgstr "USB"
#: dashboard/qml/Main.qml:366
#, kde-format
msgctxt "usb connect button"
msgid "Connect (wired)"
msgstr "Conectar (cableado)"
#: dashboard/qml/Main.qml:383 dashboard/qml/WizardPage.qml:339
#: dashboard/qml/Main.qml:323 dashboard/qml/WizardPage.qml:339
#, kde-format
msgid "No headset is connected or your headset is not in developer mode"
msgstr "No hay ningún visor conectado o tu visor no está en modo desarrollador"
#: dashboard/qml/Main.qml:404
#: dashboard/qml/Main.qml:331
#, kde-format
msgid "Disconnect"
msgstr "Desconectar"
#: dashboard/qml/Main.qml:349
#, kde-format
msgid "Steam information"
msgstr "Información de Steam"
#: dashboard/qml/Main.qml:420
#: dashboard/qml/Main.qml:370
#, kde-format
msgid "Wizard"
msgstr "Asistente"
#: dashboard/qml/Main.qml:426
#: dashboard/qml/Main.qml:377
#, kde-format
msgid "Install the app"
msgstr "Instalar aplicación"
#: dashboard/qml/Main.qml:445 dashboard/qml/SettingsPage.qml:14
#: dashboard/qml/Main.qml:398 dashboard/qml/SettingsPage.qml:14
#, kde-format
msgid "Settings"
msgstr "Ajustes"
#: dashboard/qml/Main.qml:451
#, kde-format
msgid "About"
msgstr "Acerca de"
#: dashboard/qml/Main.qml:456 dashboard/qml/TroubleshootPage.qml:10
#: dashboard/qml/Main.qml:405 dashboard/qml/TroubleshootPage.qml:10
#, kde-format
msgid "Troubleshoot"
msgstr "Solucionar problemas"
#: dashboard/qml/Main.qml:463
#, kde-format
msgid "Version %1"
msgstr "Versión %1"
#: dashboard/qml/SelectGame.qml:12
#: dashboard/qml/SelectGame.qml:14
#, kde-format
msgctxt "don't start an application automatically"
msgid "None"
msgstr "Ninguno"
#: dashboard/qml/SelectGame.qml:18
#: dashboard/qml/SelectGame.qml:20
#, kde-format
msgctxt "choose a custom application to start"
msgid "Custom"
msgstr "Personalizado"
#: dashboard/qml/SelectGame.qml:70
#: dashboard/qml/SelectGame.qml:72
#, kde-format
msgctxt "browse a file to choose the application to start"
msgid "Browse"
@@ -708,9 +621,9 @@ msgstr "Tengo un error de \"Servidor WiVRn incompatible\" en mi visor"
#: dashboard/qml/TroubleshootPage.qml:37
#, kde-format
msgid ""
"<p>The version of the headset app and the server on your computer must match."
"</p><ul><li>The headset app version is in the \"About\" page</li><li>The "
"server version is <b>%1</b></li></ul>"
"<p>The version of the headset app and the server on your computer must "
"match.</p><ul><li>The headset app version is in the \"About\" "
"page</li><li>The server version is <b>%1</b></li></ul>"
msgstr ""
"<p>La versión de la aplicación del visor y la del servidor en tu computadora "
"deben coincidir.</p><ul><li>La versión de la aplicación del visor está en la "
@@ -762,12 +675,13 @@ msgstr "Algunos juegos fallan al abrirse o tienen problemas de input"
#: dashboard/qml/TroubleshootPage.qml:62
#, kde-format
msgid ""
"For game specific issues, check on <a href=\"https://db.vronlinux.org/"
"\">vronlinux DB</a> if there are known bugs or workarounds."
"For game specific issues, check on <a "
"href=\"https://db.vronlinux.org/\">vronlinux DB</a> if there are known bugs "
"or workarounds."
msgstr ""
"Para problemas específicos de un juego, mirar en <a href=\"https://"
"db.vronlinux.org/\">vronlinux DB</a> por si hubiese algún problema conocido "
"o por soluciones."
"Para problemas específicos de un juego, mirar en <a "
"href=\"https://db.vronlinux.org/\">vronlinux DB</a> por si hubiese algún "
"problema conocido o por soluciones."
#: dashboard/qml/TroubleshootPage.qml:79
#, kde-format
@@ -918,11 +832,6 @@ msgstr ""
msgid "To connect over USB, click on \"Connect by USB\"."
msgstr "Para conectarte por USB, haz clic en \"Conectar por USB\"."
#: dashboard/qml/WizardPage.qml:329
#, kde-format
msgid "Connect by USB"
msgstr "Conectar por USB"
#: dashboard/qml/WizardPage.qml:349
#, kde-format
msgid "Troubleshooting"
@@ -971,20 +880,16 @@ msgstr "Finalizar"
msgid "Finished"
msgstr "Terminado"
#: dashboard/wivrn_server.cpp:540
#: dashboard/wivrn_server.cpp:533
#, kde-format
msgid "xrizer"
msgstr "xrizer"
#: dashboard/wivrn_server.cpp:541
#: dashboard/wivrn_server.cpp:534
#, kde-format
msgid "Open Composite"
msgstr "Open Composite"
#, kde-format
#~ msgid "PIN: %1"
#~ msgstr "PIN: %1"
#, kde-format
#~ msgctxt "automatically started application"
#~ msgid "Application"

Some files were not shown because too many files have changed in this diff Show More