Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vainfo does not load the nvidia va driver on x11, but okay on wayland #675

Closed
marioroy opened this issue Jan 7, 2023 · 13 comments
Closed

Comments

@marioroy
Copy link

marioroy commented Jan 7, 2023

It requires setting LIBVA_DRIVER_NAME=nvidia for the vainfo utility to succeed on x11.

x11

$ vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.17.0
libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
vaInitialize failed with error code -1 (unknown libva error),exit

$ LIBVA_DRIVER_NAME=nvidia vainfo
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'nvidia'
libva info: Trying to open /usr/lib64/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.17.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      <unknown profile>               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

wayland

$ vainfo
Trying display: wayland
libva info: VA-API version 1.17.0
libva info: Trying to open /usr/lib64/dri/nvidia_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.17 (libva 2.17.0)
vainfo: Driver version: VA-API NVDEC driver [egl backend]
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      <unknown profile>               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain12             : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
@benjarobin
Copy link

benjarobin commented Jan 9, 2023

At this link more information about the problem: https://bbs.archlinux.org/viewtopic.php?pid=2078521#p2078521

I did run the following a bisect to find the problematic commit :

git bisect start
git bisect bad 8d676957cd0532e2b3f7181e51978c652212dbe1
git bisect good 29e62907a5c292
Bissection : 22 révisions à tester après ceci (à peu près 5 étapes)
[552712b0259c00ca17be7f5472e994ea0d159cf0] ci: add meson permutation in the Ubuntu builds

git bisect good
Bissection : 11 révisions à tester après ceci (à peu près 4 étapes)
[d4f5dad4cd51c6a5000a1562d842f55a68eb154a] ci: style: use prettier formatting

git bisect bad
Bissection : 5 révisions à tester après ceci (à peu près 3 étapes)
[197a2e3c212755ebf50d5fc21c66c7b7cf21b401] meson: stop using configure_file copy=true

git bisect good
Bissection : 2 révisions à tester après ceci (à peu près 2 étapes)
[252405c469d248b2d8e86d78a347e4ebfb6b71bf] x11: move all FGLRX code to va_fglrx.c

git bisect good
Bissection : 0 révision à tester après ceci (à peu près 1 étape)
[c1e09e2b0301c923c06a4a62204ed7e6d40005ff] configure: add 'with-legacy' for emgd, nvctrl and fglrx

git bisect bad
Bissection : 0 révision à tester après ceci (à peu près 0 étape)
[a26852e1687ddba3b51232b586c5d68e4263f135] meson: add 'with-legacy' for emgd, nvctrl and fglrx

git bisect bad
a26852e1687ddba3b51232b586c5d68e4263f135 is the first bad commit
commit a26852e1687ddba3b51232b586c5d68e4263f135
Author: Emil Velikov <emil.velikov@collabora.com>
Date:   Tue Jul 12 18:13:04 2022 +0100

    meson: add 'with-legacy' for emgd, nvctrl and fglrx

    None of this code has been relevant (for distributions) for well over a
    decade. So move them behind a "with-legacy" toggle.

    By default we disable these options, since distributions using the meson
    build do not have the legacy components.

    Obviously anyone can toggle each piece on as-needed basis.

    v2:
     - s|enable-legacy|with-legacy|
     - split autotools equivalent to a separate patch

    Signed-off-by: Emil Velikov <emil.velikov@collabora.com>

 meson.build                  | 11 +++++++++++
 meson_options.txt            |  1 +
 va/wayland/va_wayland.c      |  2 ++
 va/wayland/va_wayland_emgd.c |  5 +++++
 va/wayland/va_wayland_emgd.h |  4 ++++
 va/x11/va_fglrx.c            |  5 +++++
 va/x11/va_fglrx.h            |  4 ++++
 va/x11/va_nvctrl.c           |  5 +++++
 va/x11/va_nvctrl.h           |  4 ++++
 va/x11/va_x11.c              |  4 ++++
 10 files changed, 45 insertions(+)

I am going to try to build libva with the bluid option with_legacy

@benjarobin
Copy link

Building with -Dwith_legacy=nvctrl fixes the problem. I am using nvidia-470xx-utils 470.161.03-2

@XinfengZhang
Copy link
Contributor

it is from #617 , @evelikov , looks https://github.com/elFarto/nvidia-vaapi-driver still need nvctrl?

@evelikov
Copy link
Contributor

evelikov commented Jan 10, 2023

One can enable the option if they need to - that's why the option exists

Edit: off the top of my head nvidia could support DRI3, which will avoid such issues. Albeit being closed source, fixing that is up-to the Nvidia team. Plus va/drm should just work I believe

@elFarto
Copy link
Contributor

elFarto commented Jan 10, 2023

@XinfengZhang We don't use/need nvctrl within the driver itself. We only need libva to pick the correct driver for NVIDIA cards.

@evelikov
Copy link
Contributor

I've been trying to reproduce the crashes on my intel+nvidia box for over a week, to no avail so far. Perhaps because I have a Intel + Nvidia combo?

@benjarobin picking up the vainfo crash - can you rebuild libva + nvidia libva driver with debug symbols so the backtrace is more useful?

Looking through the code-base - the nvidia driver doesn't have any X related code and the only XDisplayString instance in libva is in the fglrx code (disabled by default) and should be unreachable if you've got Nvidia GPU.

Thanks

@fenrus75
Copy link

fenrus75 commented Jan 30, 2023 via email

@benjarobin
Copy link

benjarobin commented Jan 30, 2023

@benjarobin picking up the vainfo crash - can you rebuild libva + nvidia libva driver with debug symbols so the backtrace is more useful?

This is already with debug symbol...

Looking through the code-base - the nvidia driver doesn't have any X related code and the only XDisplayString instance in libva is in the fglrx code (disabled by default) and should be unreachable if you've got Nvidia GPU.

I check the source code and I found the following code path which call XDisplayString when executing vainfo --display drm --device /dev/dri/renderD128:

  • __vaDriverInit_1_13() implemented in vdpau_driver.c by this line VAStatus VA_DRIVER_INIT_FUNC(void *ctx)
  • Call vdpau_Initialize_Current() which is implemented in vdpau_driver_template.h by this line static VAStatus FUNC(Initialize)(VA_DRIVER_CONTEXT_P ctx)
  • Which call vdpau_common_Initialize() very early, which is implemented in vdpau_driver.c
  • The vdpau_common_Initialize() calls immediately (the first line of the function): XDisplayString

@evelikov
Copy link
Contributor

@benjarobin you're a star - didn't realise you're using the vdpau wrapper/driver. There's a bug in that driver - will post a patch tomorrow at some point.

@marioroy
Copy link
Author

marioroy commented Jan 31, 2023

@fenrus75 (we reluctantly changed our config; we're phasing out X11 server support from the distro basically and this is a step in the opposite direction... but it's just a config so shrug)

This request was made for OS vendors still using X11. For Clear Linux, using Wayland and NVIDIA graphics, I figured the steps needed to make Chrome and derivatives work on 140 dpi or HiDPI displays. It turns out that one must set text-scaling-factor back to 1.0, enable an experimental Wayland feature scale-monitor-framebuffer, and set the display scale closely matching the display DPI 100%, 125%, 150%, ....

  1. gsettings set org.gnome.desktop.interface text-scaling-factor 1.0
  2. gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"
  3. once in Wayland, set Displays > Scale in GNOME settings

Clear Linux, running Wayland and NVIDIA graphics, is working with a 140 DPI display. I will update the README later this week.

@evelikov
Copy link
Contributor

@benjarobin feel free to pick xtknight/vdpau-va-driver-vp9@34f166a - this is the most minimalist fix required. Overall the driver needs a bunch more fixes, although there's no upstream so any patches will go to the void.

@marioroy thanks for the context - without the Clear Linux mention it was pretty confusing why Intel devs would care about Nvidia libva drivers ;-)

I'm in the process of removing X11 from the cuda base nvidia driver and the vdpau wrapper can be fixed with the above.

I believe we can close this issue now.

@benjarobin
Copy link

The official upstream git is https://cgit.freedesktop.org/vaapi/vdpau-driver, but it has been dead for 10 years...

@marioroy
Copy link
Author

marioroy commented Feb 1, 2023

@evelikov thanks for fixing the vainfo output for NVIDIA graphics. The mysterious <unknown profile> line is resolved.

@fenrus75 thanks for not rushing X11 removal in Clear Linux. There was a time when I felt like the avatars by @benjarobin, trying to get Wayland working. All is well now. Wayland works great including proper display scaling.

The animated avatars are cool, @benjarobin. Wow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants