~/Simon's Blog ❯

Nvidia and SwayWM - Take Two

If you are here for installation instructions, skip to the bottom of the page.

The last time that I tried running Sway — An i3-Compatible Wayland compositor — on my Nvidia-GPU, things weren't going too well, even though they did sort of work: Artifacts, Missing Vulkan dependencies, XWayland Hardware Acceleration, the inability to take screenshots...

Though, I have since come back and tried again on Void Linux, and am now documentation my second experience with properly running a Wayland Compositor on Nvidia's hardware and drivers.

The Good

There is actually a lot of things that I learned along the way of trying again, which I was able to resolve or at least get more info about. For instance, I learned that MR #3550 actually allows me to take screenshots and record my screen when using the Vulkan wlroots backend, and upon building wlroots with this MR, I was able to do so just fine, albeit with some performance degradation compared to e.g OBS Studio on X.Org. Another thing that worked out of the box was Hardware Accelerated XWayland. I can only assume that this commit was the fix in question, but this doesn't actually mention XWayland, so I cannot be sure. I was also able to get some unrelated things, like Nwg-Panel working after working out a lot of the quirks, and GTK themes also aren't a problem anymore now that I am running on a clean installation. Surprisingly, some games (notably ULTRAKILL) actually ran BETTER through XWayland than native X11/X.org 🤔

Overall, even though I did have to apply a patch to wlroots and debug a little, it was a MUCH better experience than last time.

Though...

It isn't all butterflies and roses, there is still some issues.

For instance, stability is — for lack of a better term — dogshit compared to X11. Maybe this is just coincidental timing, but when multitasking a lot, and then opening up a game, after some minutes it just goes...poof...lockup. Whilst this is annoying, it seems to have fixed itself after a bit of usage too, so, not sure what this is or was ¯\_(ツ)_/¯ Additionally, altough I don't think this is Sway's fault, some (by default) XWayland applications, ESPECIALLY those which usually use Electron like Discord have quite buggy visuals, if any at all.

For now, I will keep you all posted on anything I find during my usage, and update this post accordingly!


Extra: Setting this entire thing up

Of course, many of you are going to wonder how they can make this work on their systems, and I am more than happy to tell you exactly how to do that!

Note that you will need a GPU which can run driver version 495 or above.

  1. Make sure you're running a distribution with relatively new packages. Anything that Void Linux ships or newer should suffice.
  2. Install your Wayland-Compositor (preferably Sway for testing purposes). Setting your compositor up is going to be your task in terms of dependencies and config files.
  3. Compile wlroots with merge request 3550 This patch is to allow screenshots and screen recording on the Vulkan renderer. This will be useless if you're already running a build of wlroots with this patch.
  4. Set up your environment with environment variables from here This is required for Sway to work properly on Nvidia's proprietary drivers.
  5. Launch Sway using sway --unsupported-gpu. The way you do this doesn't matter as long as you followed step 4. I like to use emptty for my environment, audio, and running sway.
  6. Enjoy! Everything should be mostly working now, if you have any more issues, contact me on Telegram and I might consider helping you.

Thanks for reading! I wish you a good rest of the day, evening, night, or whatever other time you're reading this!

#linux #nvidia #sway #wayland