Repository navigation
sokol: a WebGPU build of the browser player - #3096
Merged
Merged
Conversation
The browser's other backend, behind BUILD_SOKOL_WGPU, off by default: the flag selects SOKOL_WGPU in place of SOKOL_GLES3 and links the emdawnwebgpu port, because the two backends cannot share a build — the port replaces the WebGL2 linker settings, and sokol takes exactly one backend at compile time. The engine needs nothing: the studio and the core never touch gl*, and the renderer speaks sg_* only, so what a build asks for is the layer and the shaders, which have carried WGSL beside GLSL and MSL since they were generated with --ifdef. Two things the port costs, both in cmake/sokol.cmake: it carries the header every C file includes, so it goes on the compile flags as well as the link line, and it brings C++ of its own into a C link, which moves the stack exports out of the default set — unnamed, the universal build dies in callMain with "__emscripten_stack_alloc is not a function". The CI gets a job of its own, html-webgpu, rather than a second set of passes inside html: a WebGPU-only break stops its own artifact and nothing else, where inside html it would keep every GLES3 player off the dev instance. It builds the same fifteen per-language players and the universal one with the flag on, checks each wasm for the editors and each loader for the WebGPU shim, and uploads tic80-html-webgpu in the layout the site's deploy reads. Co-Authored-By: Claude Code <noreply@anthropic.com>
…lag cannot lie A fresh review of the diff found the CI job producing a player that cannot start, and three smaller things: - The universal WebGPU build did not set -DTIC80_TARGET, so its loader asked for tic80.wasm while the job renamed the wasm to tic80webgpu.wasm. The name is not decoration: the target decides what the loader calls locateFile() with, and the site's deploy checks for the pair the name produces. The step now builds tic80webgpu and copies both files under their own names. - The check step reads the loader's own wasm name back and compares it with the file beside it, which is what catches a rename on the way out — the markers and the file list cannot see it, because the wasm next to tic80.js is simply not the one it asks for. - BUILD_SOKOL_WGPU asked for on a platform where it cannot take is now a FATAL_ERROR rather than a build that quietly keeps the other backend. The guard sits beside the SDL/SOKOL one. - The export list stays where it was: naming the stack exports keeps them in the module, so moving them to the shared line grew every GLES3 build. They are the WebGPU branch's, and a GLES3 build of the same commit is byte-identical with and without this change. Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
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.
Adds a WebGPU backend for the browser build, behind
BUILD_SOKOL_WGPU(off by default), and a CI job that builds the set the site serves.The engine needed nothing: the studio and the core never touch
gl*, the renderer speakssg_*only, and the shaders have carried WGSL beside GLSL and MSL since they were generated with--ifdef. What the build asks for is the layer —SOKOL_WGPUin place ofSOKOL_GLES3— and theemdawnwebgpuport on the compile and link lines.The two backends cannot share a build: the port replaces the WebGL2 linker settings, and sokol takes exactly one backend at compile time.
What's in it
cmake/sokol.cmake: the backend switch and the link flags. Two costs of the port are there: it carries the header every C file includes, so it goes on the compile flags too; and it brings C++ of its own into a C link, so-sDEFAULT_TO_CXXand the stack exports are named — unnamed, the universal build dies incallMainwith__emscripten_stack_alloc is not a function. The exports live in the WebGPU branch only; naming them keeps the three in the module, which a GLES3 build drops unused.CMakeLists.txt: the option, and aFATAL_ERRORfor asking for it where it cannot take (not Emscripten, or without sokol) rather than a build that quietly keeps the other backend..github/workflows/build.yml: a job of its own,html-webgpu— 15 per-language players and the universal one, staged underbuild/players-webgpu/and uploaded astic80-html-webgpu. It is separate fromhtmlso that a WebGPU-only break stops its own artifact and nothing else, where insidehtmlit would keep every GLES3 player off the dev instance.The wasm carries the name its loader asks for: the per-language pairs are
tic80.js+tic80<lang>.wasm, the universal one istic80.js+tic80webgpu.wasm, and-DTIC80_TARGET=tic80webgpuis what makes the loader ask for that name.Verified
inert.js,inert.wasm).The site serves these through its own deploy (nesbox/tic80-server); this PR only builds and uploads the set.
🤖 Generated with Claude Code