unified-hmi / remote-virtio-gpu

A UnifiedHMI project to provide a client-server based rendering engine.
Other
24 stars 14 forks source link

Remote VIRTIO GPU (RVGPU)

Remote VIRTIO GPU (RVGPU) is a client-server based rendering engine, which allows to render 3D on one device (client) and display it via network on another device (server)

Contents

Repository structure

.
├── documentation                  # documents
├── include
│    ├── librvgpu                  # librvgpu header files
│    ├── rvgpu-generic             # common header files for all components
│    ├── rvgpu-proxy               # rvgpu-proxy header files
│    ├── rvgpu-renderer            # rvgpu-renderer header files
├── src
│    ├── librvgpu                  # librvgpu source files
│    ├── rvgpu-proxy               # rvgpu-proxy source files
│    ├── rvgpu-renderer            # rvgpu-renderer source files
│    ├── rvgpu-sanity              # sanity module source files

How to Install RVGPU

The install instructions described here are tested on Ubuntu 20.04 LTS AMD64. However you can try it with different Linux distros with Wayland display server. Assuming, you have a clean Ubuntu 20.04 installed, perform the following steps.
You have two options for installing RVGPU: either build from source code (Building from Source) or install from a binary (Binary-only Install).

Building from Source

Binary-only Install

Download the remote-virtio-gpu_X.X.X.deb ubuntu package from the latest release builds from this github repository and install it.
Specify the correct version of X.X.X by referring to https://github.com/unified-hmi/remote-virtio-gpu/releases/latest
For example: remote-virtio-gpu_1.0.0.deb.

Note: An error about unresolved dependencies will occur when executing the following 2nd command, sudo dpkg -i remote-virtio-gpu_X.X.X.deb. This error can be resolved by running the 3rd one, sudo apt -f install.

  wget https://github.com/unified-hmi/remote-virtio-gpu/releases/latest/download/remote-virtio-gpu_X.X.X.deb
  sudo dpkg -i remote-virtio-gpu_X.X.X.deb
  sudo apt -f install

How to Install Virtio-loopback-driver

When using RVGPU, this module is also necessary.
For instructions on how to install Virtio-loopback-driver, please refer to the README.

How to Install Weston

The operation of RVGPU can be tested using Weston version 8.0.93 or above.
Install Weston-8.0.93

sudo apt install libjpeg-dev libwebp-dev libsystemd-dev libpam-dev libva-dev freerdp2-dev \
               libxcb-composite0-dev liblcms2-dev libcolord-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libpipewire-0.2-dev \
               libxml2-dev meson libxkbcommon-x11-dev libpixman-1-dev libinput-dev libdrm-dev wayland-protocols libcairo2-dev \
               libpango1.0-dev libdbus-1-dev libgbm-dev libxcursor-dev

wget https://wayland.freedesktop.org/releases/weston-8.0.93.tar.xz
tar -xf weston-8.0.93.tar.xz
cd ~/weston-8.0.93/
meson build/
sudo ninja -C build/ install
sudo ldconfig

Run RVGPU

RVGPU software consists of client (rvgpu-proxy) and server (rvgpu-renderer). Let's describe how to run them on the same machine via the localhost interface. We will start with rvgpu-renderer.
To use RVGPU, you should be able to load the kernel, so turn Secure Boot off.

Run rvgpu-renderer on Wayland

rvgpu-renderer with Wayland backend creates a window in the Wayland environment and renders into it. So you should have a window system supporting Wayland protocol (such as Gnome with Wayland protocol or Weston) running. To make this work, you can choose from Using Ubuntu on Wayland or Using Ubuntu (default).

Using Ubuntu on Wayland

Select Ubuntu on Wayland at the login screen. Open a terminal and run this command:

rvgpu-renderer -b 1280x720@0,0 -p 55667

After this command, launching rvgpu-proxy will make the rvgpu-renderer create a window.

Using Ubuntu (default)

You can launch a dedicated instance of Weston and run rvgpu-renderer inside it.

weston --width 2200 --height 1200 &
rvgpu-renderer -b 1280x720@0,0 -p 55667

This command will create a weston window. Launching rvgpu-proxy will make the rvgpu-renderer create nested subwindow. The script does not require the window system uses Wayland protocol, so it could be run under X Window system.

Run rvgpu-proxy

rvgpu-proxy should be able to access the kernel modules virtio-lo and virtio-gpu so it should be run with superuser privileges.

sudo -i
modprobe virtio-gpu
modprobe virtio-lo
rvgpu-proxy -s 1280x720@0,0 -n 127.0.0.1:55667

Note: Those who have performed "Building from source" please follow the instructions below.

rvgpu-proxy -s 1280x720@0,0 -n 127.0.0.1:55667 -c /usr/local/etc/virgl.capset

After you run this, another GPU node /dev/dri/cardX appear. Also, if you are running rvgpu-renderer in Wayland mode, it create a new window.

You can test the new gpu node for example running Weston-8.0.93 on it:

export XDG_RUNTIME_DIR=/tmp
weston --backend drm-backend.so --tty=2 --seat=seat_virtual -i 0

After that rvgpu-renderer will display weston rendered and transferred via localhost by rvgpu-proxy. Now you can launch glmark2-es2-wayland or some other graphical application to verify that everything works.

sudo apt install glmark2-es2-wayland
glmark2-es2-wayland

VSYNC feature

rvgpu-proxy can emulate VSYNC feature (see the -f command option). To support the VSYNC feature in rvgpu-proxy, apply and rebuild the Linux kernel with the following path remote-virtio-gpu/documentation/patches/kernel. The patches could be applied to the linux kernel with versions before 5.15. The software still could be compiled or run on the recent kernels without support for VSYNC feature.

Get the Linux kernel souce code, which must be compatible with your Linux distro, use the patch file corresponding with kernel version you get for performing build and generate the necessary deb files

Here, the build instructions described to support the VSYNC feature to the kernel version 5.8.18 for Ubuntu 20.04.

How to run RVGPU remotely

The way is almost the same as to run RVGPU locally. Launch rvgpu-renderer on one machine and rvgpu-proxy with the kernel modules on the another one, and pass the IP address and port number on which rvgpu-renderer is listening to rvgpu-proxy through -n option.

Note
Some graphical applications generate much network traffic. It is recommended to Configure the network to 1Gbps speed.

Capsets

Sometimes the software does not work because the provided virgl.capset file does not specify the capset of the rendering side. It may manifest in black window. In this case: