Merge pull request #2 from wheaney/vulkan

Vulkan
This commit is contained in:
Wayne Heaney 2023-10-23 08:56:23 -07:00 committed by GitHub
commit de4e0bad0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 308 additions and 1 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: wheaney
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: wheaney
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/vulkan/build/

11
.gitmodules vendored Normal file
View File

@ -0,0 +1,11 @@
[submodule "vulkan/modules/vkBasalt"]
path = vulkan/modules/vkBasalt
url = git@github.com:wheaney/vkBasalt.git
branch = runtime_uniforms
[submodule "vulkan/modules/sombrero"]
path = vulkan/modules/sombrero
url = git@github.com:wheaney/sombrero.git
[submodule "modules/xrealAirLinuxDriver"]
path = modules/xrealAirLinuxDriver
url = git@github.com:wheaney/xrealAirLinuxDriver.git
branch = sombrero

View File

@ -1 +1,60 @@
# breezy-desktop
# Breezy Desktop
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U8OVC0L)
## What is this?
This repo will eventually contain a collection of tools to enable virtual desktop environments for gaming and productivity on Linux using XREAL Air glasses.
As of now, only a Vulkan implementation is available, primarily for gaming but could theoretically be used for anything that uses Vulkan rendering.
## Breezy Vulkan
### Setup
#### Steam Deck via Decky Loader
This is still a work in progress... star this repo or check back later.
#### Manual installation
1. [Download the setup script](https://github.com/wheaney/breezy-desktop/releases/latest/download/breezy_vulkan_setup) and set the execute flag (e.g. from the terminal: `chmod +x ~/Downloads/breezy_vulkan_setup`)
2. Run the setup script as root (e.g. `sudo ~/Downloads/breezy_vulkan_setup`)
### Usage
Once installed, you'll want to make sure you've enabled the driver (`~/bin/xreal_driver_config -e`) and you'll probably want to disable mouse/joystick output (`~/bin/xreal_driver_config -eo`); note that these two commands can't be combined, they have to be done separately. From there, you should be able to launch any Vulkan game, plug in your glasses (at any point, not just after launching), and see a floating screen.
There's a wait period of 15 seconds after plugging in the glasses where the screen will stay static to allow for the glasses to calibrate. Once ready, the screen will anchor to the space where you are looking.
#### Multi-tap to re-center or re-calibrate
I've implemented an experimental multi-tap detection feature for screen **re-centering (2 taps)** and **re-calibrating the device (3 taps)**. To perform a multi-tap, you'll want to give decent taps on the top of the glasses. I tend to do this on the corner, right on top of the hinge. It should be a firm, sharp tap, and wait just a split second to do the second tap, as it needs to detect a slight pause in between (but it also shouldn't take more than a half a second between taps so don't wait too long).
### Troubleshooting
#### Screen drag or flickering
Framerate is really important here, because individual frames are static, so moving your head quickly may produce a noticeable flicker as it moves the screen. Higher framerates will produce an overall better experience (less flicker and smoother follow), but lower framerates should still be totally usable.
#### Unexpected screen movement or drift
It's important that your glasses are either on your head or sitting on a flat surface when they're first plugged in and calibrated. If you notice that your screen is constantly drifting in one direction or continues to move for several seconds after a head movement, almost as if the screen has some momentum that takes time to slow down, then you'll want to re-calibrate them. To do this, do a triple-tap as described in the Multi-tap section above.
#### Display size
If the screen appears very small in your view, you may be playing at the Deck screen's native resolution, and not at the glasses' native
resolution. To fix this:
1. Go to the game details in Steam, hit the Settings/cog icon, and open `Properties`, then for `Game Resolution` choose `Native`.
2. After launching the game, if it's still small, go into the game options, and in the graphics or video settings, change the resolution (the glasses run at 1920x1080).
If you *WANT* to keep a low resolution, then you can just use the `Zoom` setting to make the screen appear larger. For now this is done through the config script: `~/bin/xreal_driver_config -z 1.0`. Larger numbers zoom in (e.g. `2.0` doubles the screen size) and smaller numbers zoom out (e.g. `0.5` is half the screen size).
### Disabling
To disable the floating screen effect, either disable the driver (`~/bin/xreal_driver_config -d`), unplug the glasses, or hit the `Home` key (you'll need to bind this to your controller, if on Steam Deck).
### Updating
Rerun the `breezy_vulkan_setup` script. No need to re-download this script, as it will automatically download the latest installation binary for you.
### Uninstalling
If you wish to completely remove the installation, run the following: `sudo ~/bin/breezy_vulkan_uninstall`. This won't uninstall the base driver package, follow the instructions at the end of the uninstallation to do this manually.

39
bin/breezy_vulkan_setup Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
# This setup script should do the minimum work required to download the release package, unzip it, and kick off the
# setup script contained within.
# exit when any command fails
set -e
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# create temp directory
tmp_dir=$(mktemp -d -t breezy-vulkan-XXXXXXXXXX)
pushd $tmp_dir > /dev/null
echo "Created temp directory: ${tmp_dir}"
if [ -z "$1" ]
then
# download and unzip the latest driver
echo "Downloading latest release to: ${tmp_dir}/breezyVulkan.tar.gz"
curl -L -O https://github.com/wheaney/breezy-desktop/releases/latest/download/breezyVulkan.tar.gz
else
cp $1 $tmp_dir
fi
echo "Extracting to: ${tmp_dir}/breezy_vulkan"
tar -xf breezyVulkan.tar.gz
pushd breezy_vulkan > /dev/null
# run the setup script that comes with this release
bin/setup
echo "Deleting temp directory: ${tmp_dir}"
rm -rf $tmp_dir
cd "$(dirs -l -0)" && dirs -c

67
bin/package_vulkan Executable file
View File

@ -0,0 +1,67 @@
#!/usr/bin/env bash
# exit when any command fails
set -e
XREAL_DRIVER_DIR=modules/xrealAirLinuxDriver
source $XREAL_DRIVER_DIR/bin/inject_ua
# check out submodules, recursively for nested ones
git submodule update --init --recursive
VULKAN_DIR=vulkan
VULKAN_BUILD=$VULKAN_DIR/build
if [ ! -d "$VULKAN_BUILD" ]; then
mkdir -p $VULKAN_BUILD
else
rm -rf $VULKAN_BUILD/*
fi
VULKAN_MODULES=$VULKAN_DIR/modules
PACKAGE_DIR=$VULKAN_BUILD/breezy_vulkan
if [ ! -d "$PACKAGE_DIR" ]; then
mkdir -p $PACKAGE_DIR
else
rm -rf $PACKAGE_DIR/*
fi
# build vkBasalt
VKBASALT_MODULE_DIR=$VULKAN_MODULES/vkBasalt
VKBASALT_BUILD_DIR=$VKBASALT_MODULE_DIR/out
if [ ! -d "$VKBASALT_BUILD_DIR" ] || [ "$1" != "--skip-module-builds" ]; then
pushd $VKBASALT_MODULE_DIR
./docker-build
popd
fi
# copy vkBasalt binaries and configs
mkdir -p $PACKAGE_DIR/{vkBasalt.64,vkBasalt.32}
cp $VKBASALT_BUILD_DIR/builddir/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir/config/vkBasalt.json $PACKAGE_DIR/vkBasalt.64/
cp $VKBASALT_BUILD_DIR/builddir.32/src/libvkbasalt.so $PACKAGE_DIR/vkBasalt.32/
# copy Sombrero FX, get ReShade headers
cp $VULKAN_MODULES/sombrero/IMUAdjust.fx $PACKAGE_DIR
cp $VULKAN_MODULES/sombrero/calibrating.png $PACKAGE_DIR
wget -P $PACKAGE_DIR https://raw.githubusercontent.com/crosire/reshade-shaders/384465d0287999caa6190b5ebea506200b4f4a0a/Shaders/ReShade.fxh
wget -P $PACKAGE_DIR https://raw.githubusercontent.com/crosire/reshade-shaders/384465d0287999caa6190b5ebea506200b4f4a0a/Shaders/ReShadeUI.fxh
# copy vulkan setup scripts and configs
mkdir -p $PACKAGE_DIR/bin
copy_and_inject_ua "$XREAL_DRIVER_DIR/bin/ua.sh" "$PACKAGE_DIR/bin" "$VULKAN_DIR/bin/setup" "$VULKAN_DIR/bin/breezy_vulkan_uninstall"
cp -r $VULKAN_DIR/config $PACKAGE_DIR
# build xreal driver
XREAL_BINARY=$XREAL_DRIVER_DIR/build/xrealAirLinuxDriver.tar.gz
if [ ! -e "$XREAL_BINARY" ] || [ "$1" != "--skip-module-builds" ]; then
pushd $XREAL_DRIVER_DIR
bin/package
popd
fi
# copy xreal binary and setup script
cp $XREAL_BINARY $PACKAGE_DIR
cp $XREAL_DRIVER_DIR/bin/xreal_driver_setup $PACKAGE_DIR/bin
# bundle everything up
tar -zcvf $VULKAN_BUILD/breezyVulkan.tar.gz --directory $VULKAN_BUILD breezy_vulkan

@ -0,0 +1 @@
Subproject commit f4130ba863b4976faada90ee48f454ccf3c7d201

View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
for_install=0
if [[ -n "$1" ]] && [[ "$1" == "--for-install" ]]; then
for_install=1
fi
# we don't want the uninstall script to be able to cause a failure if being triggered by the setup script
[ "$for_install" -eq 0 ] && set -e
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
USER=${SUDO_USER:-$USER}
USER_HOME=$(getent passwd $USER | cut -d: -f6)
if [ "$for_install" -eq 0 ]; then
UA_EVENT_NAME="breezy_uninstall"
UA_CLIENT_ID="BreezyVulkan"
#INJECT_UA_CALL
fi
[ "$for_install" -eq 0 ] && echo "Removing vkBasalt binaries from $USER_HOME/.local/lib[32]/"
rm $USER_HOME/.local/lib/libvkbasalt.so
rm $USER_HOME/.local/lib32/libvkbasalt.so
[ "$for_install" -eq 0 ] && echo "Removing vkBasalt vulkan layer configs from $USER_HOME/.local/share/vulkan/implicit_layer.d/"
rm $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
rm $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json
[ "$for_install" -eq 0 ] && echo "Removing vkBasalt and reshade directories at $USER_HOME/.config/"
rm -rf $USER_HOME/.config/vkBasalt
rm -rf $USER_HOME/.config/reshade
[ "$for_install" -eq 0 ] && echo "SKIPPING xrealAirLinuxDriver uninstall to keep mouse/joystick driver functionality."
[ "$for_install" -eq 0 ] && echo "To manually uninstall xrealAirLinuxDriver, do: \"sudo ~/bin/xreal_driver_uninstall\""
# this script is self-deleting, leave this as the last command
rm -f $USER_HOME/bin/breezy_vulcan_uninstall

61
vulkan/bin/setup Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env bash
# This script gets packaged with the release and should do the bulk of the setup work. This allows this setup to be tied
# to a specific release of the code, and guarantees it will never run along-side newer or older binaries.
USER=${SUDO_USER:-$USER}
USER_HOME=$(getent passwd $USER | cut -d: -f6)
UA_EVENT_NAME="breezy_install"
if [ -e "$USER_HOME/bin/breezy_vulkan_uninstall" ]; then
echo "Cleaning up the previous installation"
# ` || true` will ensure that this can't cause a failure, even with `set -e`
$USER_HOME/bin/breezy_vulkan_uninstall --for-install || true
UA_EVENT_NAME="breezy_update"
fi
UA_CLIENT_ID="BreezyVulkan"
#INJECT_UA_CALL
echo "Copying the breezy_vulkan scripts to ${USER_HOME}/bin"
if [ ! -d "$USER_HOME/bin" ]; then
su -c 'mkdir -p '$USER_HOME'/bin' $USER
fi
cp bin/breezy_vulkan_uninstall $USER_HOME/bin
echo "Installing vkBasalt; copying binaries, configs, and shader files to ${USER_HOME}/.local and ${USER_HOME}/.config"
# much of the setup below was informed by https://github.com/simons-public/steam-deck-vkbasalt-install
# copy the vkBasalt binaries and configs
su -c 'mkdir -p '$USER_HOME'/.local/{lib,lib32,share/vulkan/implicit_layer.d}' $USER
su -c 'mkdir -p '$USER_HOME'/.config/{vkBasalt,reshade/Shaders,reshade/Textures}' $USER
cp vkBasalt.64/libvkbasalt.so $USER_HOME/.local/lib/
cp vkBasalt.32/libvkbasalt.so $USER_HOME/.local/lib32/
chown $USER:$USER $USER_HOME/.local/lib/libvkbasalt.so
chown $USER:$USER $USER_HOME/.local/lib32/libvkbasalt.so
# there is only one vkBasalt.json file, use the 64-bit directory for both, copy and make replacements
if grep -q SteamOS /etc/os-release ; then
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib/libvkbasalt.so|" -e "s/ENABLE_VKBASALT/SteamDeck/" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib32/libvkbasalt.so|" -e "s/ENABLE_VKBASALT/SteamDeck/" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json
else
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib/libvkbasalt.so|" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.json
sed -e "s|libvkbasalt.so|${USER_HOME}/.local/lib32/libvkbasalt.so|" vkBasalt.64/vkBasalt.json > $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.x86.json
fi
chown $USER:$USER $USER_HOME/.local/share/vulkan/implicit_layer.d/vkBasalt.*
# copy the vkBasalt.conf file and make replacements
sed -e "s|/path/to/reshade-shaders|${USER_HOME}/.config/reshade|" -e "s|/path/to/sombrero|${USER_HOME}/.config/reshade/Shaders/IMUAdjust.fx|" config/vkBasalt.conf > $USER_HOME/.config/vkBasalt/vkBasalt.conf
chown -R $USER:$USER $USER_HOME/.config/vkBasalt
echo "Installing the Sombrero shader and texture files to ${USER_HOME}/.config/reshade/{Shaders,Textures}"
cp *.fx* $USER_HOME/.config/reshade/Shaders
cp calibrating.png $USER_HOME/.config/reshade/Textures
chown -R $USER:$USER $USER_HOME/.config/reshade
# set up the XREAL driver using the local binary
echo "Installing xrealAirLinuxDriver"
echo "BEGIN - xreal_driver_setup"
bin/xreal_driver_setup $(pwd)/xrealAirLinuxDriver.tar.gz
echo "END - xreal_driver_setup"

View File

@ -0,0 +1,12 @@
effects = sombrero
sombrero = /path/to/sombrero
reshadeTexturePath = "/path/to/reshade-shaders/Textures"
reshadeIncludePath = "/path/to/reshade-shaders/Shaders"
depthCapture = off
#toggleKey toggles the effects on/off
toggleKey = Home
#enableOnLaunch sets if the effects are enabled when started
enableOnLaunch = True

@ -0,0 +1 @@
Subproject commit 92ceaf12b836ab3fd6e9748e5e43e1caa5cf5510

@ -0,0 +1 @@
Subproject commit 00eaebc7ef6b7f92e9a930e050f065d246054447