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

Is it possible to use WebGPU? #58

Open
BeezBumba opened this issue Aug 5, 2024 · 22 comments
Open

Is it possible to use WebGPU? #58

BeezBumba opened this issue Aug 5, 2024 · 22 comments

Comments

@BeezBumba
Copy link

I found an article that talks about the conversion from WebGL to WebGPU. WebGPU is said to have compute shaders and geometry shaders. Geometry shaders are what the emulator needs because, with them, every triangle has a shader that finds the right pixel colors. This explains why there is no color in the images. I posted this in a new issue since the other one was pretty long.
Screenshot 2024-06-13 175229
Screenshot 2024-06-13 174826

@BeezBumba
Copy link
Author

Sorry I forgot the actual link. https://developer.chrome.com/blog/from-webgl-to-webgpu

@BeezBumba
Copy link
Author

The WebGPU using a different shading language than WebGL, but the concepts are fairly the same.

@BeezBumba
Copy link
Author

I saw shader_frag and shader_vert files in the code directory. WebGL can't support geometry shaders. so could there have been a shader_geo.hlsl file? That might be easier if it's possible.

@nbarkhina
Copy link
Owner

those shaders are just used for the emulator overlay menu - "New Game, Save State, etc..." it's not used by the emulator itself

@BeezBumba
Copy link
Author

So what is your option on the whole conversion? Do you think it's possible at all?

@nbarkhina
Copy link
Owner

My knowledge of shaders unfortunately is quite basic - so I would really not know

@BeezBumba
Copy link
Author

Its not to much about shaders. It's just the conversion from WebGL to WebGPU.

@BeezBumba
Copy link
Author

Well can I ask what spots you changed so the emulator uses webGL?

@BeezBumba
Copy link
Author

and the spots where you are using the webgl context

@nbarkhina
Copy link
Owner

The emulator uses WebGL because that is what emscripten translates to when compiling from OpenGL. See this article -

https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html

Here in the code is where it sets up the OpenGL Context -

int WindowFlags = SDL_WINDOW_OPENGL;

So I don't actually use any WebGL commands, it's just straight up OpenGL which the compiler at a lower level turns into WebGL. I'm not sure how you would get it to use something else, the emulator would have to be rewritten to use something other than OpenGL - which in Desktop could use different backends (Vulkan, Direct3D, etc...) but on the web you don't have those options. So don't really think this is possible in my opinion.

@BeezBumba
Copy link
Author

Do you know how to disable the emulator emulating lag?

@BeezBumba
Copy link
Author

Emulators do that just for the pure accuracy.

@nbarkhina
Copy link
Owner

I don't believe there is any lag, the main tool for maintaining correct framerate is by syncing to the refresh rate of the monitor. this is done using the emscripten_set_main_loop() function:

emscripten_set_main_loop(mainLoop, 0, 0);

you can read about it here

https://emscripten.org/docs/api_reference/emscripten.h.html

one thing you can experiment with is setting the variable doubleSpeed to true here -

bool doubleSpeed = false;

that will attempt to run 2 frames for every 1 frame of time, however on slow machines it won't be able to keep up and won't yield any benefit.

@BeezBumba
Copy link
Author

I asked this because some games on Ipad are a lot better now with vertex buffer objects. but that update still did something with safari.

@BeezBumba
Copy link
Author

new update: the parallel graphics plugin is actually the inaccurate one. I tested it on retroarch and it gave me the same problems.

@BeezBumba
Copy link
Author

BeezBumba commented Sep 19, 2024

The parallel one is the only one i could find that was open source.

@BeezBumba
Copy link
Author

I found this one on gitlab https://gitlab.com/parallel-launcher/parallel-n64

@nbarkhina
Copy link
Owner

interesting, ok good to know it wasn't something specific to the web version.

@BeezBumba
Copy link
Author

It says it’s used specifically for the parallel launcher and that one works fine. So should you try it?

@nbarkhina
Copy link
Owner

I used the one that was already built into the parallel core in retroarch. Not sure how this one is different or if it's feasible to integrate it but if I have time I'll take a look

@BeezBumba
Copy link
Author

Should I add anything for the new mupen64plus-video-gliden64 plugin code wise? Wondering what this video plugin might offer.

@nbarkhina
Copy link
Owner

You can try experimenting with if you like, I unfortunately have not had time to look at it been busy with work

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

2 participants