Nvidia Users Testers Requested (Sway on Nvidia, Steam on Wayland)

Hiii Nvidia users! I have some things for you:

  1. Better EGL integration, particularly with wayland:

  2. Sway builds that work for Nvidia!

This culminates in Steam running on Sway on my desktop machine with an RTX 3080!

Instructions for using the EGLStreams-enabled packages from nixpkgs-wayland are here: GitHub - nix-community/nixpkgs-wayland: Automated, pre-built packages for Wayland (sway/wlroots) tools for NixOS. [maintainers=@colemickens, @Artturin]

Please test this PR: nvidia: fix egl-wayland loading by colemickens · Pull Request #139354 · NixOS/nixpkgs · GitHub ! Thanks!

(I’ll add a GitHub workflow to publish the egl-enabled packages too, for now you’ll find yourself building them from source.)

12 Likes

I can’t get sway to start.

$ nix-store --query --requisites /run/current-system/sw/bin/sway | grep wlroots
/nix/store/j6hvk58gaa2nhr01zg8n5qf3gfa5773r-wlroots-eglstreams-fef636e2685d687435859b3472ee55c0b05162dc

$ cat /etc/egl/egl_external_platform.d/10_nvidia_wayland.json
{
    "file_format_version" : "1.0.0",
    "ICD" : {
        "library_path" : "/nix/store/2v2876wypbbcd6ygbhikcny39607njaa-nvidia-x11-470.74-5.13.19/lib/libnvidia-egl-wayland.so.1"
    }
}

$ /run/current-system/sw/bin/sway --my-next-gpu-wont-be-nvidia
00:00:00.002 [sway/main.c:60] !!! Proprietary Nvidia drivers are in use !!!
00:00:00.003 [sway/server.c:55] Unable to create backend

I am using nixpkgs from your PR branch, and I have added this module to my system. I am running from /run/system/current-sw/bin/sway to avoid using the sway from home-manager.

({ ... }: {
  nixpkgs.overlays = [
    inputs.nixpkgs-wayland.overlay-egl
  ];
})

Got it working, I needed to add hardware.nvidia.modesetting.enable = true;
Sway/wlroots logging is glitchy and prints lines on top of each other, I didn’t see the error about KMS until randomly running it for the 15th time.

2 Likes

I can use sway now with gtx 1080. All of the following fail with getting EGL display.

  • glmark2-es2
  • env SDL_VIDEODRIVER=wayland xonotic-sdl
  • webgl in Firefox.

Chromium seems to work, but I am not sure how to test that. Xonotic and CS:GO start in Xwayland, but with very bad performance. It seems this is expected with Xwayland, according to the wlroots-eglstreams readme.

Based on nvidia: fix egl-wayland loading by colemickens · Pull Request #139354 · NixOS/nixpkgs · GitHub I added this to my configuration:

  environment.etc."egl/egl_external_platform.d/nvidia_wayland.json".text = ''
      {
        "file_format_version" : "1.0.0",
        "ICD" : {
            "library_path" : "/run/opengl-driver/lib/libnvidia-egl-wayland.so"
        }
    }
  '';

And now Steam is working on Gnome on wayland.

1 Like

Using libnvidia-egl-wayland.so from egl-wayland package I had better results, webgl and webrender in firefox are working now :

  environment.etc."egl/egl_external_platform.d/10_nvidia_wayland.json".text = ''
      {
        "file_format_version" : "1.0.0",
        "ICD" : {
            "library_path" : "${pkgs.egl-wayland}/lib/libnvidia-egl-wayland.so"
        }
    }
  '';

fwiw, it seems like the egl-wayland that nvidia builds with will be updated soon (ref), maybe closing this gap again? (But also, there’s apparently some regressions for certain users related to the very latest egl-wayland [that isn’t even merged yet] (ref))

Sounds like a fun landscape over all.

I tried egl-wayland 1.1.8 and I have some problems with that, like firefox not starting. I saw here that egl-wayland 1.1.8 needs the unreleased nvidia driver to work.

1 Like

Nvidia 495 (Beta) was released what will makes this simpler to run Wayland with Nvidia drivers.

3 Likes

Granted, it’s day 1, but the wlroots-eglstreams patched Sway with stable nvidia had much more consistent, better performance.

But it is working. Running HEAD of sway, with HEAD of regular wlroots, on an RTX 3080 with jonringer’s nvidia_x11_beta PR.

I am currently experimenting with a PR to add an option for adding a “custom” egl-wayland package so that it will be easy for users to play with egl-wayland from nvidia, the “current” stable, and the next stable release, all of which seem to act differently.

2 Likes

I got Sway working (somewhat properly) on Nvidia. A number of nixpkgs commits that aren’t upstream yet, and a wlroots patch that is hacky and I wouldn’t dream of upstreaming: but anyway, if someone else wants to try, there are notes: (NOTES) WORKING: sway + nvidia-beta · Issue #312 · nix-community/nixpkgs-wayland · GitHub

There’s some graphical corruption, but it’s a promising first start, though not sure how high to set expectations given … some attitudes, etc.

3 Likes

Hi @colemickens I saw that is possible to use the GBM_BACKENDS_PATH env var to indicates to Mesa where to load the GBM backend:

# without GBM_BACKENDS_PATH
❯ eglinfo
EGL client extensions string:
    EGL_EXT_platform_base EGL_EXT_device_base
    EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions
    EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11
    EGL_EXT_platform_device EGL_KHR_platform_wayland
    EGL_EXT_platform_wayland EGL_KHR_platform_gbm EGL_MESA_platform_gbm

MESA-LOADER: failed to open nouveau: /run/opengl-driver/lib/dri/nouveau_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)
failed to load driver: nouveau
MESA-LOADER: failed to open kms_swrast: /run/opengl-driver/lib/dri/kms_swrast_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)
failed to load driver: kms_swrast
MESA-LOADER: failed to open swrast: /run/opengl-driver/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/dri, suffix _dri)
failed to load swrast driver
GBM platform:
eglinfo: eglInitialize failed
...

# With GBM_BACKENDS_PATH
❯ mkdir /tmp/manolo
❯ ln -s /run/opengl-driver/lib/libnvidia-allocator.so  /tmp/manolo/nvidia-drm_gbm.so
EGL client extensions string:
    EGL_EXT_platform_base EGL_EXT_device_base
    EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions
    EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11
    EGL_EXT_platform_device EGL_KHR_platform_wayland
    EGL_EXT_platform_wayland EGL_KHR_platform_gbm EGL_MESA_platform_gbm

GBM platform:
EGL API version: 1.5
EGL vendor string: NVIDIA
EGL version string: 1.5
EGL client APIs: OpenGL_ES OpenGL
EGL extensions string:
    EGL_EXT_buffer_age EGL_EXT_client_sync
    EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import
    EGL_EXT_image_dma_buf_import_modifiers EGL_MESA_image_dma_buf_export
    EGL_EXT_output_base EGL_EXT_output_drm EGL_EXT_protected_content
    EGL_EXT_stream_consumer_egloutput EGL_EXT_stream_acquire_mode
    EGL_EXT_sync_reuse EGL_IMG_context_priority EGL_KHR_config_attribs
    EGL_KHR_create_context_no_error EGL_KHR_context_flush_control
    EGL_KHR_create_context EGL_KHR_fence_sync
    EGL_KHR_get_all_proc_addresses EGL_KHR_partial_update
    EGL_KHR_swap_buffers_with_damage EGL_KHR_no_config_context
    EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image
    EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image
    EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base
    EGL_KHR_reusable_sync EGL_KHR_stream EGL_KHR_stream_attrib
    EGL_KHR_stream_consumer_gltexture EGL_KHR_stream_cross_process_fd
    EGL_KHR_stream_fifo EGL_KHR_stream_producer_eglsurface
    EGL_KHR_surfaceless_context EGL_KHR_wait_sync EGL_NV_nvrm_fence_sync
    EGL_NV_quadruple_buffer EGL_NV_stream_consumer_eglimage
    EGL_NV_stream_cross_display EGL_NV_stream_cross_object
    EGL_NV_stream_cross_process EGL_NV_stream_cross_system
    EGL_NV_stream_dma EGL_NV_stream_flush EGL_NV_stream_metadata
    EGL_NV_stream_remote EGL_NV_stream_reset EGL_NV_stream_socket
    EGL_NV_stream_socket_inet EGL_NV_stream_socket_unix
    EGL_NV_stream_sync EGL_NV_stream_fifo_next
    EGL_NV_stream_fifo_synchronous EGL_NV_stream_consumer_gltexture_yuv
    EGL_NV_stream_attrib EGL_NV_stream_origin EGL_NV_system_time
    EGL_NV_output_drm_flip_event EGL_NV_triple_buffer
    EGL_WL_bind_wayland_display EGL_WL_wayland_eglstream
Configurations:
...

But I’m having problems with Xwayland, anything that uses OpenGL is not working in Xwayland. I think that is because Gnome-shell uses Eglstream and Xwayland tries to use GBM.

1 Like

My understanding is that for Xwayland-y stuff to work, you need a VERY recent commit of Xwayland.

I looked at trying to provide it in an overlay but… xorg has split up some stuff and added some deps and I’ve lost interest in trying to deal with it.

@colemickens Using Xwayland from this commit https://gitlab.freedesktop.org/xorg/xserver/-/commit/21e3dc3b5a576d38b549716bda0a6b34612e1f1f Xwayland works correctly. I’m using this overlay:

  xwayland = prev.xwayland.overrideAttrs (old: rec{
    version = "21.1.3";
    src = prev.fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "xorg";
      repo = "xserver";
      rev = "21e3dc3b5a576d38b549716bda0a6b34612e1f1f";
      sha256 = "sha256-i2jQY1I9JupbzqSn1VA5JDPi01nVA6m8FwVQ3ezIbnQ=";
    };
});
3 Likes

Oh, I didn’t realize it was in a tagged release, I thought it needed newer? I did just disable xwayland though, so I might try to avoid testing it.

It’s not a tagged release, it’s just the last commit in gitlab. I just used “21.1.3” as version because the last version release is “21.1.2”.

For anyone trying to get xwayland working with GBM: make sure to try nixos-unstable (works for me on 5f0194220f2402b06f7f79bba6351895facb5acb) rather than the nixpkgs-wayland overlay; something seems to have broken in Sway or wlroots such that it’s failing to register the wl_drm capability in the latest repo versions:

00:00:00.026 [INFO] [wlr] [render/wlr_renderer.c:238] Cannot get renderer DRM FD, disabling wl_drm
...
glamor: 'wl_drm' not supported
Missing Wayland requirements for glamor GBM backend
glamor: 'wl_eglstream_display' not supported
Missing Wayland requirements for glamor EGLStream backend
Failed to initialize glamor, falling back to sw

What are you running to test with?

Hardware-wise I’m running a 3070. On the software side I’ve been testing sway with

  1. the envvars in your repository (GBM_BACKEND, __GLX_VENDOR_LIBRARY_NAME, WLR_NO_HARDWARE_CURSORS)
  2. your recent nixpkgs patches from today
  3. GBM_BACKENDS_PATH pointing to /run/opengl-driver/lib/gbm
  4. xwayland built from the latest 21.1 branch of xserver

:slight_smile: Heh, I just meant what application? I’m kind of bad at this GL stuff, I’m not even sure what the basics are for validating every single piece underneath X11/Wayland, etc. I have another thing or two to try, but not even sure if I’m checking the right thing!

(edit: or is that just sway itself starting up and falling back to SW rendering? strange that I’m not seeing that if so)