Skip to content

feat: add WebGPU (wgpu) rendering backend (Linux x64)#237

Closed
yuiseki wants to merge 3 commits into
maplibre:mainfrom
yuiseki:add-webgpu-backend
Closed

feat: add WebGPU (wgpu) rendering backend (Linux x64)#237
yuiseki wants to merge 3 commits into
maplibre:mainfrom
yuiseki:add-webgpu-backend

Conversation

@yuiseki

@yuiseki yuiseki commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Launch Checklist

  • Confirm changes do not include backports from Mapbox projects — this PR only uses MapLibre Native's public mbgl::* API plus this crate's own bridge code.
  • Briefly describe the changes (below).
  • Link to related issues (below).
  • Before/after visuals — N/A, no visual change; this adds a headless backend.
  • Write tests — adds a webgpu CI lane that links and renders against the released amalgam.
  • Document changes to public APIs — GeoJson::to_json_string is temporarily removed (see below).
  • Post benchmark scores — N/A.
  • Add a CHANGELOG.md entry — skipped; this is an experimental PR (happy to add before merge).

What this does

Adds a webgpu feature that renders through MapLibre Native's wgpu-native backend, consumed as the prebuilt Linux x64 core amalgam (the other targets do not ship a wgpu amalgam yet).

Background: I added the upstream support for producing that amalgam in maplibre/maplibre-native#4220 (merged). That alone turned out not to be enough to consume it from here, so this PR adds the downstream pieces:

  • build.rs: a WebGPU graphics API behind the webgpu feature, selecting the ...-wgpu.a amalgam and linking the system libraries it pulls in (uv, GL, X11).
  • GeoJSON bridge: switch from mapbox::geojson::parse to the public mbgl::style::conversion::parseGeoJSON.
  • CI: a Linux x64 webgpu lane (library + integration tests) that links and renders against the released amalgam.

Why the GeoJSON change (the main point)

The core amalgam is built with armerge --keep-symbols 'mbgl.*', which intentionally localizes every non-mbgl symbol. So mapbox::geojson::parse / stringify are hidden, and the amalgam will never export mapbox::*. Reaching into the bundled geojson-cpp from this crate therefore cannot link against the precompiled amalgam.

So I would like to propose: stop depending on mapbox/geojson.hpp, and use mbgl/style/conversion/geojson.hpp instead. parseGeoJSON is public (mbgl::*, exported), so the bridge links cleanly against any backend's amalgam, with no vendoring.

About to_json_string / stringify

These were only used in tests. MapLibre Native currently exposes no public mbgl::* GeoJSON serializer, so I commented them out (with TEMP(webgpu amalgam) markers, trivial to restore). I intend to open a small separate PR to maplibre/maplibre-native adding a public mbgl GeoJSON stringify; once that ships, I will restore to_json_string cleanly.

No rush to merge

This is an experimental PR, and it is totally fine to hold off merging. The first goal is to show, via this PR's GitHub Actions, that the WebGPU path links and renders. I am happy to discuss the approach (especially the GeoJSON direction) before anything lands.

Validation

Verified locally on Linux x64 (NVIDIA + llvmpipe): the library and integration tests link against libmaplibre-native-core-amalgam-linux-x64-wgpu.a and render with 0 unresolved wgpu* symbols.

Related

@CommanderStorm

Copy link
Copy Markdown
Member

@Murmele @yuiseki would it be possible to collaborate? 😉
Lets get the following PR merged, or is this approach better?

@Murmele

Murmele commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

@Murmele @yuiseki would it be possible to collaborate? 😉 Lets get the following PR merged, or is this approach better?

* [feat: migrate continous mode to Wgpu textures #143](https://github.com/maplibre/maplibre-native-rs/pull/143)

My PR handles the case that you can use the wgpu textures within rust. With this PR you still have to get the texture down on the CPU and then reusing it. Basically same as we have right now for vulkan, ...
I don't have anything against merging mine first ^^

@CommanderStorm

Copy link
Copy Markdown
Member

I don't have anything against merging mine first ^^

You know you have write rights? Whenever you are ready and think it is done 😉

@Murmele

Murmele commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

I don't have anything against merging mine first ^^

You know you have write rights? Whenever you are ready and think it is done 😉

Haha yes. 😄

@yuiseki

yuiseki commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@CommanderStorm @Murmele Thank you both for your comments! And of course I’d love to collaborate!

Those comments helped me catch up on the context.

I understood @Murmele has done a great job about wgpu in #143 , awesome!
I think #143 is the correct answer for zero-copy.

I think amalgam is still useful for headless applications that don't require building from source.

Now this PR has big conflicts 😆 , so I will close this and re-open new PR that focus consume amalgam from current main branch 👍

Thanks again for your comments! I think I’m on the right track now!

@yuiseki yuiseki closed this Jun 15, 2026
@CommanderStorm

Copy link
Copy Markdown
Member

Thanks for working on the amalgam usecase, I have somewhat let that part slide a bit ❤️

ciscorn added a commit that referenced this pull request Jun 19, 2026
I found `MLN_PRECOMPILE=1` builds are currently broken, but this was not
caught by CI. This PR updates the precompiled MapLibre Native release
and fixes the link setup:

(Some of these changes are based on #237 by @yuiseki - thanks!)

- Update the precompiled MLN release to the [latest core
release](https://github.com/maplibre/maplibre-native/releases/tag/core-fa8a9c8e3261ce64940127aecc1d52f540c21c57)
- Restore the vendored bridge include path
- Link required system libraries for precompiled builds (`libuv` on
non-Apple targets, `sqlite3` on Apple targets)
- Avoid direct `mapbox::geojson` symbols from the Rust bridge, since
they are hidden in the amalgam
- Comment out now-unused `GeoJson::to_json_string()` - no public mbgl
API yet maplibre/maplibre-native#4345
- Add precompiled CI coverage to prevent regressions

Note: macOS still does not work with `MLN_PRECOMPILE=1` because the
amalgam (built with `armerge --keep-symbols 'mbgl.*'`) also hides the
C++ exception RTTI symbols.

---------

Co-authored-by: yuiseki <yui.matsumura@geolonia.com>
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