Bug 258296

Summary: multimedia/libva-intel-hybrid-driver: depend on libpthread-stubs (1/2)
Product: Ports & Packages Reporter: Evgeniy Khramtsov <evgeniy>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed DUPLICATE    
Severity: Affects Only Me Keywords: patch, patch-ready
Priority: --- Flags: jbeich: maintainer-feedback+
evgeniy: maintainer-feedback?
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
v1 (use "git am") none

Description Evgeniy Khramtsov 2021-09-05 22:39:21 UTC
Created attachment 227696 [details]
v1 (use "git am")

multimedia/libva-intel-hybrid-driver can not build when
base toolchain does not exist, and ports LLVM is used instead.

Not sure about a minimal reproducer, maybe delete 'cc'?
I have one DankBSD patch for bsd.sys.mk to use ports LLVM
and others in ei/ports. The difference between my and Greg's
setup is that Greg uses symlinks to point 'cc' to ports LLVM,
and I chose not to use symlinks.

Package contents did not change:

11.4/amd64: https://codeberg.org/ei/misc/commit/1e0f1e5eeac
11.4/i386:  https://codeberg.org/ei/misc/commit/07c8452dbe5
12.2/amd64: https://codeberg.org/ei/misc/commit/2208832a722
12.2/i386:  https://codeberg.org/ei/misc/commit/6f6107dceea
13.0/amd64: https://codeberg.org/ei/misc/commit/f002179f0e0

My 'misc' repository also contains bulk and testport logs for this change,
not adding URL links to specific commits because codeberg did not generate
log diff this time for some reason, diff between logs can also be observed
by cloning the 'misc' repository and viewing with git if needed.

On unrelated note: I plan to test the legacy VA-API driver on SNB tomorrow
and report back if it works after ports 0fe260b63e82.
Comment 1 Evgeniy Khramtsov 2021-09-05 23:03:28 UTC
> Not sure about a minimal reproducer

Maybe this link could help?:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257622#c2
Comment 2 Evgeniy Khramtsov 2021-09-06 16:45:49 UTC
(In reply to Evgeniy Khramtsov from comment #0)

> On unrelated note: I plan to test the legacy VA-API
> driver on SNB tomorrow and report back if it works

Works fine (0x0126) with www/firefox and H.264 YouTube (tested with MOZ_LOG).
vainfo seems to complain when trying hybrid driver, but otherwise VA-API works:

libva info: VA-API version 1.12.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_12
libva error: /usr/local/lib/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_12
/usr/local/lib/dri/hybrid_drv_video.so init failed
libva info: va_openDriver() returns 0
Not using hybrid_drv_video.so
vainfo: VA-API version: 1.12 (libva 2.12.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Sandybridge Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc

Note: MESA_LOADER_DRIVER_OVERRIDE=crocus session, no classic drivers here.
Comment 3 Jan Beich freebsd_committer 2021-09-06 21:50:52 UTC
(In reply to Evgeniy Khramtsov from comment #0)
> Not sure about a minimal reproducer, maybe delete 'cc'?

Still builds fine here after hiding /usr/bin/cc and /usr/bin/c++. Can you show build log from the affected environment but with v1 patch applied? I'd like to inspect *FLAGS used.

This port doesn't use pthread-stubs directly (i.e., no references in vendor code) as it comes from libdrm which limits it static linking. However, static linking is unlikely to work because libva.so loads hardware-specific drivers via dlopen(3).

$ rg -l pthread-stubs /usr/local/libdata | xargs pkg which -o
/usr/local/libdata/pkgconfig/libdrm_radeon.pc was installed by package graphics/libdrm
/usr/local/libdata/pkgconfig/libdrm_intel.pc was installed by package graphics/libdrm
/usr/local/libdata/pkgconfig/libdrm_amdgpu.pc was installed by package graphics/libdrm
/usr/local/libdata/pkgconfig/xcb.pc was installed by package x11/libxcb

(In reply to Evgeniy Khramtsov from comment #2)
> vainfo seems to complain when trying hybrid driver, but otherwise VA-API works:

HYBRID option exposes VP9 decoder which YouTube uses for resolutions larger than 1080p. SandyBridge is Gen6, so you won't notice if hybrid driver is broken unless it crashes. Adding BUILD_DEPENDS alone isn't enough to regress it because libpthread-stubs is often already installed when building outside of poudriere (non-clean environment).

> Note: MESA_LOADER_DRIVER_OVERRIDE=crocus session, no classic drivers here.

Thanks. Can you reproduce https://gitlab.freedesktop.org/mesa/mesa/-/issues/5134 ?
Comment 4 Jan Beich freebsd_committer 2021-09-06 21:55:31 UTC
(In reply to Evgeniy Khramtsov from comment #2)
> vainfo seems to complain when trying hybrid driver, but otherwise VA-API works:

Can you check if reverting ports f09237b5a6d6 makes hybrid crash, breaking VA-API? I'm just curious if that crashfix was Broadwell-specific or affected older GPU generations.
Comment 5 Evgeniy Khramtsov 2021-09-07 17:25:48 UTC
(In reply to Jan Beich from comment #3)

I guess I understood why this happened. I rebuilt ports with X11,XCB,XLIB
to test crocus with games/openmw, and realized that I could not reproduce
the build failure now: libpthread-stubs get pulled in to jail via libxcb:

=======================<phase: lib-depends    >============================
[...]
===>   libva-intel-hybrid-driver-1.0.2_4 depends on shared library: libcmrt.so - not found
===>   Installing existing package /packages/All/cmrt-1.0.6_2.pkg
[ei-ei-ei-job-01] Installing cmrt-1.0.6_2...
[ei-ei-ei-job-01] `-- Installing libva-2.12.0...
[ei-ei-ei-job-01] |   `-- Installing libX11-1.7.2,1...
[ei-ei-ei-job-01] |   | `-- Installing libxcb-1.14_1...
[ei-ei-ei-job-01] |   |   `-- Installing libXau-1.0.9...
[ei-ei-ei-job-01] |   |   `-- Extracting libXau-1.0.9: .......... done
[ei-ei-ei-job-01] |   |   `-- Installing libXdmcp-1.1.3...
[ei-ei-ei-job-01] |   |   | `-- Installing xorgproto-2021.4...
[ei-ei-ei-job-01] |   |   | `-- Extracting xorgproto-2021.4: .......... done
[ei-ei-ei-job-01] |   |   `-- Extracting libXdmcp-1.1.3: ......... done
[ei-ei-ei-job-01] |   |   `-- Installing libpthread-stubs-0.4...
[ei-ei-ei-job-01] |   |   `-- Extracting libpthread-stubs-0.4: .... done
[...]

Can you reproduce with X11,XCB,XLIB=off for multimedia/libva and hybrid driver?
I should have been less sloppy and take time to find a reproducer first...

> if that crashfix was Broadwell-specific or affected older GPU generations.

hybrid seems to be for HSW to BSW, it can't init on SNB, there is no difference
with and without ports f09237b5a6d6 (www/firefox-esr):

libva info: VA-API version 1.12.0
libva info: Trying to open /usr/local/lib/dri/iHD_drv_video.so
libva info: va_openDriver() returns -1
libva info: Trying to open /usr/local/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_12
/usr/local/lib/dri/hybrid_drv_video.so init failed
Not using hybrid_drv_video.so
libva info: va_openDriver() returns 0
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x32315659 -> yuv420p.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x30323449 -> yuv420p.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x3231564e -> nv12.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x32595559 -> yuyv422.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x59565955 -> uyvy422.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x48323234 -> yuv422p.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x58424752 -> rgb0.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x58524742 -> bgr0.
[AVHWDeviceContext @ 0x2228b70ac1c0] Format 0x30313050 -> p010le.
[AVHWDeviceContext @ 0x2228b70ac1c0] VAAPI driver: Intel i965 driver for Intel(R) Sandybridge Mobile - 2.4.1.
[AVHWDeviceContext @ 0x2228b70ac1c0] Driver not found in known nonstandard list, using standard behaviour.
[Child 57169: MediaPDecoder #1]: D/PlatformDecoderModule VA-API FFmpeg init successful
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule Choosing FFmpeg pixel format for VA-API video decoding.
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule Requesting pixel format VAAPI_VLD
[vp9 @ 0x2228e9a43900] Format vaapi_vld chosen by get_format().
[vp9 @ 0x2228e9a43900] Format vaapi_vld requires hwaccel initialisation.
[vp9 @ 0x2228e9a43900] No support for codec vp9 profile 0.
[vp9 @ 0x2228e9a43900] Failed setup for format vaapi_vld: hwaccel initialisation returned error.
[vp9 @ 0x2228e9a43900] Format vaapi_vld not usable, retrying get_format() without it.
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule Choosing FFmpeg pixel format for VA-API video decoding.
[vp9 @ 0x2228e9a43900] Failed to initialize decoder for 2560x1440 @ 0
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule avcodec_send_packet error: -1
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule Initialising FFmpeg decoder.
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule FFmpeg init successful.
[Child 57169: MediaPDecoder #2]: D/PlatformDecoderModule Choosing FFmpeg pixel format for video decoding.

I also tested H.264 on SNB: there is no difference with and without the patch,
and H.264 with VP9 on QTJ2 (0x3E9B) (CFL) decoding works with and without patch.
I verified that I deleted libva-intel-media-driver to test the legacy driver.

> Can you reproduce https://gitlab.freedesktop.org/mesa/mesa/-/issues/5134 ?

No (graphics/drm-devel-kmod gl=mesa-devel). I built ports with X11 and got the assets for games/openmw, and I could reproduce in menu and in game (~10 minutes, did not want to test more).
Comment 6 Evgeniy Khramtsov 2021-09-07 17:31:55 UTC
(In reply to Evgeniy Khramtsov from comment #5)

> could reproduce

could not
Comment 7 Jan Beich freebsd_committer 2021-09-07 18:54:32 UTC
(In reply to Evgeniy Khramtsov from comment #5)
> Can you reproduce with X11,XCB,XLIB=off for multimedia/libva and hybrid driver?

Yes. I think, it should be fixed in libdrm instead of littering every VAAPI driver with a private dependency of libdrm *itself*.

*** This bug has been marked as a duplicate of bug 258346 ***