Skip to content
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

[Feature Request] Compile to WASM #5312

Open
SaadBazaz opened this issue Jun 15, 2023 · 8 comments
Open

[Feature Request] Compile to WASM #5312

SaadBazaz opened this issue Jun 15, 2023 · 8 comments

Comments

@SaadBazaz
Copy link

Overview

This is more of a discussion.

Is it possible to compile this to WASM? Maybe it could be used in the browser that way.

Smaller details

Perhaps enscripten?

Nature of request

Discussion / Feature Request

Why would this feature be useful?

Nintendo Switch on the browser

@jduncanator
Copy link
Contributor

jduncanator commented Jun 15, 2023

This is impossible. The feature set of even WebGPU (which is brand new and only available in Chrome at the moment) is no where near enough to emulate the Nintendo Switch's GPU, not to mention the memory allocation limitations of browsers, and the lack of JIT support.

@gdkchan
Copy link
Member

gdkchan commented Jun 15, 2023

What would be the benefit when you can run the emulator natively? It will run worse on the browser for sure and have many more limitations, so I don't think there's a compelling reason to attempt such a port.

@SaadBazaz
Copy link
Author

Just thought it'd be sick

@SaadBazaz
Copy link
Author

Jk. Building a website to host multiple consoles.

Switch would be a good addition.

@gdkchan
Copy link
Member

gdkchan commented Jun 15, 2023

I did not evaluate yet if such a port would be possible. It seems that there are a lot of limitations on WASM that would limit what the emulator can do. Last time I checked, WASM applications were also limited to 4GB of memory, which is rather low for an emulator like this. On top of that, there also .NET on WASM issues (it uses Mono runtime which is slower than CoreCLR, there is some NativeAOT support in the works using RyuJIT + LLVM, but I'm not sure how far along and usable it is right now).

For all the work it would take, I don't it is worth right now. It is significantly more work than porting to iOS, which is probably one of the most difficult native platforms that the emulator could be ported to right now. That time would probably be better spent making it run natively on other platforms.

Update: It seems it is possible to have 64-bit pointer and use more than 4GB of memory now with wasm64, but I did not check what the browser supports looks like.

@Perksey
Copy link

Perksey commented Nov 16, 2023

If System.Reflection.Emit is used only it will be possible to develop a prototype provided Ryujinx can be made compatible with OpenGLES 3.0. I developed a demo of Silk.NET running in the browser using Emscripten's OpenGLES 3.0 to WebGL translation layer.

Note however that .NET in WASM is always interpreted today. There is barely any support for running .NET in WASM in full AOT mode today as this causes linking issues in the tooling. I threw a software rasteriser at this interpreter out of curiousity and it's not the fastest thing in the world.

For more see https://silkblazordemo.perksey.com and https://perksey.com/blog/blazor-silkdotnet.html

@gdkchan
Copy link
Member

gdkchan commented Nov 16, 2023

We currently generate machine code directly on the JIT. We would need to add support for WASM code generation too. We could technically add a GLES 3.0 backend, but it would be so limited that it's probably not worth the effort.

@hez2010
Copy link

hez2010 commented Dec 7, 2023

Last time I checked, WASM applications were also limited to 4GB of memory

Actually in my test the memory you can allocate is around 2GB per tab, which makes it impossible to run a switch enumerator on the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants