VirGL hardware accelerated h264/h265

carlo.luzi

New Member
Sep 24, 2022
2
0
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:
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
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!