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

Make Kludgine work on the web #49

Open
ecton opened this issue Mar 10, 2021 · 3 comments
Open

Make Kludgine work on the web #49

ecton opened this issue Mar 10, 2021 · 3 comments

Comments

@ecton
Copy link
Member

ecton commented Mar 10, 2021

This is an issue tracking the progress of making Kludgine run in a web browser using WASM. The current status is that running in a browser is not working at the moment. The current work-in-progress attempt at a simple example working can be seen here.

@ecton
Copy link
Member Author

ecton commented Mar 10, 2021

Today I made a significant amount of progress -- Kludgine now compiles to WASM successfully. Significant changes to easygpu were needed to support this, but the tl;dr is: Kludgine is not yet working in the browser. I wasn't expecting to have success today and am still thrilled with the progress made.

What is working:

  • Async runtime integration (caveats below)
  • winit event loop
  • wgpu initialization
  • shader loading
  • most of the engine's flow up until it draws a frame, which is a significant amount

What isn't working:

  • We use crossbeam for non-async channels and for a ShardedLock.
    • Atomics are available on nightly, which may offer a partial solution
    • Thread parking is the other half of the equation. I believe that in most cases where we're using these structures, thread parking shouldn't be an issue. However, we have to be careful and evaluate whatever replaces them. This is why the errors are being avoided right now -- I refactored the app startup code to not block, and since the structures are always free to unlock now, the situations where parking would need to happen are impossible in a single-threaded environment in wasm as I understand it.
  • While I was able to reduce the original error a bit, we can't create any uniform or index buffers per [WebGL] Cannot create INDEX buffer. gfx-rs/wgpu-rs#748

I'm very happy with the progress today. While nothing was drawn to the screen, I did succeed in getting a large portion of the engine runtime working -- for the engine to get to the location it did to crash, it means that the entire async app runtime is functioning correctly.

This issue is likely going to be tabled until the next wgpu update -- it's a goal for Cosmic Verge but it's not something that I need in the near future.

@ecton
Copy link
Member Author

ecton commented May 11, 2021

easygpu has been updated to wgpu-0.8.1. Progress has been made, shader code is executing. However, the shader isn't compatible with naga without enabling cross in wgpu. Rather than spend time debugging that, I'd rather figure out the better approach to embedding shaders (rust-gpu?) and then figure out what isn't working.

The other challenges that I knew I ran into last time but didn't address here:

  • Rgba8 vs Bgra8. The gl backend seems to only support Rgba8, but the optimal path is Bgra8 on the desktop.
  • BackendBit::PRIMARY doesn't pick gl in wasm. BackendBit::all() causes non-primary to be picked in some cases when a primary is available. We need to do something smarter here.

@ecton ecton moved this to Backburner in Beta Roadmap Oct 27, 2021
@ecton ecton moved this to Backburner in Beta Roadmap Oct 27, 2021
@ecton
Copy link
Member Author

ecton commented Jul 11, 2023

With the rewrite, this is now going to be blocked by khonsulabs/appit#1 in addition to some of the previous findings.

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

No branches or pull requests

1 participant