Open chiyuki0325 opened 1 year ago
Are you using v0.0.8?
This is what I just cloned and compiled from this git repository. At first, I thought it was a duplicate of #103, but after I turned on modeset, everything still didn't work as before.
Can you try running NVD_LOG=1 vainfo --display drm --device /dev/dri/renderD129
(assuming renderD129 is your NVIDIA card).
➜ vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
501.840333431 [6894-6894] ../src/vabackend.c:1872 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 0x55f2302ca8e0 31
501.840342861 [6894-6894] ../src/vabackend.c:1894 __vaDriverInit_1_0 Now have 0 (0 max) instances
501.840366208 [6894-6894] ../src/vabackend.c:1919 __vaDriverInit_1_0 Selecting Direct backend
501.844700885 [6894-6894] ../src/direct/nv-driver.c: 190 init_nvdriver Initing nvdriver...
501.844709889 [6894-6894] ../src/direct/nv-driver.c: 195 init_nvdriver Got dev info: 100 1 2 6
501.844869502 [6894-6894] ../src/direct/nv-driver.c: 256 init_nvdriver NVIDIA kernel driver version: 525.60.11
vainfo: VA-API version: 1.16 (libva 2.16.0)
vainfo: Driver version: VA-API NVDEC driver [direct 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
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
501.920647227 [6894-6894] ../src/vabackend.c:1843 nvTerminate Terminating 0x55f2302ca8e0
501.920686350 [6894-6894] ../src/vabackend.c:1857 nvTerminate Now have 0 (0 max) instances
(After setting modeset, NVIDIA card becomes D128)
I've just pushed a fix I think will help.
The new push works, the 0 57 error doesn't occur anymore, but I still can't use nvidia-vaapi-driver. Everything gave the same error, just the 0 57 error didn't occur.
(I can't figure out what's wrong and don't know how to change the issue title)
➜ vainfo --display drm --device /dev/dri/renderD128
Trying display: drm
1502.502354997 [14528-14528] ../src/vabackend.c:1872 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 0x55d3a4a3f8e0 31
1502.502363876 [14528-14528] ../src/vabackend.c:1894 __vaDriverInit_1_0 Now have 0 (0 max) instances
1502.502366456 [14528-14528] ../src/vabackend.c:1920 __vaDriverInit_1_0 Selecting Direct backend
1502.506445466 [14528-14528] ../src/direct/nv-driver.c: 190 init_nvdriver Initing nvdriver...
1502.506457112 [14528-14528] ../src/direct/nv-driver.c: 195 init_nvdriver Got dev info: 100 1 2 6
1502.506595613 [14528-14528] ../src/direct/nv-driver.c: 256 init_nvdriver NVIDIA kernel driver version: 525.60.11
vainfo: VA-API version: 1.16 (libva 2.16.0)
vainfo: Driver version: VA-API NVDEC driver [direct 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
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
1502.576142214 [14528-14528] ../src/vabackend.c:1843 nvTerminate Terminating 0x55d3a4a3f8e0
1502.576182934 [14528-14528] ../src/vabackend.c:1857 nvTerminate Now have 0 (0 max) instances
I think you just have an Optimus issue now. For this driver to work with Firefox, both have to be using the NVIDIA GPU, but trying to get Firefox to run on the GPU that isn't the GPU running X11 seems to be very difficult.
Not just Firefox, everything with vaapi doesn't work. Using optimus-manager can make X11 run on nvidia card, which can make vaapi work, but it will cause huge screen delay and tearing, so vaapi is meaningless then.
Unfortunately I don't have a real Optimus system to test with (my desktop Intel+NVIDIA system doesn't seem to act the same as a Laptop for some reason), so resolving these Optimus issues is difficult.
I do not have an Optimus system to test. Perhaps the following may resolve the issue. Basically, set NVIDIA as the primary GPU and have the Intel GPU use the modesetting driver. I saw this from an EL9 NVIDIA RPM.
$ cat /etc/X11/xorg.conf.d/nvidia-drm-outputclass.conf
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "PrimaryGPU" "yes"
Option "SLI" "Auto"
Option "BaseMosaic" "on"
EndSection
Section "OutputClass"
Identifier "intel"
MatchDriver "i915"
Driver "modesetting"
EndSection
I do not have an Optimus system to test. Perhaps the following may resolve the issue. Basically, set NVIDIA as the primary GPU and have the Intel GPU use the modesetting driver. I saw this from an EL9 NVIDIA RPM.
$ cat /etc/X11/xorg.conf.d/nvidia-drm-outputclass.conf
Section "OutputClass" Identifier "nvidia" MatchDriver "nvidia-drm" Driver "nvidia" Option "AllowEmptyInitialConfiguration" Option "PrimaryGPU" "yes" Option "SLI" "Auto" Option "BaseMosaic" "on" EndSection Section "OutputClass" Identifier "intel" MatchDriver "i915" Driver "modesetting" EndSection
This Xorg profile will make X run on the NVIDIA card with huge display lag, tearing and frame drops, so not a good solution.
I misunderstood your intention on wanting both OpenGL and HW decoding acceleration to occur on the NVIDIA GPU. Thank you for clarifying.
After upgrading v525
Nvidia driver, I reproduced this issue on my old Optimus laptop (MUXless) with Intel iGPU + Nvidia 1050ti dGPU (mobile ver.) and nvidia-vaapi-driver v0.0.8
on direct
backend.vainfo
reacts as well as v520
drvier, but somehow no application can use vaapi. However, it would work when I fallbacked to v520
driver + default EGL
backend.
I don't know how to cat the log of Firefox, but it also cannot use vaapi when playing an avc stream video, and nvidia-pmon
reports 0 ultilization about Decoder.
@xtellaris Can you try the latest master version?
@xtellaris Can you try the latest master version?
Tried https://github.com/elFarto/nvidia-vaapi-driver/commit/7113c20184e32abeb6cb3857392a1549bbcd7a5a + v525
Nvidia driver, vaapi still looks good with vainfo
but broken with mpv or firefox. Logs also looks the same as which v0.0.8
would report.
By the way, I downgraded to v520
Nvidia driver again with master version nvidia-vaapi-driver remaining, then removed env
about direct
backend and reboot. This time, the EGL
backend is broken in applications as well ( vainfo
report is good). mpv
log :
[ 0.292][v][vd] Opening decoder vp9
[ 0.292][v][vd] Looking at hwdec vp9-vaapi...
[ 0.292][v][vo/gpu] Loading hwdec drivers for format: 'vaapi'
[ 0.292][v][vo/gpu] Loading hwdec driver 'vaapi'
[ 0.292][v][vo/gpu/vaapi] using EGL dmabuf interop
[ 0.292][v][vo/gpu/vaapi] Trying to open a x11 VA display...
[ 0.292][d][vo/gpu/vaapi/vaapi] libva: VA-API version 1.16.0
[ 0.292][d][vo/gpu/vaapi/vaapi] libva: User environment variable requested driver 'nvidia'
[ 0.292][d][vo/gpu/vaapi/vaapi] libva: Trying to open /usr/lib/dri/nvidia_drv_video.so
[ 0.307][d][vo/gpu/vaapi/vaapi] libva: Found init function __vaDriverInit_1_0
[ 0.355][d][vo/gpu/vaapi/vaapi] libva: va_openDriver() returns 0
[ 0.355][v][vo/gpu/vaapi/vaapi] Initialized VAAPI: version 1.16
[ 0.355][d][ffmpeg] AVHWDeviceContext: VAAPI driver: VA-API NVDEC driver [egl backend].
[ 0.355][d][ffmpeg] AVHWDeviceContext: Driver not found in known nonstandard list, using standard behaviour.
[ 0.355][v][vo/gpu/vaapi] Going to probe surface formats (may log bogus errors)...
[ 0.382][d][vo/gpu/vaapi] Supported formats:
[ 0.382][d][vo/gpu/vaapi] nv12
[ 0.382][d][vo/gpu/vaapi] p010
[ 0.382][v][vo/gpu/vaapi] Done probing surface formats.
[ 0.382][v][vd] Trying hardware decoding via vp9-vaapi.
[ 0.382][v][vd] Selected codec: vp9 (Google VP9)
[ 0.382][v][vf] User filter list:
[ 0.382][v][vf] (empty)
[ 0.382][v][cplayer] Starting playback...
[ 0.383][v][vd] Pixel formats supported by decoder: cuda vaapi vdpau yuv420p
[ 0.383][v][vd] Codec profile: Profile 0 (0x0)
[ 0.409][v][vd] Requesting pixfmt 'vaapi' from decoder.
[ 0.574][e][ffmpeg/video] vp9: Failed to create decode context: 2 (resource allocation failed).
[ 0.574][e][ffmpeg/video] vp9: Failed setup for format vaapi: hwaccel initialisation returned error.
[ 0.574][v][vd] Pixel formats supported by decoder: cuda vdpau yuv420p yuv420p
[ 0.574][v][vd] Codec profile: Profile 0 (0x0)
[ 0.574][v][vd] Requesting pixfmt 'yuv420p' from decoder.
[ 0.576][d][osc] osc_init
[ 0.576][v][vd] Falling back to software decoding.
So I would suggest Optimus device user relys on v520
Nvidia driver + v0.0.8
nvidia-vaapi-driver for some time. And thanks for the good work !
Desktop machine RTX 3070: I can confirm Mpv segfault with master 7113c20
on v520.61.05
. All is well on v520
Nvidia driver and the v0.0.8
nvidia-vaapi-driver release.
Desktop machine RTX 3070: Mpv playblak using Nvidia driver v525.60.13
and NVD_BACKEND=direct
works with commit bb7f6fc.
This is the commit prior to the "Support YUV444 on direct-backend".
Ok, I've just tested on my system, and those versions work fine. So the issue is just for Optimus systems.
The Failed to import surface in EGL
errors are likely mpv trying to import into an Intel EGL context, which won't work.
My desktop system does not have Optimus and the reason reporting above. I reverted to commit bb7f6fc. Mpv NVD_BACKEND=direct
segfaults with commit 7113c20
on v525.60.13
.
For me, with the latest master commit (7113c20), things got different. mpv will now crash with a segmentation fault. mpv.txt prime-run mpv.txt
Ah, it's the vaapi-copy that's doing it. I can reproduce it locally now so I can investigate.
Ok, give master a go. Looks like it was a small issue from the YUV444 work that only effected the copy path.
I tested v520.61.05
. Not working playing 10-bit media mpv --hwdec=vaapi-copy --vo=xv
; e.g. https://youtu.be/Jz9TdfXlTgs format 699 (1920x1080 24 FPS 10 HDR).
[ffmpeg/video] av1: Hardware does not support image size 1920x1080 (constraints: width 128-8192 height 1587019272-8192).
[ffmpeg/video] av1: Failed setup for format vaapi: hwaccel initialisation returned error.
[ffmpeg/video] av1: Your platform doesn't suppport hardware accelerated AV1 decoding.
[ffmpeg/video] av1: Failed to get pixel format.
No issues with commit bb7f6fc.
```text #!/usr/bin/env bash ############################################################################### # # A script for playing YouTube videos via the VA-API interface. # # by Mario Roy, August 2022 # for testing video hardware acceleration in mpv # url=$1 # Display usage. if [ -z "$url" -o "$url" = "-h" -o "$url" = "--help" ]; then echo 'The YouTube URL is "Best 8k HDR of 2020 Dolby Vision"' echo "" echo "Usage:" echo " youtube-play-vaapi URL -F, --list-formats" echo " youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs -F" echo " youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs --list-formats" echo "" echo " youtube-play-vaapi URL [VIDEO_FORMAT_CODE]" echo " youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs # auto avc1" echo " youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs 136 # 720p avc1" echo " youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs 137 # 1080p avc1" echo "" exit 1 fi # YouTube Downloader ########################################################## # # Installation: pip3 install --user --upgrade yt-dlp # youtube_dl=~/.local/bin/yt-dlp if [ ! -f "$youtube_dl" ]; then echo "Please install yt-dlp as described in the README file." echo "To install, run: pip3 install --user --upgrade yt-dlp" exit 1 fi # List all available formats of the requested video. if [ "$2" = "-F" -o "$2" = "--list-formats" ]; then ${youtube_dl} --list-formats "$url" exit 0 fi # Set the format code if given on the command line. if [ -n "$2" ]; then video_format=$2 else video_format="bestvideo[height<=?1080][fps<=?30][ch!=?2]" fi # Fetch the title and audio+video URLs into an array. # title: ${lines[0]}, audio: ${lines[1]}, video: ${lines[2]} readarray -t lines < <( ${youtube_dl} --get-title -g -S "vcodec:avc1" \ -f "bestaudio+${video_format}" "$url" ) # printf '%s\n' "${lines[@]}" # mpv ######################################################################### # # Using NVIDIA graphics? # 10-bit (HDR) media works with --hwdec=vaapi-copy and --vo={xv,x11} options. # # The EGL backend (which is still the default) was broken in the 525 driver # series, so the direct backend is necessary for decoding to work. # if [ -d /proc/driver/nvidia ]; then version=$(head -1 /proc/driver/nvidia/version | awk '{ print $8 }') [ ${version%%.*} -ge 525 ] && export NVD_BACKEND=direct fi mpv --hwdec=vaapi-copy --vo=xv --force-media-title="${lines[0]}" \ --audio-file="${lines[1]}" "${lines[2]}" stty echo # restore echo ```
Edit: Updated script to set NVD_BACKEND=direct
automatically for v525.
Tested mpv --no-config --hwdec=vaapi-copy
to play a vp9 video with latest commit https://github.com/elFarto/nvidia-vaapi-driver/commit/f91a078eefd25ffd1253723050b3630f4833aaa5 (EGL
backend) on my Optimus machine with v520
driver. mpv
reported failed initialization:
[ 0.072][v][vd] Opening decoder vp9
[ 0.072][v][vd] Looking at hwdec vp9-vaapi-copy...
[ 0.072][d][vaapi] libva: VA-API version 1.16.0
[ 0.072][d][vaapi] libva: User environment variable requested driver 'nvidia'
[ 0.072][d][vaapi] libva: Trying to open /usr/lib/dri/nvidia_drv_video.so
[ 0.082][d][vaapi] libva: Found init function __vaDriverInit_1_0
[ 0.082][e][vaapi] libva: /usr/lib/dri/nvidia_drv_video.so init failed
[ 0.082][d][vaapi] libva: va_openDriver() returns 1
[ 0.082][e][vaapi] Failed to initialize VAAPI: operation failed
[ 0.082][v][vd] Could not create device.
[ 0.082][v][vd] No hardware decoding available for this codec.
[ 0.082][v][vd] Using software decoding.
And mpv --no-config --hwdec=vaapi
(non-copy decoder) still reported broken like we talked before.
Congratulations on supporting 10-bit in nvidia-vaapi-driver. The youtube script is posted above. Today, I learned that I must test 8-bit and 10-bit playback for choosing desired commit tag.
8-bit vp9 : ./youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs 243
10-bit vp9.2 : ./youtube-play-vaapi https://youtu.be/Jz9TdfXlTgs 332
Tested
mpv --no-config --hwdec=vaapi-copy
to play a vp9 video with latest commit
Can you run that again with NVD_LOG=1 set?
Tested
mpv --no-config --hwdec=vaapi-copy
to play a vp9 video with latest commitCan you run that again with NVD_LOG=1 set?
Seems it didn't use the right DRM device:
Try to specify the DRM device:
NVD_GPU isn't meant to be used like that, it's meant to just be the index of the GPU you want. The driver will pick the first NVIDIA GPU it finds without that variable being set.
You can use mpv's --vaapi-device=/dev/...
parameter to set what device to use for the vaapi-copy hwdec (it doesn't work with the vaapi hwdec option for some reason).
However, the out of memory error is puzzling. Your card has more than enough VRAM to handle 12 surfaces, so I'm not certain what's going on there.
NVD_GPU isn't meant to be used like that, it's meant to just be the index of the GPU you want. The driver will pick the first NVIDIA GPU it finds without that variable being set.
I believe most Optimus laptop have only one Nvidia GPU. In my case, nvidia-smi -L
says it is "GPU 0", So the value for NVD_GPU
should be '0' ?
I tried with --vaapi-device
, it reported "out of memery" again.
Let me try it with v0.0.8
nvidia-vaapi-driver.
Let me try it with v0.0.8 nvidia-vaapi-driver.
A very long log, as it was decoding.
Now mpv with vaapi-copy works for me, but vlc and firefox still don't work. vlc reports glconv_vaapi_x11 gl error: vaDeriveImage: operation failed
, Firefox reports [GFX1-]: glxtest: VA-API test failed: failed to initialize VAAPI connection.
on start.
vlc.txt
VLC doesn't work with this library as it required vaDeriveImage, which we don't support. The Firefox issue is the normal Optimus issue.
System information: KDE Plasma 5.26.4 on X11 Integrated Graphics: Intel CometLake-H GT2 [UHD Graphics] NVIDIA Graphics: NVIDIA GeForce GTX 1650 Ti Mobile No optimus-manager or bumblebee is used
Related logs: vainfo.txt vlc.txt mpv-vaapi.txt chromium.txt firefox.txt