feat: add WebGPU (wgpu) rendering backend (Linux x64)#237
Conversation
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, ... |
You know you have write rights? Whenever you are ready and think it is done 😉 |
Haha yes. 😄 |
|
@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 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! |
|
Thanks for working on the amalgam usecase, I have somewhat let that part slide a bit ❤️ |
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>
Launch Checklist
mbgl::*API plus this crate's own bridge code.webgpuCI lane that links and renders against the released amalgam.GeoJson::to_json_stringis temporarily removed (see below).CHANGELOG.mdentry — skipped; this is an experimental PR (happy to add before merge).What this does
Adds a
webgpufeature 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: aWebGPUgraphics API behind thewebgpufeature, selecting the...-wgpu.aamalgam and linking the system libraries it pulls in (uv,GL,X11).mapbox::geojson::parseto the publicmbgl::style::conversion::parseGeoJSON.webgpulane (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-mbglsymbol. Somapbox::geojson::parse/stringifyare hidden, and the amalgam will never exportmapbox::*. 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 usembgl/style/conversion/geojson.hppinstead.parseGeoJSONis public (mbgl::*, exported), so the bridge links cleanly against any backend's amalgam, with no vendoring.About
to_json_string/stringifyThese were only used in tests. MapLibre Native currently exposes no public
mbgl::*GeoJSON serializer, so I commented them out (withTEMP(webgpu amalgam)markers, trivial to restore). I intend to open a small separate PR to maplibre/maplibre-native adding a publicmbglGeoJSON stringify; once that ships, I will restoreto_json_stringcleanly.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.aand render with 0 unresolvedwgpu*symbols.Related