Add WebGL support to web builds#52
Merged
melody-rs merged 9 commits intoAstrabit-ST:devfrom Nov 23, 2023
Merged
Conversation
melody-rs
approved these changes
Oct 16, 2023
Member
|
@somedevfox do you think you could add an autobuild action to luminol-website? |
wgpu doesn't allow supporting both WebGL and WebGPU in the same binary yet so we have to decide at compile time which one to use. (cherry picked from commit ac4d0d9)
(cherry picked from commit 1f6f234)
This is to avoid clogging the console with useless messages. (cherry picked from commit cc857b2)
It's not supported in WebGL and probably also not supported in OpenGL. (cherry picked from commit f951d14)
(cherry picked from commit 92e9aca)
(cherry picked from commit 858fcb0)
(cherry picked from commit 4cf6193)
Firefox Nightly apparently only supports WebGPU on the main thread and not in a web worker where we need it, so the test for WebGPU support now runs in a worker thread. (cherry picked from commit 5d6bbb2)
(cherry picked from commit d9ec1b6)
melody-rs
approved these changes
Nov 23, 2023
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wgpu doesn't have support yet for having both WebGPU and WebGL support in the same binary (see gfx-rs/wgpu#2804) so I added the WebGL support behind a
webglCargo feature. To build with WebGL support using Trunk, add--features webglto the Trunk command.I also added a feature detection for WebGPU support in assets/main.js, which will always load from luminol.js and luminol_bg.wasm if WebGPU is available, and will load from luminol_webgl.js and luminol_webgl_bg.wasm if WebGPU is not supported. If luminol_webgl.js is not detected on the server, it will use luminol.js and luminol_bg.wasm even if WebGPU is not supported so that you can test with
trunk serve --features webglwithout having to rename the output files.If the web autobuild (once we have one) needs to build with both WebGPU and WebGL support, it can first build for WebGL, then move luminol.js and luminol_bg.wasm to a temporary location, then build for WebGPU and finally move those files back after renaming them to luminol_webgl.js and luminol_webgl_bg.wasm.