NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.72k stars 13.85k forks source link

vaapi failure for amdgpu #221535

Closed jnsgruk closed 1 year ago

jnsgruk commented 1 year ago

Describe the bug

I'm trying to configure hardware video acceleration for my AMD GPU (Radeon 5700XT). Desktop is running swaywm.

❯ nix-shell -p libva-utils --run vainfo
libva info: VA-API version 1.16.0
libva info: Trying to open /run/opengl-driver/lib/dri/radeonsi_drv_video.so
libva error: /run/opengl-driver/lib/dri/radeonsi_drv_video.so has no function __vaDriverInit_1_0
libva info: Trying to open /usr/lib/dri/radeonsi_drv_video.so
libva info: Trying to open /usr/lib32/dri/radeonsi_drv_video.so
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Trying to open /usr/lib/i386-linux-gnu/dri/radeonsi_drv_video.so
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

In my config, I have (in various places!)...

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

    extraPackages = with pkgs; [
      vaapiVdpau
      libvdpau-va-gl
    ];
  };

# ...

boot = {
  initrd = {
      kernelModules = [ "amdgpu" "dm-snapshot" ];
  };
}

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 6.2.6, NixOS, 23.05 (Stoat), 23.05.20230315.126f49a`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
cx405 commented 1 year ago

Please check zcat /proc/config.gz |grep -i amdgpu how the driver is built. AFAIK by default its built as module (CONFIG_DRM_AMDGPU=m) into initramfs, so boot.kernelModules will have no effect (unless kernel is rebuilt with it integrated (CONFIG_DRM_AMDGPU=y)) and its better off to use boot.initrd.kernelModules=["amdgpu"]; to force-load from initramfs.

Please check with lspci -k | grep -A 3 -E "(VGA|3D)" whether the card is using the driver. Unless Xorg/Wayland are started with a corresponding driver assigned, or amdgpu isn't force-loaded at boot, it won't be loaded - which could lead to this error. This is what is needed for Xorg to load it (as example):

boot.initrd.kernelModules=["amdgpu"];
services.xserver.videoDrivers=["amdgpu"];
services.xserver.enable=true;
services.xserver.displayManager.sddm.enable=true; #or any other
services.xserver.desktopManager.plasma5.enable=true; #or any other
hardware.opengl.extraPackages=with pkgs;[vaapiVdpau libvdpau-va-gl];

I think in your case lack of second line leads to radeonsi_drv_video.so not present in /run/opengl-driver/lib/dri/; if kernel driver is loaded at boot time or by xorg through xorg driver, then this error would imply radeonsi_drv_video.so is built without support for libvdpau-va-gl.

As example, with settings above in 22.11 under Xorg I get this:

> nix-shell -p libva-utils --run vainfo
these 2 paths will be fetched (0.46 MiB download, 2.77 MiB unpacked):
  /nix/store/sblwiksvkz5lin4m3661498njwxk76ja-libva-utils-2.15.0
  /nix/store/vy1gljyx0hx57bjnsyj05g3xw1bm2v6m-stdenv-linux
copying path '/nix/store/sblwiksvkz5lin4m3661498njwxk76ja-libva-utils-2.15.0' from 'https://cache.nixos.org'...
copying path '/nix/store/vy1gljyx0hx57bjnsyj05g3xw1bm2v6m-stdenv-linux' from 'https://cache.nixos.org'...
libva info: VA-API version 1.16.0
libva info: Trying to open /run/opengl-driver/lib/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_16
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.16 (libva 2.15.0)
vainfo: Driver version: Mesa Gallium driver 22.2.5 for AMD Radeon RX 570 Series (polaris10, LLVM 14.0.6, DRM 3.48, 6.0.10-lqx1)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

> lspci -k | grep -A 3 -E "(VGA|3D)"
26:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev ef)
        Subsystem: Micro-Star International Co., Ltd. [MSI] Radeon RX 570 Armor 8G OC
        Kernel driver in use: amdgpu
        Kernel modules: amdgpu

Kernel is boot.kernelPackages=pkgs.linuxPackages_lqx;

> uname --all 
Linux net 6.0.10-lqx1 #1-NixOS ZEN SMP PREEMPT_DYNAMIC
jnsgruk commented 1 year ago

please check zcat /proc/config.gz |grep -i amdgpu

[nix-shell:~]$ zcat /proc/config.gz |grep -i amdgpu
CONFIG_DRM_AMDGPU=m
CONFIG_DRM_AMDGPU_SI=y
CONFIG_DRM_AMDGPU_CIK=y
CONFIG_DRM_AMDGPU_USERPTR=y

its better off to use boot.initrd.kernelModules=["amdgpu"]; to force-load from initramfs

My mistake, that was a copy-pasta. I am in fact using boot.initrd.kernelModules=["amdgpu"];.

Please check with lspci -k | grep -A 3 -E "(VGA|3D)" whether the card is using the driver

[nix-shell:~]$ lspci -k | grep -A 3 -E "(VGA|3D)"
2f:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT] (rev c1)
    Subsystem: Sapphire Technology Limited Sapphire Technology Limited Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]
    Kernel driver in use: amdgpu
    Kernel modules: amdgpu

I think in your case lack of second line leads to radeonsi_drv_video.so not present in /run/opengl-driver/lib/dri/

I have checked that the file is at least present, but not sure how I'd go about verifying whether it was built with libvdpau-va-gl. I have included the libvdpau-va-gl package in my opengl conf at least.

[nix-shell:~]$ ls -la /run/opengl-driver/lib/dri/radeonsi_drv_video.so
lrwxrwxrwx 2 root root 93 Jan  1  1970 /run/opengl-driver/lib/dri/radeonsi_drv_video.so -> /nix/store/j5j4r8waw956z2xslbngiyx20kzcn6lj-mesa-22.3.5-drivers/lib/dri/radeonsi_drv_video.so

I'm also running sway, so I don't have any services.xserver.* options enabled. I'm starting sway with tuigreet (see here)

Thanks for the quick response!

cx405 commented 1 year ago

@jnsgruk Ok, so the card driver is working as expected, only VA video decoding is missing.

Do this:

> nm -D /run/opengl-driver/lib/dri/radeonsi_drv_video.so | grep __vaDriver

if it returns nothing, the library has no "__vaDriverInit_1_16" function. Could be changes/regressions in mesa-22.3.5 then.

Btw:

> ls -la /run/opengl-driver/lib/dri/radeonsi_drv_video.so
lrwxrwxrwx 1 root root 93 Jan  1  1970 /run/opengl-driver/lib/dri/radeonsi_drv_video.so -> /nix/store/r6g53nl1gxi53d1l73fywdkz75fyls07-mesa-22.2.5-drivers/lib/dri/radeonsi_drv_video.so

> nm -D /run/opengl-driver/lib/dri/radeonsi_drv_video.so | grep __vaDriver
0000000000065140 T __vaDriverInit_1_16

22.11 here, running older version.

jnsgruk commented 1 year ago

So I do get something from that nm call:

❯ nm -D /run/opengl-driver/lib/dri/radeonsi_drv_video.so | grep __vaDriver
000000000006b850 T __vaDriverInit_1_17
jnsgruk commented 1 year ago

Some additional information.. I've run sway from a tty with some more verbose logging (attached), but interestingly...

sway.log

amdgpu: amdgpu_cs_ctx_create2 failed. (-13)
00:00:00.040 [DEBUG] [wlr] [render/egl.c:420] Obtained high priority context
00:00:00.040 [DEBUG] [wlr] [render/egl.c:518] Using EGL_PLATFORM_DEVICE_EXT
00:00:00.041 [INFO] [wlr] [render/gles2/renderer.c:718] Creating GLES2 renderer
00:00:00.041 [INFO] [wlr] [render/gles2/renderer.c:719] Using OpenGL ES 3.2 Mesa 22.3.5
00:00:00.041 [INFO] [wlr] [render/gles2/renderer.c:720] GL vendor: AMD
00:00:00.041 [INFO] [wlr] [render/gles2/renderer.c:721] GL renderer: AMD Radeon RX 5700 XT (navi10, LLVM 15.0.7, DRM 3.49, 6.2.6)
00:00:00.041 [INFO] [wlr] [render/gles2/renderer.c:722] Supported GLES2 extensions: GL_EXT_blend_minmax GL_EXT_multi_draw_arrays GL_EXT_texture_filter_anisotropic GL_EXT_texture_compression_s3tc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_rgtc GL_EXT_texture_format_BGRA8888 GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_stencil8 GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_EXT_draw_instanced GL_EXT_texture_sRGB_decode GL_OES_EGL_image GL_OES_depth_texture GL_AMD_performance_monitor GL_OES_packed_depth_stencil GL_EXT_texture_type_2_10_10_10_REV GL_NV_conditional_render GL_OES_get_program_binary GL_APPLE_texture_max_level GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_NV_pack_subimage GL_EXT_frag_depth GL_NV_fbo_color_attachments GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_vertex_array_object GL_OES_viewport_array GL_ANGLE_pack_reverse_row_order GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_EXT_occlusion_query_boolean GL_EXT_robustness GL_EXT_texture_rg GL_EXT_unpack_subimage GL_NV_draw_buffers GL_NV_read_buffer GL_NV_read_depth GL_NV_read_depth_stencil GL_NV_read_stencil GL_EXT_draw_buffers GL_EXT_map_buffer_range GL_KHR_debug GL_KHR_robustness GL_KHR_texture_compression_astc_ldr GL_NV_pixel_buffer_object GL_OES_depth_texture_cube_map GL_OES_required_internalformat GL_OES_surfaceless_context GL_EXT_color_buffer_float GL_EXT_debug_label GL_EXT_sRGB_write_control GL_EXT_separate_shader_objects GL_EXT_shader_group_vote GL_EXT_shader_implicit_conversions GL_EXT_shader_integer_mix GL_EXT_tessellation_point_size GL_EXT_tessellation_shader GL_ANDROID_extension_pack_es31a GL_EXT_base_instance GL_EXT_compressed_ETC1_RGB8_sub_texture GL_EXT_copy_image GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex GL_EXT_gpu_shader5 GL_EXT_polygon_offset_clamp GL_EXT_primitive_bounding_box GL_EXT_render_snorm GL_EXT_shader_io_blocks GL_EXT_texture_border_clamp GL_EXT_texture_buffer GL_EXT_texture_cube_map_array GL_EXT_texture_norm16 GL_EXT_texture_view GL_KHR_blend_equation_advanced GL_KHR_context_flush_control GL_KHR_robust_buffer_access_behavior GL_NV_image_formats GL_NV_shader_noperspective_interpolation GL_OES_copy_image GL_OES_draw_buffers_indexed GL_OES_draw_elements_base_vertex GL_OES_gpu_shader5 GL_OES_primitive_bounding_box GL_OES_sample_shading GL_OES_sample_variables GL_OES_shader_io_blocks GL_OES_shader_multisample_interpolation GL_OES_tessellation_point_size GL_OES_tessellation_shader GL_OES_texture_border_clamp GL_OES_texture_buffer GL_OES_texture_cube_map_array GL_OES_texture_stencil8 GL_OES_texture_storage_multisample_2d_array GL_OES_texture_view GL_EXT_blend_func_extended GL_EXT_buffer_storage GL_EXT_float_blend GL_EXT_geometry_point_size GL_EXT_geometry_shader GL_EXT_shader_samples_identical GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_KHR_no_error GL_KHR_texture_compression_astc_sliced_3d GL_OES_EGL_image_external_essl3 GL_OES_geometry_point_size GL_OES_geometry_shader GL_OES_shader_image_atomic GL_EXT_clear_texture GL_EXT_clip_cull_distance GL_EXT_disjoint_timer_query GL_EXT_texture_compression_s3tc_srgb GL_EXT_window_rectangles GL_MESA_shader_integer_functions GL_EXT_clip_control GL_EXT_color_buffer_half_float GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_semaphore GL_EXT_semaphore_fd GL_EXT_texture_compression_bptc GL_EXT_texture_mirror_clamp_to_edge GL_KHR_parallel_shader_compile GL_NV_alpha_to_coverage_dither_control GL_AMD_framebuffer_multisample_advanced GL_EXT_EGL_image_storage GL_EXT_texture_shadow_lod GL_INTEL_blackhole_render GL_MESA_framebuffer_flip_y GL_NV_compute_shader_derivatives GL_EXT_demote_to_helper_invocation GL_EXT_depth_clamp GL_EXT_texture_query_lod GL_MESA_bgra
00:00:00.059 [DEBUG] [wlr] [render/allocator/allocator.c:106] Trying to create gbm allocator
00:00:00.063 [DEBUG] [wlr] [render/allocator/gbm.c:210] Created GBM allocator with backend drm
00:00:00.063 [DEBUG] [wlr] [render/allocator/gbm.c:213] Using DRM node /dev/dri/card0

and...

00:00:00.037 [INFO] [wlr] [render/egl.c:348] Supported EGL display extensions: EGL_ANDROID_blob_cache EGL_ANDROID_native_fence_sync EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_IMG_context_priority EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_context_flush_control EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image_base EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export EGL_MESA_query_driver EGL_WL_bind_wayland_display
00:00:00.037 [INFO] [wlr] [render/egl.c:350] Supported EGL device extensions: EGL_EXT_device_drm EGL_EXT_device_drm_render_node
00:00:00.037 [INFO] [wlr] [render/egl.c:352] EGL vendor: Mesa Project
00:00:00.037 [DEBUG] [wlr] [render/egl.c:121] Supported DMA-BUF formats:
00:00:00.037 [DEBUG] [wlr] [render/egl.c:165]   AB4H (0x48344241)
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     INVALID (0x00FFFFFFFFFFFFFF): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,DCC,DCC_PIPE_ALIGN,DCC_INDEPENDENT_128B,DCC_MAX_COMPRESSED_BLOCK=128B,DCC_CONSTANT_ENCODE,PIPE_XOR_BITS=4 (0x020000000096BB02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,PIPE_XOR_BITS=4 (0x0200000000801B02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_S_X,PIPE_XOR_BITS=4 (0x0200000000801902): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_D (0x0200000000000A01): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_S (0x0200000000000901): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     LINEAR (0x0000000000000000): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:165]   XB4H (0x48344258)
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     INVALID (0x00FFFFFFFFFFFFFF): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,DCC,DCC_PIPE_ALIGN,DCC_INDEPENDENT_128B,DCC_MAX_COMPRESSED_BLOCK=128B,DCC_CONSTANT_ENCODE,PIPE_XOR_BITS=4 (0x020000000096BB02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,PIPE_XOR_BITS=4 (0x0200000000801B02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_S_X,PIPE_XOR_BITS=4 (0x0200000000801902): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_D (0x0200000000000A01): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_S (0x0200000000000901): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     LINEAR (0x0000000000000000): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:165]   AB48 (0x38344241)
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     INVALID (0x00FFFFFFFFFFFFFF): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,DCC,DCC_PIPE_ALIGN,DCC_INDEPENDENT_128B,DCC_MAX_COMPRESSED_BLOCK=128B,DCC_CONSTANT_ENCODE,PIPE_XOR_BITS=4 (0x020000000096BB02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,PIPE_XOR_BITS=4 (0x0200000000801B02): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_S_X,PIPE_XOR_BITS=4 (0x0200000000801902): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_D (0x0200000000000A01): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX9,GFX9_64K_S (0x0200000000000901): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     LINEAR (0x0000000000000000): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:165]   XB48 (0x38344258)
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     INVALID (0x00FFFFFFFFFFFFFF): ✓ texture  ✓ render
00:00:00.037 [DEBUG] [wlr] [render/egl.c:104]     GFX10,GFX9_64K_R_X,DCC,DCC_PIPE_ALIGN,DCC_INDEPENDENT_128B,DCC_MAX_COMPRESSED_BLOCK=128B,DCC_CONSTANT_ENCODE,PIPE_XOR_BITS=4 (0x020000000096BB02): ✓ texture  ✓ render
emmanuelrosa commented 1 year ago

I use this:

  environment.variables = {
    # VAAPI and VDPAU config for accelerated video.
    # See https://wiki.archlinux.org/index.php/Hardware_video_acceleration
    "VDPAU_DRIVER" = "radeonsi";
    "LIBVA_DRIVER_NAME" = "radeonsi";
  };
cx405 commented 1 year ago

@jnsgruk I found this post and they use same libva version as currently in master (2.17.1).

In addition, I found these lines suspicious in your very first logs:

libva info: VA-API version 1.16.0
..
radeonsi_drv_video.so has no function __vaDriverInit_1_0

First line should be reading: libva info: VA-API version 1.17.0 on your system instead, because this is would be the version which radeonsi_drv_video.so delivers.

Second line indicates vainfo failed to detect even level 0 ABI (version 1.0) and there are 1_0 ... 1_17 versions, if I understand it right.

For lack of whats going on here, let me ping libva maintainer for awareness. I hope this isn't taken as rude. @SuperSandro2000

jnsgruk commented 1 year ago

@cx405 thanks very much for your thoughts and responses!

I was a bit worried I was making a bug about a misconfiguration, but the more I look at this the more it looks like an actual bug

cx405 commented 1 year ago

@jnsgruk Yw, this could still be a configuration issue, if packages are taken from different channels and mixed: vainfo/libva from older version, kernel (which includes amdgpu and radeon gl mesa implementation) from newer. Old vainfo would/could fail to detect newer 17 iteration, compaining none found. I am out of ideas at this point.

jnsgruk commented 1 year ago

Hey @SuperSandro2000 :wave: any ideas here? Happy to provide more information if required :)

peterhoeg commented 1 year ago

This may sound really silly, but you have tried rebooting, right?

jnsgruk commented 1 year ago

This may sound really silly, but you have tried rebooting, right?

Hah! Yes, many times :) Thanks for the response either way

jnsgruk commented 1 year ago

Okay, so troubleshooting another app and another issue led me to try adding libva-utils into my machine's flake, rather than running it using nix-shell, and it worked fine:

❯ vainfo
...
libva info: VA-API version 1.17.0
libva info: Trying to open /run/opengl-driver/lib/dri/radeonsi_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.17.1)
vainfo: Driver version: Mesa Gallium driver 22.3.7 for AMD Radeon RX 5700 XT (navi10, LLVM 15.0.7, DRM 3.49, 6.2.7)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

So it seems things are working, but just not when invoked using nix-shell. If nothing else we should probably consider what updating the docs might look like.

ngotchac commented 1 year ago

I had the exact same experience: vainfo not working in nix-shell, but working when adding libva-utils to my system. However, it seems that mpv fails at hardware decoding a H264 video, and vlc doesn't complain, but renders garbage :/

ngotchac commented 1 year ago

Actually, never mind, I had a somewhat corrupted video file. I just tried out with a couple of different encodings (h264, hevc, av1) via mpv and Firefox, and it all works fine!

trinitronx commented 1 year ago

For future people searching this error message:

$ vainfo 
Trying display: wayland
Trying display: x11
libva error: /usr/lib/dri/radeonsi_drv_video.so has no function __vaDriverInit_1_0
vaInitialize failed with error code -1 (unknown libva error),exit

I encountered this while testing VA-API on Manjaro (both cinnamon & wayland + sway) desktops. The root cause was that versions of libva-mesa-driver package was mismatched against a different libraries and packages which needed the __vaDriverInit_* symbol (function call). That symbol name is versioned, so any dependencies calling into that library file expect that symbol to exist including the version number suffix.

The fix was to upgrade all packages to versions which were compiled and linked together as a versioned set. In my case, there were libraries from various Community repos mixed with the base & extras, and packages had been installed piecemeal rather than running a full upgrade. On ArchLinux / Manjaro, this meant to run sudo pacman -Su after installing the mesa-nonfree / nonfree.eu package repo.

To see all defined __vaDriverInit_* symbols installed on the system under /usr/lib, I used:

find /usr/lib -iname '*.socket' -prune -o -iname '*.so*' -print0  | xargs -0 -I{} -n1 bash -c 'nm -AgDC {};' | grep vaDriverInit
Sidenotes & Questions:

    What is __vaDriverInit_1_0 & Why is it missing?

    Why are codecs so difficult to install & fragile on Linux? (click to expand)

## What is `__vaDriverInit_1_0` / `__vaDriverInit_*`? On the distributions tested, that symbol is provided by `/usr/lib/dri/*_drv_video.so` libraries. As stated in the [mailing list thread][2]: > the `_video.so` files are the vaapi ones. There has been a [change in the Mesa (`>= 22.2` upstream codec build options][3], and Distro packaging ([Fedora][4], [Manjaro][5], [Ubuntu][6], probably others) of these. Due to this, users may notice certain codecs appear to be not supported as they used to be on the same hardware. This may lead others into the situation of installing other versions of mesa drivers on their systems, leading to the mixed library versioning configuration mentioned by @cx405. In short, it boils down to software patents, hardware IP, and codec licensing. The larger distros don't want to open themselves up to legal liability.
Further Questions:

Why are these codecs so difficult to install?

It worked before, but now it doesn't... what gives?

What's all this nonsense about legal concerns? I purchased the hardware advertised to support these codecs, and with the expectation it doing so on any OS!

(click to expand)
 
Someone on the [Fedora Mailing List][2] explained it as follows: > Think of it like a jigsaw puzzle, where the person who places the last piece in the puzzle pays the license. But then stop thinking of it like that and just assume it's a lot vaguer and way more legally involved than that. "I am not a lawyer", but it seems to be related to the Textualism interpretation of copyright laws by patent trolls and those with other greed-seeking behavior w.r.t. who implements the "last puzzle piece" of the codec-enabling pipeline assuming liability. This stands in opposition to the original spirit of the law & interpretation given the Zeitgeist or circumstances at the time they were written & passed. > Isn't it Ironic that the "_you touched it last_" arguments common among children on the playground have evolved into another form amongst adults through a complex set of technology, patent laws, and the socially constructed value-measurement system of _currency_? 😏 Also **_very ironically_**, the original intent behind copyright and patent laws was to encourage innovation by granting original inventors a grace period of legally protected time to recoup their investment in creating such technologies. Due to the nature of the "societal game" of competitive capitalism, those original inventors could have been left at a loss and out-competed by other copycats who didn't have to invest the same amount of time, money, and effort into producing the invention at the start. After some grace period, the patent would expire and it was _**originally intended that they be released into the public domain**_ for all to benefit from, create derivative works, and increase the collection of public commons for the common good of society. However, over many years the law and human behaviors driven by cognitive biases such as loss aversion bias, and patent law now have the opposite 180° effect: **_Stifling innovation instead!_** All thanks to a long evolution of greed-seeking behavior, cognitive biases, and well-funded corporations funding lobbyists to influence lawmakers. > **_"This is why we cannot have nice things"... 🫰🧌🫰 💰🤑💰_** For more on this topic, watch Part 3 of the excellent independent mini-docuseries called "[Everything Is a Remix Part 3: Innovation and Creation][7]" (which also _ironically_ itself was being attacked by patent trolls! 🙄😒). The full series can be found at: https://www.everythingisaremix.info (And [Internet Archive][8] for anything that's being contested by the copyright trolls).