ALVR (Air Light VR)

repository·master·Indexed 26 days ago

https://github.com/alvr-org/alvr

A tool for streaming VR games from a high-end gaming PC to standalone VR headsets over Wi-Fi. Supports Windows and Linux, and is compatible with headsets including Meta Quest, Pico Neo, Apple Vision Pro, and Vive Focus. The project includes specialized components such as a Vulkan capture layer for Linux, an ADB-based wired connection manager, and audio streaming utilities.

Tokens
32.9K
Snippets
56
Records
244
Agent score
93%

What's inside ALVR

  1. Overview of alvr_common crate

    master
    The alvr_common crate provides shared foundational functionality used across the entire ALVR workspace. It is primarily used for accessing common constants, the logging front-end, and re-exports of frequently used external dependencies to ensure consistency across different ALVR components.
  2. Overview of the ALVR capture vulkan layer

    master

    The ALVR capture vulkan layer is a specialized component designed to bypass limitations in the SteamVR runtime on Linux, specifically the inability to allow software-based output devices.

    It functions by:

    1. Adding a virtual display to the vkGetPhysicalDeviceDisplayPropertiesKHR call.
    2. Implementing all functions related to that virtual device.
    3. Sharing swapchain images with the ALVR server process.
    4. Communicating present calls to facilitate streaming.

    Note: This layer is heavily dependent on SteamVR due to necessary hacks, such as manipulating requested extensions and searching the stack to locate the headset position.

  3. Understand ALVR video upscaling behavior

    master

    ALVR currently does not perform upscaling before mapping the image to an OpenGL texture. Instead, the Quest's OVR (Oculus VR) system handles interpolation to match screen pixels. The interpolation method used by OVR depends on the resolution relative to the target:

    • Resolutions above 100%: Uses bilinear interpolation.
    • Resolutions below 100%: Uses nearest neighbor interpolation.

    Because Asynchronous Timewarp (ATW) is used on the Quest, it is not possible to achieve a perfect 1:1 pixel match for the upscaled image.

  4. Understand the ALVR Architecture

    master

    ALVR consists of two main components: the Streamer and the Client.

    Streamer (Windows/Linux)

    Composed of two parts:

    1. Dashboard: A GUI application used to manage settings, monitor statistics, and perform installation actions. It can launch SteamVR.
    2. Driver (Server): A binary dynamically loaded by SteamVR. It is responsible for client discovery and streaming.

    Client (Android VR Headsets)

    • A single unified APK named alvr_client_android.apk.
    • Powered by OpenXR.
    • Compatible with Quest, recent Pico, HTC Focus 3, and XR Elite headsets.

    Communication between the client and driver occurs via TCP or UDP sockets.

  5. Test Intel hardware encoding (VA-API)

    master

    Use the following commands to validate hardware encoding offloading on Intel GPUs using the intel-media-driver via VA-API. Monitor the process with nvtop. Ensure your hardware supports the target codec (e.g., AV1 requires Arc A-Series).

    # VA-API AVC (h264) hardware encoding
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v h264_vaapi -qp 18 \
    intel-h264_vaapi-90fps-300s.mp4
    
    # VA-API HEVC (h265) hardware encoding
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v hevc_vaapi -qp 18 \
    intel-hevc_vaapi-90fps-300s.mp4
    
    # VA-API AV1 hardware encoding (Arc A-Series only)
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v av1_vaapi -qp 18 \
    intel-av1_vaapi-90fps-300s.mp4
  6. Configure Foveated Encoding

    master

    ALVR implements Foveated Encoding to improve streaming performance. Unlike native foveated rendering which reduces GPU render load, ALVR's approach compresses the outskirts of the frame before transmission. The image is then re-expanded on the client side after decoding.

    Currently, ALVR supports Fixed Foveation using an algorithm based on Oculus AADT (Axis-Aligned Distorted Transfer), which compresses the lateral and vertical edges of the image. This method is chosen for its low impact on the headset's GPU compared to previous elliptical or slice-based algorithms.

  7. Test AMD hardware encoding (VA-API)

    master

    Use the following commands to validate hardware encoding offloading on AMD GPUs using mesa-va-drivers via VA-API. Video Core Next (VCN) hardware is required. Monitor with nvtop. AV1 support requires VCN 4.0+ or Navi 3x hardware.

    # VA-API AVC (h264) hardware encoding
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v h264_vaapi -qp 18 \
    amd-h264_vaapi-90fps-300s.mp4
    
    # VA-API HEVC (h265) hardware encoding
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v hevc_vaapi -qp 18 \
    amd-hevc_vaapi-90fps-300s.mp4
    
    # VA-API AV1 hardware encoding (VCN 4.0+, Navi 3x only)
    ffmpeg -hide_banner \
    -f lavfi -i testsrc2=duration=300:size=1280x720:rate=90 \
    -vaapi_device /dev/dri/renderD128 -vf 'format=nv12,hwupload' \
    -c:v av1_vaapi -qp 18 \
    amd-av1_vaapi-90fps-300s.mp4
  8. Configure wireless networks for ALVR

    master

    To minimize latency and packet loss in wireless VR streaming, follow these best practices:

    Hardware & Connection

    • Wired PC: The PC streaming the content should have a wired connection to the network.
    • Router/AP: Use a modern mid-to-high-end router/access point supporting at least 802.11ac (ideally 802.11ax).
    • Proximity: Keep the headset and access point as close as possible with minimal obstructions.

    WiFi Configuration

    • Frequency Band: High-speed devices (like the standalone headset) should use 5GHz only.
    • Channel Width: Use the largest possible channel width (e.g., 160MHz for 802.11ax, 80MHz for 802.11ac).
    • Channel Selection: Use the lowest utilization and lowest channel number possible. Avoid manual channel selection unless in extreme noise environments.
    • Device Management:
      • Move low-bandwidth devices (e.g., thermostats) to the 2.4GHz band.
      • Disable unnecessary wireless networks (like printer networks) to reduce interference.
      • Enable airtime fairness on supported routers to prevent slow clients from consuming excessive airtime.
  9. Optimize ALVR resolution, refresh rate, and codec

    master

    To achieve a sharp image, balance resolution, sharpening, and bitrate based on your connection type and hardware:

    Connection Presets

    • Wireless (Good Router): Use medium resolution preset with 1.0 sharpening.
      • H.264: Constant 400-500 Mbps.
      • HEVC: Constant 100-150 Mbps.
    • Wired:
      • H.264: Constant 800-1000 Mbps.

    Codec Selection Guide

    • AV1: Requires latest generation GPUs (Nvidia RTX 4xxx, AMD Radeon RX 7xxx) and is only supported on Quest 3.
    • HEVC/H.265: Best for bitrate-constrained scenarios.
    • AVC/H.264 (with CAVLC): May reduce decode latency slightly but requires significantly higher bitrates for comparable quality.
    • Software encoding (x264): Use for high core-count CPUs if no hardware encoder is available (e.g., RX6500). Requires a USB3 cable.

    Refresh Rate

    • Higher is better, but lower settings provide more consistency on older hardware.
    • Note: For Quest 2, 120 Hz must be enabled in the headset settings.