(Optimus) Vulkan broken on Ubuntu 18.04 LTS with gdm3 or via startx if nvidia-drm modeset is enabled (cannot initialize the swap chain as a non-root user?)

Lenovo ideapad 510-15IKB
OS: Ubuntu 18.04 bionic
Kernel: x86_64 Linux 4.15.0-20-generic
DE: GNOME
CPU: Intel Core i5-7200U @ 4x 3.1GHz
GPU: Intel HD 620 + NVIDIA GeForce 940MX (Optimus)
UEFI boot, Secure Boot disabled.
Driver: 396.24 via graphics-drivers PPA (standard non-PPA nvidia-graphics-drivers-390 driver also affected)

Note: OpenGL applications are not affected.

Vulkan applications (e.g. vulkan-smoketest, Unreal Editor, Dolphin, SDK demos) cannot initialize the Vulkan swap chain and crash. If I run any program that uses the GPU (e.g. glxgears, vulkan-smoketest, nvidia-bug-report.sh) as root (with sudo) then any Vulkan program as a normal user, Vulkan works until I shut down or reboot the computer.

This only happens if:

  • I start X via GDM or startx (sddm and lightdm are not affected) as a non-root user
  • nvidia-drm.modeset=1 is set (I added it to GRUB_CMDLINE_LINUX_DEFAULT)

Launchpad: https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-390/+bug/1769857
nvidia-bug-report.log-beforesudo.gz (125 KB)
nvidia-bug-report.log-aftersudo.gz (126 KB)