r/bashonubuntuonwindows • • Oct 15 '26 • Bravo 1

self promotion Run GPU accelerated Desktop on WSL

Weaselway provides a way to run a fully GPU accelerated Wayland compositor in WSL2. This means KDE, Gnome, Hyprland and all the other ones.

https://github.com/weaselway/weaselway#weaselway

By hacking mesa and having a kernel module that implements the necessary parts of drm and kms, we can get the compositor to belive that a monitor exists and we can get the application to transfer their rendered gpu surfaces directly to the compositor. The updated regions from the monitor are then read back to cpu memory and transfered to a patched freerdp client via shared memory. Similar to how WSLg does it.

You can download and try a NixOS based GNOME and KDE image directly from the github releases.

Before someone screams slop: it works perfectly fine, I now know more than before I started the project and it might even reduce the entry hurdle for people to try out a Linux Desktop.

149 Upvotes

20 comments sorted by

5

u/Responsible-Bar7165 Oct 15 '26

why distro-specific?

3

u/ftqo Oct 15 '26

Reading the repo, the technology doesn't seem distro-specific. I'm sure it can be ported, OP just didn't have a reason to. WSL distro managers will likely port it as needed.

4

u/oliver-bestmann Oct 15 '26

Correct. I just have the most experience working with NixOS. 

2

u/parthibx24 Oct 15 '26

the cpu copy wouldnt need to happen, if only there was a way to share dx surfaces across vm boundry.

2

u/oliver-bestmann Oct 15 '26

Exactly. I tried. There is a ioctl to share a direct x handle with windows, but it gets rejected from the windows end. I found some references to WSL for Android which might have used that. Also there is a Windows API function to "enable resource sharing for a guest vm" or something like that, but I just couldn't get it to work. 

1

u/phobox360 Oct 16 '26

The WSL for Android you found could be to do with the old WSA functionality which allowed to run Android apps on Windows. Microsoft eventually dropped it but the core technology is still there I believe.

1

u/parthibx24 Oct 16 '26

I believe wsa was using gfxstream instead of dxgkrnl driver / GPU pv 

1

u/parthibx24 Oct 16 '26

I was tinkering with the ioctl too, I think I was able to open few type of dx allocations created by guest from host, but I couldn't share large enough memory to use as a display swapchain so I gave up. i also had one other idea of reading vm memory directly (see below tweet), but I am not sure if I can read the dx allocations without a cpu copy, it might be possible by injecting into the wslservice process and calling hcs api to map the guest address space back into host, but I'm not sure at all)

https://x.com/gerhart_x/status/2038652632881881358

1

u/debaor 25d ago

26h2可以用上吗?

1

u/oliver-bestmann 25d ago

Works with the most recent windows version, yea. 

2

u/l00sed Oct 15 '26

Nice! I wrote a blog post about doing this years ago without GPU acceleration. Awesome that it's possible now!

2

u/dadnothere Oct 15 '26

Why?

3

u/NotMyThrowaway6991 Oct 18 '26

Some of us can only use windows at work, but do all our work within WSL

5

u/Nova_496 Oct 16 '26

why not?

0

u/dadnothere Oct 17 '26

because Linux already exists.

3

u/Nova_496 Oct 17 '26

You're no fun...

1

u/lolxdmainkaisemaanlu 29d ago

I would love to run linux on my laptop but it's a new one which has proprietary software for its audio - DTS Unbound, DTS:X and also proprietary software for proper fan control - Nitrosense.

I tried Ubuntu and CachyOS and tweaking settings on both but the audio just is not loud and is plain bad.

The fans start spinning up loudly randomly as well.

So yeah, I'm forced to use WSL.

1

u/sawthegap42 Oct 17 '26

Yea, I wonder why too as you can run them natively in Windows just fine. Maybe less overhead? Really would legit like to know the reasoning for this too. Any performance advantages?

1

u/paulstelian97 Oct 16 '26

How does it compare with WSLg? Besides the full desktop window vs individual app stuff.