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

Finalize WASM and zig-0.12.0 support (see #50) #51

Merged
merged 44 commits into from
Jan 17, 2024
Merged

Conversation

floooh
Copy link
Owner

@floooh floooh commented Jan 12, 2024

  • add WebGL2 and WebGPU shaders
  • fix WebGPU support
  • Emscripten linker step: automatically scan for library dependencies instead of taking a single hardwired lib_sokol
  • Emscripten linker step: use -Oz for ReleaseSmall and -O3 for ReleaseFast
  • Emscripten linker step: allow passing additional args as string slice
  • update readme
  • mention -sUSE_OFFSET_CONVERTER requirement for Emscripten linker option when using Zig allocators
  • fix pacman.zig
  • fix kc85.zig
  • add shell.html file
  • fix wasm-emscripten on Windows (detection of Windows was broken before emsdk script)
  • run emsc install+activate only once
  • final test on macOS
  • final test on Linux
  • final test on Windows

...not this time, but should be considered for an update

@floooh
Copy link
Owner Author

floooh commented Jan 12, 2024

@kassane fyi 👆(PR into master to keep track of what I'm adding... e.g. the black screen samples are working now...

@kassane
Copy link
Contributor

kassane commented Jan 12, 2024

@kassane fyi 👆(PR into master to keep track of what I'm adding... e.g. the black screen samples are working now...

Amazing!
image

@floooh
Copy link
Owner Author

floooh commented Jan 12, 2024

Now with a shell.html which fills the whole client area :)

image

- only run emsdk setup once
- move emsdk linker and run steps into separate functions
- remove stuff that's only needed when not using package manager
- some general structural cleanup
@kassane kassane mentioned this pull request Jan 4, 2024
@floooh
Copy link
Owner Author

floooh commented Jan 15, 2024

KC85 emulator running in browser (wasn't supported before, but quite trivial now):

Screenshot 2024-01-15 at 16 39 34

@kassane
Copy link
Contributor

kassane commented Jan 15, 2024

On: a2e4b46

Does this do a recursive dependency lookup on libsokol?
For example, if you had any examples that used cimgui, would it link it directly to sokol so that emcc would pull both of them?

@floooh
Copy link
Owner Author

floooh commented Jan 15, 2024

The idea is that one could add additional C library compile steps (like for instance cimgui) to the top-level module (same as happens with the sokol C library), and the Emscripten linker step would pick those up automatically.

I don't actually know whether it's fully recursive, but for the cimgui case, I wouldn't add that dependency to the sokol module, but to the 'Zig main module' (obviously that loop which scans for dependencies isn't recursive, but I don't know if the 'dependency iterator' does that for me... from looking around in the stdlib where this dependency iterator is used, all places I saw don't have any sort of 'explicit recursion', but still seem to walk over all dependencies).

I haven't actually tested it though, only made sure that it discovers the sokol library dependency.

@floooh floooh merged commit 2edeb6f into master Jan 17, 2024
6 checks passed
@floooh floooh deleted the zig-0.12.0-wasm branch January 17, 2024 18:11
@floooh
Copy link
Owner Author

floooh commented Jan 17, 2024

Whoop whoop!

@kkukshtel
Copy link

@floooh Been tracing through these changes as I look to move my own sokol-based engine to work with wasm. If the intention is that sokol is being comsumed as a wasm module directly (DLL-like), is it sufficient to use wasm32-freestanding or does sokol always require the intermediate emscripten step (and hence the build.zig template here) for the EM_JS() stuff you mentioned in another thread?

@floooh
Copy link
Owner Author

floooh commented Feb 10, 2024

@kkukshtel yeah, you'll need to compile the sokol C library as wasm32-emscripten, and link the final executable (or WASM 'DLL' I guess) with the Emscripten linker.

Decoupling the sokol headers from Emscripten is currently not feasable unfortunately (since even without the use of EM_JS, it would require writing our own browser API shims and/or parts of the Emscripten helper functions).

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

Successfully merging this pull request may close these issues.

3 participants