nvidia-vaapi-driver
nvidia-vaapi-driver copied to clipboard
Direct backend does not work with Optimus
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
➜ vainfo
Trying display: wayland
Trying display: x11
1584.561294865 [43611-43611] ../src/vabackend.c:1872 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 0x563808dea830 10
1584.561303181 [43611-43611] ../src/vabackend.c:1894 __vaDriverInit_1_0 Now have 0 (0 max) instances
1584.561304615 [43611-43611] ../src/vabackend.c:1919 __vaDriverInit_1_0 Selecting Direct backend
1584.564994600 [43611-43611] ../src/direct/nv-driver.c: 190 init_nvdriver Initing nvdriver...
1584.565004049 [43611-43611] ../src/direct/nv-driver.c: 195 init_nvdriver Got dev info: 0 0 0 0
1584.565075145 [43611-43611] ../src/direct/nv-driver.c: 256 init_nvdriver NVIDIA kernel driver version: 525.60.11
1584.565084783 [43611-43611] ../src/direct/nv-driver.c: 79 nv_rm_control nv_rm_control failed: 0 57
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
1584.638244179 [43611-43611] ../src/vabackend.c:1843 nvTerminate Terminating 0x563808dea830
1584.638276164 [43611-43611] ../src/vabackend.c:1857 nvTerminate Now have 0 (0 max) instances
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.
System info
OS: Arch Linux x86_64
Host: 80WW Lenovo R720-15IKBN
Kernel: 6.1.0-2-cachyos-tt-lto
Resolution: 1920x1080
DE: Plasma 5.26.4
WM: KWin
CPU: Intel i5-7300HQ (4) @ 3.500GHz
GPU: Intel HD Graphics 630
GPU: NVIDIA GeForce GTX 1050 Ti Mobile
vainfo with NVD_LOG=1
$ NVD_LOG=1 vainfo
Trying display: wayland
Trying display: x11
3946.807369180 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1872 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 0x56222bdbf400 10
3946.807378086 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1894 __vaDriverInit_1_0 Now have 0 (0 max) instances
3946.807382529 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1919 __vaDriverInit_1_0 Selecting Direct backend
3946.812762990 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/direct/direct-export-buf.c: 94 direct_initExporter Found NVIDIA GPU 0 at /dev/dri/renderD129
3946.812772203 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/direct/nv-driver.c: 190 init_nvdriver Initing nvdriver...
3946.812796033 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/direct/nv-driver.c: 195 init_nvdriver Got dev info: 100 1 0 0
3946.812909381 [11902-11902] ../nvidia-vaapi-driver-0.0.8/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
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
3946.898700073 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1843 nvTerminate Terminating 0x56222bdbf400
3946.898797690 [11902-11902] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1857 nvTerminate Now have 0 (0 max) instances
vainfo --display drm --device /dev/dri/renderD129
According to the log above, I believe nvidia-vaapi-driver v0.0.8
do find the right drm device, but I tested mannually as well.
$ NVD_LOG=1 vainfo --display drm --device /dev/dri/renderD129
Trying display: drm
4710.969159513 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1872 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 0x5615b00728e0 31
4710.969194533 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1894 __vaDriverInit_1_0 Now have 0 (0 max) instances
4710.969211394 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1919 __vaDriverInit_1_0 Selecting Direct backend
4710.974636477 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/direct/nv-driver.c: 190 init_nvdriver Initing nvdriver...
4710.974661048 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/direct/nv-driver.c: 195 init_nvdriver Got dev info: 100 1 0 0
4710.974802033 [12585-12585] ../nvidia-vaapi-driver-0.0.8/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
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
4711.052943601 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1843 nvTerminate Terminating 0x5615b00728e0
4711.053010242 [12585-12585] ../nvidia-vaapi-driver-0.0.8/src/vabackend.c:1857 nvTerminate Now have 0 (0 max) instances
mpv log about vaapi
mpv has successfully reached the nvidia-vaapi-driver
but tried to use some EGL methods then failed.
...
[ 0.068][v][vd] Opening decoder vp9
[ 0.068][v][vd] Looking at hwdec vp9-vaapi...
[ 0.068][v][vo/gpu] Loading hwdec drivers for format: 'vaapi'
[ 0.068][v][vo/gpu] Loading hwdec driver 'vaapi'
[ 0.068][v][vo/gpu/vaapi] using EGL dmabuf interop
[ 0.068][v][vo/gpu/vaapi] Trying to open a x11 VA display...
[ 0.068][d][vo/gpu/vaapi/vaapi] libva: VA-API version 1.16.0
[ 0.069][d][vo/gpu/vaapi/vaapi] libva: User environment variable requested driver 'nvidia'
[ 0.069][d][vo/gpu/vaapi/vaapi] libva: Trying to open /usr/lib/dri/nvidia_drv_video.so
[ 0.085][d][vo/gpu/vaapi/vaapi] libva: Found init function __vaDriverInit_1_0
[ 0.134][d][vo/gpu/vaapi/vaapi] libva: va_openDriver() returns 0
[ 0.134][v][vo/gpu/vaapi/vaapi] Initialized VAAPI: version 1.16
[ 0.134][d][ffmpeg] AVHWDeviceContext: VAAPI driver: VA-API NVDEC driver [direct backend].
[ 0.134][d][ffmpeg] AVHWDeviceContext: Driver not found in known nonstandard list, using standard behaviour.
[ 0.134][v][vo/gpu/vaapi] Going to probe surface formats (may log bogus errors)...
[ 0.161][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.161][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.162][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.162][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.164][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.164][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.165][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.165][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.168][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.168][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.168][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.168][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.171][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.171][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.171][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.171][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.174][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.174][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.175][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.175][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.177][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.177][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.178][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.178][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.180][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.180][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.181][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.181][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.183][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.183][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.184][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.184][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.187][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.187][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.187][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.187][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.190][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.190][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.191][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.191][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.193][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.193][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.194][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.194][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.196][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.196][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.197][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.197][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.199][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.199][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.200][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.200][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.203][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.203][d][vo/gpu/vaapi] Unsupported format: nv12
[ 0.203][d][vo/gpu/vaapi] Failed to import surface in EGL: 12300
[ 0.203][d][vo/gpu/vaapi] Unsupported format: p010
[ 0.203][d][vo/gpu/vaapi] Supported formats:
[ 0.203][v][vo/gpu/vaapi] Done probing surface formats.
[ 0.229][v][vo/gpu] Loading failed.
[ 0.229][v][vd] Could not create device.
[ 0.229][v][vd] No hardware decoding available for this codec.
[ 0.229][v][vd] Using software decoding.
...
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.
youtube-play-vaapi script
#!/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?
vainfo
$ NVD_LOG=1 vainfo
Trying display: wayland
Trying display: x11
18617.000468062 [21816-21816] ../src/vabackend.c:2079 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 10
18617.000481508 [21816-21816] ../src/vabackend.c:2088 __vaDriverInit_1_0 Now have 0 (0 max) instances
18617.000487249 [21816-21816] ../src/vabackend.c:2111 __vaDriverInit_1_0 Selecting EGL backend
18617.006142321 [21816-21816] ../src/export-buf.c: 137 findGPUIndexFromFd Defaulting to CUDA GPU ID 0. Use NVD_GPU to select a specific CUDA GPU
18617.006152590 [21816-21816] ../src/export-buf.c: 154 findGPUIndexFromFd Looking for GPU index: 0
18617.008503462 [21816-21816] ../src/export-buf.c: 166 findGPUIndexFromFd Found 4 EGL devices
18617.008611529 [21816-21816] ../src/export-buf.c: 175 findGPUIndexFromFd Got EGL_CUDA_DEVICE_NV value '0' for EGLDevice 0
18617.008646480 [21816-21816] ../src/export-buf.c: 213 findGPUIndexFromFd Selecting EGLDevice 0
18617.009883169 [21816-21816] ../src/export-buf.c: 284 egl_initExporter Driver supports 16-bit surfaces
vainfo: VA-API version: 1.16 (libva 2.16.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
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain12 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
18617.100282926 [21816-21816] ../src/vabackend.c:2051 nvTerminate Terminating 0x5635f6688400
18617.100290411 [21816-21816] ../src/export-buf.c: 66 egl_releaseExporter Releasing exporter, 0 outstanding frames
18617.100295772 [21816-21816] ../src/export-buf.c: 83 egl_releaseExporter Done releasing frames
18617.100300584 [21816-21816] ../src/vabackend.c:2065 nvTerminate Now have 0 (0 max) instances
Seems it didn't use the right DRM device:
mpv with NVD_LOG=1
$ NVD_LOG=1 mpv --no-config \
--hwdec=vaapi-copy --log-file=/tmp/mpv.log \
"/home/xtellaris/Videos/Test/Mad Max - Fury Road - Official Retaliate Trailer [HD] [MonFNCgK4WE].webm"
(+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
18529.483018244 [21722-21722] ../src/vabackend.c:2079 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 31
18529.483030001 [21722-21722] ../src/vabackend.c:2088 __vaDriverInit_1_0 Now have 0 (0 max) instances
18529.483035148 [21722-21722] ../src/vabackend.c:2111 __vaDriverInit_1_0 Selecting EGL backend
18529.483053366 [21722-21722] ../src/backend-common.c: 31 isNvidiaDrmFd Invalid driver for DRM device: i915
[vaapi] libva: /usr/lib/dri/nvidia_drv_video.so init failed
[vaapi] Failed to initialize VAAPI: operation failed
VO: [gpu] 1920x1080 yuv420p
V: 00:00:11 / 00:02:32 (8%) Dropped: 4
Exiting... (Quit)
Try to specify the DRM device:
mpv with NVD_LOG=1 NVD_GPU=/dev/dri/renderD129
$ NVD_LOG=1 NVD_GPU=/dev/dri/renderD129 mpv --no-config \
--hwdec=vaapi-copy --log-file=/tmp/mpv.log \
"/home/xtellaris/Videos/Test/Mad Max - Fury Road - Official Retaliate Trailer [HD] [MonFNCgK4WE].webm"
(+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
18840.997886256 [21924-21924] ../src/vabackend.c:2079 __vaDriverInit_1_0 Initialising NVIDIA VA-API Driver: 31
18840.997914587 [21924-21924] ../src/vabackend.c:2088 __vaDriverInit_1_0 Now have 0 (0 max) instances
18840.997937037 [21924-21924] ../src/vabackend.c:2111 __vaDriverInit_1_0 Selecting EGL backend
18840.997953428 [21924-21924] ../src/export-buf.c: 154 findGPUIndexFromFd Looking for GPU index: 0
18840.998841475 [21924-21924] ../src/export-buf.c: 166 findGPUIndexFromFd Found 4 EGL devices
18840.998985142 [21924-21924] ../src/export-buf.c: 175 findGPUIndexFromFd Got EGL_CUDA_DEVICE_NV value '0' for EGLDevice 0
18840.999019721 [21924-21924] ../src/export-buf.c: 213 findGPUIndexFromFd Selecting EGLDevice 0
18841.000245895 [21924-21924] ../src/export-buf.c: 284 egl_initExporter Driver supports 16-bit surfaces
18841.060436957 [21924-21924] ../src/vabackend.c:1393 nvQueryImageFormats In nvQueryImageFormats
18841.093327437 [21924-21924] ../src/vabackend.c: 637 nvCreateConfig got profile: 19 with 0 attributes
18841.093343299 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) (nil) 0
18841.093349390 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) 0x55780103d700 7
18841.095262949 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) (nil) 0
18841.095272460 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) 0x557801543a40 7
18841.097140378 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x5578015433e0)
18841.097151838 [21924-21924] ../src/vabackend.c:1487 nvDeriveImage In nvDeriveImage
18841.097159416 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x55780102e420)
18841.097165213 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x55780102bea0)
18841.097169993 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801544720)
18841.097175087 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801544cb0)
18841.097180670 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801545240)
18841.097185320 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x5578015457d0)
18841.097190671 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801545d60)
18841.097195941 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x5578015462f0)
18841.097201090 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801546880)
18841.097205738 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x557801546e10)
18841.097210821 [21924-21924] ../src/vabackend.c: 915 nvCreateSurfaces2 Creating surface 1920x1080, format 1 (0x5578015473a0)
18841.128154318 [21924-21924] ../src/vabackend.c: 637 nvCreateConfig got profile: 19 with 0 attributes
18841.128170089 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) (nil) 0
18841.128175978 [21924-21924] ../src/vabackend.c:1747 nvQuerySurfaceAttributes with 10 (8) 0x557801638dc0 7
18841.130051760 [21924-21924] ../src/vabackend.c: 979 nvCreateContext with 12 render targets, 12 surfaces, at 1920x1080
18841.285175717 [21924-21924] ../src/vabackend.c:1032 nvCreateContext CUDA ERROR 'out of memory' (2)
[ffmpeg/video] vp9: Failed to create decode context: 2 (resource allocation failed).
[ffmpeg/video] vp9: Failed setup for format vaapi: hwaccel initialisation returned error.
18841.285247014 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x5578015473a0)
18841.285252011 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285257824 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801546e10)
18841.285262041 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285266504 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801546880)
18841.285270626 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285275398 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x5578015462f0)
18841.285279411 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285284094 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801545d60)
18841.285288132 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285292610 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x5578015457d0)
18841.285296741 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285301172 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801545240)
18841.285305191 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285309760 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801544cb0)
18841.285313789 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285318349 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x557801544720)
18841.285322451 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285327018 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x55780102bea0)
18841.285331089 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285335698 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x55780102e420)
18841.285339804 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.285344252 [21924-21924] ../src/vabackend.c: 949 nvDestroySurfaces Destroying surface -1 (0x5578015433e0)
18841.285348363 [21924-21924] ../src/export-buf.c: 359 egl_detachBackingImageFromSurface Cannot detach NULL BackingImage from Surface
18841.287118723 [21924-21924] ../src/vabackend.c:2051 nvTerminate Terminating 0x5578010245f0
18841.287129673 [21924-21924] ../src/export-buf.c: 66 egl_releaseExporter Releasing exporter, 0 outstanding frames
18841.287134920 [21924-21924] ../src/export-buf.c: 83 egl_releaseExporter Done releasing frames
18841.287139914 [21924-21924] ../src/vabackend.c:2065 nvTerminate Now have 0 (0 max) instances
VO: [gpu] 1920x1080 yuv420p
V: 00:00:02 / 00:02:32 (2%)
Exiting... (Quit)