VirGL hardware accelerated h264/h265

carlo.luzi

New Member
Sep 24, 2022
2
1
1
Hello community,

after reading this post on Phoronix, I try to make hardware accelerated h264/h265 transcoding works with PVE 8.1 and Fedora 39 guest with virtio-gpu virtio-gl.

In the host, vainfo give me hardware transcoding capability:

Code:
root@pve-nuc11:/root# pveversion
pve-manager/8.1.3/b46aac3b42da5d15 (running kernel: 6.5.11-4-pve)
root@pve-nuc11:/root# vainfo
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.12.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSliceLP
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           :    VAEntrypointVLD
      VAProfileJPEGBaseline           :    VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain10             :    VAEntrypointVLD
      VAProfileVP9Profile0            :    VAEntrypointVLD
      VAProfileVP9Profile2            :    VAEntrypointVLD

but the Fedora guest don't see any codec:

Code:
liveuser@localhost-live:~130$ cat /etc/system-release
Fedora release 39 (Thirty Nine)
liveuser@localhost-live:~$ sudo vainfo
Trying display: wayland
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
Trying display: x11
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib64/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.20.0)
vainfo: Driver version: Mesa Gallium driver 23.2.1 for virgl (Mesa Intel(R) UHD Graphics (CML GT2))
vainfo: Supported profile and entrypoints
      VAProfileNone                   :    VAEntrypointVideoProc

I'm missing a piece or this capability is not yet supported?

Thank you
 
Last edited:
  • Like
Reactions: fsteccanella
Ohhh, this would be so useful! I'll report back if I find anything. I'd love to be able to divvy up resources in a similar fashion as SR-IOV.
 
Would you mind posting your XML? Or at least some of it regarding SPICE and VirGL?

I'm doing a little digging. I've only used VirGL on macOS, which was fantastic btw, I'm wondering if you don't need to specify that it's a headless system:

Code:
<graphics type="egl-headless">
      <gl rendernode="/dev/dri/renderD128"/>
    </graphics>

Edit: This might only be required for NVIDIA.
 
Last edited:
Would you mind posting your XML? Or at least some of it regarding SPICE and VirGL?

I'm doing a little digging. I've only used VirGL on macOS, which was fantastic btw, I'm wondering if you don't need to specify that it's a headless system:

Code:
<graphics type="egl-headless">
      <gl rendernode="/dev/dri/renderD128"/>
    </graphics>

Edit: This might only be required for NVIDIA.

I can give you the proxmox configuration stored in /etc/pve/qemu-server:

Code:
agent: 1
bios: ovmf
boot: order=scsi0;ide2;net0
cores: 2
cpu: host
efidisk0: nmve-vol:vm-111-disk-0,efitype=4m,pre-enrolled-keys=1,size=1M
ide2: nvme-dir:iso/Fedora-Workstation-Live-x86_64-39-1.5.iso,media=cdrom,size=2079836K
machine: q35
memory: 2048
meta: creation-qemu=8.1.2,ctime=1700826329
name: fedora-nomachine-gpu
net0: virtio=BC:24:11:C4:4F:44,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: nmve-vol:vm-111-disk-1,iothread=1,size=16G
scsihw: virtio-scsi-single
smbios1: uuid=d0599936-0ac2-4120-9d51-8d2804e0701d
sockets: 1
vga: virtio-gl
vmgenid: 263d33b5-9021-453a-918c-ca70805d5749

For the headless configuration I found this forum post, it seems that the egl-headless option is already added by proxmox. However I tried to add it manually but no change in vainfo codec list.

Reading this reply in reddit it seems that the egl-headless option is used to play nice with SPICE. I wonder, in case the option is inserted automatically by proxmox, if there is a way to remove it to see if anything changes with the codec list.

I made a small digression and tried using a mediated device with Intel GVT-g as indicated in this blog post and it works (there are more codecs because I installed updated drivers in the VM):

Code:
local@fedora:~$ vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.20.0
libva error: vaGetDriverNames() failed with unknown libva error
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.20.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.3.5 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :    VAEntrypointVideoProc
      VAProfileNone                   :    VAEntrypointStats
      VAProfileMPEG2Simple            :    VAEntrypointVLD
      VAProfileMPEG2Simple            :    VAEntrypointEncSlice
      VAProfileMPEG2Main              :    VAEntrypointVLD
      VAProfileMPEG2Main              :    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointFEI
      VAProfileH264Main               :    VAEntrypointEncSliceLP
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointFEI
      VAProfileH264High               :    VAEntrypointEncSliceLP
      VAProfileVC1Simple              :    VAEntrypointVLD
      VAProfileVC1Main                :    VAEntrypointVLD
      VAProfileVC1Advanced            :    VAEntrypointVLD
      VAProfileJPEGBaseline           :    VAEntrypointVLD
      VAProfileJPEGBaseline           :    VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:    VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :    VAEntrypointVLD
      VAProfileVP8Version0_3          :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointFEI
      VAProfileHEVCMain10             :    VAEntrypointVLD
      VAProfileHEVCMain10             :    VAEntrypointEncSlice
      VAProfileVP9Profile0            :    VAEntrypointVLD
      VAProfileVP9Profile2            :    VAEntrypointVLD

However, I hope to be able to use VirGL as the author of the post has abandoned the solution due to stability problems. The stability issues may have been resolved with the latest kernel releases, but Intel no longer seems to support GVT-g technology in its drivers.
 
Hehe, silly me. I almost forgot I was on the Proxmox forums. I am super interested, though. I'll fire up my backup box, which has an Intel iGPU as well, and start tinkering tomorrow. Hopefully someone will have some first hand knowledge, but if not- I'll be happy to hammer away at this with you.
I see they just added AV1 support as well. I don't think this was the scope of the project, originally, but a welcome addition.

I've used VirGL on macOS with Parallels before, and it blew my mind. So nice!

I've also tried out GVT-g as well. It was lackluster, unfortunately.

Anyways, I'll report back once I have something to add!
 
I definitely have VirGL working, but I haven't been able to expose hardware accelerated encoding/decoding yet. Pretty frustrating. I have an AMD iGPU available in my desktop- if I get some time I'll try it on there. Maybe it's only working on AMD at this time.
 
I have the same problem with AMD integrated GPU (Ryzen 9 7950X3D).
OpenGL works great but hardware encoding/decoding does not.
The guest is debian and i even tried trixie(testing).
I checked the config and proxmox adds -display egl-headless,gl=core .
 
I've hit a wall as well. I can't figure out what they would be doing differently to make it work. I've tried up to Debian SID, for both Proxmox and the guest with no success.
 
Hi, I'm trying to do the same things but failed.
But I've noticed a things in guest VM:
Code:
ferrets@LinuxMint:~$ lspci -nnk
00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0]
    Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
00:01.0 VGA compatible controller [0300]: Red Hat, Inc. Virtio 1.0 GPU [1af4:1050] (rev 01)
    Subsystem: Red Hat, Inc. Virtio 1.0 GPU [1af4:1100]
    Kernel driver in use: virtio-pci
00:1a.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 [8086:2937] (rev 03)
    Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
    Kernel driver in use: uhci_hcd
..........
the guest VM is using virtio-pci driver for graphics, but both this and this are saying that video acceleration are working on virtio_gpu driver. Do you know how to force using virtio-gpu for graphics?
 
Hi!
Hi, I'm trying to do the same things but failed.
But I've noticed a things in guest VM:
Code:
ferrets@LinuxMint:~$ lspci -nnk
00:00.0 Host bridge [0600]: Intel Corporation 82G33/G31/P35/P31 Express DRAM Controller [8086:29c0]
    Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
00:01.0 VGA compatible controller [0300]: Red Hat, Inc. Virtio 1.0 GPU [1af4:1050] (rev 01)
    Subsystem: Red Hat, Inc. Virtio 1.0 GPU [1af4:1100]
    Kernel driver in use: virtio-pci
00:1a.0 USB controller [0c03]: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 [8086:2937] (rev 03)
    Subsystem: Red Hat, Inc. QEMU Virtual Machine [1af4:1100]
    Kernel driver in use: uhci_hcd
..........
the guest VM is using virtio-pci driver for graphics, but both this and this are saying that video acceleration are working on virtio_gpu driver. Do you know how to force using virtio-gpu for graphics?
I have also been trying for months unfortunately without success. It works only inside LXC. It seems that it has not been integrated into qemu and I hope it will be done with the next releases
 
Any progress of these? If it will work, possible to use HW transcode video on Plex?
 
I'm in the exactly same situation with a k8s cluster composed by Talos VM on Proxmox and a Frigate pod (with /dev/dri/renderD128 mounted) running on it.

the pod is showing:
Code:
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.10.0)
vainfo: Driver version: Mesa Gallium driver 22.3.6 for virgl (Mesa Intel(R) HD Graphics 530 (SKL GT2))
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
 
Hi,

In case it is useful to someone, I succeeded to make VirGL hardware accelerated h264 to work

Install mesa 23​

Add bookworm-backports to /etc/apt/sources.list :
deb http://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware

Code:
# apt-get update
# apt install -t bookworm-backports libvirglrenderer1

Install latest pve-qemu with patch​

Code:
# git clone https://github.com/proxmox/pve-qemu
# cd pve-qemu
# git submodule update --init --recursive

NOTE: there is a problem with a missing submodule in qemu in actual version : https://github.com/tianocore/edk2/pull/6402
submodule https://github.com/Zeex/subhook need to be changed to https://github.com/tianocore/edk2-subhook

Apply the attached patch based on https://gitlab.com/huangrui123/qemu/-/commit/5e4ce15f4f30d983b57778a44436833b6eabd7bc in qemu directory

Code:
# make deb
# dpkg -i pve-qemu-kvm_9.1.2-3_amd64.deb

Relaunch guest then :

Code:
$ vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.3.4 - kisak-mesa PPA for virgl (AMD Radeon Graphics (radeonsi, raphael_mendocino, LL...)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileNone                   :    VAEntrypointVideoProc
 

Attachments

Hi,

In case it is useful to someone, I succeeded to make VirGL hardware accelerated h264 to work

Install mesa 23​

Add bookworm-backports to /etc/apt/sources.list :
deb http://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware

Code:
# apt-get update
# apt install -t bookworm-backports libvirglrenderer1

Install latest pve-qemu with patch​

Code:
# git clone https://github.com/proxmox/pve-qemu
# cd pve-qemu
# git submodule update --init --recursive

NOTE: there is a problem with a missing submodule in qemu in actual version : https://github.com/tianocore/edk2/pull/6402
submodule https://github.com/Zeex/subhook need to be changed to https://github.com/tianocore/edk2-subhook

Apply the attached patch based on https://gitlab.com/huangrui123/qemu/-/commit/5e4ce15f4f30d983b57778a44436833b6eabd7bc in qemu directory

Code:
# make deb
# dpkg -i pve-qemu-kvm_9.1.2-3_amd64.deb

Relaunch guest then :

Code:
$ vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.3.4 - kisak-mesa PPA for virgl (AMD Radeon Graphics (radeonsi, raphael_mendocino, LL...)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileNone                   :    VAEntrypointVideoProc
You've found the final piece of the puzzle!

Maybe we'll see this feature in Proxmox VE 8.4!
 
  • Like
Reactions: julbouln
Hi,

In case it is useful to someone, I succeeded to make VirGL hardware accelerated h264 to work

Install mesa 23​

Add bookworm-backports to /etc/apt/sources.list :
deb http://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware

Code:
# apt-get update
# apt install -t bookworm-backports libvirglrenderer1

Install latest pve-qemu with patch​

Code:
# git clone https://github.com/proxmox/pve-qemu
# cd pve-qemu
# git submodule update --init --recursive

NOTE: there is a problem with a missing submodule in qemu in actual version : https://github.com/tianocore/edk2/pull/6402
submodule https://github.com/Zeex/subhook need to be changed to https://github.com/tianocore/edk2-subhook

Apply the attached patch based on https://gitlab.com/huangrui123/qemu/-/commit/5e4ce15f4f30d983b57778a44436833b6eabd7bc in qemu directory

Code:
# make deb
# dpkg -i pve-qemu-kvm_9.1.2-3_amd64.deb

Relaunch guest then :

Code:
$ vainfo
libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.3.4 - kisak-mesa PPA for virgl (AMD Radeon Graphics (radeonsi, raphael_mendocino, LL...)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileNone                   :    VAEntrypointVideoProc
I think these commands need to perform on host, I am very new to Linux and PVE, may I know how to apply the patch as stated in

NOTE: there is a problem with a missing submodule in qemu in actual version : https://github.com/tianocore/edk2/pull/6402
submodule https://github.com/Zeex/subhook need to be changed to https://github.com/tianocore/edk2-subhook

Apply the attached patch based on https://gitlab.com/huangrui123/qemu/-/commit/5e4ce15f4f30d983b57778a44436833b6eabd7bc in qemu direct
ory
 
Last edited:
hello folks,

this does not work on a recent checkout of https://github.com/proxmox/pve-qemu
however i managed to get it to work with the stable-8 branch.
current bookworm version of libvirglrenderer1 is 0.10.4-1, so it will trigger the meson build starting with version 0.9.

on the way to getting the final .deb file you will need to install shitloads of dependencies...just go with the flow and install there

1. Install mesa24​


vainfo

vainfo: Driver version: Mesa Gallium driver 22.3.6 for AMD Radeon Graphics (gfx1100, LLVM 15.0.6, DRM 3.59, 6.8.12-8-pve)

Add bookworm-backports to /etc/apt/sources.list:
echo -n "deb http://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware" >> /etc/apt/sources.list

then
apt update
apt install -t bookworm-backports mesa-va-drivers

vainfo

outputs
vainfo: Driver version: Mesa Gallium driver 24.2.8-1~bpo12+1 for AMD Radeon RX 7900 GRE (radeonsi, navi31, LLVM 15.0.6, DRM 3.59, 6.8.12-8-pve)

2. Get sources​

NOTE: the problem with a missing submodule in qemu edk2 has been fixed in current master but not in stable-8

Code:
git clone https://github.com/proxmox/pve-qemu
cd pve-qemu
git checkout stable-8
git submodule update --init --recursive

NOTE: there is a problem with a missing submodule in qemu in actual version :
submodule https://github.com/Zeex/subhook need to be changed to https://github.com/tianocore/edk2-subhook

grep -ril "https://github.com/Zeex/subhook"

and replace with the new repo https://github.com/tianocore/edk2-subhook and try again:

git submodule update --init --recursive

and then

Code:
cd qemu
meson subprojects download

3. patch​

place virgl.patch into the qemu dir and patch file with

patch < virgl.patch

virgl.patch:
Code:
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 9f34d0e661..ac4befd712 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -14,6 +14,7 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
+#include "qemu/drm.h"
 #include "trace.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-gpu.h"
@@ -563,12 +564,22 @@ static int virgl_make_context_current(void *opaque, int scanout_idx,
                                    qctx);
 }
 
+static int virgl_get_drm_fd(void *opaque)
+{
+    int fd = -1;
+
+    fd = qemu_drm_rendernode_open(NULL);
+
+    return fd;
+}
+
 static struct virgl_renderer_callbacks virtio_gpu_3d_cbs = {
     .version             = 1,
     .write_fence         = virgl_write_fence,
     .create_gl_context   = virgl_create_context,
     .destroy_gl_context  = virgl_destroy_context,
     .make_current        = virgl_make_context_current,
+    .get_drm_fd          = virgl_get_drm_fd,
 };
 
 static void virtio_gpu_print_stats(void *opaque)
@@ -625,7 +636,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
 int virtio_gpu_virgl_init(VirtIOGPU *g)
 {
     int ret;
-    uint32_t flags = 0;
+    uint32_t flags = VIRGL_RENDERER_USE_VIDEO;
 
 #if VIRGL_RENDERER_CALLBACKS_VERSION >= 4
     if (qemu_egl_display) {
diff --git a/meson.build b/meson.build
index 91a0aa64c6..f2e8ff31de 100644
--- a/meson.build
+++ b/meson.build
@@ -1211,7 +1211,15 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
   virgl = dependency('virglrenderer',
                      method: 'pkg-config',
                      required: get_option('virglrenderer'))
+               
 endif
+
+if virgl.version().version_compare('>= 0.9.0') and virgl.version().version_compare('< 1.0.0')
+  message('Enabling virglrenderer unstable APIs')
+  virgl = declare_dependency(compile_args: '-DVIRGL_RENDERER_UNSTABLE_APIS',
+                             dependencies: virgl)
+endif
+
 rutabaga = not_found
 if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
   rutabaga = dependency('rutabaga_gfx_ffi',

4. build & install & restart​


Code:
cd ..
make deb
dpkg -i pve-qemu-kvm_9.0.2-5_amd64.deb

reboot guests
in guest:

Code:
root@gfx:~# vainfo
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/virtio_gpu_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 24.2.8-1ubuntu1~24.04.1 for virgl (AMD Radeon RX 7900 GRE (radeonsi, navi31, LLVM 15.0....)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
      VAProfileH264Main               :    VAEntrypointVLD
      VAProfileH264Main               :    VAEntrypointEncSlice
      VAProfileH264High               :    VAEntrypointVLD
      VAProfileH264High               :    VAEntrypointEncSlice
      VAProfileHEVCMain               :    VAEntrypointVLD
      VAProfileHEVCMain               :    VAEntrypointEncSlice
      VAProfileNone                   :    VAEntrypointVideoProc
 
Last edited:
hey folks its me again,

here i am using the most recent version of virglrenderer so the sources can be build from pve-qemu master branch,
enjoy!

1. update to proxmox 6.11 (not necessary)

apt update
apt install proxmox-kernel-6.11
reboot

2. install amdgpu for ubuntu noble (not necessary)

wget https://repo.radeon.com/amdgpu-install/6.3.4/ubuntu/noble/amdgpu-install_6.3.60304-1_all.deb
sudo apt install ./amdgpu-install_6.3.60304-1_all.deb
amdgpu-install -y --usecase=workstation,rocm
reboot

check if it is loaded

dkms status

3. Install mesa 24 (might be necessary)

Add bookworm-backports to /etc/apt/sources.list:
echo -n "deb http://deb.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware" >> /etc/apt/sources.list

then

apt update
apt install -t bookworm-backports mesa-va-drivers


4. build virglrenderer

Code:
git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
cd virglrenderer
meson build -Dvenus=true -Dvideo=True -Dprefix=/usr
cd build
ninja install

check if it is loaded

ldd /bin/qemu-system-x86_64 | grep virgl
ls -lahrt /usr/lib/x86_64-linux-gnu/libvirglrenderer.so.1

5. build pve-qemu
git clone https://github.com/proxmox/pve-qemu
cd pve-qemu
git submodule update --init --recursive
cd qemu
meson subprojects download

6. patch

place virgl.patch into the qemu dir and patch file with

patch < virgl.patch

virgl.patch:
Code:
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 145a0b3879..2fee481219 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -14,6 +14,7 @@
 #include "qemu/osdep.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
+#include "qemu/drm.h"
 #include "trace.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-gpu.h"
@@ -1030,12 +1031,23 @@ static int virgl_make_context_current(void *opaque, int scanout_idx,
                                    qctx);
 }
 
+static int virgl_get_drm_fd(void *opaque)
+{
+    int fd = -1;
+
+    fd = qemu_drm_rendernode_open(NULL);
+
+    return fd;
+}
+
+
 static struct virgl_renderer_callbacks virtio_gpu_3d_cbs = {
     .version             = 1,
     .write_fence         = virgl_write_fence,
     .create_gl_context   = virgl_create_context,
     .destroy_gl_context  = virgl_destroy_context,
     .make_current        = virgl_make_context_current,
+    .get_drm_fd          = virgl_get_drm_fd,
 };
 
 static void virtio_gpu_print_stats(void *opaque)
@@ -1094,7 +1106,7 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
 int virtio_gpu_virgl_init(VirtIOGPU *g)
 {
     int ret;
-    uint32_t flags = 0;
+    uint32_t flags = VIRGL_RENDERER_USE_VIDEO;
     VirtIOGPUGL *gl = VIRTIO_GPU_GL(g);
 
 #if VIRGL_RENDERER_CALLBACKS_VERSION >= 4
diff --git a/meson.build b/meson.build
index 147097c652..707efc3861 100644
--- a/meson.build
+++ b/meson.build
@@ -1350,6 +1350,13 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
                      method: 'pkg-config',
                      required: get_option('virglrenderer'))
 endif
+
+if virgl.version().version_compare('>= 1.0.0')
+  message('Enabling virglrenderer unstable APIs')
+  virgl = declare_dependency(compile_args: '-DVIRGL_RENDERER_UNSTABLE_APIS -DVIRGL_RENDERER_VENUS',
+                            dependencies: virgl)
+endif
+
 rutabaga = not_found
 if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
   rutabaga = dependency('rutabaga_gfx_ffi',

4. build & install & restart​



Code:
cd ..
make deb
dpkg -i pve-qemu-kvm_9.2.0-2_amd64.deb

reboot guest
 
Last edited: