-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add updated WSL2 Instructions #5040
Conversation
These are much more helpful directions. Thank you! Note: this came from helping in #5013. |
If I'm not mistaken, I believe these instructions are only relevant to wsl2 on windows 10. On windows 11 it should be able to use wslg which is better supported for graphics through wsl. In other words, this section should probably link to https://github.com/microsoft/wslg to mention it's a possible option that doesn't need cross compiling. |
Unfortunately no, WSLg has the exact same limitation as described, you cannot use vulkan with it yet, and bevy can't use opengl. |
Ah, right, I haven't used wsl in a while so I didn't really follow up that space. I stopped using it around when wslg was announced. |
Wish there was a way to go about this without cross compilation but I just don't see it happening until bevy supports opengl. WSL2 supporting vulkan seems pretty far off, assuming it will ever support it in the first place. |
you can use xwin to compile to windows msvc using xwin from within wsl, (not cargo-xwin, they do similar stuff but not this one) this doesnt require mingw to exist on windows to run, and can be statically linked so users dont need any other libraries
|
I've just started playing around with Bevy today, and got it setup with WSL2 (Ubuntu) on Windows 10. My laptop has I could be misunderstanding something, but I wanted to say that I got the breakout example mentioned in the Bevy Getting Started guide working without running any X server. I'm a total Rust and Bevy beginner, so I could be missing something.😊But... it seems to work! No X server needed. The command I ran to launch the breakout example, copied from the guide, was: I believe this means the existing WSLg version works with Bevy? I don't see anywhere where this is documented, so I thought it was worth pointing out. However, I could be missing the point that @hecksadecimal brought up:
Before I get into all the details, the trick that got it working for me that wasn't documented was installing the I'll document my steps/setup here.I first started by following the steps on Installing Linux dependencies and installing the below packages. Not sure if I needed to install the Wayland packages. I guess I could test that. sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev
# If using Wayland, you will also need to install
sudo apt-get install libwayland-dev libxkbcommon-dev At this point, I did NOT install Then I followed the steps linked in the guide WSL documentation to set up graphics and audio. At this point, running I followed the steps under # Add the PPA to your system and update. I doubt this is necessary to get things working, but I was just following the guide.
sudo add-apt-repository ppa:oibaf/graphics-drivers
sudo apt update
sudo apt upgrade
sudo apt install libvulkan1 mesa-vulkan-drivers vulkan-utils
# The vulkan-utils package couldn't be found, so I ran the below command instead
sudo apt install libvulkan1 mesa-vulkan-drivers Then, I ran My DISPLAY variable was set to I also removed the SummaryWithout any X server running like VcXsrv, I am able to run a graphical Bevy application on WSL2 (Ubuntu) on Windows 10 using an AMD graphics card (integrated graphics). This leads me to believe that WSLg works pretty well with Bevy. Maybe it doesn't work with everything? I am not certain about OpenGL and Vulkan, but I wasn't able to find anyone else mentioning this. Maybe this can be worked into the guide? Specifically the part about needing to install the I'm interested to hear what others say and I hope this was helpful! |
I managed to get Vulkan working with WSL2 on Windows 11, but I had to clone mesa, build it from source with the experimental Microsoft Dzn driver for Vulkan over D3D12, and then run my bevy app with:
Full flow: sudo apt-get install build-essential git
sudo apt-get build-dep mesa
# If the second command yields `E: You must put some 'deb-src' URIs in your sources.list`,
# edit your "/etc/apt/sources.list" and remove '#' manually (or with your favorite editing tool) from deb-src URIs.
# Then, save the file and run `sudo apt update && sudo apt upgrade`.
# NOTE: you should probably save a backup of "/etc/apt/sources.list" before overriding it
git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa
# The next command will build Mesa from source in "./mesa/build" with the experimental Dzn driver
# and install it in "/usr/local/share/vulkan/icd.d". To install to a local folder,
# try running with `--prefix=$HOME/wsl-dev` (full disclosure, I haven't tried this option)
meson setup ./build -Dvulkan-drivers=microsoft-experimental && cd build && sudo ninja install
# Now, with everything in place, we can run our bevy app with Vulkan on WSL2!
export WGPU_BACKEND=vulkan
export VK_ICD_FILENAMES=/usr/local/share/vulkan/icd.d/dzn_icd.x86_64.json
cargo run
# Or simply
WGPU_BACKEND=vulkan VK_ICD_FILENAMES=/usr/local/share/vulkan/icd.d/dzn_icd.x86_64.json cargo run |
I was experimenting with this, today, and I can confirm that the notes contributed by @kwilson33 are accurate … … and it is possible to get Bevy's examples (well, In brief, starting from a fresh Ubuntu 22.10 environment under the WSL, this almost suffices: sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev \
libwayland-dev libxkbcommon-dev \
libvulkan1 mesa-vulkan-drivers But it does not. Some prerequisite is missing. I know where to go, next, however: Microsoft suggest one might run sudo apt install gedit -y
gedit ~/.bashrc … and AND after So, great. It works. Everything from (It also works after a Next StepsMy next line of investigation will be to try out the approach proposed last week by @benny-n and to look deeper into precisely what is coming in with Some VersionsHere are some version numbers and diagnostic outputs from my experiment, today: Bevy was at revision
|
I think it's also important to note that from my observations Vulkan uses llvmpipe as the default driver when rendering in WSL2, therefore even though it works out of the box without any PPA as shown in the comment above, it renders from the CPU's integrated graphics instead of using the actual graphics card, or at least for me it did. @stephenmartindale, can you confirm this? I tried making it render through the GPU by playing with env variables and config files, but eventually the only thing that worked was cloning mesa from source like I explained in this comment |
Yeah. I can confirm what @benny-n says: my experiment was using Current OpinionsHaving done some further experiments, my current opinion is that my original cross-compilation approach that used Ignoring the actual execution from the host file-system, advantages of cross-compilation with
Verdict on this Documentation ChangePersonally, I would judge that the best thing to do with the Bevy documentation – as it stands – is to extirpate all mention of W.S.L. 2 from The section certainly does not belong there as a sub-section of the Ubuntu instructions because it pertains to Windows – not Ubuntu – and, even on Windows, should theoretically be distro.-agnostic in the most ideal case. Instead, perhaps a document specifically presenting a brief summary of possible approaches ( That document could provide comprehensive instructions for any approaches that "just work" and do not incur undesirable compromises like the use of CPU rendering (And I would argue that, today, there aren't any that truly fit this mandate.) or link out to other sources of long-form material or perhaps GitHub gists that provide more detailed walkthroughs – presumably including discussions of their compromises. At some point, I will get around to cleaning up my own scripts and approach and I've even a How about it? I have time and have done a fair bit of reading and experimentation on the subject so I could write up a "summary of approaches"-style thing, to supersede this MR, if that would be welcomed. |
I have opened #8383 with a draft summary-of-approaches document, based on discussions, here. It's a first-draft (I haven't even done a grammar pass on it) but please feel free to give me some feedback. Specifically, I'd like to know:
Also, to me, it seems obvious why such a document SHOULD exist (There's clearly interest in using the WSL 2 as one's dev. environment.) but do I need to spell that out in the merge request, anyway, as some kind of motivation section? |
This should be fine: it's fairly self-evident and this thread is linked for those who really need to know more. |
Hi all, inspired by this thread I am experimenting a bit with WSLg as well. It seems for me that apart form the dependencies mentioned by @stephenmartindale
only one extra was needed to run:
Although I am not on a clean install. (didn't use the WSLg here before though at all). The sound is not working for me yet. But it also was not working when I tried the Probably I should soon try this on a clean install again to confirm any missing libraries |
Closing as part of backlog cleanup: while it seems the comments here generated some useful tips that should still show up on Bevy repo searches, the original PR is no longer likely to be accurate/relevant. |
Objective
Solution