r/mpv•
imthebatmax

Problem with vulkan and wayland on Nvidia optimus laptop running Fedora 37

Hello, I'm having a problem with mpv on my laptop (with Nvidia Optimus graphics), which is currently running Fedora 37.

I switched from X11 to wayland and this seems to have caused an issue, because when I try to play any video mpv starts and audio plays correctly, but video doesn't. It doesn't even show a window.

I'm pretty sure the issue is somehow related to the fact that I'm using Vulkan because by running mpv with --no-config I can get videos to play, but as soon as I add --gpu-api=vulkan I get the issue described above. Even setting --gpu-context=waylandvk doesn't resolve the problem.

On a second note, I'm not sure if my dedicated gpu (Nvidia GTX 1060 Max-Q) is working on wayland at all, as when using profile=gpu-hq with hardware decoding hwdec=auto-safe, which defaults to NVDEC on X11, I only get vaapi which makes me believe that mpv might be using the integrated Intel gpu instead of the Nvidia one.

I installed mpv from rpmfusion and the output of mpv --version is provided below:

mpv 0.35.1 Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
FFmpeg library versions:
   libavutil       57.28.100
   libavcodec      59.37.100
   libavformat     59.27.100
   libswscale      6.7.100
   libavfilter     8.44.100
   libswresample   4.7.100
FFmpeg version: 5.1.2

Mesa version is 22.3.5 and the output of nvidia-smi is the following:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.89.02    Driver Version: 525.89.02    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   48C    P8     5W /  60W |      4MiB /  6144MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

When trying to play a video using wayland this is the output I get:

[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pipewire] 48000Hz mono 1ch floatp
VO: [gpu] 1920x1048 yuv420p
[vo/gpu/libplacebo] vk->CreateSwapchainKHR(vk->dev, &sinfo, PL_VK_ALLOC, &p->swapchain): VK_ERROR_INITIALIZATION_FAILED (../src/vulkan/swapchain.c:583)
[vo/gpu/libplacebo] Failed (re)creating swapchain!
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
AV: 00:00:00 / 01:20:46 (0%) A-V:  0.000
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
AV: 00:00:28 / 01:20:46 (1%) A-V:  0.000
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
AV: 00:00:28 / 01:20:46 (1%) A-V:  0.000
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
AV: 00:00:28 / 01:20:46 (1%) A-V:  0.000
[vo/gpu/libplacebo] Failed resizing swapchain: unknown size?
AV: 00:00:32 / 01:20:46 (1%) A-V:  0.000

Exiting... (Quit)

I tried looking around online for a solution, but I couldn't really find anything so any help with this would be appreciated. Thanks for reading!

Posted Feb 19, 2023, 4:55 PM UTC

30
Camodude1•

It appears that the non-free Nvidia codecs must be installed or updated. If you've tried this and still received the same result, your GPU may require installation of an edge codec package, if one is available. If a package is installed but still produces the same problem, it may not be supported at all or it may still be in development. If this is the case, I would contact Fedora for assistance. There isn't much one can do as Nvidia absolutely stinks at supporting Linux.

2
imthebatmaxOP•

Hey, thanks a lot for your reply! I'm not sure what you mean by non-free Nvidia codecs. I installed multimedia codecs from RPMFusion following the documentation and Nvidia drivers following the Howto/NVIDIA guide.

I did some more investigating and I'm pretty sure that my Nvidia gpu doesn't work with mpv on wayland at the moment. I tried running mpv --vulkan-device=help and it seems to recognize the Nvidia gpu as the output is

Available vulkan devices:
  'Intel(R) HD Graphics 630 (KBL GT2)' (GPU 0, ID 8086:591b)
  'NVIDIA GeForce GTX 1060 with Max-Q Design' (GPU 1, ID 10de:1c20)
  'llvmpipe (LLVM 15.0.7, 256 bits)' (GPU 2, ID 10005:0)

However, trying to manually set the Nvidia gpu as a vulkan device with --vulkan-device='NVIDIA GeForce GTX 1060 with Max-Q Design' causes the issue, while using --vulkan-device='Intel(R) HD Graphics 630 (KBL GT2)' doesn't so I guess it's just one of those Nvidia on Linux issues.

2
Camodude1•

What I meant by non free was what you got from the documents that you follow. It means codecs that are covered by software patents that cannot be freely shared because of legal issues. That's all. Yeah, based off the information it does seem to be Nvidia Linux issue.

What I suggests, Go onto Linus Torvalds github page and make a bug request on this issue. Paste the information that you gave me to the bug report and see what happens. 😃

1