Video Acceleration Not working in Intel Iris Xe graphic (13th gen i51340p)

I had recently install NixOS 23.05 on my Lenovo ideapad slim 5i laptop.
The cpu is intel i5-1340p, comes with integrated iris Xe graphics.
Kernel: 6.4.15-xanmod1

I wanted to test how the gpu perform, so I monitor the gpu usage using intel_gpu_top but find that the video and videoEnhance is always 0%, only rendering/3D is showing high usage.

Then I found that vainfo show the below error:

❯ vainfo 
Trying display: wayland
libva info: VA-API version 1.18.0
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib32/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Trying to open /usr/lib/i386-linux-gnu/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /run/opengl-driver/lib/dri/i965_drv_video.so
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Trying to open /usr/lib32/dri/i965_drv_video.so
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so
libva info: Trying to open /usr/lib/i386-linux-gnu/dri/i965_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

Checked the /run/opengl-driver/lib/dri/ directory and found that indeed i965_drv_video.so and iHD_drv_video.so doesn’t exist. (I am not sure whether one of these should exist, maybe this indicate something is wrong)

❯ ls -l /run/opengl-driver/lib/dri/
.r-xr-xr-x 33M root  1 Jan  1970 crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 d3d12_dri.so -> crocus_dri.so
.r-xr-xr-x 14M root  1 Jan  1970 d3d12_drv_video.so
lrwxrwxrwx  13 root  1 Jan  1970 i915_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 iris_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 kms_swrast_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 nouveau_dri.so -> crocus_dri.so
lrwxrwxrwx  18 root  1 Jan  1970 nouveau_drv_video.so -> d3d12_drv_video.so
lrwxrwxrwx  13 root  1 Jan  1970 r300_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 r600_dri.so -> crocus_dri.so
lrwxrwxrwx  18 root  1 Jan  1970 r600_drv_video.so -> d3d12_drv_video.so
lrwxrwxrwx  13 root  1 Jan  1970 radeonsi_dri.so -> crocus_dri.so
lrwxrwxrwx  18 root  1 Jan  1970 radeonsi_drv_video.so -> d3d12_drv_video.so
lrwxrwxrwx  13 root  1 Jan  1970 swrast_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 virtio_gpu_dri.so -> crocus_dri.so
lrwxrwxrwx  18 root  1 Jan  1970 virtio_gpu_drv_video.so -> d3d12_drv_video.so
lrwxrwxrwx  13 root  1 Jan  1970 vmwgfx_dri.so -> crocus_dri.so
lrwxrwxrwx  13 root  1 Jan  1970 zink_dri.so -> crocus_dri.so

I had tried searching through forums and video acceleration guide:
https://nixos.wiki/wiki/Accelerated_Video_Playback
adding the extraPackages as shown:

{
  ...
  nixpkgs.config.packageOverrides = pkgs: {
    vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
  };
  hardware.opengl = {
    enable = true;
    extraPackages = with pkgs; [
      intel-media-driver # LIBVA_DRIVER_NAME=iHD
      vaapiIntel         # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
      vaapiVdpau
      libvdpau-va-gl
    ];
  };
  ...
}

Iris Xe graphics does show up in lspci:

❯ nix-shell -p pciutils --run lspci | grep -i VGA
00:02.0 VGA compatible controller: Intel Corporation Raptor Lake-P [Iris Xe Graphics] (rev 04)

I am stuck now, not sure what to do next. Can someone give some advise on this matter? From what I can tell the graphics driver is probably working but some video driver (or hardware acceleration driver) is not working?

1 Like

I just realized I make a mistake in my configuration.nix file, and now the issue is fixed.
I accidentally put the opengl extra packages in the nixpkgs.overlays block instead of the hardware block.

Now the video acceleration is working fine.

hardware = {
    opengl.enable = true;
    opengl.driSupport = true;
    opengl.driSupport32Bit = true;

    opengl.extraPackages = with pkgs; [
        intel-media-driver
        vaapiVdpau
        libvdpau-va-gl
      ];
    bluetooth.enable = true;

  };

for reference this is the correct configuration. Since the issue is solved, the thread can be closed.

2 Likes

Thank you for posting the solution!

Before the opengl settings YouTube video playback in Firefox was fine, but I was confused by the high CPU usage of the RDD Process…

Now everything is fine.