Compare commits

..
Author SHA1 Message Date
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
296 changed files with 34281 additions and 37843 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 -121
View File
@@ -6,80 +6,68 @@ 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: |
${{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
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 +84,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 +92,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 +106,54 @@ 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
- 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 +164,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 +193,7 @@ jobs:
if: ${{ vars.APK_ONLY == '' }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -249,11 +211,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: |
@@ -261,21 +230,11 @@ jobs:
${{github.workspace}}/cmake-fetch/*-subbuild/*-populate-prefix/src/*.zip
${{github.workspace}}/cmake-fetch/*.tar.*
${{github.workspace}}/cmake-fetch/*.zip
${{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 +275,7 @@ jobs:
VERSION_CODE=$(( $VERSION_CODE + 1 ))
fi
CSS=images/wivrn-release.css
APPNAME=WiVRn
else
VERSION_CODE=1
@@ -323,29 +283,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 +324,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 +332,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 +372,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 +420,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 +438,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 +453,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 +462,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 +510,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
+33 -50
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)
@@ -59,8 +54,8 @@ set(OVR_COMPAT_SEARCH_PATH "/opt/xrizer:/usr/local/lib/OpenComposite:/usr/lib/Op
option(WIVRN_FEATURE_DEBUG_GUI "Enable Monado debug GUI" OFF)
option(WIVRN_FEATURE_RENDERDOC "Support renderdoc" OFF)
option(WIVRN_FEATURE_SOLARXR "Enable SolarXR driver" ON)
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" ON)
set(WIVRN_FEATURE_SOLARXR OFF) # Will be added back when merged in upstream Monado
option(WIVRN_FEATURE_STEAMVR_LIGHTHOUSE "Enable SteamVR Lighthouse driver" OFF)
set(WIVRN_CSS "${CMAKE_SOURCE_DIR}/images/wivrn-local.css" CACHE STRING "Stylesheet to use to render SVGs" )
@@ -72,7 +67,6 @@ set(WIVRN_OPENXR_MANIFEST_TYPE "relative" CACHE STRING "How to reference librari
if (NOT WIVRN_OPENXR_MANIFEST_TYPE IN_LIST WIVRN_OPENXR_MANIFEST_TYPE_VALUES)
message(FATAL_ERROR "WIVRN_OPENXR_MANIFEST_TYPE must be one of ${WIVRN_OPENXR_MANIFEST_TYPE_VALUES}")
endif()
option(WIVRN_OPENXR_MANIFEST_ABI "Generate an ABI specific OpenXR manifest")
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
@@ -102,9 +96,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 +171,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)
@@ -201,7 +199,7 @@ if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
find_package(Fontconfig REQUIRED)
if (WIVRN_USE_SYSTEM_OPENXR)
find_package(OpenXR 1.1.53 REQUIRED)
find_package(OpenXR 1.1.48 REQUIRED)
endif()
if (WIVRN_USE_SYSTEM_LIBKTX)
@@ -218,7 +216,7 @@ endif()
if (WIVRN_BUILD_DISSECTOR)
if (WIVRN_USE_SYSTEM_OPENXR)
find_package(OpenXR 1.1.53 REQUIRED)
find_package(OpenXR 1.1.48 REQUIRED)
endif()
find_package(Wireshark REQUIRED)
endif()
@@ -229,6 +227,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,9 +238,9 @@ 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)
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)
URL_HASH SHA256=a41adf423315e35489c1e67689c7bb74c7edd4d207a477b7b19c45cd440c2f67)
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.48.tar.gz
URL_HASH SHA256=c9372992dcdfac643e28796e41d4dbd36c4cdf0388d01fa89245628edae9d411)
FetchContent_Declare(spdlog EXCLUDE_FROM_ALL SYSTEM URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz
URL_HASH SHA256=8741753e488a78dd0d0024c980e1fb5b5c85888447e309d9cb9d949bdb52aa3e)
FetchContent_Declare(stb EXCLUDE_FROM_ALL SYSTEM URL https://github.com/nothings/stb/archive/013ac3beddff3dbffafd5177e7972067cd2b5083.zip
@@ -253,14 +253,14 @@ FetchContent_Declare(libktx EXCLUDE_FROM_ALL SYSTEM URL https://github.co
FetchContent_Declare(implot EXCLUDE_FROM_ALL SYSTEM URL https://github.com/epezent/implot/archive/3da8bd34299965d3b0ab124df743fe3e076fa222.zip
URL_HASH SHA256=e9b439a94aa6f09fcf12ed9c2cd784efe5e99e96242122aa683e690b29f7a59f)
file(GLOB IMGUI_PATCHES CONFIGURE_DEPENDS patches/imgui/*)
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.5.tar.gz
URL_HASH SHA256=0eb50fe9aeba1a51f96b5843c7f630a32ed2e9362d693c61b87e4fa870cf826d
FetchContent_Declare(imgui EXCLUDE_FROM_ALL SYSTEM URL https://github.com/ocornut/imgui/archive/refs/tags/v1.92.4.tar.gz
URL_HASH SHA256=0e175d4d941112532549b418ced0bd546abe9024ecb9b5f431f8a67a2197b0ba
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${IMGUI_PATCHES}
)
FetchContent_Declare(uni-algo EXCLUDE_FROM_ALL SYSTEM URL https://github.com/uni-algo/uni-algo/archive/v1.2.0.tar.gz
URL_HASH SHA256=f2a1539cd8635bc6088d05144a73ecfe7b4d74ee0361fabed6f87f9f19e74ca9)
FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v3.16.0.tar.gz
URL_HASH SHA256=7d7b4037b737992342049ffab14f22fa10243e01664f8c3a0657aa247ac52f71)
FetchContent_Declare(entt EXCLUDE_FROM_ALL SYSTEM URL https://github.com/skypjack/entt/archive/refs/tags/v3.15.0.tar.gz
URL_HASH SHA256=01466fcbf77618a79b62891510c0bbf25ac2804af5751c84982b413852234d66)
FetchContent_Declare(curl EXCLUDE_FROM_ALL SYSTEM URL https://github.com/curl/curl/releases/download/curl-8_17_0/curl-8.17.0.tar.xz
URL_HASH SHA256=955f6e729ad6b3566260e8fef68620e76ba3c31acf0a18524416a185acf77992)
FetchContent_Declare(spirv-reflect EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/SPIRV-Reflect/archive/refs/tags/vulkan-sdk-1.4.328.1.tar.gz
@@ -271,27 +271,11 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS monado-rev)
file(STRINGS monado-rev MONADO_REV)
# Server dependencies
FetchContent_Declare(monado
GIT_REPOSITORY https://gitlab.freedesktop.org/monado/monado.git
# The flatpak manifest is updated automatically
GIT_TAG ${MONADO_REV}
URL https://gitlab.freedesktop.org/monado/monado/-/archive/${MONADO_REV}/monado-${MONADO_REV}.tar.gz
PATCH_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patches/apply.sh ${MONADO_PATCHES}
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)
@@ -305,18 +289,18 @@ if (WIVRN_BUILD_SERVER OR WIVRN_BUILD_SERVER_LIBRARY)
add_subdirectory(server)
if (WIVRN_BUILD_SERVER)
message(STATUS "Selected encoders:")
message(STATUS "\tNVENC : ${WIVRN_USE_NVENC}")
message(STATUS "\tVAAPI : ${WIVRN_USE_VAAPI}")
message(STATUS "\tVulkan: ${WIVRN_USE_VULKAN_ENCODE}")
message(STATUS "\tx264 : ${WIVRN_USE_X264}")
message(STATUS "")
message(STATUS "Audio backends:")
message(STATUS "\tPipewire : ${WIVRN_USE_PIPEWIRE}")
message(STATUS "\tPulseaudio: ${WIVRN_USE_PULSEAUDIO}")
message(STATUS "")
message(STATUS "Optional features:")
message(STATUS "\tsystemd: ${WIVRN_USE_SYSTEMD}")
message("Selected encoders:")
message("\tNVENC : ${WIVRN_USE_NVENC}")
message("\tVAAPI : ${WIVRN_USE_VAAPI}")
message("\tVulkan: ${WIVRN_USE_VULKAN_ENCODE}")
message("\tx264 : ${WIVRN_USE_X264}")
message("")
message("Audio backends:")
message("\tPipewire : ${WIVRN_USE_PIPEWIRE}")
message("\tPulseaudio: ${WIVRN_USE_PULSEAUDIO}")
message("")
message("Optional features:")
message("\tsystemd: ${WIVRN_USE_SYSTEMD}")
endif()
endif()
@@ -331,7 +315,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
+44 -89
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,52 +41,51 @@ 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).
### 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:
- Steam games that are flagged as VR. Steam may need to be restarted for the list to be updated when new games are installed.
- .desktop files that contain `X-WiVRn-VR` in the `Categories` section. Files are searched in [standard locations](https://specifications.freedesktop.org/desktop-entry/latest/file-naming.html#desktop-file-id) which usually include `~/.local/share/applications` and `/usr/share/applications/`.
You can set an application to be started automatically when you connect your headset in the dashboard settings or [manually](docs/configuration.md#application)
### 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/), 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 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 OpenComposite.
### Steam Flatpak
If you're using the Steam Flatpak, you'll need to grant read only access to the following paths:
```bash
flatpak override \
flatpak override --user \
--filesystem=xdg-run/wivrn:ro \
--filesystem=xdg-data/flatpak/app/io.github.wivrn.wivrn:ro \
--filesystem=/var/lib/flatpak/app/io.github.wivrn.wivrn:ro \
--filesystem=xdg-config/openxr:ro \
--filesystem=xdg-config/openvr:ro \
com.valvesoftware.Steam
```
When using a user installation of flatpak Steam, use `override --user` instead of `override`.
Then create a symlink for the OpenXR configuration file (the directory `~/.var/app/com.valvesoftware.Steam/.config/openxr` will need to be created if it doesn't already exist):
```bash
ln -s ~/.config/openxr/1 ~/.var/app/com.valvesoftware.Steam/.config/openxr/1
```
### 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 +99,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 +125,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 +142,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
@@ -0,0 +1,168 @@
{
"profileId": "generic-trigger-squeeze",
"fallbackProfileIds": [],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "generic-trigger-squeeze-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "generic-trigger-squeeze-right",
"assetPath": "right.glb"
},
"none": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
},
"xr_standard_squeeze_pressed_mirror": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_mirror_value",
"minNodeName": "xr_standard_squeeze_pressed_mirror_min",
"maxNodeName": "xr_standard_squeeze_pressed_mirror_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "generic-trigger-squeeze-none",
"assetPath": "none.glb"
}
}
}
Binary file not shown.
@@ -0,0 +1,286 @@
{
"profileId": "htc-vive-focus-3",
"fallbackProfileIds": [
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "htc-vive-focus-3-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "htc-vive-focus-3-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
@@ -0,0 +1,330 @@
{
"profileId": "meta-quest-touch-plus",
"fallbackProfileIds": [
"oculus-touch-v3",
"oculus-touch",
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "meta-quest-touch-plus-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "meta-quest-touch-plus-right",
"assetPath": "right.glb"
}
}
}
@@ -0,0 +1,330 @@
{
"profileId": "meta-quest-touch-pro",
"fallbackProfileIds": [
"oculus-touch-v2",
"oculus-touch",
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "meta-quest-touch-pro-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "meta-quest-touch-pro-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
@@ -0,0 +1,329 @@
{
"profileId": "oculus-touch-v2",
"fallbackProfileIds": [
"oculus-touch",
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "oculus-touch-v2-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "oculus-touch-v2-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,330 @@
{
"profileId": "oculus-touch-v3",
"fallbackProfileIds": [
"oculus-touch-v2",
"oculus-touch",
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "oculus-touch-v3-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
},
"thumbrest": {
"type": "button",
"gamepadIndices": {
"button": 6
},
"rootNodeName": "thumbrest",
"visualResponses": {
"thumbrest_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "thumbrest_pressed_value",
"minNodeName": "thumbrest_pressed_min",
"maxNodeName": "thumbrest_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "oculus-touch-v3-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,286 @@
{
"profileId": "pico-4",
"fallbackProfileIds": [
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "pico-4-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "pico-4-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,286 @@
{
"profileId": "pico-neo3",
"fallbackProfileIds": [
"generic-trigger-squeeze-thumbstick"
],
"layouts": {
"left": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"x-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "x_button",
"visualResponses": {
"x_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "x_button_pressed_value",
"minNodeName": "x_button_pressed_min",
"maxNodeName": "x_button_pressed_max"
}
}
},
"y-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "y_button",
"visualResponses": {
"y_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "y_button_pressed_value",
"minNodeName": "y_button_pressed_min",
"maxNodeName": "y_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "pico-neo3-left",
"assetPath": "left.glb"
},
"right": {
"selectComponentId": "xr-standard-trigger",
"components": {
"xr-standard-trigger": {
"type": "trigger",
"gamepadIndices": {
"button": 0
},
"rootNodeName": "xr_standard_trigger",
"visualResponses": {
"xr_standard_trigger_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_trigger_pressed_value",
"minNodeName": "xr_standard_trigger_pressed_min",
"maxNodeName": "xr_standard_trigger_pressed_max"
}
}
},
"xr-standard-squeeze": {
"type": "squeeze",
"gamepadIndices": {
"button": 1
},
"rootNodeName": "xr_standard_squeeze",
"visualResponses": {
"xr_standard_squeeze_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_squeeze_pressed_value",
"minNodeName": "xr_standard_squeeze_pressed_min",
"maxNodeName": "xr_standard_squeeze_pressed_max"
}
}
},
"xr-standard-thumbstick": {
"type": "thumbstick",
"gamepadIndices": {
"button": 3,
"xAxis": 2,
"yAxis": 3
},
"rootNodeName": "xr_standard_thumbstick",
"visualResponses": {
"xr_standard_thumbstick_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_pressed_value",
"minNodeName": "xr_standard_thumbstick_pressed_min",
"maxNodeName": "xr_standard_thumbstick_pressed_max"
},
"xr_standard_thumbstick_xaxis_pressed": {
"componentProperty": "xAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_xaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_xaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_xaxis_pressed_max"
},
"xr_standard_thumbstick_yaxis_pressed": {
"componentProperty": "yAxis",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "xr_standard_thumbstick_yaxis_pressed_value",
"minNodeName": "xr_standard_thumbstick_yaxis_pressed_min",
"maxNodeName": "xr_standard_thumbstick_yaxis_pressed_max"
}
}
},
"a-button": {
"type": "button",
"gamepadIndices": {
"button": 4
},
"rootNodeName": "a_button",
"visualResponses": {
"a_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "a_button_pressed_value",
"minNodeName": "a_button_pressed_min",
"maxNodeName": "a_button_pressed_max"
}
}
},
"b-button": {
"type": "button",
"gamepadIndices": {
"button": 5
},
"rootNodeName": "b_button",
"visualResponses": {
"b_button_pressed": {
"componentProperty": "button",
"states": [
"default",
"touched",
"pressed"
],
"valueNodeProperty": "transform",
"valueNodeName": "b_button_pressed_value",
"minNodeName": "b_button_pressed_min",
"maxNodeName": "b_button_pressed_max"
}
}
}
},
"gamepadMapping": "xr-standard",
"rootNodeName": "pico-neo3-right",
"assetPath": "right.glb"
}
}
}
Binary file not shown.
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'
+11 -26
View File
@@ -65,15 +65,6 @@ if(ANDROID)
target_compile_definitions(wivrn PRIVATE -DXR_USE_PLATFORM_ANDROID -DVK_USE_PLATFORM_ANDROID_KHR)
target_link_options(wivrn PRIVATE -Wl,--undefined=ANativeActivity_onCreate)
target_link_options(wivrn
PRIVATE
-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/android/exported_symbols.txt
# This causes the linker to emit an error when a version script names a
# symbol that is not found, rather than silently ignoring that line.
-Wl,--no-undefined-version
)
set_target_properties(wivrn PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/android/exported_symbols.txt)
file(GLOB PLATFORM_SOURCE CONFIGURE_DEPENDS
"android/*.cpp"
"audio/android/*.cpp"
@@ -194,7 +185,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 +204,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()
@@ -263,13 +254,11 @@ set(ASSETS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../assets-source)
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-pride.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${IMAGES_SRC_DIR}/wivrn-christmas.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png WIDTH 540 HEIGHT 540 CSS ${WIVRN_CSS_ABS})
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/passthrough.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png WIDTH 256 HEIGHT 256)
wivrn_rasterize_svg(SOURCE ${ASSETS_SRC_DIR}/default-environment.svg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png WIDTH 256 HEIGHT 256)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn.png DESTINATION ${ASSETS_DIR}/wivrn.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-pride.png DESTINATION ${ASSETS_DIR}/wivrn-pride.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/wivrn-christmas.png DESTINATION ${ASSETS_DIR}/wivrn-christmas.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${ASSETS_SRC_DIR}/default_icon.png DESTINATION ${ASSETS_DIR}/default_icon.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/passthrough.png DESTINATION ${ASSETS_DIR}/passthrough.ktx2 TARGET wivrn)
wivrn_generate_ktx( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/default-environment.png DESTINATION ${ASSETS_DIR}/default-environment.ktx2 TARGET wivrn)
@@ -278,18 +267,14 @@ if(WIVRN_COMPRESS_GLB)
else()
wivrn_copy_file( SOURCE ${ASSETS_SRC_DIR}/ground.glb DESTINATION ${ASSETS_DIR}/ground.glb TARGET wivrn)
endif()
wivrn_webxr_download()
wivrn_webxr_controller(PROFILE generic-trigger-squeeze DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE htc-vive-focus-3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE meta-quest-touch-plus DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE meta-quest-touch-pro DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE oculus-touch-v2 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE oculus-touch-v3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE pico-4 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE pico-4u DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE pico-neo3 DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller(PROFILE samsung-galaxyxr DESTINATION ${ASSETS_DIR}/controllers TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/generic-trigger-squeeze DESTINATION ${ASSETS_DIR}/controllers/generic-trigger-squeeze TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/htc-vive-focus-3 DESTINATION ${ASSETS_DIR}/controllers/htc-vive-focus-3 TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/meta-quest-touch-plus DESTINATION ${ASSETS_DIR}/controllers/meta-quest-touch-plus TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/meta-quest-touch-pro DESTINATION ${ASSETS_DIR}/controllers/meta-quest-touch-pro TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/oculus-touch-v2 DESTINATION ${ASSETS_DIR}/controllers/oculus-touch-v2 TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/oculus-touch-v3 DESTINATION ${ASSETS_DIR}/controllers/oculus-touch-v3 TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/pico-4 DESTINATION ${ASSETS_DIR}/controllers/pico-4 TARGET wivrn)
wivrn_webxr_controller( SOURCE ${ASSETS_SRC_DIR}/controllers/pico-neo3 DESTINATION ${ASSETS_DIR}/controllers/pico-neo3 TARGET wivrn)
# Add the VR splash screen (only used on Quest)
-11
View File
@@ -1,11 +0,0 @@
LIBAPP {
global:
ANativeActivity_onCreate;
android_main;
Java_org_meumeu_wivrn_BroadcastReceiver_onReceive;
Java_org_meumeu_wivrn_MainActivity_onRequestPermissionsResult;
Java_org_meumeu_wivrn_MainActivity_onActivityResult;
Java_org_meumeu_wivrn_MainActivity_onNewIntent;
local:
*;
};
-36
View File
@@ -1,36 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2025 Guillaume Meunier <guillaume.meunier@centraliens.net>
* 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 "jnipp.h"
namespace jni::details
{
void handle_java_exception()
{
auto & env = jni_thread::env();
if (auto exc = env.ExceptionOccurred())
{
env.ExceptionClear();
std::string str = object<"java/lang/Object">{exc}.call<jni::string>("toString");
throw std::runtime_error("Java exception " + str);
}
}
} // namespace jni::details
+4 -40
View File
@@ -25,7 +25,6 @@
#include <tuple>
#include <jni.h>
#include <type_traits>
namespace jni
{
@@ -172,9 +171,6 @@ struct type_map<int>
template <typename T>
using type_map_t = type_map<T>::type;
void handle_java_exception();
} // namespace details
struct klass
@@ -219,17 +215,7 @@ struct klass
assert(method_id);
auto handles = details::handle(std::forward<Args>(args)...);
return R(std::apply([&](auto &... t) {
if constexpr (std::is_void_v<R>)
{
(env.*R1::call_static_method)(*this, method_id, t...);
details::handle_java_exception();
}
else
{
auto res = (env.*R1::call_static_method)(*this, method_id, t...);
details::handle_java_exception();
return res;
}
return (env.*R1::call_static_method)(*this, method_id, t...);
},
handles));
}
@@ -297,17 +283,7 @@ struct object
assert(method_id);
auto handles = details::handle(std::forward<Args>(args)...);
return R(std::apply([&](auto &... t) {
if constexpr (std::is_void_v<R>)
{
(env.*R1::call_method)(*this, method_id, t...);
details::handle_java_exception();
}
else
{
auto res = (env.*R1::call_method)(*this, method_id, t...);
details::handle_java_exception();
return res;
}
return (env.*R1::call_method)(*this, method_id, t...);
},
handles));
}
@@ -320,17 +296,7 @@ struct object
assert(method_id);
auto handles = details::handle(std::forward<Args>(args)...);
return R(std::apply([&](auto &... t) {
if constexpr (std::is_void_v<R>)
{
(env.*R1::call_method)(*this, method_id, t...);
details::handle_java_exception();
}
else
{
auto res = (env.*R1::call_method)(*this, method_id, t...);
details::handle_java_exception();
return res;
}
return (env.*R1::call_method)(*this, method_id, t...);
},
handles));
}
@@ -361,9 +327,7 @@ static object<Type> new_object(Args &&... args)
assert(method_id);
auto handles = details::handle(std::forward<Args>(args)...);
return object<Type>(std::apply([&](auto &... t) {
auto res = env.NewObject(klass, method_id, t...);
details::handle_java_exception();
return res;
return env.NewObject(klass, method_id, t...);
},
handles));
}
+18 -40
View File
@@ -24,7 +24,6 @@
#include "scene.h"
#include "spdlog/common.h"
#include "spdlog/spdlog.h"
#include "utils/class_from_member.h"
#include "utils/contains.h"
#include "utils/files.h"
#include "utils/i18n.h"
@@ -722,13 +721,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
@@ -764,7 +761,6 @@ void application::initialize_vulkan()
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME);
vk_device_extensions.push_back(VK_KHR_MULTIVIEW_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
optional_device_extensions.emplace(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
optional_device_extensions.emplace(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME);
@@ -888,30 +884,24 @@ void application::initialize_vulkan()
vk::PhysicalDeviceSamplerYcbcrConversionFeaturesKHR{
.samplerYcbcrConversion = true,
},
vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR{},
vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR{
.timelineSemaphore = true,
},
vk::PhysicalDeviceMultiviewFeaturesKHR{
.multiview = true,
},
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{}};
auto check_feature_flag = [&](auto feature_flag, const char * extension_name) -> bool {
using FeatureStruct = class_from_member_t<decltype(feature_flag)>;
if (utils::contains(vk_device_extensions, extension_name) and
vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, FeatureStruct>().template get<FeatureStruct>().*feature_flag)
{
device_create_info.get<FeatureStruct>().*feature_flag = true;
return true;
}
else
{
device_create_info.unlink<FeatureStruct>();
return false;
}
};
check_feature_flag(&vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR::timelineSemaphore, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME);
check_feature_flag(&vk::PhysicalDeviceIndexTypeUint8FeaturesEXT::indexTypeUint8, VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME);
if (utils::contains(vk_device_extensions, VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME))
{
auto [_, feat] = vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
auto & create_feat = device_create_info.get<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
create_feat.timelineSemaphore = feat.timelineSemaphore;
}
else
{
device_create_info.unlink<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>();
}
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
@@ -1063,19 +1053,6 @@ void application::initialize_actions()
}
}
// Patch profile to add pinch_ext/pose and poke_ext/pose
if (xr_instance.has_extension(XR_EXT_HAND_INTERACTION_EXTENSION_NAME) //
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
and not utils::contains(profile.input_sources, "/user/hand/left/input/pinch_ext/pose"))
{
spdlog::info("Adding pinch_ext/pose for interaction profile {}", profile.profile_name);
profile.input_sources.push_back("/user/hand/left/input/pinch_ext/pose");
profile.input_sources.push_back("/user/hand/right/input/pinch_ext/pose");
spdlog::info("Adding poke_ext/pose for interaction profile {}", profile.profile_name);
profile.input_sources.push_back("/user/hand/left/input/poke_ext/pose");
profile.input_sources.push_back("/user/hand/right/input/poke_ext/pose");
}
// Dynamically add VIVE XR Trackers to the profile if available
if (utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME) and
xr_instance.has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME))
@@ -1234,8 +1211,6 @@ void application::initialize()
XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME,
XR_EXT_USER_PRESENCE_EXTENSION_NAME,
XR_ANDROID_FACE_TRACKING_EXTENSION_NAME,
XR_BD_BODY_TRACKING_EXTENSION_NAME,
XR_FB_BODY_TRACKING_EXTENSION_NAME,
@@ -1243,6 +1218,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,
@@ -1253,7 +1232,6 @@ void application::initialize()
XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME,
XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME,
XR_META_LOCAL_DIMMING_EXTENSION_NAME,
};
for (const auto & i: interaction_profiles)
@@ -1336,7 +1314,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
+12 -89
View File
@@ -19,9 +19,7 @@
#include "configuration.h"
#include "application.h"
#include "utils/contains.h"
#include "utils/json_string.h"
#include "wivrn_packets.h"
#include <fstream>
#include <magic_enum.hpp>
@@ -30,9 +28,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,42 +94,10 @@ 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();
switch (guess_model())
{
case model::oculus_quest:
case model::oculus_quest_2:
case model::meta_quest_pro:
case model::meta_quest_3:
case model::meta_quest_3s:
high_power_mode = false;
break;
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise:
case model::htc_vive_focus_3:
case model::htc_vive_xr_elite:
case model::htc_vive_focus_vision:
case model::lynx_r1:
case model::samsung_galaxy_xr:
case model::unknown:
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 +121,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();
@@ -170,27 +129,6 @@ configuration::configuration(xr::system & system, xr::session & session)
if (auto val = root["resolution_scale"]; val.is_double())
resolution_scale = val.get_double();
if (auto val = root["stream_scale"]; val.is_double())
stream_scale = val.get_double();
if (auto val = root["codec"]; val.is_string())
{
const auto codec_str = val.get_string().value();
for (const auto & [c, name]: magic_enum::enum_entries<wivrn::video_codec>())
{
if (codec_str == name)
{
codec = c;
}
}
}
if (auto val = root["bit_depth"]; val.is_uint64())
bit_depth = val.get_uint64();
if (auto val = root["bitrate_bps"]; val.is_number())
bitrate_bps = val.get_uint64();
if (auto val = root["enable_stream_gui"]; val.is_bool())
enable_stream_gui = val.get_bool();
@@ -240,13 +178,18 @@ configuration::configuration(xr::system & system, xr::session & session)
if (auto val = root["high_power_mode"]; val.is_bool())
high_power_mode = val.get_bool();
if (auto val = root["extended_config"]; val.is_bool())
extended_config = val.get_bool();
}
catch (std::exception & e)
{
spdlog::warn("Cannot read configuration: {}", e.what());
// Restore default configuration
servers.clear();
preferred_refresh_rate.reset();
minimum_refresh_rate.reset();
resolution_scale = 1.4;
openxr_post_processing = {};
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
}
}
@@ -302,16 +245,11 @@ 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;
if (stream_scale)
json << ",\"stream_scale\":" << *stream_scale;
if (codec)
json << ",\"codec\":" << json_string(magic_enum::enum_name(*codec));
json << ",\"bit_depth\":" << (uint64_t)bit_depth;
json << ",\"bitrate_bps\":" << bitrate_bps;
json << ",\"openxr_post_processing\":";
write_openxr_post_processing(json, openxr_post_processing);
json << ",\"passthrough_enabled\":" << std::boolalpha << passthrough_enabled;
@@ -329,20 +267,5 @@ void configuration::save()
json << ",\"locale\":" << json_string(locale);
json << ",\"environment_model\":" << json_string(environment_model);
json << ",\"high_power_mode\":" << std::boolalpha << high_power_mode;
json << ",\"extended_config\":" << std::boolalpha << extended_config;
json << "}";
}
void configuration::set_stream_scale(float val)
{
stream_scale = val;
}
float configuration::get_stream_scale() const
{
if (stream_scale)
return *stream_scale;
if (check_feature(feature::eye_gaze))
return 0.3;
return 0.5;
}
+6 -24
View File
@@ -21,7 +21,6 @@
#include "hardware.h"
#include "wivrn_discover.h"
#include "wivrn_packets.h"
#include <map>
#include <mutex>
@@ -31,9 +30,8 @@
namespace xr
{
class session;
class system;
} // namespace xr
}
class configuration
{
@@ -49,13 +47,9 @@ 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;
uint32_t bitrate_bps = 50'000'000;
uint8_t bit_depth = 10;
float resolution_scale = 1.4;
bool passthrough_enabled = false;
bool mic_unprocessed_audio = false;
@@ -77,13 +71,10 @@ 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;
// Allow unsafe config values
bool extended_config = false;
bool high_power_mode = false;
bool first_run = true;
@@ -95,21 +86,12 @@ public:
private:
mutable std::mutex mutex;
std::map<feature, bool> features;
std::optional<float> stream_scale;
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();
void set_stream_scale(float);
float get_stream_scale() const;
uint32_t max_bitrate() const
{
return extended_config ? 800'000'000u : 200'000'000u;
}
};
+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};
+19 -24
View File
@@ -42,7 +42,6 @@ struct wivrn::android::decoder::mapped_hardware_buffer
{
vk::raii::DeviceMemory memory = nullptr;
vk::raii::Image vimage = nullptr;
vk::Extent2D extent{};
vk::raii::ImageView image_view = nullptr;
vk::ImageLayout layout = vk::ImageLayout::eUndefined;
};
@@ -86,12 +85,11 @@ struct android_blit_handle : public decoder::blit_handle
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
vk::ImageView image_view,
vk::Image image,
vk::Extent2D extent,
vk::ImageLayout & current_layout,
decltype(vk_data) vk_data,
decltype(image_reader) image_reader,
decltype(aimage) aimage) :
decoder::blit_handle(feedback, view_info, image_view, image, extent, current_layout),
decoder::blit_handle(feedback, view_info, image_view, image, current_layout),
vk_data(vk_data),
image_reader(image_reader),
aimage(std::move(aimage)) {}
@@ -105,21 +103,19 @@ namespace wivrn::android
decoder::decoder(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
float fps,
uint8_t stream_index,
std::weak_ptr<scenes::stream> weak_scene,
shard_accumulator * accumulator) :
stream_index(stream_index), device(device), weak_scene(weak_scene), accumulator(accumulator)
wivrn::decoder(description), stream_index(stream_index), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
{
spdlog::info("hbm_mutex.native_handle() = {}", (void *)hbm_mutex.native_handle());
auto width = description.width;
auto height = description.height / (stream_index == 2 ? 2 : 1);
AImageReader * ir;
check(AImageReader_newWithUsage(
width,
height,
description.video_width,
description.video_height,
AIMAGE_FORMAT_PRIVATE,
AHARDWAREBUFFER_USAGE_CPU_READ_NEVER | AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE,
scenes::stream::image_buffer_size + 4 /* maxImages */,
@@ -135,18 +131,18 @@ decoder::decoder(
"vkGetAndroidHardwareBufferPropertiesANDROID");
{
AMediaFormat_ptr format(AMediaFormat_new());
AMediaFormat_setString(format.get(), AMEDIAFORMAT_KEY_MIME, mime(description.codec[stream_index]));
AMediaFormat_setString(format.get(), AMEDIAFORMAT_KEY_MIME, mime(description.codec));
// AMediaFormat_setInt32(format.get(), "vendor.qti-ext-dec-low-latency.enable", 1); // Qualcomm low
// latency mode
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, width);
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, height);
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(description.fps));
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_WIDTH, description.video_width);
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_HEIGHT, description.video_height);
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_OPERATING_RATE, std::ceil(fps));
AMediaFormat_setInt32(format.get(), AMEDIAFORMAT_KEY_PRIORITY, 0);
media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec[stream_index])));
media_codec.reset(AMediaCodec_createDecoderByType(mime(description.codec)));
if (not media_codec)
throw std::runtime_error(std::string("Cannot create decoder for MIME type ") + mime(description.codec[stream_index]));
throw std::runtime_error(std::string("Cannot create decoder for MIME type ") + mime(description.codec));
char * codec_name;
check(AMediaCodec_getName(media_codec.get(), &codec_name), "AMediaCodec_getName");
@@ -312,7 +308,6 @@ void decoder::on_image_available(AImageReader * reader)
info->view_info,
*vk_data->image_view,
*vk_data->vimage,
vk_data->extent,
vk_data->layout,
std::move(vk_data),
image_reader,
@@ -366,8 +361,11 @@ void decoder::create_sampler(const AHardwareBuffer_Desc & buffer_desc, vk::Andro
};
// suggested values from decoder don't actually read the metadata, so it's garbage
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrRange = vk::SamplerYcbcrRange::eItuFull;
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrModel = vk::SamplerYcbcrModelConversion::eYcbcr709;
if (description.range)
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrRange = vk::SamplerYcbcrRange(*description.range);
if (description.color_model)
ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>().ycbcrModel = vk::SamplerYcbcrModelConversion(*description.color_model);
ycbcr_conversion = vk::raii::SamplerYcbcrConversion(device, ycbcr_create_info.get<vk::SamplerYcbcrConversionCreateInfo>());
@@ -413,6 +411,7 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
if (!*ycbcr_sampler || memcmp(&ahb_format, &format_properties, sizeof(format_properties)))
{
memcpy(&ahb_format, &format_properties, sizeof(format_properties));
extent_ = {buffer_desc.width, buffer_desc.height};
spdlog::info("decoded image size: {}x{}", buffer_desc.width, buffer_desc.height);
create_sampler(buffer_desc, ahb_format);
hardware_buffer_map.clear();
@@ -491,10 +490,6 @@ std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AI
handle->vimage = std::move(vimage);
handle->image_view = std::move(image_view);
handle->memory = std::move(memory);
handle->extent = vk::Extent2D{
.width = buffer_desc.width,
.height = buffer_desc.height,
};
hardware_buffer_map[hardware_buffer] = handle;
return handle;
@@ -574,8 +569,8 @@ void decoder::supported_codecs(std::vector<wivrn::video_codec> & result)
// In order or preference, from preferred to least preferred
for (auto codec: {
wivrn::video_codec::av1,
wivrn::video_codec::h265,
wivrn::video_codec::h264,
wivrn::video_codec::h265,
})
{
AMediaCodec_ptr media_codec(AMediaCodec_createDecoderByType(mime(codec)));
+3 -1
View File
@@ -67,6 +67,7 @@ public:
private:
uint8_t stream_index;
float fps;
vk::raii::Device & device;
@@ -121,7 +122,8 @@ private:
public:
decoder(vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
float fps,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator);
+8 -12
View File
@@ -31,12 +31,13 @@ std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
vk::raii::Device & device,
vk::raii::PhysicalDevice & phys_dev,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
float fps,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * acc)
{
switch (description.codec[stream_index])
switch (description.codec)
{
case h264:
case h265:
@@ -46,6 +47,7 @@ std::shared_ptr<wivrn::decoder> wivrn::decoder::make(
device,
phys_dev,
description,
fps,
stream_index,
scene,
acc);
@@ -71,20 +73,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;
}
+14 -3
View File
@@ -42,18 +42,25 @@ public:
wivrn::to_headset::video_stream_data_shard::view_info_t view_info;
vk::ImageView image_view = nullptr;
vk::Image image = nullptr;
vk::Extent2D extent{};
vk::ImageLayout & current_layout;
vk::Semaphore semaphore = nullptr;
uint64_t * semaphore_val = nullptr;
};
const wivrn::to_headset::video_stream_description::item description;
protected:
decoder(const wivrn::to_headset::video_stream_description::item & description) :
description(description) {}
vk::Extent2D extent_; // Must be populated when sampler is set
public:
static std::shared_ptr<decoder> make(
vk::raii::Device &,
vk::raii::PhysicalDevice &,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
float fps,
uint8_t stream_index,
std::weak_ptr<scenes::stream>,
shard_accumulator *);
@@ -65,7 +72,11 @@ public:
const to_headset::video_stream_data_shard::view_info_t & view_info) = 0;
virtual vk::Sampler sampler() = 0;
const vk::Extent2D extent()
{
return extent_;
}
static const std::vector<wivrn::video_codec> & supported_codecs();
static std::vector<wivrn::video_codec> supported_codecs();
};
} // namespace wivrn
+8 -16
View File
@@ -73,7 +73,6 @@ struct decoder::ffmpeg_blit_handle : public wivrn::decoder::blit_handle
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
vk::ImageView image_view,
vk::Image image,
vk::Extent2D extent,
vk::ImageLayout & current_layout,
int image_index,
wivrn::ffmpeg::decoder * self) :
@@ -82,7 +81,6 @@ struct decoder::ffmpeg_blit_handle : public wivrn::decoder::blit_handle
view_info,
image_view,
image,
extent,
current_layout,
},
image_index(image_index),
@@ -102,19 +100,16 @@ struct decoder::ffmpeg_blit_handle : public wivrn::decoder::blit_handle
decoder::decoder(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator) :
wivrn::decoder(description),
device(device),
codec(nullptr, free_codec_context),
sws(nullptr, sws_freeContext),
weak_scene(scene),
accumulator(accumulator),
extent{
.width = description.width,
.height = description.height / (stream_index == 2 ? 2u : 1u),
}
accumulator(accumulator)
{
free_images.resize(image_count);
@@ -126,8 +121,8 @@ decoder::decoder(
.imageType = vk::ImageType::e2D,
.format = vk::Format::eA8B8G8R8SrgbPack32,
.extent = {
.width = extent.width,
.height = extent.height,
.width = description.width,
.height = description.height,
.depth = 1,
},
.mipLevels = 1,
@@ -144,6 +139,7 @@ decoder::decoder(
decoded_images[i].image = image_allocation(device, image_info, alloc_info);
decoded_images[i].image.map();
extent_ = vk::Extent2D{description.width, description.height};
vk::ImageSubresource resource;
resource.aspectMask = vk::ImageAspectFlagBits::eColor;
@@ -168,7 +164,7 @@ decoder::decoder(
decoded_images[i].current_layout = vk::ImageLayout::eUndefined;
}
auto avcodec = avcodec_find_decoder(codec_id(description.codec[stream_index]));
auto avcodec = avcodec_find_decoder(codec_id(description.codec));
if (avcodec == nullptr)
{
throw std::runtime_error{"avcodec_find_decoder failed"};
@@ -196,8 +192,6 @@ decoder::decoder(
void decoder::push_data(std::span<std::span<const uint8_t>> data, uint64_t frame_index, bool partial)
{
if (frame_index != this->frame_index)
packet.clear();
for (const auto & d: data)
packet.insert(packet.end(), d.begin(), d.end());
this->frame_index = frame_index;
@@ -237,7 +231,7 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
if (!sws)
{
sws.reset(sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, extent.width, extent.height, AV_PIX_FMT_RGB0, SWS_BILINEAR, nullptr, nullptr, nullptr));
sws.reset(sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format, description.width, description.height, AV_PIX_FMT_RGB0, SWS_BILINEAR, nullptr, nullptr, nullptr));
}
std::unique_lock lock(mutex);
@@ -263,7 +257,6 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
view_info,
*decoded_images[index].image_view,
decoded_images[index].image,
extent,
decoded_images[index].current_layout,
index,
this);
@@ -274,7 +267,6 @@ void decoder::frame_completed(const wivrn::from_headset::feedback & feedback, co
void decoder::supported_codecs(std::vector<wivrn::video_codec> & res)
{
// As long as we do software decoding, prefer faster ones
res.push_back(wivrn::video_codec::h264);
res.push_back(wivrn::video_codec::h265);
res.push_back(wivrn::video_codec::av1);
+1 -2
View File
@@ -73,14 +73,13 @@ private:
uint64_t frame_index;
std::weak_ptr<scenes::stream> weak_scene;
shard_accumulator * accumulator;
const vk::Extent2D extent;
std::mutex mutex;
public:
decoder(vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator);
+39 -34
View File
@@ -32,12 +32,11 @@ struct raw_blit_handle : public wivrn::decoder::blit_handle
const wivrn::to_headset::video_stream_data_shard::view_info_t & view_info,
vk::ImageView image_view,
vk::Image image,
vk::Extent2D extent,
vk::ImageLayout & current_layout,
vk::Semaphore semaphore,
uint64_t & semaphore_val,
std::atomic_bool & free) :
wivrn::decoder::blit_handle{feedback, view_info, image_view, image, extent, current_layout, semaphore, &semaphore_val},
wivrn::decoder::blit_handle{feedback, view_info, image_view, image, current_layout, semaphore, &semaphore_val},
free(free) {}
~raw_blit_handle()
{
@@ -47,7 +46,8 @@ struct raw_blit_handle : public wivrn::decoder::blit_handle
vk::raii::Sampler make_sampler(
vk::raii::Device & device,
vk::SamplerYcbcrConversion ycbcr_conversion)
vk::raii::SamplerYcbcrConversion & ycbcr_conversion,
to_headset::video_stream_description::channels_t channels)
{
vk::StructureChain info{
vk::SamplerCreateInfo{
@@ -60,11 +60,17 @@ vk::raii::Sampler make_sampler(
.maxAnisotropy = 1,
},
vk::SamplerYcbcrConversionInfo{
.conversion = ycbcr_conversion,
.conversion = *ycbcr_conversion,
},
};
if (ycbcr_conversion == VK_NULL_HANDLE)
info.unlink<vk::SamplerYcbcrConversionInfo>();
switch (channels)
{
case wivrn::to_headset::video_stream_description::channels_t::colour:
break;
case wivrn::to_headset::video_stream_description::channels_t::alpha:
info.unlink<vk::SamplerYcbcrConversionInfo>();
break;
}
return vk::raii::Sampler(device, info.get());
}
} // namespace
@@ -75,18 +81,20 @@ raw_decoder::raw_decoder(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator) :
decoder(description),
device(device),
ycbcr_conversion(stream_index == 2 ? nullptr : vk::raii::SamplerYcbcrConversion(device, {
.format = vk::Format::eG8B8R82Plane420Unorm,
.ycbcrModel = vk::SamplerYcbcrModelConversion::eYcbcr709,
.ycbcrRange = vk::SamplerYcbcrRange::eItuFull,
.chromaFilter = vk::Filter::eNearest,
})),
sampler_(make_sampler(device, *ycbcr_conversion)),
ycbcr_conversion(device,
{
.format = vk::Format::eG8B8R82Plane420Unorm,
.ycbcrModel = vk::SamplerYcbcrModelConversion(description.color_model.value_or(VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709)),
.ycbcrRange = vk::SamplerYcbcrRange(description.range.value_or(VK_SAMPLER_YCBCR_RANGE_ITU_FULL)),
.chromaFilter = vk::Filter::eNearest,
}),
sampler_(make_sampler(device, ycbcr_conversion, description.channels)),
command_pool(device, vk::CommandPoolCreateInfo{
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
.queueFamilyIndex = vk_queue_family_index,
@@ -97,24 +105,22 @@ raw_decoder::raw_decoder(
})[0]
.release()),
fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled}),
stream_index(stream_index),
extent{
.width = description.width,
.height = description.height / (stream_index == 2 ? 2u : 1u),
},
weak_scene(scene),
accumulator(accumulator)
{
vk::DeviceSize buffer_size = extent.width * extent.height;
extent_ = vk::Extent2D{
.width = description.width,
.height = description.height,
};
vk::DeviceSize buffer_size = description.width * description.height;
vk::Format format{};
switch (stream_index)
switch (description.channels)
{
case 0: // colour left
case 1: // colour right
buffer_size += buffer_size / 2;
case to_headset::video_stream_description::channels_t::colour:
buffer_size += (description.width * description.height) / 2;
format = vk::Format::eG8B8R82Plane420Unorm;
break;
case 2: // alpha (monochrome)
case to_headset::video_stream_description::channels_t::alpha:
format = vk::Format::eR8Unorm;
break;
}
@@ -142,8 +148,8 @@ raw_decoder::raw_decoder(
.imageType = vk::ImageType::e2D,
.format = format,
.extent = {
.width = extent.width,
.height = extent.height,
.width = description.width,
.height = description.height,
.depth = 1,
},
.mipLevels = 1,
@@ -214,7 +220,6 @@ void raw_decoder::frame_completed(
view_info,
*item->view_full,
item->image,
extent,
item->current_layout,
*item->semaphore,
item->semaphore_val,
@@ -258,20 +263,20 @@ void raw_decoder::frame_completed(
.layerCount = 1,
},
.imageExtent = {
.width = extent.width,
.height = extent.height,
.width = description.width,
.height = description.height,
.depth = 1,
},
},
vk::BufferImageCopy{
.bufferOffset = vk::DeviceSize(extent.width * extent.height),
.bufferOffset = vk::DeviceSize(description.width * description.height),
.imageSubresource = {
.aspectMask = vk::ImageAspectFlagBits::ePlane1,
.layerCount = 1,
},
.imageExtent = {
.width = extent.width / 2u,
.height = extent.height / 2u,
.width = description.width / 2u,
.height = description.height / 2u,
.depth = 1,
},
},
@@ -281,7 +286,7 @@ void raw_decoder::frame_completed(
input[0],
item->image,
item->current_layout,
stream_index < 2 ? 2 : 1,
description.channels == to_headset::video_stream_description::channels_t::colour ? 2 : 1,
regions.data());
vk::ImageMemoryBarrier barrier{
+10 -4
View File
@@ -48,9 +48,6 @@ private:
vk::CommandBuffer cmd;
vk::raii::Fence fence;
uint8_t stream_index;
const vk::Extent2D extent;
std::array<image, image_count> image_pool;
std::weak_ptr<scenes::stream> weak_scene;
@@ -60,12 +57,13 @@ private:
std::array<buffer_allocation, 2> input;
uint8_t * input_pos;
from_headset::feedback feedback;
to_headset::video_stream_data_shard::view_info_t view_info;
public:
raw_decoder(vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
uint8_t stream_index,
std::weak_ptr<scenes::stream> scene,
shard_accumulator * accumulator);
@@ -81,6 +79,14 @@ public:
return *sampler_;
}
vk::Extent2D image_size()
{
return {
description.width,
description.height,
};
}
static std::vector<wivrn::video_codec> supported_codecs();
private:
+3 -3
View File
@@ -55,7 +55,7 @@ static bool is_complete(const shard_set & shards)
const auto & frame = shards.data;
if (frame.empty())
return false;
if (not(frame.back() and frame.back()->timing_info))
if (not(frame.back() and frame.back()->flags & video_stream_data_shard::end_of_frame))
return false;
for (const auto & shard: frame)
if (not shard)
@@ -99,7 +99,7 @@ static void debug_why_not_sent(const shard_set & shards)
++missing;
}
bool end = frame.back() and frame.back()->timing_info;
bool end = frame.back() and frame.back()->flags & video_stream_data_shard::end_of_frame;
spdlog::info("frame {} was not sent with {} data shards, {}{} missing", frame_idx, data, end ? "" : "at least ", missing);
}
@@ -185,7 +185,7 @@ void shard_accumulator::try_submit_frame(uint16_t shard_idx)
for (size_t idx = shard_idx; idx < last_idx; ++idx)
payload.emplace_back(data_shards[idx]->payload);
bool frame_complete = last_idx == data_shards.size() and data_shards.back()->timing_info;
bool frame_complete = last_idx == data_shards.size() and data_shards.back()->flags & video_stream_data_shard::end_of_frame;
decoder_->push_data(payload, data_shards[shard_idx]->frame_idx, not frame_complete);
if (not frame_complete)
+13 -2
View File
@@ -81,10 +81,11 @@ public:
vk::raii::PhysicalDevice & physical_device,
xr::instance & instance,
uint32_t vk_queue_family_index,
const wivrn::to_headset::video_stream_description & description,
const wivrn::to_headset::video_stream_description::item & description,
float fps,
std::weak_ptr<scenes::stream> scene,
uint8_t stream_index) :
decoder_(decoder::make(device, physical_device, vk_queue_family_index, description, stream_index, scene, this)),
decoder_(decoder::make(device, physical_device, vk_queue_family_index, description, fps, stream_index, scene, this)),
current(stream_index),
next(stream_index),
weak_scene(scene),
@@ -95,11 +96,21 @@ public:
void push_shard(wivrn::to_headset::video_stream_data_shard &&);
auto & desc() const
{
return decoder_->description;
}
vk::Sampler sampler()
{
return decoder_->sampler();
}
const vk::Extent2D extent()
{
return decoder_->extent();
}
using blit_handle = decoder::blit_handle;
private:
+16 -21
View File
@@ -43,31 +43,26 @@ std::future<file_picker_result> file_picker::open()
open_doc.start([promise](int result_code, intent && data) mutable {
try
{
if (result_code == -1 /* Activity.RESULT_OK */)
{
auto uri = data.get_uri();
auto uri_string = (std::string)uri.call<jni::string>("toString");
if (result_code != -1 /* Activity.RESULT_OK */)
return;
jni::object<""> activity(application::native_app()->activity->clazz);
auto content_resolver = activity.call<jni::object<"android/content/ContentResolver">>("getContentResolver");
auto uri = data.get_uri();
auto uri_string = (std::string)uri.call<jni::string>("toString");
content_resolver.call<void>("takePersistableUriPermission", uri, jni::Int{1} /* Intent.FLAG_GRANT_READ_URI_PERMISSION */);
jni::object<""> activity(application::native_app()->activity->clazz);
auto content_resolver = activity.call<jni::object<"android/content/ContentResolver">>("getContentResolver");
auto pfd = content_resolver.call<jni::object<"android/os/ParcelFileDescriptor">>("openFileDescriptor", uri, jni::string{"r"});
int fd = pfd.call<int>("getFd");
content_resolver.call<void>("takePersistableUriPermission", uri, jni::Int{1} /* Intent.FLAG_GRANT_READ_URI_PERMISSION */);
// The file descriptor is owned by the ParcelFileDescriptor, dup it before
// passing it to mapped_file to ensure the original fd is not closed
promise->set_value({
.accepted = true,
.path = uri_string,
.file = utils::mapped_file{fd},
});
}
else
{
promise->set_value({.accepted = false});
}
auto pfd = content_resolver.call<jni::object<"android/os/ParcelFileDescriptor">>("openFileDescriptor", uri, jni::string{"r"});
int fd = pfd.call<int>("getFd");
// The file descriptor is owned by the ParcelFileDescriptor, dup it before
// passing it to mapped_file to ensure the original fd is not closed
promise->set_value(file_picker_result{
.path = uri_string,
.file = utils::mapped_file{fd},
});
}
catch (...)
{
-6
View File
@@ -23,14 +23,8 @@
struct file_picker_result
{
bool accepted = false;
std::filesystem::path path;
utils::mapped_file file;
operator bool() const
{
return accepted;
}
};
class file_picker
+6 -28
View File
@@ -319,17 +319,15 @@ std::string controller_name()
case model::pico_neo_3:
return "pico-neo3";
case model::pico_4:
case model::pico_4s: // TODO: split when we have the pico-4s 3d model
case model::pico_4_pro:
case model::pico_4_enterprise:
return "pico-4";
case model::pico_4s:
return "pico-4u";
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
case model::htc_vive_xr_elite:
return "htc-vive-focus-3";
case model::samsung_galaxy_xr:
return "samsung-galaxyxr";
case model::lynx_r1:
case model::unknown:
return "generic-trigger-squeeze";
@@ -376,10 +374,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;
@@ -393,8 +391,10 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
return {{0, -0.010, -0.025}, glm::angleAxis(glm::radians(-12.f), glm::vec3{1, 0, 0})};
case xr::spaces::aim_left:
return {{0, 0, 0.03}, {1, 0, 0, 0}};
case xr::spaces::aim_right:
return {{0, 0, -0.03}, {1, 0, 0, 0}};
return {{0, 0, 0.03}, {1, 0, 0, 0}};
default:
break;
@@ -425,28 +425,6 @@ std::pair<glm::vec3, glm::quat> controller_offset(std::string_view profile, xr::
break;
}
else if (profile == "pico-neo3")
switch (space)
{
case xr::spaces::grip_left:
case xr::spaces::grip_right:
return {{0, 0.005, -0.051}, glm::angleAxis(glm::radians(-29.400f), glm::vec3{1, 0, 0})};
default:
break;
}
else if (profile == "samsung-galaxyxr")
switch (space)
{
case xr::spaces::grip_left:
return {{-0.005, 0.000, 0.035}, {1, 0, 0, 0}};
case xr::spaces::grip_right:
return {{0.005, 0.000, 0.035}, {1, 0, 0, 0}};
default:
break;
}
return {{0, 0, 0}, {1, 0, 0, 0}};
}
+6 -21
View File
@@ -18,9 +18,7 @@
#pragma once
#include "application.h"
#include "utils/alignment.h"
#include "utils/contains.h"
#include "vk/allocation.h"
#include <fastgltf/tools.hpp>
#include <fastgltf/types.hpp>
@@ -31,8 +29,6 @@ class gpu_buffer
{
std::vector<std::byte> bytes;
vk::PhysicalDeviceLimits limits;
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT feat_uint8;
fastgltf::Asset & asset;
vk::BufferUsageFlags usage;
@@ -62,15 +58,8 @@ class gpu_buffer
}
public:
gpu_buffer(vk::raii::PhysicalDevice physical_device, fastgltf::Asset & asset) :
asset(asset),
usage(0)
{
limits = physical_device.getProperties().limits;
if (utils::contains(application::instance().get_vk_device_extensions(), VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
std::tie(std::ignore, feat_uint8) = physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceIndexTypeUint8FeaturesEXT>();
}
gpu_buffer(vk::PhysicalDeviceProperties properties, fastgltf::Asset & asset) :
limits(properties.limits), asset(asset), usage(0) {}
template <typename T>
size_t add_uniform(const T & data_to_add)
@@ -90,7 +79,7 @@ public:
return add(alignment, data_to_add);
}
std::pair<size_t, vk::IndexType> add_indices(const fastgltf::Accessor & accessor)
size_t add_indices(const fastgltf::Accessor & accessor)
{
usage |= vk::BufferUsageFlagBits::eIndexBuffer;
@@ -101,11 +90,7 @@ public:
std::vector<uint8_t> indices(accessor.count);
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
if (feat_uint8.indexTypeUint8)
return {add(4, indices), vk::IndexType::eUint8EXT};
else
return {add(4, std::vector<uint16_t>{indices.begin(), indices.end()}), vk::IndexType::eUint16};
return add(4, indices);
}
case fastgltf::ComponentType::Short:
@@ -113,7 +98,7 @@ public:
std::vector<uint16_t> indices(accessor.count);
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
return {add(4, indices), vk::IndexType::eUint16};
return add(4, indices);
}
case fastgltf::ComponentType::Int:
@@ -121,7 +106,7 @@ public:
std::vector<uint32_t> indices(accessor.count);
using index_t = std::remove_cvref_t<decltype(*indices.data())>;
fastgltf::copyFromAccessor<index_t>(asset, accessor, indices.data());
return {add(4, indices), vk::IndexType::eUint32};
return add(4, indices);
}
default:
+2
View File
@@ -23,11 +23,13 @@
#include "utils/thread_safe.h"
#include "vk/allocation.h"
#include "vk/vk_allocator.h"
#include <chrono>
#include <cstdint>
#include <ktx.h>
#include <ktxvulkan.h>
#include <memory>
#include <span>
#include <spdlog/fmt/chrono.h>
#include <spdlog/spdlog.h>
#include <stdexcept>
#include <tuple>
-116
View File
@@ -1,116 +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/>.
*/
#include "image_writer.h"
#include "utils/thread_safe.h"
#include <cassert>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
void write_image(
vk::raii::Device & device,
thread_safe<vk::raii::Queue> & queue,
uint32_t queue_family_index,
const std::filesystem::path & path,
vk::Image image,
const vk::ImageCreateInfo & info)
{
assert(info.usage & vk::ImageUsageFlagBits::eTransferSrc);
assert(info.extent.depth == 1);
assert(info.format == vk::Format::eR8G8B8A8Srgb);
buffer_allocation output_buffer{
device,
vk::BufferCreateInfo{
.size = info.extent.height * info.extent.width * 4,
.usage = vk::BufferUsageFlagBits::eTransferDst,
},
VmaAllocationCreateInfo{
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
.usage = VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
},
"Saved image buffer"};
vk::raii::CommandPool cp{
device,
vk::CommandPoolCreateInfo{
.queueFamilyIndex = queue_family_index,
}};
vk::raii::CommandBuffer command_buffer = std::move(device.allocateCommandBuffers(
{
.commandPool = *cp,
.level = vk::CommandBufferLevel::ePrimary,
.commandBufferCount = 1,
})[0]);
vk::raii::Fence fence = device.createFence({});
command_buffer.begin(vk::CommandBufferBeginInfo{});
command_buffer.pipelineBarrier(
vk::PipelineStageFlagBits::eColorAttachmentOutput,
vk::PipelineStageFlagBits::eTransfer,
vk::DependencyFlags{},
{},
{},
vk::ImageMemoryBarrier{
.srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite,
.dstAccessMask = vk::AccessFlagBits::eTransferRead,
.oldLayout = vk::ImageLayout::eColorAttachmentOptimal,
.newLayout = vk::ImageLayout::eTransferSrcOptimal,
.image = image,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
},
});
command_buffer.copyImageToBuffer(
image,
vk::ImageLayout::eTransferSrcOptimal,
output_buffer,
vk::BufferImageCopy{
.bufferOffset = 0,
.bufferRowLength = 0,
.bufferImageHeight = 0,
.imageSubresource = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.mipLevel = 0,
.baseArrayLayer = 0,
.layerCount = 1,
},
.imageOffset = {0, 0, 0},
.imageExtent = info.extent,
});
command_buffer.end();
queue.lock()->submit(vk::SubmitInfo{
.commandBufferCount = 1,
.pCommandBuffers = &*command_buffer,
},
*fence);
if (auto result = device.waitForFences(*fence, true, 1'000'000'000); result == vk::Result::eSuccess)
stbi_write_png(path.c_str(), info.extent.width, info.extent.height, 4, output_buffer.data(), 0);
}
-42
View File
@@ -1,42 +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 "utils/thread_safe.h"
#include "vk/allocation.h"
#include <filesystem>
#include <vulkan/vulkan.hpp>
void write_image(
vk::raii::Device & device,
thread_safe<vk::raii::Queue> & queue,
uint32_t queue_family_index,
const std::filesystem::path & path,
vk::Image image,
const vk::ImageCreateInfo & info);
inline void write_image(
vk::raii::Device & device,
thread_safe<vk::raii::Queue> & queue,
uint32_t queue_family_index,
const std::filesystem::path & path,
const image_allocation & image)
{
write_image(device, queue, queue_family_index, path, (vk::Image)image, image.info());
}
+65 -97
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;
}
@@ -653,9 +651,9 @@ std::vector<imgui_context::controller_state> imgui_context::read_controllers_sta
}
}
if (current_aim_interaction == 0 or not controller_position.first)
if (current_aim_interaction == 0)
state.pointer_position = index_tip_position.first;
else if (current_aim_interaction == 1 or not index_tip_position.first)
else if (current_aim_interaction == 1)
state.pointer_position = controller_position.first;
else
{
@@ -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);
+11 -31
View File
@@ -19,7 +19,6 @@
#pragma once
#include <array>
#include <inplace_vector.hpp>
#include <memory>
#include <type_traits>
#include <utility>
@@ -56,14 +55,6 @@ struct texture
struct material
{
struct alignas(16) texture_info
{
alignas(4) uint32_t texcoord = 0;
alignas(4) float rotation = 0;
alignas(8) glm::vec2 offset = {0, 0};
alignas(8) glm::vec2 scale = {1, 1};
};
struct gpu_data
{
glm::vec4 base_color_factor = glm::vec4(1, 1, 1, 1);
@@ -74,11 +65,13 @@ struct material
float normal_scale = 1;
float alpha_cutoff = 0.5;
texture_info base_color;
texture_info metallic_roughness;
texture_info occlusion;
texture_info emissive;
texture_info normal;
uint32_t base_color_texcoord = 0;
uint32_t metallic_roughness_texcoord = 0;
uint32_t occlusion_texcoord = 0;
uint32_t emissive_texcoord = 0;
uint32_t normal_texcoord = 0;
// TODO: add fastgltf::TextureTransform?
};
std::shared_ptr<texture> base_color_texture;
@@ -101,7 +94,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 +104,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 +149,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;
+67 -148
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>
@@ -169,11 +166,6 @@ glm::vec3 convert(const fastgltf::math::nvec3 & v)
return {v[0], v[1], v[2]};
}
glm::vec2 convert(const fastgltf::math::nvec2 & v)
{
return {v[0], v[1]};
}
components::animation_track_base::interpolation_t convert(fastgltf::AnimationInterpolation interpolation)
{
switch (interpolation)
@@ -274,45 +266,19 @@ void write_vertex_attribute_aux(std::byte * output, size_t stride, int component
{
case 1:
for (size_t i = 0, n = input.size(); i < n; i++, output += stride)
*reinterpret_cast<glm::vec<1, T> *>(output) = input[i];
*reinterpret_cast<glm::vec<1, T> *>(output) = glm::vec<1, T>(input[i].x);
break;
case 2:
for (size_t i = 0, n = input.size(); i < n; i++, output += stride)
*reinterpret_cast<glm::vec<2, T> *>(output) = input[i];
*reinterpret_cast<glm::vec<2, T> *>(output) = glm::vec<2, T>(input[i].x, input[i].y);
break;
case 3:
for (size_t i = 0, n = input.size(); i < n; i++, output += stride)
*reinterpret_cast<glm::vec<3, T> *>(output) = input[i];
*reinterpret_cast<glm::vec<3, T> *>(output) = glm::vec<3, T>(input[i].x, input[i].y, input[i].z);
break;
case 4:
for (size_t i = 0, n = input.size(); i < n; i++, output += stride)
*reinterpret_cast<glm::vec<4, T> *>(output) = input[i];
break;
default:
abort();
}
}
template <typename T>
void write_vertex_attribute_aux(std::byte * output, size_t stride, int components, glm::vec4 value, size_t size)
{
switch (components)
{
case 1:
for (size_t i = 0, n = size; i < n; i++, output += stride)
*reinterpret_cast<glm::vec<1, T> *>(output) = value;
break;
case 2:
for (size_t i = 0, n = size; i < n; i++, output += stride)
*reinterpret_cast<glm::vec<2, T> *>(output) = value;
break;
case 3:
for (size_t i = 0, n = size; i < n; i++, output += stride)
*reinterpret_cast<glm::vec<3, T> *>(output) = value;
break;
case 4:
for (size_t i = 0, n = size; i < n; i++, output += stride)
*reinterpret_cast<glm::vec<4, T> *>(output) = value;
*reinterpret_cast<glm::vec<3, T> *>(output) = glm::vec<4, T>(input[i].x, input[i].y, input[i].z, input[i].w);
break;
default:
abort();
@@ -337,24 +303,6 @@ void write_vertex_attribute(std::vector<std::byte> & output, size_t offset, size
}
}
void write_vertex_attribute(std::vector<std::byte> & output, size_t offset, size_t stride, vk::Format format, glm::vec4 value, size_t size)
{
assert(output.size() >= size * stride);
switch (format)
{
case vk::Format::eR32Sfloat:
case vk::Format::eR32G32Sfloat:
case vk::Format::eR32G32B32Sfloat:
case vk::Format::eR32G32B32A32Sfloat:
write_vertex_attribute_aux<float>(output.data() + offset, stride, vk::componentCount(format), value, size);
return;
default:
return;
}
}
void copy_vertex_attributes(
const fastgltf::Asset & asset,
const fastgltf::Accessor & accessor,
@@ -367,18 +315,6 @@ void copy_vertex_attributes(
write_vertex_attribute(buffer, attribute.offset, binding.stride, attribute.format, read_vertex_attribute(asset, accessor));
}
void fill_vertex_attributes(
glm::vec4 value,
size_t size,
std::vector<std::byte> & buffer,
const vk::VertexInputBindingDescription & binding,
const vk::VertexInputAttributeDescription & attribute)
{
assert(buffer.size() >= size * binding.stride);
write_vertex_attribute(buffer, attribute.offset, binding.stride, attribute.format, value, size);
}
std::pair<size_t, std::vector<std::vector<std::byte>>> create_vertex_buffers(
const renderer::vertex_layout & layout,
const fastgltf::Asset & asset,
@@ -427,20 +363,7 @@ std::pair<size_t, std::vector<std::vector<std::byte>>> create_vertex_buffers(
gltf_attribute = primitive.findAttribute(name + "_0");
if (gltf_attribute == primitive.attributes.cend())
{
// If the attribute is not specified in the glTF, use the default value or 0 if none is found
static const std::unordered_map<std::string_view, glm::vec4> default_values = {
std::pair{"COLOR", glm::vec4{1, 1, 1, 1}}};
if (auto iter = default_values.find(name); iter != default_values.end())
fill_vertex_attributes(iter->second, vertex_count, buffer, binding, attribute);
else
{
// The buffer is already initialized at 0
}
continue;
}
}
const fastgltf::Accessor & accessor = asset.accessors.at(gltf_attribute->accessorIndex);
@@ -516,23 +439,15 @@ 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 |
fastgltf::Extensions::KHR_texture_transform);
fastgltf::Parser parser(fastgltf::Extensions::KHR_texture_basisu);
auto gltf_options =
fastgltf::Options::DontRequireValidAssetMember |
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 +464,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 +487,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 +717,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 +727,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);
@@ -843,37 +750,37 @@ public:
material_data.roughness_factor = gltf_material.pbrData.roughnessFactor;
material_data.alpha_cutoff = gltf_material.alphaCutoff;
auto f = [&](const auto & texture_info,
std::shared_ptr<renderer::texture> & texture,
renderer::material::texture_info & info) {
if (not texture_info)
return;
if (gltf_material.pbrData.baseColorTexture)
{
material.base_color_texture = textures.at(gltf_material.pbrData.baseColorTexture->textureIndex);
material_data.base_color_texcoord = gltf_material.pbrData.baseColorTexture->texCoordIndex;
}
texture = textures.at(texture_info->textureIndex);
info.texcoord = texture_info->texCoordIndex;
if (auto & xform = texture_info->transform)
{
if (xform->texCoordIndex)
info.texcoord = *xform->texCoordIndex;
info.rotation = xform->rotation;
info.offset = convert(xform->uvOffset);
info.scale = convert(xform->uvScale);
}
};
f(gltf_material.pbrData.baseColorTexture, material.base_color_texture, material_data.base_color);
f(gltf_material.pbrData.metallicRoughnessTexture, material.metallic_roughness_texture, material_data.metallic_roughness);
f(gltf_material.occlusionTexture, material.occlusion_texture, material_data.occlusion);
f(gltf_material.emissiveTexture, material.emissive_texture, material_data.emissive);
f(gltf_material.normalTexture, material.normal_texture, material_data.normal);
if (gltf_material.pbrData.metallicRoughnessTexture)
{
material.metallic_roughness_texture = textures.at(gltf_material.pbrData.metallicRoughnessTexture->textureIndex);
material_data.metallic_roughness_texcoord = gltf_material.pbrData.metallicRoughnessTexture->texCoordIndex;
}
if (gltf_material.occlusionTexture)
{
material.occlusion_texture = textures.at(gltf_material.occlusionTexture->textureIndex);
material_data.occlusion_texcoord = gltf_material.occlusionTexture->texCoordIndex;
material_data.occlusion_strength = gltf_material.occlusionTexture->strength;
}
if (gltf_material.emissiveTexture)
{
material.emissive_texture = textures.at(gltf_material.emissiveTexture->textureIndex);
material_data.emissive_texcoord = gltf_material.emissiveTexture->texCoordIndex;
}
if (gltf_material.normalTexture)
{
material.normal_texture = textures.at(gltf_material.normalTexture->textureIndex);
material_data.normal_texcoord = gltf_material.normalTexture->texCoordIndex;
material_data.normal_scale = gltf_material.normalTexture->scale;
}
material.offset = staging_buffer.add_uniform(material_data);
}
@@ -887,7 +794,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>();
@@ -902,17 +808,37 @@ public:
fastgltf::Accessor & indices_accessor = gltf.accessors.at(*gltf_primitive.indicesAccessor);
primitive_ref.indexed = true;
std::tie(primitive_ref.index_offset, primitive_ref.index_type) = staging_buffer.add_indices(indices_accessor);
primitive_ref.index_offset = staging_buffer.add_indices(indices_accessor);
primitive_ref.index_count = indices_accessor.count;
switch (indices_accessor.componentType)
{
case fastgltf::ComponentType::Byte:
case fastgltf::ComponentType::UnsignedByte:
primitive_ref.index_type = vk::IndexType::eUint8EXT;
break;
case fastgltf::ComponentType::Short:
case fastgltf::ComponentType::UnsignedShort:
primitive_ref.index_type = vk::IndexType::eUint16;
break;
case fastgltf::ComponentType::Int:
case fastgltf::ComponentType::UnsignedInt:
primitive_ref.index_type = vk::IndexType::eUint32;
break;
default:
throw std::runtime_error("Invalid index type");
break;
}
}
else
primitive_ref.indexed = false;
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";
@@ -929,7 +855,6 @@ public:
int binding;
// Attributes that affect the vertices position go in a different buffer
if (semantic == "POSITION" or
semantic == "JOINTS" or
semantic == "WEIGHTS")
@@ -1027,6 +952,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;
@@ -1163,23 +1089,16 @@ std::shared_ptr<entt::registry> scene_loader::operator()(
const std::filesystem::path & gltf_texture_cache,
std::function<void(float)> progress_cb)
{
vk::PhysicalDeviceProperties physical_device_properties = physical_device.getProperties();
auto data_buffer = fastgltf::GltfDataBuffer::FromBytes(data.data(), data.size());
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)
@@ -1189,7 +1108,7 @@ std::shared_ptr<entt::registry> scene_loader::operator()(
// Load all buffers from URIs
ctx.load_all_buffers();
gpu_buffer staging_buffer(physical_device, asset);
gpu_buffer staging_buffer(physical_device_properties, asset);
// Load all textures
auto textures = ctx.load_all_textures(gltf_texture_cache, progress_cb);
+61 -16
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>
@@ -139,7 +138,7 @@ std::shared_ptr<renderer::texture> scene_renderer::create_default_texture(image_
return std::make_shared<renderer::texture>(image_view, renderer::sampler_info{});
}
std::shared_ptr<renderer::material> scene_renderer::create_default_material()
std::shared_ptr<renderer::material> scene_renderer::create_default_material(vk::raii::CommandPool & cb_pool)
{
image_loader loader(device, physical_device, queue, queue_family_index);
@@ -262,7 +261,7 @@ static std::array layout_bindings_0{
.binding = 8,
.descriptorType = vk::DescriptorType::eUniformBuffer,
.descriptorCount = 1,
.stageFlags = vk::ShaderStageFlagBits::eVertex | vk::ShaderStageFlagBits::eFragment,
.stageFlags = vk::ShaderStageFlagBits::eFragment,
},
};
@@ -286,7 +285,7 @@ scene_renderer::scene_renderer(
layout_0(create_descriptor_set_layout(layout_bindings_0, vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptorKHR))
{
// Create the default material
default_material = create_default_material();
default_material = create_default_material(cb_pool);
// Create Vulkan resources
frame_resources.resize(frames_in_flight);
@@ -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,
+7 -1
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
@@ -144,7 +148,7 @@ class scene_renderer
vk::raii::Pipeline create_pipeline(const pipeline_info & info);
std::shared_ptr<renderer::texture> create_default_texture(image_loader & loader, std::vector<uint8_t> pixel, const std::string & name);
std::shared_ptr<renderer::material> create_default_material();
std::shared_ptr<renderer::material> create_default_material(vk::raii::CommandPool & cb_pool);
vk::raii::DescriptorSetLayout create_descriptor_set_layout(std::span<vk::DescriptorSetLayoutBinding> bindings, vk::DescriptorSetLayoutCreateFlags flags = {});
// Caches
@@ -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);
};
+364
View File
@@ -0,0 +1,364 @@
/*
* 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 "blitter.h"
#include "application.h"
#include "utils/ranges.h"
#include "vk/pipeline.h"
#include "vk/shader.h"
#include "vk/specialization_constants.h"
#include <format>
#include <ranges>
#include <spdlog/spdlog.h>
namespace wivrn
{
static const uint32_t num_views = 2;
blitter::blitter(vk::raii::Device & device, size_t view) :
device(device), view(view)
{
}
void blitter::reset(const to_headset::video_stream_description & desc)
{
using channels_t = to_headset::video_stream_description::channels_t;
this->desc = desc;
current = {};
target = image_allocation();
image_view = nullptr;
rp = nullptr;
fb = nullptr;
sampler = nullptr;
pipelines.clear();
passthrough_rgb = passthrough_a = -1;
auto w = desc.width / num_views;
for (auto [i, item]: utils::enumerate(desc.items))
{
if (item.offset_x <= view * w and
item.offset_y == 0 and
item.offset_x + item.width * item.subsampling >= (view + 1) * w and
item.height * item.subsampling >= desc.height)
{
spdlog::info("Stream {} is eligible for blit-less path on view {}", i, view);
switch (item.channels)
{
case channels_t::colour:
passthrough_rgb = i;
break;
case channels_t::alpha:
passthrough_a = i;
break;
}
const bool alpha = item.channels == to_headset::video_stream_description::channels_t::alpha;
auto & r = alpha ? current.rect_a : current.rect_rgb;
r = vk::Rect2D{
.offset = {
.x = int32_t(view * w) - item.offset_x,
.y = 0,
},
};
}
}
if (passthrough_rgb != -1 and passthrough_a != -1)
return;
target = image_allocation(
device,
vk::ImageCreateInfo{
.imageType = vk::ImageType::e2D,
.format = vk::Format::eB8G8R8A8Srgb,
.extent = {
.width = w,
.height = desc.height,
.depth = 1,
},
.mipLevels = 1,
.arrayLayers = 1,
.usage = vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eColorAttachment,
},
{
.usage = VMA_MEMORY_USAGE_AUTO,
},
std::format("blit image {}", view));
image_view = device.createImageView(vk::ImageViewCreateInfo{
.image = vk::Image(target),
.viewType = vk::ImageViewType::e2D,
.format = target.info().format,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.levelCount = 1,
.layerCount = 1,
}});
// render pass
{
vk::AttachmentReference color_ref{
.attachment = 0,
.layout = vk::ImageLayout::eColorAttachmentOptimal,
};
vk::SubpassDescription subpass{
.pipelineBindPoint = vk::PipelineBindPoint::eGraphics,
.colorAttachmentCount = 1,
.pColorAttachments = &color_ref,
};
vk::AttachmentDescription color_desc{
.format = target.info().format,
.loadOp = vk::AttachmentLoadOp::eDontCare,
.finalLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
};
rp = device.createRenderPass(vk::RenderPassCreateInfo{
.attachmentCount = 1,
.pAttachments = &color_desc,
.subpassCount = 1,
.pSubpasses = &subpass,
});
}
fb = device.createFramebuffer(
vk::FramebufferCreateInfo{
.renderPass = *rp,
.attachmentCount = 1,
.pAttachments = &*image_view,
.width = w,
.height = desc.height,
.layers = 1,
});
sampler = device.createSampler(vk::SamplerCreateInfo{
.magFilter = vk::Filter::eLinear,
.minFilter = vk::Filter::eLinear,
.addressModeU = vk::SamplerAddressMode::eClampToBorder,
.addressModeV = vk::SamplerAddressMode::eClampToBorder,
.addressModeW = vk::SamplerAddressMode::eClampToBorder,
.borderColor = vk::BorderColor::eFloatOpaqueBlack,
});
pipelines.resize(desc.items.size());
for (auto [i, item]: utils::enumerate(desc.items))
{
pipelines[i].used = item.offset_x < (view + 1) * w and
item.offset_x + item.width * item.subsampling > view * w;
}
current.rgb = *image_view;
current.sampler_rgb = *sampler;
current.rect_rgb = vk::Rect2D{.extent = {w, desc.height}};
current.layout_rgb = vk::ImageLayout::eShaderReadOnlyOptimal;
}
void blitter::begin(vk::raii::CommandBuffer & cmd)
{
assert(not desc.items.empty());
if (*fb == VK_NULL_HANDLE)
{
current.rgb = nullptr;
current.a = nullptr;
current.sampler_rgb = nullptr;
current.sampler_a = nullptr;
return;
}
current.rgb = *image_view;
current.sampler_rgb = *sampler;
cmd.beginRenderPass(
{
.renderPass = *rp,
.framebuffer = *fb,
.renderArea = {
.offset = {0, 0},
.extent = {target.info().extent.width, target.info().extent.height},
},
},
vk::SubpassContents::eInline);
}
void blitter::push_image(vk::raii::CommandBuffer & cmd, uint8_t stream, vk::Sampler sampler, const vk::Extent2D & extent_, vk::ImageView image, vk::ImageLayout layout)
{
if (stream == passthrough_rgb)
{
current.rgb = image;
current.sampler_rgb = sampler;
current.layout_rgb = layout;
current.rect_rgb.extent = vk::Extent2D{
extent_.width * desc.items[stream].subsampling,
extent_.height * desc.items[stream].subsampling,
};
return;
}
if (stream == passthrough_a)
{
current.a = image;
current.sampler_a = sampler;
current.layout_a = layout;
current.rect_a.extent = vk::Extent2D{
extent_.width * desc.items[stream].subsampling,
extent_.height * desc.items[stream].subsampling,
};
return;
}
if (pipelines.empty())
return;
assert(stream < pipelines.size());
auto & p = pipelines[stream];
if (not p.used)
return;
const auto & extent = target.info().extent;
const auto & description = desc.items[stream];
if (not *p.pipeline)
{
const bool alpha = description.channels == to_headset::video_stream_description::channels_t::alpha;
vk::DescriptorSetLayoutBinding sampler_layout_binding{
.binding = 0,
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
.descriptorCount = 1,
.stageFlags = vk::ShaderStageFlagBits::eFragment,
.pImmutableSamplers = &sampler,
};
p.set_layout = device.createDescriptorSetLayout(vk::DescriptorSetLayoutCreateInfo{
.flags = vk::DescriptorSetLayoutCreateFlagBits::ePushDescriptorKHR,
.bindingCount = 1,
.pBindings = &sampler_layout_binding,
});
auto vert_constants = make_specialization_constants(
float(description.width) / extent_.width,
float(description.height) / extent_.height);
auto frag_constants = make_specialization_constants(
VkBool32(alpha));
// Create graphics pipeline
auto vertex_shader = load_shader(device, "stream.vert");
auto fragment_shader = load_shader(device, "stream.frag");
p.layout = device.createPipelineLayout(vk::PipelineLayoutCreateInfo{
.setLayoutCount = 1,
.pSetLayouts = &*p.set_layout,
});
vk::pipeline_builder pipeline_info{
.Stages = {{
.stage = vk::ShaderStageFlagBits::eVertex,
.module = *vertex_shader,
.pName = "main",
.pSpecializationInfo = vert_constants,
},
{
.stage = vk::ShaderStageFlagBits::eFragment,
.module = *fragment_shader,
.pName = "main",
.pSpecializationInfo = frag_constants,
}},
.VertexBindingDescriptions = {},
.VertexAttributeDescriptions = {},
.InputAssemblyState = {{
.topology = vk::PrimitiveTopology::eTriangleStrip,
}},
// With vk::DynamicState::eViewport, vk::DynamicState::eScissor the number of viewports
// and scissors is still used, put a vector with one element
.Viewports = {{}},
.Scissors = {{}},
.RasterizationState = {{
.polygonMode = vk::PolygonMode::eFill,
.lineWidth = 1,
}},
.MultisampleState = {{
.rasterizationSamples = vk::SampleCountFlagBits::e1,
}},
.ColorBlendAttachments = {
{.colorWriteMask = alpha ? vk::ColorComponentFlagBits::eA
: vk::ColorComponentFlagBits::eA | vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB}},
.DynamicStates = {vk::DynamicState::eViewport, vk::DynamicState::eScissor},
.layout = *p.layout,
.renderPass = *rp,
.subpass = 0,
};
p.pipeline = device.createGraphicsPipeline(application::get_pipeline_cache(), pipeline_info);
spdlog::info("Created blit pipeline for stream {}, view {}", stream, view);
}
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, *p.pipeline);
vk::DescriptorImageInfo image_info{
.imageView = image,
.imageLayout = layout,
};
cmd.pushDescriptorSetKHR(
vk::PipelineBindPoint::eGraphics,
*p.layout,
0,
vk::WriteDescriptorSet{
.dstBinding = 0,
.descriptorCount = 1,
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
.pImageInfo = &image_info,
});
int x0 = description.offset_x - view * extent.width;
int y0 = description.offset_y;
int x1 = x0 + description.width * description.subsampling;
int y1 = y0 + description.height * description.subsampling;
cmd.setViewport(
0,
vk::Viewport{
.x = (float)x0,
.y = (float)y0,
.width = float(description.width * description.subsampling),
.height = float(description.height * description.subsampling),
.minDepth = 0,
.maxDepth = 1,
});
x0 = std::clamp<int>(x0, 0, extent.width);
x1 = std::clamp<int>(x1, 0, extent.width);
y0 = std::clamp<int>(y0, 0, extent.height);
y1 = std::clamp<int>(y1, 0, extent.height);
cmd.setScissor(
0,
vk::Rect2D{
.offset = {.x = x0, .y = y0},
.extent = {.width = uint32_t(x1 - x0), .height = uint32_t(y1 - y0)},
});
cmd.draw(3, 1, 0, 0);
}
blitter::output blitter::end(vk::raii::CommandBuffer & cmd)
{
if (*fb)
cmd.endRenderPass();
return current;
}
} // namespace wivrn
+72
View File
@@ -0,0 +1,72 @@
/*
* 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 "vk/allocation.h"
#include "wivrn_packets.h"
#include <vulkan/vulkan_raii.hpp>
namespace wivrn
{
class blitter
{
public:
struct output
{
vk::ImageView rgb;
vk::Sampler sampler_rgb;
vk::Rect2D rect_rgb;
vk::ImageLayout layout_rgb;
vk::ImageView a;
vk::Sampler sampler_a;
vk::Rect2D rect_a;
vk::ImageLayout layout_a;
};
private:
vk::raii::Device & device;
size_t view;
to_headset::video_stream_description desc;
// indices to simply passthrough, if -1 image needs to be blitted
int passthrough_rgb = -1;
int passthrough_a = -1;
image_allocation target;
vk::raii::ImageView image_view = nullptr;
vk::raii::RenderPass rp = nullptr;
vk::raii::Framebuffer fb = nullptr;
vk::raii::Sampler sampler = nullptr;
struct pipeline_t
{
vk::raii::DescriptorSetLayout set_layout = nullptr;
vk::raii::PipelineLayout layout = nullptr;
vk::raii::Pipeline pipeline = nullptr;
bool used = false; // true if we need this image for blitting
};
std::vector<pipeline_t> pipelines;
output current;
public:
blitter(vk::raii::Device & device, size_t view);
void reset(const to_headset::video_stream_description & desc);
void begin(vk::raii::CommandBuffer &);
void push_image(vk::raii::CommandBuffer & buf, uint8_t stream, vk::Sampler sampler, const vk::Extent2D &, vk::ImageView image, vk::ImageLayout);
output end(vk::raii::CommandBuffer &);
};
} // namespace wivrn
+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);
};
+64 -51
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);
@@ -1202,6 +1231,8 @@ void scenes::lobby::on_focused()
},
};
face_tracker = xr::make_face_tracker(instance, system, session);
// 0.4mm / pixel
std::vector<imgui_context::viewport> vps{
{
@@ -1238,17 +1269,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);
@@ -1264,18 +1285,9 @@ void scenes::lobby::on_focused()
auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auto tm = std::localtime(&t);
switch (tm->tm_mon)
{
case 5:
about_picture = imgui_ctx->load_texture("assets://wivrn-pride.ktx2");
break;
case 11:
about_picture = imgui_ctx->load_texture("assets://wivrn-christmas.ktx2");
break;
default:
about_picture = imgui_ctx->load_texture("assets://wivrn.ktx2");
break;
}
std::string image = tm->tm_mon == 5 ? "wivrn-pride" : "wivrn";
about_picture = imgui_ctx->load_texture("assets://" + image + ".ktx2");
default_environment_screenshot = imgui_ctx->load_texture("assets://default-environment.ktx2");
@@ -1320,8 +1332,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 +1365,7 @@ void scenes::lobby::on_unfocused()
right_hand.reset();
face_tracker.emplace<std::monostate>();
clear_swapchains();
multicast.reset();
}
@@ -1361,8 +1374,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:
+3 -2
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;
@@ -131,7 +134,6 @@ class lobby : public scene_impl<lobby>
tab current_tab = tab::server_list;
tab last_current_tab = tab::server_list;
int optional_feature_index = 0; // Which step of the first run screen are we in
ImTextureID about_picture;
virtual_keyboard keyboard;
@@ -219,7 +221,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();
+76 -216
View File
@@ -32,14 +32,12 @@
#include "utils/i18n.h"
#include "utils/mapped_file.h"
#include "utils/overloaded.h"
#if WIVRN_CLIENT_DEBUG_MENU
#include "utils/ranges.h"
#endif
#include "version.h"
#include "xr/body_tracker.h"
#include <algorithm>
#include <cassert>
#include <chrono> // IWYU pragma: keep
#include <chrono>
#include <entt/entity/fwd.hpp>
#include <fastgltf/math.hpp>
#include <fastgltf/types.hpp>
@@ -249,51 +247,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 +494,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 +514,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))
@@ -611,7 +566,6 @@ void scenes::lobby::gui_settings()
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
}
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
@@ -619,10 +573,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 +586,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 +597,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,21 +617,45 @@ void scenes::lobby::gui_settings()
}
}
// Render resolution
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();
}
{
const auto current = config.resolution_scale;
const auto width = stream_view.recommendedImageRectWidth;
const auto height = stream_view.recommendedImageRectHeight;
auto intScale = int(current * 10);
auto intScale = int(current * 100);
const auto slider = ImGui::SliderInt(
_("Render resolution").append("##resolution_scale").c_str(),
_("Resolution scale").append("##resolution_scale").c_str(),
&intScale,
5,
config.extended_config ? 35 : 15,
fmt::format(_F("{}%% - {}x{} per eye"), intScale * 10, int(width * current), int(height * current)).c_str());
50,
350,
fmt::format(_F("%d%% - {}x{} per eye"), int(width * current), int(height * current)).c_str());
if (slider)
{
config.resolution_scale = intScale * 0.1;
config.resolution_scale = intScale * 0.01;
config.save();
}
imgui_ctx->vibrate_on_hover();
@@ -689,114 +667,6 @@ void scenes::lobby::gui_settings()
}
}
// foveation
{
const int step = 5;
const auto current = config.get_stream_scale();
int intval = round((1 - current) * 100 / step);
const auto slider = ImGui::SliderInt(
_("Foveated encoding").append("##stream_scale").c_str(),
&intval,
0,
100 / step,
fmt::format(_F("{}%%"), intval * step).c_str());
if (slider)
{
// clamp out of the slider to have the 50% value centered
intval = std::clamp(intval,
config.extended_config ? 0 : 30 / step,
80 / step);
config.set_stream_scale(1 - intval * step * 0.01);
config.save();
}
if (ImGui::IsItemHovered())
{
if (config.check_feature(feature::eye_gaze))
imgui_ctx->tooltip(_("Higher values focus image quality where you look at,\n"
"improving latency, power efficiency and quality."));
else
imgui_ctx->tooltip(_("Higher values focus image quality at the center,\n"
"improving latency, power efficiency and quality."));
}
imgui_ctx->vibrate_on_hover();
}
{
auto codec_name = [](const std::optional<wivrn::video_codec> codec) {
if (not codec)
return _C("Codec", "Automatic");
switch (*codec)
{
case wivrn::h264:
return _C("Codec", "H.264");
case wivrn::h265:
return _C("Codec", "H.265");
case wivrn::av1:
return _C("Codec", "AV1");
case wivrn::raw:
break;
}
assert(false);
__builtin_unreachable();
};
if (ImGui::BeginCombo(_S("Codec"), codec_name(config.codec).c_str()))
{
if (ImGui::Selectable(codec_name({}).c_str(), not config.codec))
{
config.codec = std::nullopt;
config.save();
}
for (auto codec: decoder::supported_codecs())
{
// don't show raw in GUI
if (codec == wivrn::raw)
continue;
if (ImGui::Selectable(codec_name(codec).c_str(), config.codec == codec))
{
config.codec = codec;
config.save();
}
}
ImGui::EndCombo();
}
imgui_ctx->vibrate_on_hover();
if (config.codec == wivrn::video_codec::av1 or config.codec == wivrn::video_codec::h265)
{
ImGui::SameLine(0.f, 10.f);
bool ten_bit = config.bit_depth == 10;
if (ImGui::Checkbox(_S("10-bit"), &ten_bit))
{
config.bit_depth = ten_bit ? 10 : 8;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
}
// Bitrate
{
const int step = 5;
const int mb = 1'000'000;
const auto current = config.bitrate_bps;
auto val = int(current / mb / step);
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());
if (slider)
{
config.bitrate_bps = val * mb * step;
config.save();
}
imgui_ctx->vibrate_on_hover();
}
if (instance.has_extension(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
{
if (ImGui::Checkbox(_S("High power mode"), &config.high_power_mode))
@@ -827,8 +697,8 @@ void scenes::lobby::gui_settings()
ImGui::Unindent();
ImGui::EndDisabled();
}
if (system.hand_tracking_supported())
{
ImGui::BeginDisabled(not system.hand_tracking_supported());
bool enabled = config.check_feature(feature::hand_tracking);
if (ImGui::Checkbox(_S("Enable hand tracking"), &enabled))
{
@@ -837,9 +707,10 @@ void scenes::lobby::gui_settings()
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
ImGui::EndDisabled();
}
if (application::get_eye_gaze_supported())
{
ImGui::BeginDisabled(not application::get_eye_gaze_supported());
bool enabled = config.check_feature(feature::eye_gaze);
if (ImGui::Checkbox(_S("Enable eye tracking"), &enabled))
{
@@ -848,26 +719,30 @@ void scenes::lobby::gui_settings()
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
ImGui::EndDisabled();
}
if (system.face_tracker_supported() != xr::face_tracker_type::none)
{
ImGui::BeginDisabled(std::holds_alternative<std::monostate>(face_tracker));
bool enabled = config.check_feature(feature::face_tracking);
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
{
config.set_feature(feature::face_tracking, enabled);
}
ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) and (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled))
imgui_ctx->tooltip(_("This feature is not supported by your headset"));
imgui_ctx->vibrate_on_hover();
}
if (auto body_tracker = system.body_tracker_supported(); body_tracker != xr::body_tracker_type::none)
auto body_tracker = system.body_tracker_supported();
{
ImGui::BeginDisabled(body_tracker == xr::body_tracker_type::none);
bool enabled = config.check_feature(feature::body_tracking);
if (ImGui::Checkbox(_S("Enable body tracking"), &enabled))
{
config.set_feature(feature::body_tracking, enabled);
}
ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled))
{
if (ImGui::GetItemFlags() & ImGuiItemFlags_Disabled)
@@ -882,32 +757,31 @@ void scenes::lobby::gui_settings()
}
imgui_ctx->vibrate_on_hover();
if (body_tracker == xr::body_tracker_type::fb)
}
if (body_tracker == xr::body_tracker_type::fb)
{
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
ImGui::Indent();
if (ImGui::Checkbox(_S("Enable lower body tracking"), &config.fb_lower_body))
{
ImGui::BeginDisabled(not config.check_feature(feature::body_tracking));
ImGui::Indent();
if (ImGui::Checkbox(_S("Enable lower body tracking"), &config.fb_lower_body))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Estimate lower body joint positions using Generative Legs\nRequires 'Hand and body tracking' to be enabled in the Quest movement tracking settings"));
ImGui::BeginDisabled(not config.fb_lower_body);
if (ImGui::Checkbox(_S("Enable hip tracking"), &config.fb_hip))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Only takes affect with lower body tracking enabled\nMay be desired when using another source of hip tracking"));
ImGui::EndDisabled();
ImGui::Unindent();
ImGui::EndDisabled();
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Estimate lower body joint positions using Generative Legs\nRequires 'Hand and body tracking' to be enabled in the Quest movement tracking settings"));
ImGui::BeginDisabled(not config.fb_lower_body);
if (ImGui::Checkbox(_S("Enable hip tracking"), &config.fb_hip))
{
config.save();
}
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Only takes affect with lower body tracking enabled\nMay be desired when using another source of hip tracking"));
ImGui::EndDisabled();
ImGui::Unindent();
ImGui::EndDisabled();
}
{
@@ -917,13 +791,6 @@ void scenes::lobby::gui_settings()
imgui_ctx->tooltip(_("Enables the configuration window to be shown while the game is streaming.\nIf enabled, the window is activated by pressing both thumbsticks."));
}
{
ImGui::Checkbox(_S("Extended configuration values"), &config.extended_config);
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Allows unsafe configuration values, use at your own risk."));
}
ImGui::PopStyleVar(); // ImGuiStyleVar_ItemSpacing
}
@@ -1052,7 +919,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);
}
@@ -1289,8 +1156,6 @@ void scenes::lobby::gui_first_run()
current_tab = tab::server_list;
config.first_run = false;
config.save();
ImGui::PopStyleVar(); // ImGuiStyleVar_ItemSpacing
return;
}
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10);
@@ -1557,7 +1422,6 @@ static const char * get_face_icon(XrTime predicted_display_time, xr::face_tracke
const char * result = nullptr;
std::visit(utils::overloaded{
[](std::monostate &) {},
[&](xr::android_face_tracker &) { result = ICON_FA_FACE_SMILE_WINK; },
[&](xr::htc_face_tracker &) { result = ICON_FA_FACE_SMILE_WINK; },
[&](auto & ft) {
ft.get_weights(predicted_display_time, expression);
@@ -1640,10 +1504,6 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
.icon_disabled = ICON_FA_FACE_MEH_BLANK,
});
}
else if (system.face_tracker_supported() != xr::face_tracker_type::none and config.check_feature(feature::face_tracking))
{
face_tracker = xr::make_face_tracker(instance, system, session);
}
if (system.body_tracker_supported() != xr::body_tracker_type::none)
{
+16 -115
View File
@@ -26,18 +26,12 @@
#include "imgui.h"
#include "imgui_internal.h"
#include "imspinner.h"
#include "render/image_writer.h"
#include "render/scene_renderer.h"
#include "utils/files.h"
#include "utils/i18n.h"
#include "utils/json_string.h"
#include "vk/allocation.h"
#include <algorithm>
#include <boost/url/url.hpp>
#include <boost/url/url_view.hpp>
#include <chrono>
#include <spdlog/fmt/chrono.h>
#include <spdlog/spdlog.h>
#include "IconsFontAwesome6.h"
@@ -59,12 +53,8 @@ void scenes::lobby::save_environment_json()
<< ",\"description\":" << json_string(model.description)
<< ",\"screenshot\":" << json_string(model.screenshot_url)
<< ",\"url\":" << json_string(model.gltf_url)
<< ",\"size\":" << model.size;
// TODO only if not the default value
ss << ",\"local_screenshot\":" << json_string(model.local_screenshot_path.string());
ss << ",\"local_path\":" << json_string(model.local_gltf_path.string());
ss << "},";
<< ",\"size\":" << model.size
<< "},";
}
if (not empty)
ss.seekp(-1, ss.cur);
@@ -122,16 +112,8 @@ std::vector<scenes::lobby::environment_model> scenes::lobby::load_environment_js
model.size = val.get_int64();
model.builtin = false;
if (auto val = i["local_screenshot"]; val.is_string())
model.local_screenshot_path = val.get_string().value();
else
model.local_screenshot_path = application::get_config_path() / "environments" / (model.name + ".png");
if (auto val = i["local_path"]; val.is_string())
model.local_gltf_path = val.get_string().value();
else
model.local_gltf_path = application::get_config_path() / "environments" / (model.name + ".glb");
model.local_screenshot_path = application::get_config_path() / "environments" / (model.name + ".png");
model.local_gltf_path = application::get_config_path() / "environments" / (model.name + ".glb");
models.push_back(std::move(model));
}
@@ -196,107 +178,26 @@ void scenes::lobby::update_file_picker()
try
{
load_environment_status = "";
file_picker_result picked_file = lobby_file_picker_future.get();
if (not picked_file)
return;
future_environment = utils::async<std::pair<std::string, std::shared_ptr<entt::registry>>, float>(
[this, picked_file = std::move(picked_file)](auto token) {
auto t = std::chrono::system_clock::now();
auto local_path = application::get_cache_path() / fmt::format("local-{:%F-%T}.glb", t);
auto local_screenshot_path = application::get_cache_path() / fmt::format("local-{:%F-%T}.png", t);
[this](auto token, file_picker_result environment) {
auto local_path = application::get_cache_path() / "local.glb";
utils::write_whole_file(local_path, (std::span<const std::byte>)picked_file.file);
utils::write_whole_file(local_path, (std::span<const std::byte>)environment.file);
environment_model model{
.name = _S("Locally loaded environment"),
.author = "",
.description = "",
.screenshot_url = "",
.gltf_url = fmt::format("local-{:%F-%T}", t), // Used as key
.size = picked_file.file.size(),
.local_screenshot_path = local_screenshot_path,
.local_gltf_path = local_path,
};
// TODO remove only local.glb from cache
clear_gltf_cache();
int n = 2;
while (std::ranges::find(local_environments, model.name, &environment_model::name) != local_environments.end())
{
model.name = fmt::format(_F("Locally loaded environment ({})"), n++);
}
local_environments.push_back(model);
std::ranges::sort(local_environments, std::less{});
save_environment_json();
std::shared_ptr<entt::registry> env = load_gltf(local_path, [&](float progress) { token.set_progress(progress); });
// Create a screenshot of the loaded environment
scene_renderer::frame_info frame{
.projection = projection_matrix(
XrFovf{
.angleLeft = -0.7,
.angleRight = 0.7,
.angleUp = 0.7,
.angleDown = -0.7,
},
constants::lobby::near_plane),
.view = view_matrix(XrPosef{
.orientation = {0, 0, 0, 1},
.position = {0, 1.6, 0},
})};
image_allocation output{
device,
vk::ImageCreateInfo{
.imageType = vk::ImageType::e2D,
.format = vk::Format::eR8G8B8A8Srgb,
.extent = {512, 512, 1},
.mipLevels = 1,
.arrayLayers = 1,
.usage = vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
},
VmaAllocationCreateInfo{
.usage = VmaMemoryUsage::VMA_MEMORY_USAGE_AUTO,
},
"Screenshot image",
};
scene_renderer local_renderer{device, physical_device, queue, queue_family_index};
local_renderer.start_frame();
local_renderer.render(
*env,
{
constants::lobby::sky_color.r,
constants::lobby::sky_color.g,
constants::lobby::sky_color.b,
constants::lobby::sky_color.a,
},
layer_lobby,
vk::Extent2D{
output.info().extent.width,
output.info().extent.height,
}, // Output size
output.info().format, // Output format
vk::Format::eD32Sfloat, // Depth format
output, // Output image
vk::Image{}, // Depth image
{&frame, 1}, // View info
false);
local_renderer.end_frame();
local_renderer.wait_idle(); // TODO get a semaphore from end_frame instead
write_image(device, queue, queue_family_index, local_screenshot_path, output);
return std::make_pair(local_path, env);
});
return std::make_pair(
local_path,
load_gltf(local_path, [&](float progress) {
token.set_progress(progress);
}));
},
lobby_file_picker_future.get());
}
catch (std::exception & e)
{
spdlog::warn("Cannot load local environment: {}", e.what());
load_environment_status = fmt::format(_F("Cannot load local environment: {}"), e.what());
}
}
+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, ">"},
+226 -268
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 = {
@@ -154,11 +153,9 @@ static const std::array supported_depth_formats{
scenes::stream::stream(std::string server_name, scene & parent_scene) :
scene_impl<stream>(supported_color_formats, supported_depth_formats, parent_scene),
apps{*this, std::move(server_name)}
apps{*this, std::move(server_name)},
blitters{blitter(device, 0), blitter(device, 1)}
{
auto views = system.view_configuration_views(viewconfig);
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
}
static from_headset::visibility_mask_changed::masks get_visibility_mask(xr::instance & inst, xr::session & session, int view)
@@ -201,58 +198,60 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
.variant = application::get_messages_info().variant,
};
auto view = self->system.view_configuration_views(self->viewconfig)[0];
view = override_view(view, guess_model());
auto resolution_scale = application::get_config().resolution_scale;
view.recommendedImageRectWidth *= resolution_scale;
view.recommendedImageRectHeight *= resolution_scale;
info.recommended_eye_width = view.recommendedImageRectWidth;
info.recommended_eye_height = view.recommendedImageRectHeight;
auto [flags, views] = self->session.locate_views(
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
self->instance.now(),
application::space(xr::spaces::view));
assert(views.size() == info.fov.size());
for (auto [i, j]: std::views::zip(views, info.fov))
{
auto [flags, views] = self->session.locate_views(
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
self->instance.now(),
application::space(xr::spaces::view));
assert(views.size() == info.fov.size());
for (auto [i, j]: std::views::zip(views, info.fov))
j = i.fov;
j = i.fov;
}
const auto & config = application::get_config();
{
auto view = self->system.view_configuration_views(self->viewconfig)[0];
view = override_view(view, guess_model());
info.render_eye_width = view.recommendedImageRectWidth * config.resolution_scale;
info.render_eye_height = view.recommendedImageRectHeight * config.resolution_scale;
}
{
auto scale = config.get_stream_scale();
info.stream_eye_width = info.render_eye_width * scale;
info.stream_eye_height = info.render_eye_height * scale;
}
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.preferred_refresh_rate = *config.preferred_refresh_rate;
info.minimum_refresh_rate = config.minimum_refresh_rate.value_or(0);
}
else
{
// Default to highest refresh rate
info.preferred_refresh_rate = info.available_refresh_rates.back();
}
}
}
if (info.available_refresh_rates.empty())
{
spdlog::warn("Unable to detect refresh rates");
info.available_refresh_rates = {guessed_fps};
info.settings.preferred_refresh_rate = guessed_fps;
info.preferred_refresh_rate = guessed_fps;
}
info.settings.bitrate_bps = config.bitrate_bps;
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())
@@ -260,9 +259,6 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
case xr::face_tracker_type::none:
info.face_tracking = from_headset::face_type::none;
break;
case xr::face_tracker_type::android:
info.face_tracking = from_headset::face_type::android;
break;
case xr::face_tracker_type::fb:
case xr::face_tracker_type::pico:
info.face_tracking = from_headset::face_type::fb2;
@@ -300,31 +296,13 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
if (not(config.check_feature(feature::microphone)))
info.microphone = {};
if (config.codec)
{
info.supported_codecs = {*config.codec};
switch (*config.codec)
{
case h264:
case raw:
break;
case h265:
case av1:
info.bit_depth = config.bit_depth;
}
}
else
info.supported_codecs = decoder::supported_codecs();
info.supported_codecs = decoder::supported_codecs();
return info;
}());
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))
{
@@ -420,14 +398,17 @@ void scenes::stream::on_focused()
{
gui_status_last_change = instance.now();
auto views = system.view_configuration_views(viewconfig);
// stream_view = override_view(views[0], guess_model());
width = views[0].recommendedImageRectWidth;
height = views[0].recommendedImageRectHeight;
std::string profile = controller_name();
input.emplace(
*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 +452,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 +468,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)
@@ -506,11 +478,17 @@ void scenes::stream::on_focused()
}
recenter_left = get_action("recenter_left").first;
recenter_right = get_action("recenter_right").first;
settings_adjust = get_action("settings_adjust").first;
foveation_pitch = get_action("foveation_pitch").first;
foveation_distance = get_action("foveation_distance").first;
foveation_ok = get_action("foveation_ok").first;
foveation_cancel = get_action("foveation_cancel").first;
assert(video_stream_description);
std::unique_lock lock(decoder_mutex);
setup_reprojection_swapchain(
video_stream_description->defoveated_width / view_count,
video_stream_description->defoveated_height);
if (application::get_config().high_power_mode)
{
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT);
@@ -518,8 +496,8 @@ void scenes::stream::on_focused()
}
else
{
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_LOW_EXT);
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_GPU_EXT, XR_PERF_SETTINGS_LEVEL_SUSTAINED_LOW_EXT);
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_LEVEL_POWER_SAVINGS_EXT);
session.set_performance_level(XR_PERF_SETTINGS_DOMAIN_GPU_EXT, XR_PERF_SETTINGS_LEVEL_POWER_SAVINGS_EXT);
}
}
@@ -528,9 +506,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();
}
@@ -564,9 +542,11 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
std::swap(handle, decoders[stream].latest_frames[handle->feedback.frame_index % decoders[stream].latest_frames.size()]);
}
if (state_ != state::streaming and not(decoders[0].empty() and decoders[1].empty()))
if (state_ != state::streaming and std::ranges::all_of(decoders, [](accumulator_images & i) {
return i.alpha() or not i.empty();
}))
{
set_state(state::streaming);
state_ = state::streaming;
spdlog::info("Stream scene ready at t={}", instance.now());
}
}
@@ -577,6 +557,11 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
}
}
bool scenes::stream::accumulator_images::alpha() const
{
return decoder->desc().channels == wivrn::to_headset::video_stream_description::channels_t::alpha;
}
bool scenes::stream::accumulator_images::empty() const
{
for (const auto & frame: latest_frames)
@@ -587,15 +572,18 @@ bool scenes::stream::accumulator_images::empty() const
return true;
}
std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::common_frame(XrTime display_time)
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::common_frame(XrTime display_time)
{
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)
for (size_t i = 0; i < decoders.size(); ++i)
{
if (decoders[i].alpha() and not alpha)
continue;
if (i == 0)
{
for (const auto & h: decoders[i].latest_frames)
@@ -605,7 +593,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 +606,8 @@ 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::vector<std::shared_ptr<shard_accumulator::blit_handle>> result;
result.reserve(decoders.size());
if (not common_frames.empty())
{
auto min = std::ranges::min_element(common_frames,
@@ -631,10 +620,12 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
assert(*min);
auto frame_index = (*min)->feedback.frame_index;
for (auto [i, decoder]: utils::enumerate(decoders))
for (const auto & decoder: decoders)
{
if (alpha or i < view_count)
result[i] = decoder.frame(frame_index);
if (alpha or not decoder.alpha())
result.emplace_back(decoder.frame(frame_index));
else
result.emplace_back(nullptr);
}
}
else
@@ -653,9 +644,9 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
spdlog::warn(frames);
}
for (auto [i, decoder]: utils::enumerate(decoders))
for (const auto & decoder: decoders)
{
if (alpha or i < view_count)
if (alpha or not decoder.alpha())
{
auto min = std::ranges::min_element(decoder.latest_frames,
std::ranges::less{},
@@ -664,8 +655,10 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
return std::numeric_limits<XrTime>::max();
return std::abs(frame->view_info.display_time - display_time);
});
result[i] = *min;
result.emplace_back(*min);
}
else
result.emplace_back(nullptr);
}
}
return result;
@@ -673,51 +666,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,48 +732,51 @@ 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::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 (decoders.empty() or not frame_state.shouldRender)
{
// TODO: stop/restart video stream
session.begin_frame();
session.end_frame(frame_state.predictedDisplayTime, {});
std::unique_lock lock(frames_mutex);
for (auto & i: decoders)
{
for (auto & frame: i.latest_frames)
frame.reset();
}
return;
}
@@ -815,17 +788,18 @@ 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();
}
assert(swapchain);
if (device.waitForFences(*fence, VK_TRUE, UINT64_MAX) == vk::Result::eTimeout)
throw std::runtime_error("Vulkan fence timeout");
device.resetFences(*fence);
// We don't need those after vkWaitForFences
current_blit_handles.fill(nullptr);
current_blit_handles.clear();
gpu_timestamps timestamps;
if (query_pool_filled)
@@ -865,24 +839,25 @@ void scenes::stream::render(const XrFrameState & frame_state)
// Search for frame with desired display time on all decoders
// If no such frame exists, use the latest frame for each decoder
current_blit_handles = common_frame(frame_state.predictedDisplayTime);
std::array<XrPosef, view_count> pose;
std::array<XrFovf, view_count> fov;
std::array<wivrn::to_headset::foveation_parameter, view_count> foveation;
std::array<XrPosef, 2> pose{};
std::array<XrFovf, 2> fov{};
std::array<wivrn::to_headset::foveation_parameter, 2> foveation{};
bool use_alpha = false;
std::array<stream_defoveator::input, view_count> images;
for (size_t i = 0; i < view_count + use_alpha; ++i)
for (auto & blit_handle: current_blit_handles)
{
auto & blit_handle = current_blit_handles[i];
if (not blit_handle)
continue;
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;
pose = blit_handle->view_info.pose;
fov = blit_handle->view_info.fov;
foveation = blit_handle->view_info.foveation;
use_alpha = blit_handle->view_info.alpha;
if (blit_handle->current_layout == vk::ImageLayout::eUndefined)
@@ -903,59 +878,37 @@ void scenes::stream::render(const XrFrameState & frame_state)
command_buffer.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands, vk::PipelineStageFlagBits::eAllCommands, {}, {}, {}, barrier);
blit_handle->current_layout = vk::ImageLayout::eGeneral;
}
if (i < view_count)
{
foveation[i] = blit_handle->view_info.foveation[i];
pose[i] = blit_handle->view_info.pose[i];
fov[i] = blit_handle->view_info.fov[i];
// colour image
images[i] = {
.rgb = blit_handle->image_view,
.sampler_rgb = decoders[i].decoder->sampler(),
.rect_rgb = {
.extent = blit_handle->extent,
},
.layout_rgb = blit_handle->current_layout,
};
}
else
{
// alpha image, must set for each view
for (int j = 0; j < view_count; ++j)
{
images[j].a = blit_handle->image_view;
images[j].sampler_a = decoders[i].decoder->sampler();
images[j].rect_a = vk::Rect2D{
// in full size pixels
.offset = {
.x = j * video_stream_description->width,
},
.extent = {
.width = blit_handle->extent.width * 2,
.height = blit_handle->extent.height * 2,
},
};
images[j].layout_a = blit_handle->current_layout;
}
}
}
// Blit images from the decoders
std::array<blitter::output, view_count> blitted;
for (auto [i, b]: utils::enumerate(blitters))
{
b.begin(command_buffer);
for (auto [j, blit_handle]: utils::enumerate(current_blit_handles))
{
if (not blit_handle)
continue;
b.push_image(command_buffer, j, decoders[j].decoder->sampler(), decoders[j].decoder->extent(), blit_handle->image_view, blit_handle->current_layout);
}
blitted[i] = b.end(command_buffer);
}
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
XrExtent2Di extents[view_count];
{
int32_t max_width = 0;
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);
}
if (not swapchain)
setup_reprojection_swapchain(max_width, max_height);
else if (swapchain.width() < max_width or swapchain.height() < max_height)
// If the defoveated image is larger than the swapchain, try to reallocate one
if (swapchain.width() < max_width or swapchain.height() < max_height)
{
// If the defoveated image is larger than the swapchain, try to reallocate one
try
{
spdlog::info("Recreating swapchain, from {}x{} to {}x{}",
@@ -976,21 +929,20 @@ void scenes::stream::render(const XrFrameState & frame_state)
}
}
}
assert(swapchain);
// defoveate the image
int image_index = swapchain.acquire();
swapchain.wait();
defoveator->defoveate(command_buffer, foveation, images, image_index);
defoveator->defoveate(command_buffer, foveation, blitted, image_index);
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 1);
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, *query_pool, 2);
command_buffer.end();
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 +967,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 +977,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 +998,22 @@ 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::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 +1050,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 +1094,22 @@ 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::foveation_settings:
case gui_status::applications:
case gui_status::application_launcher:
gui_status = gui_status::hidden;
break;
}
}
}
@@ -1158,7 +1118,7 @@ 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)
@@ -1166,29 +1126,36 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
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);
video_stream_description = description;
decoders.clear();
for (const auto & [stream_index, item]: utils::enumerate(decoders))
if (description.items.empty())
{
item = accumulator_images{
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, description, shared_from_this(), stream_index),
};
spdlog::info("Stopping video stream");
return;
}
if (defoveator)
defoveator->reset_pipelines();
video_stream_description = description;
for (auto & b: blitters)
b.reset(description);
for (const auto & [stream_index, item]: utils::enumerate(description.items))
{
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
decoders.push_back(accumulator_images{
.decoder = std::make_unique<shard_accumulator>(device, physical_device, instance, queue_family_index, item, description.fps, shared_from_this(), stream_index),
});
}
}
void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint32_t swapchain_height)
{
assert(swapchain_width);
assert(swapchain_height);
device.waitIdle();
session.set_refresh_rate(video_stream_description->fps);
const uint32_t video_width = video_stream_description->width / view_count;
const uint32_t video_height = video_stream_description->height;
auto views = system.view_configuration_views(viewconfig);
swapchain = xr::swapchain(instance, session, device, swapchain_format, swapchain_width, swapchain_height, 1, views.size());
@@ -1201,11 +1168,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());
}
@@ -1232,7 +1202,7 @@ scene::meta & scenes::stream::get_meta_scene()
{"recenter_left", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"recenter_right", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"settings_adjust", XR_ACTION_TYPE_FLOAT_INPUT},
{"foveation_pitch", XR_ACTION_TYPE_FLOAT_INPUT},
{"foveation_distance", XR_ACTION_TYPE_FLOAT_INPUT},
{"foveation_ok", XR_ACTION_TYPE_BOOLEAN_INPUT},
{"foveation_cancel", XR_ACTION_TYPE_BOOLEAN_INPUT},
@@ -1264,7 +1234,7 @@ scene::meta & scenes::stream::get_meta_scene()
{"recenter_left", "/user/hand/left/input/squeeze/value"},
{"recenter_right", "/user/hand/right/input/squeeze/value"},
{"settings_adjust", "/user/hand/right/input/thumbstick/y"},
{"foveation_pitch", "/user/hand/right/input/thumbstick/y"},
{"foveation_distance", "/user/hand/left/input/thumbstick/y"},
{"foveation_ok", "/user/hand/right/input/a/click"},
{"foveation_cancel", "/user/hand/right/input/b/click"},
@@ -1285,18 +1255,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)
+36 -44
View File
@@ -24,6 +24,7 @@
#include "decoder/shard_accumulator.h"
#include "render/imgui_impl.h"
#include "scene.h"
#include "scenes/blitter.h"
#include "scenes/input_profile.h"
#include "stream_defoveator.h"
#include "utils/thread_safe.h"
@@ -32,7 +33,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 +46,7 @@ public:
{
initializing,
streaming,
stalled,
shutdown,
stalled
};
static const size_t image_buffer_size = 3;
@@ -55,7 +54,8 @@ public:
private:
static const size_t view_count = 2;
static const size_t decoder_count = view_count + 1;
using stream_description = wivrn::to_headset::video_stream_description::item;
struct accumulator_images
{
@@ -64,6 +64,7 @@ private:
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, image_buffer_size> latest_frames;
std::shared_ptr<wivrn::shard_accumulator::blit_handle> frame(uint64_t id) const;
bool alpha() const;
bool empty() const;
};
@@ -71,14 +72,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::vector<std::shared_ptr<wivrn::shard_accumulator::blit_handle>> 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 +90,9 @@ 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::vector<accumulator_images> decoders; // Locked by decoder_mutex
std::array<blitter, view_count> blitters;
std::optional<stream_defoveator> defoveator;
@@ -105,16 +108,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,33 +125,31 @@ 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,
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;
XrAction recenter_right = XR_NULL_HANDLE;
XrAction settings_adjust = XR_NULL_HANDLE;
XrAction foveation_pitch = XR_NULL_HANDLE;
XrAction foveation_distance = XR_NULL_HANDLE;
XrAction foveation_ok = XR_NULL_HANDLE;
XrAction foveation_cancel = XR_NULL_HANDLE;
@@ -175,7 +167,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::vector<std::shared_ptr<wivrn::shard_accumulator::blit_handle>> current_blit_handles;
XrTime running_application_req = 0;
thread_safe<to_headset::running_applications> running_applications;
@@ -209,16 +201,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 +222,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 +237,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;
@@ -261,11 +253,13 @@ private:
struct gpu_timestamps
{
float gpu_barrier = 0;
float gpu_time = 0;
};
struct global_metric
struct global_metric //: gpu_timestamps
{
float gpu_barrier;
float gpu_time;
float cpu_time = 0;
float bandwidth_rx = 0;
@@ -314,14 +308,12 @@ 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::vector<std::shared_ptr<wivrn::shard_accumulator::blit_handle>> & 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
+2 -10
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:
@@ -303,7 +295,7 @@ static size_t required_vertices(const wivrn::to_headset::foveation_parameter & p
void stream_defoveator::defoveate(vk::raii::CommandBuffer & command_buffer,
const std::array<wivrn::to_headset::foveation_parameter, 2> & foveation,
const std::array<input, 2> & inputs,
std::span<wivrn::blitter::output> inputs,
int destination)
{
if (destination < 0 || destination >= (int)output_images.size())
@@ -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),
+3 -16
View File
@@ -19,6 +19,7 @@
#pragma once
#include "blitter.h"
#include "vk/allocation.h"
#include "wivrn_packets.h"
#include <vulkan/vulkan_raii.hpp>
@@ -60,18 +61,6 @@ class stream_defoveator
pipeline_t & ensure_pipeline(size_t view, vk::Sampler rgb, vk::Sampler a);
public:
struct input
{
vk::ImageView rgb;
vk::Sampler sampler_rgb;
vk::Rect2D rect_rgb;
vk::ImageLayout layout_rgb;
vk::ImageView a;
vk::Sampler sampler_a;
vk::Rect2D rect_a;
vk::ImageLayout layout_a;
};
stream_defoveator(
vk::raii::Device & device,
vk::raii::PhysicalDevice & physical_device,
@@ -81,13 +70,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,
std::span<wivrn::blitter::output> inputs,
int destination);
static XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &);
XrExtent2Di defoveated_size(const wivrn::to_headset::foveation_parameter &) const;
};
+171 -234
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>
@@ -87,7 +86,7 @@ ImPlotPoint getter(int index, void * data_)
}
} // namespace
void scenes::stream::accumulate_metrics(XrTime predicted_display_time, const std::array<std::shared_ptr<shard_accumulator::blit_handle>, view_count + 1> & blit_handles, const gpu_timestamps & timestamps)
void scenes::stream::accumulate_metrics(XrTime predicted_display_time, const std::vector<std::shared_ptr<shard_accumulator::blit_handle>> & blit_handles, const gpu_timestamps & timestamps)
{
uint64_t rx = network_session->bytes_received();
uint64_t tx = network_session->bytes_sent();
@@ -168,11 +167,12 @@ void scenes::stream::gui_performance_metrics()
ImVec2 window_size = ImGui::GetWindowSize() - ImVec2(2, 2) * style.WindowPadding;
const std::array plots = {
static const std::array plots = {
// clang-format off
plot(_("CPU time"), {{"", &global_metric::cpu_time}}, "s"),
plot(_("GPU time"), {{_("Defoveate"), &global_metric::gpu_time}}, "s"),
plot(_("GPU time"), {{_("Reproject"), &global_metric::gpu_time},
{_("Blit"), &global_metric::gpu_barrier}}, "s"),
plot(_("Network"), {{_("Download"), &global_metric::bandwidth_rx},
{_("Upload"), &global_metric::bandwidth_tx}}, "bit/s"),
@@ -339,10 +339,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 +374,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();
}
@@ -380,12 +386,10 @@ void scenes::stream::gui_compact_view()
static void send_settings_changed_packet(xr::session & session, wivrn_session * network, const configuration & config, float predicted_display_period)
{
const auto & refresh_rates = session.get_refresh_rates();
from_headset::settings_changed packet{
.bitrate_bps = config.bitrate_bps,
};
if (not refresh_rates.empty())
from_headset::settings_changed packet{};
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
@@ -398,7 +402,6 @@ static void send_settings_changed_packet(xr::session & session, wivrn_session *
std::string openxr_post_processing_flag_name(XrCompositionLayerSettingsFlagsFB flag); // TODO declaration in a .h file
void scenes::stream::gui_settings(float predicted_display_period)
{
const ImGuiStyle & style = ImGui::GetStyle();
auto & config = application::get_config();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20, 20));
@@ -408,11 +411,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 +425,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 +437,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()))
@@ -454,20 +458,6 @@ void scenes::stream::gui_settings(float predicted_display_period)
}
}
{
const auto text = _("Bitrate:");
const auto size = ImGui::CalcTextSize(text.c_str());
ImGui::Text("%s", text.c_str());
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;
imgui_ctx->vibrate_on_hover();
if (ImGui::IsItemHovered())
imgui_ctx->tooltip(_("Click to adjust bitrate"));
}
if (application::get_openxr_post_processing_supported())
{
ImGui::Text("%s", _S("OpenXR post-processing"));
@@ -525,87 +515,62 @@ 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();
}
void scenes::stream::gui_bitrate_settings(float predicted_display_period)
{
auto & config = application::get_config();
ImGui::PushFont(nullptr, constants::gui::font_size_large);
ImGui::Text("%s", _S("Use the right thumbstick to adjust the bitrate"));
ImGui::Text("%s", _S("Press A to go back"));
ImGui::Text("%s", fmt::format(_F("Bitrate: {}Mbit/s"), config.bitrate_bps / 1'000'000).c_str());
ImGui::PopFont();
// Maximum speed of 20Mbit/s
float delta = application::read_action_float(settings_adjust).value_or(std::pair{0, 0}).second * 20'000'000.f * predicted_display_period;
config.bitrate_bps = std::clamp(config.bitrate_bps + static_cast<int32_t>(delta), 1'000'000u, config.max_bitrate());
bool ok = application::read_action_bool(foveation_ok).value_or(std::pair{0, false}).second;
if (ok)
{
config.save();
next_gui_status = stream_tab::settings;
}
send_settings_changed_packet(session, network_session.get(), application::get_config(), predicted_display_period);
}
void scenes::stream::gui_foveation_settings(float predicted_display_period)
{
ImGui::PushFont(nullptr, constants::gui::font_size_large);
@@ -616,7 +581,7 @@ void scenes::stream::gui_foveation_settings(float predicted_display_period)
ImGui::PopFont();
// Maximum speed 1 rad/s
float delta_pitch = application::read_action_float(settings_adjust).value_or(std::pair{0, 0}).second * predicted_display_period;
float delta_pitch = application::read_action_float(foveation_pitch).value_or(std::pair{0, 0}).second * predicted_display_period;
// Maximum speed 2m/s @ 1m
float delta_distance = std::exp(std::log(2) * application::read_action_float(foveation_distance).value_or(std::pair{0, 0}).second * predicted_display_period);
@@ -629,7 +594,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 +605,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 +694,69 @@ 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::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 +768,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 +788,23 @@ 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::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 +817,48 @@ 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::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 +871,54 @@ 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:
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 +932,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 +945,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 +970,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 +1010,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 +1037,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{
+282 -281
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)
@@ -649,13 +671,9 @@ static device_id derived_from(device_id target)
{
case device_id::LEFT_AIM:
case device_id::LEFT_PALM:
case device_id::LEFT_PINCH_POSE:
case device_id::LEFT_POKE:
return device_id::LEFT_GRIP;
case device_id::RIGHT_AIM:
case device_id::RIGHT_PALM:
case device_id::RIGHT_PINCH_POSE:
case device_id::RIGHT_POKE:
return device_id::RIGHT_GRIP;
default:
assert(false);
@@ -707,19 +725,6 @@ void scenes::stream::on_interaction_profile_changed(const XrEventDataInteraction
DO_PROFILE(meta, touch_controller_quest_2)
DO_PROFILE(samsung, odyssey_controller)
DO_PROFILE(valve, index_controller)
// FIXME: remove once support for pre-1.1 profiles is dropped
if (profile == "/interaction_profiles/facebook/touch_controller_pro")
{
interaction_profiles[i] = interaction_profile::meta_touch_pro_controller;
continue;
}
if (profile == "/interaction_profiles/meta/touch_controller_plus")
{
interaction_profiles[i] = interaction_profile::meta_touch_plus_controller;
continue;
}
spdlog::warn("unknown interaction profile {}", profile);
}
catch (std::exception & e)
{
@@ -728,28 +733,24 @@ 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,
device_id::LEFT_PALM,
device_id::LEFT_PINCH_POSE,
device_id::LEFT_POKE,
device_id::RIGHT_AIM,
device_id::RIGHT_PALM,
device_id::RIGHT_PINCH_POSE,
device_id::RIGHT_POKE,
})
{
// 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)
const bool right = target >= device_id::RIGHT_GRIP && target <= device_id::RIGHT_PALM;
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));
+10 -42
View File
@@ -1,10 +1,11 @@
// kate: hl glsl
const int nb_views = 2;
const int nb_clipping = 4;
const int nb_texcoords = 2;
const bool use_pbr = false;
const bool use_normal_maps = true;
const bool use_normal_maps = false;
layout(set = 0, binding = 0) uniform scene_ubo
{
@@ -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
@@ -31,16 +33,7 @@ layout(set = 0, binding = 4) uniform sampler2D metallic_roughness_texture;
layout(set = 0, binding = 5) uniform sampler2D occlusion_texture;
layout(set = 0, binding = 6) uniform sampler2D emissive_texture;
layout(set = 0, binding = 7) uniform sampler2D normal_map_texture;
struct texture_info
{
int texcoord;
float rotation;
vec2 offset;
vec2 scale;
};
layout(std140, set = 0, binding = 8) uniform material_ubo
layout(set = 0, binding = 8) uniform material_ubo
{
vec4 base_color_factor;
vec4 base_emissive_factor;
@@ -50,11 +43,11 @@ layout(std140, set = 0, binding = 8) uniform material_ubo
float normal_scale;
float alpha_cutoff;
texture_info base_color;
texture_info metallic_roughness;
texture_info occlusion;
texture_info emissive;
texture_info normal;
int base_color_texcoord;
int metallic_roughness_texcoord;
int occlusion_texcoord;
int emissive_texcoord;
int normal_texcoord;
} material;
const float dither_pattern[4][4] = {
@@ -98,26 +91,6 @@ vec4 dither(ivec2 frag_coord, vec4 colour)
return colour + one_over_d_linear_to_srgb(colour) * vec4(dither_thd, dither_thd, dither_thd, 0) / 255.0f;
}
vec2 compute_texcoord(texture_info info, vec2 in_texcoord)
{
mat3 translation = mat3(
1, 0, 0,
0, 1, 0,
info.offset.x, info.offset.y, 1);
mat3 rotation = mat3(
cos(info.rotation), sin(info.rotation), 0,
-sin(info.rotation), cos(info.rotation), 0,
0, 0, 1);
mat3 scale = mat3(
info.scale.x, 0, 0,
0, info.scale.y, 0,
0, 0, 1);
mat3 matrix = translation * rotation * scale;
return (matrix * vec3(in_texcoord, 1)).xy;
}
#ifdef FRAG_SHADER
#define VS_TO_FS in
#else
@@ -129,9 +102,4 @@ layout(location = 0) VS_TO_FS vec3 normal;
layout(location = 1) VS_TO_FS vec4 tangent;
layout(location = 2) VS_TO_FS vec4 frag_pos;
layout(location = 3) VS_TO_FS vec4 light_pos;
layout(location = 4) VS_TO_FS vec2 texcoord_base_color;
layout(location = 5) VS_TO_FS vec2 texcoord_metallic_roughness;
layout(location = 6) VS_TO_FS vec2 texcoord_occlusion;
layout(location = 7) VS_TO_FS vec2 texcoord_emissive;
layout(location = 8) VS_TO_FS vec2 texcoord_normal;
layout(location = 9) VS_TO_FS vec4 vertex_color;
layout(location = 4) VS_TO_FS vec2 texcoord[nb_texcoords];
+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
+7 -7
View File
@@ -30,21 +30,21 @@ layout(early_fragment_tests) in;
void main()
{
vec4 albedo = vertex_color * material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord[0]);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord[0])).rgb;
vec3 normal_unit;
if (use_normal_maps)
{
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord_normal).xyz * 2 - 1));
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord[0]).xyz * 2 - 1));
// glTF spec §3.7.2.1
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
mat3 TBN = mat3(tangent.xyz, bitangent, normal);
mat3 TBN = mat3(tangent.xyz, bitangent, normal); // View space to tangent space?
// Normal in view space
normal_unit = normalize(TBN * sampled_normal);
normal_unit = TBN * sampled_normal;
}
else
normal_unit = normalize(normal);
@@ -54,8 +54,8 @@ void main()
if (use_pbr)
{
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord_occlusion).r - 1);
vec4 mr = texture(metallic_roughness_texture, texcoord_metallic_roughness);
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord[0]).r - 1);
vec4 mr = texture(metallic_roughness_texture, texcoord[0]);
vec3 half_vec = normalize(light_dir + view_dir);
+9 -6
View File
@@ -34,15 +34,14 @@ layout(location = 5) in vec4 in_color;
out gl_PerVertex
{
vec4 gl_Position;
float gl_ClipDistance[nb_clipping];
};
void main()
{
texcoord_base_color = compute_texcoord(material.base_color, in_texcoord[material.base_color.texcoord]);
texcoord_metallic_roughness = compute_texcoord(material.metallic_roughness, in_texcoord[material.metallic_roughness.texcoord]);
texcoord_occlusion = compute_texcoord(material.occlusion, in_texcoord[material.occlusion.texcoord]);
texcoord_emissive = compute_texcoord(material.emissive, in_texcoord[material.emissive.texcoord]);
texcoord_normal = compute_texcoord(material.normal, in_texcoord[material.normal.texcoord]);
// TODO: use base_color_texcoord et al instead of always using texcoord 0
for (int i = 0; i < nb_texcoords; i++)
texcoord[i] = in_texcoord[i];
// TODO on CPU?
mat3 mv = inverse(transpose(mat3(mesh.modelview[gl_ViewIndex])));
@@ -57,5 +56,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));
}
}
+7 -7
View File
@@ -30,21 +30,21 @@ layout(location = 0) out vec4 out_color;
void main()
{
vec4 albedo = vertex_color * material.base_color_factor * texture(base_color_texture, texcoord_base_color);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord_emissive)).rgb;
vec4 albedo = material.base_color_factor * texture(base_color_texture, texcoord[0]);
vec3 emissive_color = (material.base_emissive_factor * texture(emissive_texture, texcoord[0])).rgb;
vec3 normal_unit;
if (use_normal_maps)
{
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord_normal).xyz * 2 - 1));
vec3 sampled_normal = normalize(vec3(material.normal_scale, material.normal_scale, 1) * (texture(normal_map_texture, texcoord[0]).xyz * 2 - 1));
// glTF spec §3.7.2.1
vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
mat3 TBN = mat3(tangent.xyz, bitangent, normal);
mat3 TBN = mat3(tangent.xyz, bitangent, normal); // View space to tangent space?
// Normal in view space
normal_unit = normalize(TBN * sampled_normal);
normal_unit = TBN * sampled_normal;
}
else
normal_unit = normalize(normal);
@@ -54,8 +54,8 @@ void main()
if (use_pbr)
{
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord_occlusion).r - 1);
vec4 mr = texture(metallic_roughness_texture, texcoord_metallic_roughness);
float ao = 1 + material.occlusion_strength * (texture(occlusion_texture, texcoord[0]).r - 1);
vec4 mr = texture(metallic_roughness_texture, texcoord[0]);
vec3 half_vec = normalize(light_dir + view_dir);
+13 -9
View File
@@ -36,15 +36,14 @@ layout(location = 7) in vec4 in_weights;
out gl_PerVertex
{
vec4 gl_Position;
float gl_ClipDistance[nb_clipping];
};
void main()
{
texcoord_base_color = compute_texcoord(material.base_color, in_texcoord[material.base_color.texcoord]);
texcoord_metallic_roughness = compute_texcoord(material.metallic_roughness, in_texcoord[material.metallic_roughness.texcoord]);
texcoord_occlusion = compute_texcoord(material.occlusion, in_texcoord[material.occlusion.texcoord]);
texcoord_emissive = compute_texcoord(material.emissive, in_texcoord[material.emissive.texcoord]);
texcoord_normal = compute_texcoord(material.normal, in_texcoord[material.normal.texcoord]);
// TODO: use base_color_texcoord et al instead of always using texcoord 0
for (int i = 0; i < nb_texcoords; i++)
texcoord[i] = in_texcoord[i];
mat4 skinMatrix =
in_weights.x * joints.joint_matrices[int(in_joints.x)] +
@@ -52,8 +51,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 +60,14 @@ 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"
+63
View File
@@ -0,0 +1,63 @@
/*
* WiVRn VR streaming
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2022 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/>.
*/
#version 450
#ifdef VERT_SHADER
layout(constant_id = 0) const float useful_size_x = 1.0;
layout(constant_id = 1) const float useful_size_y = 1.0;
vec2 positions[3] = vec2[](
vec2(-1.0, -1.0),
vec2(3.0, -1.0),
vec2(-1.0, 3.0));
vec2 uvs[3] = vec2[](
vec2(0.0, 0.0),
vec2(2.0 * useful_size_x, 0.0),
vec2(0.0, 2.0 * useful_size_y));
layout(location = 0) out vec2 outUV;
void main()
{
outUV = uvs[gl_VertexIndex];
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
}
#endif
#ifdef FRAG_SHADER
layout(binding = 0) uniform sampler2D texSampler;
layout(constant_id = 0) const bool is_alpha = false;
layout(location = 0) in vec2 inUV;
layout(location = 0) out vec4 outColor;
void main()
{
outColor = texture(texSampler, inUV);
outColor.a = outColor.r;
if (!is_alpha)
{
outColor.a = 1;
}
}
#endif

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