Add multiBackend Android flavor for runtime OpenGL/Vulkan switching (#4288)
This commit is contained in:
committed by
GitHub
parent
ccb9af119e
commit
b0388d186d
@@ -4,12 +4,15 @@ The rendering backend is selected at build time through Gradle product flavors.
|
||||
|
||||
## Available backends
|
||||
|
||||
| Flavor | Backend | Status | Notes |
|
||||
|---|---|---|---|
|
||||
| `opengl` | OpenGL ES | Stable | Default, widest device compatibility |
|
||||
| `vulkan` | Vulkan | Stable | Better performance on modern devices |
|
||||
| `webgpuDawn` | WebGPU (Dawn) | Experimental | Uses Vulkan internally, see [WebGPU](./android-webgpu.md) |
|
||||
| `webgpuWgpu` | WebGPU (wgpu-native) | Experimental | Uses Vulkan internally, arm64-v8a only, see [WebGPU](./android-webgpu.md) |
|
||||
| Flavor | Backend | Status | Maven Central artifact | Notes |
|
||||
|---|---|---|---|---|
|
||||
| `opengl` | OpenGL ES | Stable | `org.maplibre.gl:android-sdk-opengl` | Default, widest device compatibility |
|
||||
| `vulkan` | Vulkan | Stable | `org.maplibre.gl:android-sdk-vulkan` | Better performance on modern devices |
|
||||
| `webgpuDawn` | WebGPU (Dawn) | Experimental | not published | Uses Vulkan internally, see [WebGPU](./android-webgpu.md) |
|
||||
| `webgpuWgpu` | WebGPU (wgpu-native) | Experimental | not published | Uses Vulkan internally, arm64-v8a only, see [WebGPU](./android-webgpu.md) |
|
||||
| `multiBackend` | OpenGL ES + Vulkan | Experimental | `org.maplibre.gl:android-sdk-vulkan-opengl` | Both backends in one AAR, chosen at runtime |
|
||||
|
||||
`org.maplibre.gl:android-sdk` is also published and currently maps to the `vulkan` flavor's release build. `-debug` suffixed artifact (e.g. `android-sdk-vulkan-debug`) is published for each flavor as well.
|
||||
|
||||
## Building with a specific backend
|
||||
|
||||
@@ -29,6 +32,9 @@ cd platform/android
|
||||
|
||||
# WebGPU (wgpu-native)
|
||||
./gradlew :MapLibreAndroidTestApp:installWebgpuWgpuDebug
|
||||
|
||||
# Both OpenGL ES and Vulkan, backend chosen at runtime
|
||||
./gradlew :MapLibreAndroidTestApp:installMultiBackendDebug
|
||||
```
|
||||
|
||||
The same pattern applies to the library module (`MapLibreAndroid`):
|
||||
@@ -49,5 +55,8 @@ Each flavor sets different CMake arguments:
|
||||
- `vulkan`: `-DMLN_WITH_VULKAN=ON`
|
||||
- `webgpuDawn`: `-DMLN_WITH_WEBGPU=ON`, `-DMLN_WEBGPU_IMPL_DAWN=ON`
|
||||
- `webgpuWgpu`: `-DMLN_WITH_WEBGPU=ON`, `-DMLN_WEBGPU_IMPL_WGPU=ON`
|
||||
- `multiBackend`: `-DMLN_ANDROID_MULTI_BACKEND=ON`
|
||||
|
||||
Only one backend is active per build. Renderer-specific Java code lives in `src/opengl/`, `src/vulkan/`, or `src/webgpu/` source sets.
|
||||
For `opengl`, `vulkan`, and the WebGPU flavors, only one backend is compiled in and it's fixed for the lifetime of the app. `multiBackend` is the exception - it ships both the OpenGL ES and Vulkan native libraries and picks one at runtime.
|
||||
|
||||
Renderer-specific Java code is split between flavor-specific source sets (`src/opengl/`, `src/vulkan/`, `src/multiBackend/`) and shared per-backend code in `src/sharedRenderer/opengl/` and `src/sharedRenderer/vulkan/`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# WebGPU on Android
|
||||
|
||||
Two WebGPU implementations are supported: **Dawn** (Google, C++) and **wgpu-native** (Rust). Both use Vulkan internally on Android. The Gradle product flavors are `webgpuDawn` and `webgpuWgpu`, sharing the `src/webgpu/` Java source set.
|
||||
Two WebGPU implementations are supported: **Dawn** (Google, C++) and **wgpu-native** (Rust). Both use Vulkan internally on Android. The Gradle product flavors are `webgpuDawn` and `webgpuWgpu`, sharing the `src/vulkan/` and `src/sharedRenderer/vulkan/` Java source sets.
|
||||
|
||||
## Building with Dawn
|
||||
|
||||
|
||||
Reference in New Issue
Block a user