diff --git a/.bazelignore b/.bazelignore
index 7b4ec7aef3d..4c373e4d17f 100644
--- a/.bazelignore
+++ b/.bazelignore
@@ -1,4 +1,4 @@
bazel-bin
bazel-out
bazel-testlogs
-node_modules
\ No newline at end of file
+node_modules
diff --git a/.bazelrc b/.bazelrc
index 1f834b3a07c..402ac2662c7 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -7,4 +7,4 @@ common --incompatible_disallow_empty_glob
coverage --experimental_ui_max_stdouterr_bytes=10485760
-common:macos --linkopt=-L/opt/homebrew/lib
\ No newline at end of file
+common:macos --linkopt=-L/opt/homebrew/lib
diff --git a/.bazelversion b/.bazelversion
index 643916c03f1..ae9a76b9249 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-7.3.1
+8.0.0
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index cd7d8561a41..9106980e3bf 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -6,4 +6,3 @@ contact_links:
- name: "💬 Chat with us on Slack"
url: https://slack.openstreetmap.us/
about: "Join #maplibre-native on the Open Street Map Slack"
-
diff --git a/.github/actions/android-build-and-upload-render-test/action.yml b/.github/actions/android-build-and-upload-render-test/action.yml
index 1c2bcb4c3b0..47af2811b99 100644
--- a/.github/actions/android-build-and-upload-render-test/action.yml
+++ b/.github/actions/android-build-and-upload-render-test/action.yml
@@ -22,4 +22,4 @@ runs:
if-no-files-found: error
path: |
./render-test/android/RenderTestsApp-${{ inputs.flavor }}.apk
- ./render-test/android/RenderTests-${{ inputs.flavor }}.apk
\ No newline at end of file
+ ./render-test/android/RenderTests-${{ inputs.flavor }}.apk
diff --git a/.github/actions/get-pr-number/action.yml b/.github/actions/get-pr-number/action.yml
index 23da26d09c3..d75aba3a125 100644
--- a/.github/actions/get-pr-number/action.yml
+++ b/.github/actions/get-pr-number/action.yml
@@ -16,4 +16,4 @@ runs:
- id: cat
run: echo pr-number="$(cat ./pr_number)" >> $GITHUB_OUTPUT
- shell: bash
\ No newline at end of file
+ shell: bash
diff --git a/.github/actions/qt5-build/Dockerfile b/.github/actions/qt5-build/Dockerfile
deleted file mode 100644
index 66b144e83d1..00000000000
--- a/.github/actions/qt5-build/Dockerfile
+++ /dev/null
@@ -1,5 +0,0 @@
-FROM ghcr.io/maplibre/linux-builder:centos7-gcc11
-
-# Copy and set the entry point
-COPY entrypoint.sh /entrypoint.sh
-ENTRYPOINT ["/entrypoint.sh"]
diff --git a/.github/actions/qt5-build/action.yml b/.github/actions/qt5-build/action.yml
deleted file mode 100644
index c0dcb66689a..00000000000
--- a/.github/actions/qt5-build/action.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-# action.yml
-name: 'Qt5 Linux Builder'
-description: 'Helper action to build in a specific Docker container'
-runs:
- using: 'docker'
- image: 'Dockerfile'
diff --git a/.github/actions/qt5-build/entrypoint.sh b/.github/actions/qt5-build/entrypoint.sh
deleted file mode 100755
index e651013cda7..00000000000
--- a/.github/actions/qt5-build/entrypoint.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash -l
-
-source scl_source enable devtoolset-11 rh-git218
-
-set -e
-set -x
-
-export CCACHE_DIR="$GITHUB_WORKSPACE/.ccache"
-export PATH="$QT_ROOT_DIR/bin:$PATH"
-
-mkdir build && cd build
-cmake ../source/ \
- -G Ninja \
- -DCMAKE_BUILD_TYPE="Release" \
- -DCMAKE_C_COMPILER_LAUNCHER="ccache" \
- -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
- -DMLN_WITH_QT=ON \
- -DMLN_QT_IGNORE_ICU=OFF
-ninja
diff --git a/.github/actions/save-pr-number/action.yml b/.github/actions/save-pr-number/action.yml
index 5f5225614d7..0bf36e008da 100644
--- a/.github/actions/save-pr-number/action.yml
+++ b/.github/actions/save-pr-number/action.yml
@@ -13,4 +13,4 @@ runs:
uses: actions/upload-artifact@v3
with:
name: pr-number
- path: ./pr_number
\ No newline at end of file
+ path: ./pr_number
diff --git a/.github/changed-files.yml b/.github/changed-files.yml
index ff4910a0fbb..152273e6013 100644
--- a/.github/changed-files.yml
+++ b/.github/changed-files.yml
@@ -65,4 +65,4 @@ android:
- 'test/**'
- 'vendor/**'
- '.gitmodules'
- - '!**/*.md'
\ No newline at end of file
+ - '!**/*.md'
diff --git a/.github/renovate.json b/.github/renovate.json
index 2d485150fc6..51d5f307f20 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -1,3 +1,3 @@
{
"enabledManagers": ["gradle-wrapper", "bazel"]
-}
\ No newline at end of file
+}
diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml
index a26ad33a352..c121ca7bc01 100644
--- a/.github/workflows/android-ci.yml
+++ b/.github/workflows/android-ci.yml
@@ -212,6 +212,18 @@ jobs:
working-directory: test/android
steps:
+ - name: Free Disk Space (Ubuntu)
+ if: startsWith(runner.name, 'GitHub Actions')
+ uses: jlumbroso/free-disk-space@main
+ with:
+ tool-cache: false
+ android: false
+ dotnet: true
+ haskell: true
+ large-packages: true
+ docker-images: true
+ swap-storage: false
+
- uses: actions/checkout@v4
with:
submodules: recursive
diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml
index 6fa39007aa2..35594f091c8 100644
--- a/.github/workflows/android-release.yml
+++ b/.github/workflows/android-release.yml
@@ -2,19 +2,10 @@ name: android-release
on:
workflow_dispatch:
- inputs:
- renderer:
- description: "Select renderering backend"
- required: true
- default: "OpenGL"
- type: choice
- options:
- - OpenGL
- - Vulkan
jobs:
build:
- runs-on: ubuntu-24.04
+ runs-on: MapLibre_Native_Ubuntu_24_04_x84_16_core
defaults:
run:
working-directory: platform/android
@@ -28,17 +19,6 @@ jobs:
submodules: recursive
fetch-depth: 0
- - name: Map renderer input
- id: backend_lowercase
- run: |
- if [ "${{ github.event.inputs.renderer }}" = "OpenGL" ]; then
- echo "backend_lowercase=drawable" >> "$GITHUB_ENV"
- elif [ "${{ github.event.inputs.renderer }}" = "Vulkan" ]; then
- echo "backend_lowercase=vulkan" >> "$GITHUB_ENV"
- fi
-
- - run: echo "cmake.dir=$(dirname "$(dirname "$(command -v cmake)")")" >> local.properties
-
- uses: actions/setup-java@v4
with:
distribution: "temurin"
@@ -65,6 +45,7 @@ jobs:
- name: Update version name
run: |
RELEASE_VERSION="$( git describe --tags --match=android-v*.*.* --abbrev=0 | sed 's/^android-v//' )"
+ echo version="$RELEASE_VERSION" >> "$GITHUB_ENV"
echo "Latest version from tag: $RELEASE_VERSION"
if [ -n "$RELEASE_VERSION" ]; then
sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${RELEASE_VERSION}/" MapLibreAndroid/gradle.properties
@@ -74,20 +55,9 @@ jobs:
shell: bash
- name: Build package
- run: make apackage
- env:
- RENDERER: ${{ env.backend_lowercase }}
-
- - name: Build release Test App
run: |
- MAPLIBRE_DEVELOPER_CONFIG_XML='${{ secrets.MAPLIBRE_DEVELOPER_CONFIG_XML }}'
- if [ -n "${MAPLIBRE_DEVELOPER_CONFIG_XML}" ]; then
- echo "${MAPLIBRE_DEVELOPER_CONFIG_XML}" > MapLibreAndroidTestApp/src/main/res/values/developer-config.xml
- make android
- else
- echo "No secrets.MAPLIBRE_DEVELOPER_CONFIG_XML variable set, skipping apk build..."
- fi
- shell: bash
+ RENDERER=vulkan make apackage
+ RENDERER=drawable make apackage
# create github release
- name: Prepare release
@@ -99,15 +69,15 @@ jobs:
echo version_tag="$( git describe --tags --match=android-v*.*.* --abbrev=0 )" >> "$GITHUB_OUTPUT"
shell: bash
- - name: Check if version is valid semver
+ - name: Check if version is pre-release
id: check_version
run: |
- version_tag="${{ steps.prepare_release.outputs.version_tag }}"
- if [[ $version_tag =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
- echo "Valid semver: $version_tag"
+ version="${{ env.version }}"
+ if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "Valid semver: $version"
echo "prerelease=false" >> "$GITHUB_ENV"
else
- echo "Invalid semver: $version_tag"
+ echo "Invalid semver: $version"
echo "prerelease=true" >> "$GITHUB_ENV"
fi
@@ -123,25 +93,44 @@ jobs:
draft: false
prerelease: ${{ env.prerelease }}
- - name: Upload aar
- id: upload-release-asset
+ - name: Upload aar (OpenGL)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-${{ env.backend_lowercase }}-release.aar
+ asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-drawable-release.aar
asset_name: MapLibreAndroid-release.aar
asset_content_type: application/zip
- - name: Upload debug symbols
+ - name: Upload aar (Vulkan)
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-vulkan-release.aar
+ asset_name: MapLibreAndroid-release-vulkan.aar
+ asset_content_type: application/zip
+
+ - name: Upload debug symbols (OpenGL)
+ uses: actions/upload-release-asset@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ upload_url: ${{ steps.create_release.outputs.upload_url }}
+ asset_path: platform/android/build/debug-symbols-opengl.tar.gz
+ asset_name: debug-symbols-maplibre-android-opengl-${{ steps.prepare_release.outputs.version_tag }}.tar.gz
+ asset_content_type: application/gzip
+
+ - name: Upload debug symbols (Vulkan)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: platform/android/build/debug-symbols.tar.gz
- asset_name: debug-symbols.tar.gz
+ asset_path: platform/android/build/debug-symbols-vulkan.tar.gz
+ asset_name: debug-symbols-maplibre-android-vulkan-${{ steps.prepare_release.outputs.version_tag }}.tar.gz
asset_content_type: application/gzip
- name: Clean release
@@ -164,4 +153,3 @@ jobs:
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
- RENDERER: ${{ env.backend_lowercase }}
diff --git a/.github/workflows/gh-pages-android-api.yml b/.github/workflows/gh-pages-android-api.yml
index abe4b3fc690..5f327f21091 100644
--- a/.github/workflows/gh-pages-android-api.yml
+++ b/.github/workflows/gh-pages-android-api.yml
@@ -26,7 +26,7 @@ jobs:
run: ./gradlew dokkaGenerate
- name: Deploy 🚀
- uses: JamesIves/github-pages-deploy-action@v4.6.9
+ uses: JamesIves/github-pages-deploy-action@v4.7.2
with:
branch: gh-pages
folder: platform/android/MapLibreAndroid/build/dokka/html
diff --git a/.github/workflows/gh-pages-android-examples.yml b/.github/workflows/gh-pages-android-examples.yml
index 5ebde8efcd0..090401df1a6 100644
--- a/.github/workflows/gh-pages-android-examples.yml
+++ b/.github/workflows/gh-pages-android-examples.yml
@@ -23,7 +23,7 @@ jobs:
run: make mkdocs-build
- name: Deploy 🚀
- uses: JamesIves/github-pages-deploy-action@v4.6.9
+ uses: JamesIves/github-pages-deploy-action@v4.7.2
with:
branch: gh-pages
folder: platform/android/site
diff --git a/.github/workflows/gh-pages-cpp-api.yml b/.github/workflows/gh-pages-cpp-api.yml
index f2e9efa39a5..1095e1fbad3 100644
--- a/.github/workflows/gh-pages-cpp-api.yml
+++ b/.github/workflows/gh-pages-cpp-api.yml
@@ -20,7 +20,7 @@ jobs:
run: doxygen
- name: Deploy 🚀
- uses: JamesIves/github-pages-deploy-action@v4.6.9
+ uses: JamesIves/github-pages-deploy-action@v4.7.2
with:
branch: gh-pages
folder: docs/doxygen/html
diff --git a/.github/workflows/gh-pages-docc.yml b/.github/workflows/gh-pages-docc.yml
new file mode 100644
index 00000000000..d02221794f3
--- /dev/null
+++ b/.github/workflows/gh-pages-docc.yml
@@ -0,0 +1,74 @@
+name: gh-pages-docc
+
+permissions:
+ id-token: write
+ pages: write
+ contents: write
+
+on:
+ workflow_dispatch:
+ workflow_run:
+ workflows:
+ - ios-ci
+ types:
+ - completed
+
+jobs:
+ gh-pages-docc-build:
+ if: ${{ github.ref_name == 'main' }}
+ name: Build DocC Docs
+ runs-on: macos-latest
+ steps:
+ - name: Checkout 🛎️
+ uses: actions/checkout@v4
+
+ - name: Configure AWS Credentials
+ uses: aws-actions/configure-aws-credentials@v4
+ with:
+ aws-region: us-west-2
+ role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
+ role-session-name: ${{ github.run_id }}
+
+ - name: Build DocC documentation
+ working-directory: .
+ run: |
+ HOSTING_BASE_PATH="maplibre-native/ios/latest" platform/ios/scripts/docc.sh
+
+ # workaround since colons in filenames are not allowed in artifacts
+ # https://github.com/actions/upload-artifact/issues/333
+ - name: Create ZIP archive
+ run: |
+ cd build
+ zip -r docs.zip docs/
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: docc-docs
+ path: build/docs.zip
+
+ gh-pages-docc-deploy:
+ needs: gh-pages-docc-build
+ name: Deploy DocC Docs
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout 🛎️
+ uses: actions/checkout@v4
+
+ - name: Download DocC docs artifacts
+ uses: actions/download-artifact@v4
+ with:
+ name: docc-docs
+ path: build
+
+ - name: Unzip documentation
+ run: |
+ cd build
+ unzip docs.zip
+ rm docs.zip
+
+ - name: Deploy DocC documentation (main) 🚀
+ uses: JamesIves/github-pages-deploy-action@v4.7.2
+ with:
+ branch: gh-pages
+ folder: build/docs
+ target-folder: ios/latest/
diff --git a/.github/workflows/gh-pages-mdbook.yml b/.github/workflows/gh-pages-mdbook.yml
index cb76f166427..1ebce477a66 100644
--- a/.github/workflows/gh-pages-mdbook.yml
+++ b/.github/workflows/gh-pages-mdbook.yml
@@ -41,7 +41,7 @@ jobs:
name: book
path: artifacts/book
- name: Deploy
- uses: JamesIves/github-pages-deploy-action@v4.6.9
+ uses: JamesIves/github-pages-deploy-action@v4.7.2
with:
branch: gh-pages
folder: artifacts/book
diff --git a/.github/workflows/ios-ci.yml b/.github/workflows/ios-ci.yml
index 7310a6f3bb8..afd21f42ffd 100644
--- a/.github/workflows/ios-ci.yml
+++ b/.github/workflows/ios-ci.yml
@@ -134,7 +134,7 @@ jobs:
- name: Build CppUnitTests .ipa and .xctest for AWS Device Farm
run: |
set -e
- bazel run --//:renderer=metal //platform/ios:xcodeproj
+ bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=metal"
build_dir="$(mktemp -d)"
xcodebuild build-for-testing -scheme CppUnitTests -project MapLibre.xcodeproj -derivedDataPath "$build_dir"
ios_cpp_test_app_dir="$(dirname "$(find "$build_dir" -name CppUnitTestsApp.app)")"
@@ -199,15 +199,6 @@ jobs:
run: |
HOSTING_BASE_PATH="maplibre-native/ios/latest" platform/ios/scripts/docc.sh
- - name: Deploy DocC documentation (main) 🚀
- if: github.ref == 'refs/heads/main'
- uses: JamesIves/github-pages-deploy-action@v4.6.9
- continue-on-error: true
- with:
- branch: gh-pages
- folder: build/docs
- target-folder: ios/latest/
-
ios-release:
runs-on: macos-14
needs: ios-build
diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml
index 97b90961f82..9293f241065 100644
--- a/.github/workflows/linux-ci.yml
+++ b/.github/workflows/linux-ci.yml
@@ -37,6 +37,7 @@ jobs:
- name: Get all Linux files that have changed
if: github.event_name != 'workflow_dispatch'
id: changed-files
+
uses: tj-actions/changed-files@v45
with:
files_yaml_from_source_file: .github/changed-files.yml
@@ -52,7 +53,7 @@ jobs:
strategy:
fail-fast: true
matrix:
- renderer: [legacy, drawable, vulkan]
+ renderer: [legacy, drawable, vulkan, drawable-rust]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
@@ -91,6 +92,11 @@ jobs:
- if: matrix.renderer == 'drawable'
run: echo renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV"
+ - if: matrix.renderer == 'drawable-rust'
+ run: |
+ echo "renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON -DMLN_USE_RUST=ON" >> "$GITHUB_ENV"
+ cargo install cxxbridge-cmd
+
- if: matrix.renderer == 'legacy'
run: echo renderer_flag_cmake=-DMLN_LEGACY_RENDERER=ON >> "$GITHUB_ENV"
@@ -158,7 +164,12 @@ jobs:
- name: Run render test
id: render_test
- run: xvfb-run -a build/mbgl-render-test-runner --manifestPath=metrics/linux-${{ matrix.renderer }}.json
+ run: |
+ renderer="${{ matrix.renderer }}"
+ if [[ "$renderer" == *-rust ]]; then
+ renderer=${renderer%-rust}
+ fi
+ xvfb-run -a build/mbgl-render-test-runner --manifestPath=metrics/linux-"$renderer".json
- name: Upload render test result
if: always() && steps.render_test.outcome == 'failure'
diff --git a/.github/workflows/qt-ci.yml b/.github/workflows/qt-ci.yml
index 521f0217963..e889c5cd685 100644
--- a/.github/workflows/qt-ci.yml
+++ b/.github/workflows/qt-ci.yml
@@ -60,64 +60,40 @@ jobs:
matrix:
include:
- name: Linux
- os: ubuntu-22.04
- build_type: RelWithDebInfo
- qt_version: 5.15.2
- qt_target: desktop
- compiler: ""
- - name: Linux
- os: ubuntu-22.04
+ os: ubuntu-24.04
build_type: RelWithDebInfo
- qt_version: 6.7.0
+ qt_version: 6.8.1
qt_target: desktop
compiler: ""
- name: Linux_GCC13
os: ubuntu-24.04
build_type: RelWithDebInfo
- qt_version: 6.7.0
+ qt_version: 6.8.1
qt_target: desktop
compiler: "gcc-13"
- - name: macOS
- os: macos-13
- build_type: RelWithDebInfo
- qt_version: 5.15.2
- qt_target: desktop
- deployment_target: 10.15
- deployment_arch: "x86_64"
- compiler: ""
- name: macOS
os: macos-14
build_type: RelWithDebInfo
- qt_version: 6.7.0
+ qt_version: 6.8.1
qt_target: desktop
- deployment_target: 11.0
+ deployment_target: 12.0
deployment_arch: "x86_64;arm64"
compiler: ""
- - name: macOS_LLVM18
+ - name: macOS_LLVM
os: macos-14
build_type: RelWithDebInfo
- qt_version: 6.7.0
+ qt_version: 6.8.1
qt_target: desktop
- deployment_target: 11.0
+ deployment_target: 12.0
deployment_arch: "arm64"
compiler: "llvm"
- - name: win64_msvc2019
- os: windows-2022
- build_type: "RelWithDebInfo"
- compiler_type: x64
- compiler_version: 14.29
- qt_version: 5.15.2
- qt_target: desktop
- qt_arch: win64_msvc2019_64
- qt_tools: ""
- - name: win64_msvc2019
+ - name: win64_msvc2022
os: windows-2022
build_type: "RelWithDebInfo"
compiler_type: x64
- compiler_version: 14.29
- qt_version: 6.7.0
+ qt_version: 6.8.1
qt_target: desktop
- qt_arch: win64_msvc2019_64
+ qt_arch: win64_msvc2022_64
qt_tools: ""
runs-on: ${{ matrix.os }}
env:
@@ -200,11 +176,10 @@ jobs:
xcode-version: latest-stable
- name: Setup MSVC
- if: matrix.qt_arch == 'win64_msvc2019_64'
+ if: matrix.qt_arch == 'win64_msvc2022_64'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.compiler_type }}
- toolset: ${{ matrix.compiler_version }}
- name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@v5
@@ -220,15 +195,6 @@ jobs:
tools: ${{ matrix.qt_tools }}
extra: --base https://mirrors.ocf.berkeley.edu/qt/
- - name: Update ccache
- if: runner.os == 'Windows'
- shell: bash
- run: |
- # version is pinned due to issues with caching MSVC in 4.8
- choco.exe install ccache --version=4.7.5 --no-progress
- ccache.exe --version
- echo "CCACHE_CONFIGPATH=C:/Users/runneradmin/AppData/Roaming/ccache/ccache.conf" >> "$GITHUB_ENV"
-
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1
with:
@@ -249,16 +215,12 @@ jobs:
-DMLN_WITH_QT=ON
ninja
- - name: Build maplibre-native (Linux, Qt5)
- if: runner.os == 'Linux' && matrix.qt_version == '5.15.2'
- uses: ./source/.github/actions/qt5-build
-
- name: Build maplibre-native (Linux, Qt6)
- if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler == ''
+ if: runner.os == 'Linux' && matrix.compiler == ''
uses: ./source/.github/actions/qt6-build
- name: Build maplibre-native (Linux, Qt6, custom compiler)
- if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != ''
+ if: runner.os == 'Linux' && matrix.compiler != ''
run: |
mkdir build && cd build
qt-cmake ../source/ \
@@ -270,7 +232,7 @@ jobs:
ninja
- name: Build maplibre-native (Linux, Qt6, custom compiler, internal libraries)
- if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != ''
+ if: runner.os == 'Linux' && matrix.compiler != ''
run: |
mkdir build-internal && cd build-internal
qt-cmake ../source/ \
@@ -284,7 +246,7 @@ jobs:
ninja
- name: Run tests (Linux)
- if: runner.os == 'Linux' && matrix.qt_version != '5.15.2' && matrix.compiler != ''
+ if: runner.os == 'Linux' && matrix.compiler != ''
uses: coactions/setup-xvfb@v1
with:
run: ctest --output-on-failure
diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml
index d00231ebeba..5e0bb5a3640 100644
--- a/.github/workflows/windows-ci.yml
+++ b/.github/workflows/windows-ci.yml
@@ -51,9 +51,40 @@ jobs:
run: |
Write-Host "Changed file(s): ${{ steps.changed-files.outputs.windows_all_changed_files }}"
- windows-build-and-test:
+ windows-get-or-build-dependencies:
if: needs.pre-job.outputs.should_skip != 'true'
needs: pre-job
+ runs-on: windows-2022
+ steps:
+ - run: |
+ git config --system core.longpaths true
+
+ - uses: actions/checkout@v4
+ with:
+ submodules: recursive
+ fetch-depth: 0
+
+ - uses: ilammy/msvc-dev-cmd@v1
+
+ - name: Export GitHub Actions cache environment variables
+ uses: actions/github-script@v7
+ with:
+ script: |
+ core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
+ core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
+
+ - name: Acquire/Build Maplibre Native Core Dependencies
+ env:
+ CI: 1
+ VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
+ timeout-minutes: 60
+ run: |
+ & ${{ github.workspace }}\platform\windows\Get-VendorPackages.ps1 -Triplet ${{ env.VSCMD_ARG_TGT_ARCH }}-windows -Renderer All
+
+
+ windows-build-and-test:
+# if: needs.pre-job.outputs.should_skip != 'true'
+ needs: windows-get-or-build-dependencies
strategy:
matrix:
renderer: [opengl, egl, vulkan, osmesa]
@@ -87,7 +118,7 @@ jobs:
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- - uses: mozilla-actions/sccache-action@v0.0.6
+ - uses: mozilla-actions/sccache-action@v0.0.7
- name: Initialize sccache
run: |
@@ -98,11 +129,12 @@ jobs:
env:
CI: 1
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- VCPKG_KEEP_ENV_VARS: "CMAKE_CXX_COMPILER_LAUNCHER;CMAKE_C_COMPILER_LAUNCHER"
+# VCPKG_KEEP_ENV_VARS: "CMAKE_CXX_COMPILER_LAUNCHER;CMAKE_C_COMPILER_LAUNCHER"
CMAKE_C_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}"
CMAKE_CXX_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}"
RENDERER: "${{ matrix.renderer }}"
RENDERING_MODE: "${{ matrix.rendering_mode }}"
+ timeout-minutes: 60
run: |
cmake --version
& ${{ github.workspace }}\.github\scripts\windows-ci_configure_wrapper.ps1
diff --git a/.gitmodules b/.gitmodules
index 9876bf6711b..72537dd37ef 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -55,3 +55,6 @@
[submodule "vendor/glslang"]
path = vendor/glslang
url = https://github.com/KhronosGroup/glslang.git
+[submodule "vendor/PMTiles"]
+ path = vendor/PMTiles
+ url = https://github.com/protomaps/PMTiles.git
diff --git a/.nvmrc b/.nvmrc
index b3935607590..409940768f2 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-23
\ No newline at end of file
+23
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 28f89bb74d6..3d1a7f8a7be 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,8 +2,9 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- - id: check-yaml
- args: [--allow-multiple-documents, --unsafe]
+ - id: check-yaml
+ args: [--allow-multiple-documents, --unsafe]
+ - id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.4
hooks:
@@ -20,10 +21,17 @@ repos:
- id: actionlint
additional_dependencies: [shellcheck-py]
- repo: https://github.com/nicklockwood/SwiftFormat
- rev: "0.55.2"
+ rev: "0.55.3"
hooks:
- id: swiftformat
args: [--swiftversion, "5.8"]
+- repo: local
+ hooks:
+ - id: rustfmt
+ name: rustfmt
+ entry: bash -c 'cd rustutils && cargo fmt' --
+ language: rust
+ types: [rust]
ci:
# sometimes fails https://github.com/keith/pre-commit-buildifier/issues/13
skip: [buildifier]
diff --git a/BUILD.bazel b/BUILD.bazel
index 9e7d53e0373..9b387f5a613 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,5 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary")
-load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
+load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@npm//:defs.bzl", "npm_link_all_packages")
load(
"//bazel:core.bzl",
@@ -124,11 +124,11 @@ cc_library(
":mbgl-core-generated-private-artifacts",
":mbgl-core-generated-public-artifacts",
"//vendor:boost",
- "//vendor:csscolorparser",
"//vendor:earcut.hpp",
"//vendor:eternal",
"//vendor:mapbox-base",
"//vendor:parsedate",
+ "//vendor:pmtiles",
"//vendor:polylabel",
"//vendor:protozero",
"//vendor:unique_resource",
@@ -148,6 +148,13 @@ cc_library(
"//vendor:metal-cpp",
],
"//conditions:default": [],
+ }) + select({
+ ":rust": [
+ "//rustutils:rustutilslib",
+ ],
+ "//conditions:default": [
+ "//vendor:csscolorparser",
+ ],
}),
)
@@ -194,6 +201,19 @@ config_setting(
},
)
+bool_flag(
+ name = "use_rust",
+ build_setting_default = False,
+ visibility = ["//visibility:public"],
+)
+
+config_setting(
+ name = "rust",
+ flag_values = {
+ "//:use_rust": "true",
+ },
+)
+
exports_files(
[
"LICENSE.md",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 52267c770b0..3c6b1da70de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,11 +11,13 @@ option(MLN_WITH_OPENGL "Build with OpenGL renderer" ON)
option(MLN_WITH_EGL "Build with EGL renderer" OFF)
option(MLN_WITH_VULKAN "Build with Vulkan renderer" OFF)
option(MLN_WITH_OSMESA "Build with OSMesa (Software) renderer" OFF)
+option(MLN_WITH_PMTILES "Build with PMTiles support" ON)
option(MLN_WITH_WERROR "Make all compilation warnings errors" ON)
option(MLN_LEGACY_RENDERER "Include the legacy rendering pathway" ON)
option(MLN_DRAWABLE_RENDERER "Include the drawable rendering pathway" OFF)
option(MLN_USE_UNORDERED_DENSE "Use ankerl dense containers for performance" ON)
option(MLN_USE_TRACY "Enable Tracy instrumentation" OFF)
+option(MLN_USE_RUST "Use components in Rust" OFF)
if (MLN_WITH_CLANG_TIDY)
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
@@ -153,7 +155,6 @@ if(MLN_DRAWABLE_RENDERER)
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_atlases_tweaker.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/gpu_expression.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/uniform_block.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/uniform_buffer.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/vertex_attribute.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/texture2d.hpp
@@ -177,7 +178,6 @@ if(MLN_DRAWABLE_RENDERER)
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/line_drawable_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/symbol_drawable_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/collision_drawable_data.hpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/uniform_block.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/uniform_buffer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/vertex_attribute.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/render_target.cpp
@@ -941,7 +941,7 @@ list(APPEND SRC_FILES
${PROJECT_SOURCE_DIR}/src/mbgl/util/bounding_volumes.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/chrono.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/client_options.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/util/color.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/util/color$,.rs.cpp,.cpp>
${PROJECT_SOURCE_DIR}/src/mbgl/util/constants.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/convert.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/util/event.cpp
@@ -1035,6 +1035,7 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_circle.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_box.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_collision_circle.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_custom_symbol_icon.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_debug.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_fill_outline.hpp
@@ -1051,10 +1052,13 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_gradient.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_pattern.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_line_sdf.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_location_indicator.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_raster.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/drawable_wide_vector.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/background_pattern.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/circle.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/clipping_mask.hpp
@@ -1139,9 +1143,7 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/background_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/circle_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/collision_layer_ubo.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/common_ubo.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/style/layers/custom_drawable_layer.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/layermanager/custom_drawable_layer_factory.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/custom_drawable_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/debug_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp
@@ -1151,17 +1153,18 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/line_layer_ubo.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/custom_drawable_layer_ubo.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/location_indicator_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/raster_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_defines.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/symbol_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/widevector_ubo.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/style/layers/custom_drawable_layer.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/layermanager/custom_drawable_layer_factory.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/gl/shader_program_gl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/buffer_allocator.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/drawable_gl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/drawable_gl_builder.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/layer_group_gl.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/gl/uniform_block_gl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/uniform_buffer_gl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/vertex_attribute_gl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/texture2d.hpp
@@ -1175,7 +1178,6 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_impl.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/layer_group_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture2d.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_block_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_buffer_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_attribute_gl.cpp
)
@@ -1206,23 +1208,19 @@ if(MLN_WITH_METAL)
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/renderable_resource.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/texture2d.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/tile_layer_group.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/mtl/uniform_block.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/uniform_buffer.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/upload_pass.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/vertex_attribute.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/mtl/vertex_buffer_resource.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/background.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/background_pattern.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/circle.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/clipping_mask.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/common.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/collision_box.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/collision_circle.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/collision.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/debug.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/fill.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/fill_extrusion.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/fill_extrusion_pattern.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/heatmap.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/heatmap_texture.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/hillshade.hpp
@@ -1231,9 +1229,7 @@ if(MLN_WITH_METAL)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/raster.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_group.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/shader_program.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/symbol_icon.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/symbol_sdf.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/symbol_text_and_icon.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/mtl/symbol.hpp
)
list(APPEND
SRC_FILES
@@ -1251,32 +1247,27 @@ if(MLN_WITH_METAL)
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/texture2d.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/render_pass.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/tile_layer_group.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/mtl/uniform_block.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/uniform_buffer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/upload_pass.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/vertex_attribute.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/mtl/vertex_buffer_resource.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/shader_program.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/background.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/background_pattern.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/circle.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/collision_box.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/collision_circle.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/collision.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/clipping_mask.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/custom_symbol_icon.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/debug.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/fill.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/fill_extrusion.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/fill_extrusion_pattern.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/heatmap.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/heatmap_texture.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/hillshade_prepare.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/line.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/raster.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol_icon.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol_sdf.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol_text_and_icon.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/symbol.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/mtl/widevector.cpp
)
find_library(METAL_FRAMEWORK Metal)
@@ -1322,11 +1313,15 @@ if(MLN_WITH_VULKAN)
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/clipping_mask.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/collision.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/common.hpp
- ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/debug.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/custom_symbol_icon.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/fill_extrusion.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/heatmap.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/heatmap_texture.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/hillshade.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/hillshade_prepare.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/line.hpp
+ ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/location_indicator.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/raster.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/symbol.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/vulkan/widevector.hpp
@@ -1358,12 +1353,16 @@ if(MLN_WITH_VULKAN)
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/circle.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/clipping_mask.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/collision.cpp
- ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/common.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/custom_symbol_icon.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/debug.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/fill.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/fill_extrusion.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/heatmap.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/heatmap_texture.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/hillshade.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/hillshade_prepare.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/line.cpp
+ ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/location_indicator.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/raster.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/symbol.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/vulkan/widevector.cpp
@@ -1450,6 +1449,7 @@ include(${PROJECT_SOURCE_DIR}/vendor/earcut.hpp.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/eternal.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/mapbox-base.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/parsedate.cmake)
+include(${PROJECT_SOURCE_DIR}/vendor/pmtiles.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/polylabel.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/protozero.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/tracy.cmake)
@@ -1459,6 +1459,10 @@ include(${PROJECT_SOURCE_DIR}/vendor/vector-tile.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/wagyu.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/metal-cpp.cmake)
+if(MLN_USE_RUST)
+include(${PROJECT_SOURCE_DIR}/rustutils/rustutils.cmake)
+endif()
+
target_link_libraries(
mbgl-core
PRIVATE
@@ -1469,16 +1473,17 @@ target_link_libraries(
Mapbox::Base::cheap-ruler-cpp
mbgl-compiler-options
mbgl-vendor-boost
- mbgl-vendor-csscolorparser
mbgl-vendor-earcut.hpp
mbgl-vendor-eternal
mbgl-vendor-parsedate
+ mbgl-vendor-pmtiles
mbgl-vendor-polylabel
mbgl-vendor-protozero
mbgl-vendor-unique_resource
mbgl-vendor-vector-tile
mbgl-vendor-wagyu
$<$:mbgl-vendor-metal-cpp>
+ $,mbgl-rustutils,mbgl-vendor-csscolorparser>
PUBLIC
Mapbox::Base
Mapbox::Base::Extras::expected-lite
@@ -1490,9 +1495,8 @@ target_link_libraries(
unordered_dense
)
-export(TARGETS
+set(EXPORT_TARGETS
mbgl-core
-
mapbox-base
mapbox-base-cheap-ruler-cpp
mapbox-base-extras-expected-lite
@@ -1508,10 +1512,10 @@ export(TARGETS
mapbox-base-variant
mbgl-compiler-options
mbgl-vendor-boost
- mbgl-vendor-csscolorparser
mbgl-vendor-earcut.hpp
mbgl-vendor-eternal
mbgl-vendor-parsedate
+ mbgl-vendor-pmtiles
mbgl-vendor-polylabel
mbgl-vendor-protozero
mbgl-vendor-unique_resource
@@ -1519,10 +1523,16 @@ export(TARGETS
mbgl-vendor-wagyu
mbgl-vendor-metal-cpp
unordered_dense
-
- FILE MapboxCoreTargets.cmake
)
+if(MLN_USE_RUST)
+ list(APPEND EXPORT_TARGETS mbgl-rustutils rustutils)
+else()
+ list(APPEND EXPORT_TARGETS mbgl-vendor-csscolorparser)
+endif()
+
+export(TARGETS ${EXPORT_TARGETS} FILE MapboxCoreTargets.cmake)
+
if(MLN_WITH_VULKAN)
include(${PROJECT_SOURCE_DIR}/vendor/vulkan.cmake)
diff --git a/LICENSES.core.md b/LICENSES.core.md
index 558d0e48945..25d402398c8 100644
--- a/LICENSES.core.md
+++ b/LICENSES.core.md
@@ -633,4 +633,3 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```
---
-
diff --git a/MODULE.bazel b/MODULE.bazel
index fc8010bcf7c..e71dc40ae56 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,13 +1,14 @@
module(name = "maplibre")
-bazel_dep(name = "apple_support", version = "1.17.0", repo_name = "build_bazel_apple_support")
+bazel_dep(name = "apple_support", version = "1.17.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
-bazel_dep(name = "rules_apple", version = "3.11.2", repo_name = "build_bazel_rules_apple")
+bazel_dep(name = "rules_apple", version = "3.16.1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "rules_swift", version = "2.2.3", repo_name = "build_bazel_rules_swift")
-bazel_dep(name = "rules_xcodeproj", version = "2.8.1")
+bazel_dep(name = "rules_xcodeproj", version = "2.10.0")
bazel_dep(name = "aspect_rules_js", version = "2.1.0")
bazel_dep(name = "rules_nodejs", version = "6.3.2")
+bazel_dep(name = "libuv", version = "1.48.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "20.14.0")
@@ -54,16 +55,39 @@ http_archive(
urls = ["https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip"],
)
-new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
-
-new_local_repository(
- name = "libuv",
- build_file = "@//vendor:libuv.BUILD",
- path = "/opt/homebrew/opt/libuv",
-)
-
darwin_config = use_repo_rule("//platform/darwin:bazel/darwin_config_repository_rule.bzl", "darwin_config")
darwin_config(
name = "darwin_config",
)
+
+bazel_dep(name = "rules_rust", version = "0.56.0")
+bazel_dep(name = "cxx.rs", version = "1.0.136")
+git_override(
+ module_name = "cxx.rs",
+ commit = "d54e44698c3fa5833a861cb3ae502533b92f2f57",
+ remote = "https://github.com/dtolnay/cxx.git",
+)
+
+rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
+rust.toolchain(
+ edition = "2021",
+ extra_target_triples = [
+ "aarch64-apple-ios-sim",
+ "x86_64-apple-ios",
+ "aarch64-apple-ios",
+ "aarch64-apple-darwin",
+ "x86_64-apple-darwin",
+ ],
+)
+use_repo(rust, "rust_toolchains")
+
+register_toolchains("@rust_toolchains//:all")
+
+crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
+crate.from_cargo(
+ name = "crates",
+ cargo_lockfile = "//rustutils:Cargo.lock",
+ manifests = ["//rustutils:Cargo.toml"],
+)
+use_repo(crate, "crates")
diff --git a/README.md b/README.md
index 8fa6c7a213a..26df2071c1f 100644
--- a/README.md
+++ b/README.md
@@ -115,7 +115,7 @@ class MainActivity : AppCompatActivity() {
```
-For more information, refer to the [Android API Documentation](https://maplibre.org/maplibre-native/android/api/), [Android Examples Documentation](https://maplibre.org/maplibre-native/docs/book/android/getting-started-guide.html) or the [MapLibre Native Android `README.md`](platform/android/README.md).
+For more information, refer to the [Android API Documentation](https://maplibre.org/maplibre-native/android/api/), [Android Examples Documentation](https://maplibre.org/maplibre-native/android/examples/getting-started/) or the [MapLibre Native Android `README.md`](platform/android/README.md).
## iOS
@@ -213,7 +213,7 @@ xed platform/ios/MapLibre.xcodeproj
To generate and open the Xcode project.
-More information: [`platform/android/CONTRIBUTING.md`](platform/ios/CONTRIBUTING.md).
+More information: [`platform/ios/CONTRIBUTING.md`](platform/ios/CONTRIBUTING.md).
## Other Platforms
diff --git a/bazel/core.bzl b/bazel/core.bzl
index 472fde18105..75a30b5b152 100644
--- a/bazel/core.bzl
+++ b/bazel/core.bzl
@@ -84,6 +84,8 @@ MLN_GENERATED_OPENGL_SHADER_HEADERS = [
"include/mbgl/shaders/gl/drawable_line_pattern.hpp",
"include/mbgl/shaders/gl/drawable_line_sdf.hpp",
"include/mbgl/shaders/gl/drawable_line.hpp",
+ "include/mbgl/shaders/gl/drawable_location_indicator.hpp",
+ "include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp",
"include/mbgl/shaders/gl/drawable_raster.hpp",
"include/mbgl/shaders/gl/drawable_symbol_icon.hpp",
"include/mbgl/shaders/gl/drawable_symbol_sdf.hpp",
@@ -377,6 +379,7 @@ MLN_CORE_SOURCE = [
"src/mbgl/storage/local_file_source.hpp",
"src/mbgl/storage/main_resource_loader.hpp",
"src/mbgl/storage/network_status.cpp",
+ "src/mbgl/storage/pmtiles_file_source.hpp",
"src/mbgl/storage/resource.cpp",
"src/mbgl/storage/resource_options.cpp",
"src/mbgl/storage/resource_transform.cpp",
@@ -581,7 +584,6 @@ MLN_CORE_SOURCE = [
"src/mbgl/util/bounding_volumes.cpp",
"src/mbgl/util/chrono.cpp",
"src/mbgl/util/client_options.cpp",
- "src/mbgl/util/color.cpp",
"src/mbgl/util/constants.cpp",
"src/mbgl/util/convert.cpp",
"src/mbgl/util/event.cpp",
@@ -649,7 +651,14 @@ MLN_CORE_SOURCE = [
"src/mbgl/util/version.cpp",
"src/mbgl/util/version.hpp",
"src/mbgl/util/work_request.cpp",
-]
+] + select({
+ "//:rust": [
+ "src/mbgl/util/color.rs.cpp",
+ ],
+ "//conditions:default": [
+ "src/mbgl/util/color.cpp",
+ ],
+})
MLN_CORE_HEADERS = [
"include/mbgl/gfx/context.hpp",
@@ -940,7 +949,6 @@ MLN_DRAWABLES_SOURCE = [
"src/mbgl/gfx/line_drawable_data.hpp",
"src/mbgl/gfx/symbol_drawable_data.hpp",
"src/mbgl/gfx/collision_drawable_data.hpp",
- "src/mbgl/gfx/uniform_block.cpp",
"src/mbgl/gfx/uniform_buffer.cpp",
"src/mbgl/gfx/vertex_attribute.cpp",
"src/mbgl/renderer/change_request.cpp",
@@ -992,7 +1000,6 @@ MLN_DRAWABLES_HEADERS = [
"include/mbgl/gfx/drawable_atlases_tweaker.hpp",
"include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp",
"include/mbgl/gfx/gpu_expression.hpp",
- "include/mbgl/gfx/uniform_block.hpp",
"include/mbgl/gfx/uniform_buffer.hpp",
"include/mbgl/gfx/vertex_attribute.hpp",
"include/mbgl/gfx/texture2d.hpp",
@@ -1003,7 +1010,6 @@ MLN_DRAWABLES_HEADERS = [
"include/mbgl/shaders/background_layer_ubo.hpp",
"include/mbgl/shaders/circle_layer_ubo.hpp",
"include/mbgl/shaders/collision_layer_ubo.hpp",
- "include/mbgl/shaders/common_ubo.hpp",
"include/mbgl/shaders/custom_drawable_layer_ubo.hpp",
"include/mbgl/shaders/debug_layer_ubo.hpp",
"include/mbgl/shaders/fill_layer_ubo.hpp",
@@ -1014,6 +1020,7 @@ MLN_DRAWABLES_HEADERS = [
"include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp",
"include/mbgl/shaders/layer_ubo.hpp",
"include/mbgl/shaders/line_layer_ubo.hpp",
+ "include/mbgl/shaders/location_indicator_ubo.hpp",
"include/mbgl/shaders/raster_layer_ubo.hpp",
"include/mbgl/shaders/shader_defines.hpp",
"include/mbgl/shaders/shader_program_base.hpp",
@@ -1031,7 +1038,6 @@ MLN_DRAWABLES_GL_SOURCE = [
"src/mbgl/gl/drawable_gl_impl.hpp",
"src/mbgl/gl/layer_group_gl.cpp",
"src/mbgl/gl/texture2d.cpp",
- "src/mbgl/gl/uniform_block_gl.cpp",
"src/mbgl/gl/uniform_buffer_gl.cpp",
"src/mbgl/gl/vertex_attribute_gl.cpp",
"src/mbgl/shaders/gl/shader_info.cpp",
@@ -1043,7 +1049,6 @@ MLN_DRAWABLES_GL_HEADERS = [
"include/mbgl/gl/drawable_gl.hpp",
"include/mbgl/gl/drawable_gl_builder.hpp",
"include/mbgl/gl/layer_group_gl.hpp",
- "include/mbgl/gl/uniform_block_gl.hpp",
"include/mbgl/gl/uniform_buffer_gl.hpp",
"include/mbgl/gl/vertex_attribute_gl.hpp",
"include/mbgl/gl/texture2d.hpp",
@@ -1067,32 +1072,27 @@ MLN_DRAWABLES_MTL_SOURCE = [
"src/mbgl/mtl/texture2d.cpp",
"src/mbgl/mtl/render_pass.cpp",
"src/mbgl/mtl/tile_layer_group.cpp",
- "src/mbgl/mtl/uniform_block.cpp",
"src/mbgl/mtl/uniform_buffer.cpp",
"src/mbgl/mtl/upload_pass.cpp",
"src/mbgl/mtl/vertex_attribute.cpp",
"src/mbgl/mtl/vertex_buffer_resource.cpp",
"src/mbgl/shaders/mtl/shader_program.cpp",
"src/mbgl/shaders/mtl/background.cpp",
- "src/mbgl/shaders/mtl/background_pattern.cpp",
"src/mbgl/shaders/mtl/circle.cpp",
- "src/mbgl/shaders/mtl/collision_box.cpp",
- "src/mbgl/shaders/mtl/collision_circle.cpp",
+ "src/mbgl/shaders/mtl/collision.cpp",
"src/mbgl/shaders/mtl/clipping_mask.cpp",
"src/mbgl/shaders/mtl/custom_symbol_icon.cpp",
"src/mbgl/shaders/mtl/debug.cpp",
"src/mbgl/shaders/mtl/fill.cpp",
"src/mbgl/shaders/mtl/fill_extrusion.cpp",
- "src/mbgl/shaders/mtl/fill_extrusion_pattern.cpp",
"src/mbgl/shaders/mtl/heatmap.cpp",
"src/mbgl/shaders/mtl/heatmap_texture.cpp",
"src/mbgl/shaders/mtl/hillshade.cpp",
"src/mbgl/shaders/mtl/hillshade_prepare.cpp",
"src/mbgl/shaders/mtl/line.cpp",
"src/mbgl/shaders/mtl/raster.cpp",
- "src/mbgl/shaders/mtl/symbol_icon.cpp",
- "src/mbgl/shaders/mtl/symbol_sdf.cpp",
- "src/mbgl/shaders/mtl/symbol_text_and_icon.cpp",
+ "src/mbgl/shaders/mtl/symbol.cpp",
+ "src/mbgl/shaders/mtl/widevector.cpp",
"src/mbgl/style/layers/mtl/custom_layer_render_parameters.cpp",
]
@@ -1111,23 +1111,19 @@ MLN_DRAWABLES_MTL_HEADERS = [
"include/mbgl/mtl/renderable_resource.hpp",
"include/mbgl/mtl/texture2d.hpp",
"include/mbgl/mtl/tile_layer_group.hpp",
- "include/mbgl/mtl/uniform_block.hpp",
"include/mbgl/mtl/uniform_buffer.hpp",
"include/mbgl/mtl/upload_pass.hpp",
"include/mbgl/mtl/vertex_attribute.hpp",
"include/mbgl/mtl/vertex_buffer_resource.hpp",
"include/mbgl/shaders/mtl/background.hpp",
- "include/mbgl/shaders/mtl/background_pattern.hpp",
"include/mbgl/shaders/mtl/circle.hpp",
"include/mbgl/shaders/mtl/clipping_mask.hpp",
- "include/mbgl/shaders/mtl/collision_box.hpp",
- "include/mbgl/shaders/mtl/collision_circle.hpp",
+ "include/mbgl/shaders/mtl/collision.hpp",
"include/mbgl/shaders/mtl/common.hpp",
"include/mbgl/shaders/mtl/custom_symbol_icon.hpp",
"include/mbgl/shaders/mtl/debug.hpp",
"include/mbgl/shaders/mtl/fill.hpp",
"include/mbgl/shaders/mtl/fill_extrusion.hpp",
- "include/mbgl/shaders/mtl/fill_extrusion_pattern.hpp",
"include/mbgl/shaders/mtl/heatmap.hpp",
"include/mbgl/shaders/mtl/heatmap_texture.hpp",
"include/mbgl/shaders/mtl/hillshade.hpp",
@@ -1136,9 +1132,7 @@ MLN_DRAWABLES_MTL_HEADERS = [
"include/mbgl/shaders/mtl/raster.hpp",
"include/mbgl/shaders/mtl/shader_group.hpp",
"include/mbgl/shaders/mtl/shader_program.hpp",
- "include/mbgl/shaders/mtl/symbol_icon.hpp",
- "include/mbgl/shaders/mtl/symbol_sdf.hpp",
- "include/mbgl/shaders/mtl/symbol_text_and_icon.hpp",
+ "include/mbgl/shaders/mtl/symbol.hpp",
"include/mbgl/style/layers/mtl/custom_layer_render_parameters.hpp",
"include/mbgl/shaders/mtl/widevector.hpp",
]
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
index ed085650a91..818ab90e00c 100644
--- a/benchmark/CMakeLists.txt
+++ b/benchmark/CMakeLists.txt
@@ -11,6 +11,7 @@ add_library(
${PROJECT_SOURCE_DIR}/benchmark/src/mbgl/benchmark/benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/storage/offline_database.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/util/tilecover.benchmark.cpp
+ ${PROJECT_SOURCE_DIR}/benchmark/util/color.benchmark.cpp
)
target_include_directories(
diff --git a/benchmark/android/.gitignore b/benchmark/android/.gitignore
index ac96206f319..3bb19ffd786 100644
--- a/benchmark/android/.gitignore
+++ b/benchmark/android/.gitignore
@@ -1 +1 @@
-.gradle/
\ No newline at end of file
+.gradle/
diff --git a/benchmark/android/gradle/wrapper/gradle-wrapper.properties b/benchmark/android/gradle/wrapper/gradle-wrapper.properties
index c1d5e018598..e0fd02028bc 100644
--- a/benchmark/android/gradle/wrapper/gradle-wrapper.properties
+++ b/benchmark/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
diff --git a/benchmark/android/gradlew b/benchmark/android/gradlew
index f5feea6d6b1..f3b75f3b0d4 100755
--- a/benchmark/android/gradlew
+++ b/benchmark/android/gradlew
@@ -86,8 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
-' "$PWD" ) || exit
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
diff --git a/benchmark/android/settings.gradle b/benchmark/android/settings.gradle
index 573abcb323c..e7b4def49cb 100644
--- a/benchmark/android/settings.gradle
+++ b/benchmark/android/settings.gradle
@@ -1,2 +1 @@
include ':app'
-
diff --git a/benchmark/fixtures/api/style.json b/benchmark/fixtures/api/style.json
index 5270b6cecee..728e037e905 100644
--- a/benchmark/fixtures/api/style.json
+++ b/benchmark/fixtures/api/style.json
@@ -6511,4 +6511,4 @@
"maptiler:copyright": "This style was generated on MapTiler Cloud. Usage outside of MapTiler Cloud requires valid OpenMapTiles Production Package: https://openmaptiles.com/production-package/ -- please contact us.",
"openmaptiles:version": "3.x"
}
-}
\ No newline at end of file
+}
diff --git a/benchmark/fixtures/api/style_formatted_labels.json b/benchmark/fixtures/api/style_formatted_labels.json
index fbb17af0043..383b3404369 100644
--- a/benchmark/fixtures/api/style_formatted_labels.json
+++ b/benchmark/fixtures/api/style_formatted_labels.json
@@ -6511,4 +6511,4 @@
"maptiler:copyright": "This style was generated on MapTiler Cloud. Usage outside of MapTiler Cloud requires valid OpenMapTiles Production Package: https://openmaptiles.com/production-package/ -- please contact us.",
"openmaptiles:version": "3.x"
}
-}
\ No newline at end of file
+}
diff --git a/benchmark/ios/Info.plist b/benchmark/ios/Info.plist
index 0c6fd614413..32dacb529de 100644
--- a/benchmark/ios/Info.plist
+++ b/benchmark/ios/Info.plist
@@ -59,4 +59,4 @@
-
\ No newline at end of file
+
diff --git a/benchmark/util/color.benchmark.cpp b/benchmark/util/color.benchmark.cpp
new file mode 100644
index 00000000000..a6b90d0ebf6
--- /dev/null
+++ b/benchmark/util/color.benchmark.cpp
@@ -0,0 +1,31 @@
+#include
+
+#include
+#include
+#include
+
+static const std::vector testStrings = {"#000000",
+ "#FFFFFF",
+ "#FF00FFAA",
+ "rgba(255, 0, 0, 1.0)",
+ "rgb(0, 255, 0)",
+ "blue",
+ "red",
+ "invalid-color",
+ "rgba(255, 255, 255, 0.5)",
+ "#123"};
+
+namespace {
+
+void ColorParse(benchmark::State& state) {
+ for (auto _ : state) {
+ for (const auto& str : testStrings) {
+ auto result = mbgl::Color::parse(str);
+ benchmark::DoNotOptimize(result);
+ }
+ }
+}
+
+}; // namespace
+
+BENCHMARK(ColorParse);
diff --git a/benchmark/util/tilecover.benchmark.cpp b/benchmark/util/tilecover.benchmark.cpp
index b3c63c61e81..dde9f3e9e2b 100644
--- a/benchmark/util/tilecover.benchmark.cpp
+++ b/benchmark/util/tilecover.benchmark.cpp
@@ -15,7 +15,7 @@ static void TileCountBounds(benchmark::State& state) {
auto count = util::tileCount(sanFrancisco, 10);
length += count;
}
- (void)length;
+ benchmark::DoNotOptimize(length);
}
static void TileCoverPitchedViewport(benchmark::State& state) {
@@ -29,7 +29,7 @@ static void TileCoverPitchedViewport(benchmark::State& state) {
auto tiles = util::tileCover(transform.getState(), 8);
length += tiles.size();
}
- (void)length;
+ benchmark::DoNotOptimize(length);
}
static void TileCoverBounds(benchmark::State& state) {
@@ -38,7 +38,7 @@ static void TileCoverBounds(benchmark::State& state) {
auto tiles = util::tileCover(sanFrancisco, 8);
length += tiles.size();
}
- (void)length;
+ benchmark::DoNotOptimize(length);
}
static const auto geomPolygon = Polygon{
@@ -62,7 +62,7 @@ static void TileCoverPolygon(benchmark::State& state) {
auto tiles = util::tileCover(geomPolygon, 8);
length += tiles.size();
}
- (void)length;
+ benchmark::DoNotOptimize(length);
}
static void TileCountPolygon(benchmark::State& state) {
@@ -72,7 +72,7 @@ static void TileCountPolygon(benchmark::State& state) {
auto tiles = util::tileCount(geomPolygon, 16);
length += tiles;
}
- (void)length;
+ benchmark::DoNotOptimize(length);
}
BENCHMARK(TileCountBounds);
diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt
index 72690e61a90..0ff7593fbea 100644
--- a/bin/CMakeLists.txt
+++ b/bin/CMakeLists.txt
@@ -59,4 +59,4 @@ install(TARGETS mbgl-offline mbgl-render RUNTIME DESTINATION bin)
if(MLN_WITH_OPENGL)
target_compile_definitions(mbgl-render PRIVATE "MLN_RENDER_BACKEND_OPENGL=1")
-endif()
\ No newline at end of file
+endif()
diff --git a/bin/render.cpp b/bin/render.cpp
index 26e1fa11ba0..6520f7baff1 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -38,6 +38,9 @@ int main(int argc, char* argv[]) {
args::ValueFlag widthValue(argumentParser, "pixels", "Image width", {'w', "width"});
args::ValueFlag heightValue(argumentParser, "pixels", "Image height", {'h', "height"});
+ args::ValueFlag mapModeValue(
+ argumentParser, "MapMode", "Map mode (e.g. 'static', 'tile', 'continuous')", {'m', "mode"});
+
try {
argumentParser.ParseCLI(argc, argv);
} catch (const args::Help&) {
@@ -79,18 +82,26 @@ int main(int argc, char* argv[]) {
util::RunLoop loop;
+ MapMode mapMode = MapMode::Static;
+ if (mapModeValue) {
+ const auto modeStr = args::get(mapModeValue);
+ if (modeStr == "tile") {
+ mapMode = MapMode::Tile;
+ } else if (modeStr == "continuous") {
+ mapMode = MapMode::Continuous;
+ }
+ }
+
HeadlessFrontend frontend({width, height}, static_cast(pixelRatio));
- Map map(frontend,
- MapObserver::nullObserver(),
- MapOptions()
- .withMapMode(MapMode::Static)
- .withSize(frontend.getSize())
- .withPixelRatio(static_cast(pixelRatio)),
- ResourceOptions()
- .withCachePath(cache_file)
- .withAssetPath(asset_root)
- .withApiKey(apikey)
- .withTileServerOptions(mapTilerConfiguration));
+ Map map(
+ frontend,
+ MapObserver::nullObserver(),
+ MapOptions().withMapMode(mapMode).withSize(frontend.getSize()).withPixelRatio(static_cast(pixelRatio)),
+ ResourceOptions()
+ .withCachePath(cache_file)
+ .withAssetPath(asset_root)
+ .withApiKey(apikey)
+ .withTileServerOptions(mapTilerConfiguration));
if (style.find("://") == std::string::npos) {
style = std::string("file://") + style;
diff --git a/design-proposals/2022-09-02-kotlin.md b/design-proposals/2022-09-02-kotlin.md
index d0850a19e2f..de1adfb54df 100644
--- a/design-proposals/2022-09-02-kotlin.md
+++ b/design-proposals/2022-09-02-kotlin.md
@@ -24,4 +24,4 @@ Full backward compatibility
## Rejected Alternatives
-The alternative is that we go forward with java, meaning that we effectively should port our existing kotlin code to java, which I can't find evidence of any project ever attempting.
\ No newline at end of file
+The alternative is that we go forward with java, meaning that we effectively should port our existing kotlin code to java, which I can't find evidence of any project ever attempting.
diff --git a/design-proposals/2023-06-17-android-annotations.md b/design-proposals/2023-06-17-android-annotations.md
index bdcf5c401af..6506b20609e 100644
--- a/design-proposals/2023-06-17-android-annotations.md
+++ b/design-proposals/2023-06-17-android-annotations.md
@@ -278,4 +278,4 @@ One remaining task is to consider supporting an `InfoWindow`-like feature with o
## Rejected Alternatives
-* Moving the existing code to `maplibre-native` without further considerations leads to chaos, because it would leave users with the choice between two rather mediocre APIs – one being mediocre by design, the other because it is deprecated. Additionally, it would leave the codebase with two confusingly similar codebases. With this proposal, we can offer one new and clean API, and redirect calls to the old API to the new one.
\ No newline at end of file
+* Moving the existing code to `maplibre-native` without further considerations leads to chaos, because it would leave users with the choice between two rather mediocre APIs – one being mediocre by design, the other because it is deprecated. Additionally, it would leave the codebase with two confusingly similar codebases. With this proposal, we can offer one new and clean API, and redirect calls to the old API to the new one.
diff --git a/design-proposals/2023-11-08-complex-animatable-interactive-annotations.md b/design-proposals/2023-11-08-complex-animatable-interactive-annotations.md
index 09665004173..0fb81b98652 100644
--- a/design-proposals/2023-11-08-complex-animatable-interactive-annotations.md
+++ b/design-proposals/2023-11-08-complex-animatable-interactive-annotations.md
@@ -59,4 +59,3 @@ No migration plan needed unless we introduce a Phase 3 to cleanup existing platf
Historically the gap has been somewhat filled by the different platform layers. On the iOS platform there is a MapKit style “AnnotationDelegate”, which in some cases draws directly to the mglMap core and in others will add views as subviews to the MGLMapView. On Android there is a whole proposal for updating the Annotations API (design-proposals/2023-06-17-android-annotations.md). Note: This proposal is for purely additive code and we do not plan to change any of these existing systems at this time. Those who have attempted to make complex map applications using these workarounds quickly run into performance issues and other problems like incompatibility with clustering or label collisions.
If one were to attempt to create such a system using SymbolLayers, they will quickly find that they need to build out a whole system to handle touch events (usually involving querying a screen rect for map features). They will find that if they want to draw many different high resolution images they now need to deal with manually adding images to the stylesheet and the performance implications of doing so. They will also find that any attempts at animating the content can cause full layout recalculations of the map and will rarely animate as expected.
-
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 0e55ad4718c..89fbe5a90b7 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:22.04
+FROM ubuntu:24.04
# Install build tools and dependencies
RUN apt-get update \
@@ -23,12 +23,16 @@ RUN apt-get update \
ccache \
ninja-build \
pkg-config \
+ python3 \
+ python3-pip \
+ python-is-python3 \
clang-tidy \
&& : # end of the RUN cmd - easier to keep a colon at the end of the list, than to keep the backslashes in check
# This could also be `.../releases/latest/download/bazelisk-linux-amd64` for the latest version, but for predictability better hardcode it
# Detect if current CPU is x64 or ARM64 and download the appropriate binary
-RUN if [ "$(uname -m)" = "aarch64" ]; then \
+RUN echo "Download and install Bazel" \
+ && if [ "$(uname -m)" = "aarch64" ]; then \
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-arm64 -o /usr/local/bin/bazel ;\
else \
curl -fsSL https://github.com/bazelbuild/bazelisk/releases/download/v1.20.0/bazelisk-linux-amd64 -o /usr/local/bin/bazel ;\
@@ -36,25 +40,35 @@ RUN if [ "$(uname -m)" = "aarch64" ]; then \
&& chmod +x /usr/local/bin/bazel \
&& :
-WORKDIR /app
-
-ARG USERNAME=user
+# This username is hardcoded in several places, and should simply match whatever base image uses
+ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create docker user wuth sudo rights as passed in by the build command
# This was modeled on https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
# On a Mac, USER_GID might already exist, so ignore it if it fails (--force)
-RUN groupadd --force --gid $USER_GID $USERNAME \
- && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
+RUN groupmod --gid $USER_GID $USERNAME \
+ && usermod --uid $USER_UID --gid $USER_GID $USERNAME \
+ && chown -R $USER_UID:$USER_GID /home/$USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
+# This allows users to `docker run` without specifying -u and -g
+USER $USERNAME
+
+#RUN pip install pre-commit
+
+ENV RUSTUP_HOME=/home/$USERNAME/.cache/.rustup \
+ CARGO_HOME=/home/$USERNAME/.cache/.cargo \
+ PATH=/home/$USERNAME/.cache/.cargo/bin:$PATH
+
+# As the very last step, copy the startup script
+USER root
COPY startup.sh /usr/local/bin/startup.sh
RUN chmod +x /usr/local/bin/startup.sh
-
-# This allows users to `docker run` without specifying -u and -g
USER $USERNAME
+WORKDIR /app
ENTRYPOINT ["/usr/local/bin/startup.sh"]
CMD ["bash"]
diff --git a/docker/README.md b/docker/README.md
index 5a090f86db6..62b9896716a 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -33,11 +33,11 @@ docker build \
```bash
# Run all build commands using the docker container.
# You can also execute build commands from inside the docker container by starting it without the build command.
-docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image
+docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/ubuntu/.cache" maplibre-native-image
```
You can also use the container to run just one specific commands, e.g. `cmake` or `bazel`. Any downloaded dependencies will be cached in the `docker/.cache` directory.
```bash
-docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image cmake ...
+docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/ubuntu/.cache" maplibre-native-image cmake ...
```
diff --git a/docker/startup.sh b/docker/startup.sh
index 6bb1f9a17e6..9534d378dc6 100644
--- a/docker/startup.sh
+++ b/docker/startup.sh
@@ -1,13 +1,52 @@
#!/bin/sh
-if [ ! -d /app/.github ] || [ ! -d /home/user/.cache ]; then
+if [ ! -d /app/.github ] || [ ! -d ~/.cache ]; then
echo " "
echo "ERROR: Docker container was not started properly."
echo " From the root of this repo, run the following command."
echo " You may add any command to perform in the container at the end of this command."
echo " "
- echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:/home/user/.cache" maplibre-native-image'
+ # shellcheck disable=SC2016
+ echo ' docker run --rm -it -v "$PWD:/app/" -v "$PWD/docker/.cache:'"$HOME"'/.cache" maplibre-native-image'
exit 1
fi
+export PATH="$PATH:~/.local/bin/"
+
+
+# Work in progress: install and configure Swift and pre-commit
+# Detect if current CPU is x64 or ARM64 and download the appropriate binary
+#RUN echo "Download and install SWIFT" \
+# && if [ "$(uname -m)" = "aarch64" ]; then \
+# curl -fsSL https://download.swift.org/swift-5.10.1-release/ubuntu2204-aarch64/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu22.04-aarch64.tar.gz \
+# -o /tmp/swift.tar.gz ;\
+# else \
+# curl -fsSL https://download.swift.org/swift-5.10.1-release/ubuntu2204/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-ubuntu22.04.tar.gz \
+# -o /tmp/swift.tar.gz ;\
+# fi \
+# && tar -xzf /tmp/swift.tar.gz -C / --strip-components=1 \
+# && rm /tmp/swift.tar.gz \
+# && :
+#if [ ! -f "/app/.git/hooks/pre-commit" ]; then
+# echo "Configuring pre-commit git hooks by creating a .git/hooks/pre-commit file..."
+# ~/.local/bin/pre-commit install
+#fi
+
+
+
+if [ ! -f "$CARGO_HOME/env" ]; then
+ echo "Downloading and installing Rust..."
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
+fi
+. "$CARGO_HOME/env"
+
+
+
+if ! command -v cxxbridge > /dev/null; then
+ echo "Installing cxxbridge..."
+ cargo install cxxbridge-cmd
+fi
+
+
+
exec "$@"
diff --git a/docs/.gitignore b/docs/.gitignore
index 712ac0122c0..78dcd7b93ed 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1,2 +1,2 @@
book
-*.bkp
\ No newline at end of file
+*.bkp
diff --git a/docs/mdbook/README.md b/docs/mdbook/README.md
index 268e1aec7f8..9e4a483131d 100644
--- a/docs/mdbook/README.md
+++ b/docs/mdbook/README.md
@@ -2,7 +2,11 @@
## Build Locally
-Get the `mdbook` utility, see https://rust-lang.github.io/mdBook/guide/installation.html
+Get the `mdbook` utility as well as [`mdbook-alerts`](https://github.com/lambdalisue/rs-mdbook-alerts), see https://rust-lang.github.io/mdBook/guide/installation.html
+
+```
+cargo install mdbook mdbook-alerts
+```
Run
diff --git a/docs/mdbook/book.toml b/docs/mdbook/book.toml
index 120536f1290..f68116e87f7 100644
--- a/docs/mdbook/book.toml
+++ b/docs/mdbook/book.toml
@@ -3,7 +3,9 @@ authors = ["MapLibre Contributors"]
language = "en"
multilingual = false
src = "src"
-title = "MapLibre Native Documentation"
+title = "MapLibre Native Developer Documentation"
[output.html]
additional-css = ["diff.css"]
+
+[preprocessor.alerts]
diff --git a/docs/mdbook/diff.css b/docs/mdbook/diff.css
index 623e2edb68d..a8f4609bd26 100644
--- a/docs/mdbook/diff.css
+++ b/docs/mdbook/diff.css
@@ -369,4 +369,4 @@
.d2h-moved-tag {
border: 1px solid #3572b0
-}
\ No newline at end of file
+}
diff --git a/docs/mdbook/src/SUMMARY.md b/docs/mdbook/src/SUMMARY.md
index ce37391c1c4..ce9cf262dc0 100644
--- a/docs/mdbook/src/SUMMARY.md
+++ b/docs/mdbook/src/SUMMARY.md
@@ -2,13 +2,26 @@
[Introduction](./introduction.md)
+- [Platforms](./platforms.md)
+
+- [Android](./android/README.md)
+ - [Tests](./android/android-tests.md)
+ - [Documentation](./android/android-documentation.md)
+ - [Benchmark](./android/benchmark.md)
+
+- [iOS](./ios/README.md)
+ - [Tests](ios/ios-tests.md)
+ - [Documentation](ios/ios-documentation.md)
+
- [Design](./design/README.md)
- - [Ten Thousand Foot View](design/ten-thousand-foot-view.md)
- - [Coordinate System](design/coordinate-system.md)
- - [Expressions](design/expressions.md)
- - [Architectural Problems and Recommendations](design/archictural-problems-and-recommendations.md)
- - [Android Map Rendering Data Flow](design/android-map-rendering-data-flow.md)
- - [Geometry Tile Worker](design/geometry-tile-worker.md)
+ - [Ten Thousand Foot View](design/ten-thousand-foot-view.md)
+ - [Coordinate System](design/coordinate-system.md)
+ - [Expressions](design/expressions.md)
+ - [Architectural Problems and Recommendations](design/archictural-problems-and-recommendations.md)
+ - [Android Map Rendering Data Flow](design/android-map-rendering-data-flow.md)
+ - [Geometry Tile Worker](design/geometry-tile-worker.md)
- [Profiling applications that use MapLibre Native](./profiling/README.md)
- - [Tracy profiling](./profiling/tracy-profiling.md)
+ - [Tracy profiling](./profiling/tracy-profiling.md)
+
+- [Rust](./rust.md)
diff --git a/platform/android/DEVELOPING.md b/docs/mdbook/src/android/README.md
similarity index 50%
rename from platform/android/DEVELOPING.md
rename to docs/mdbook/src/android/README.md
index e8e19dd3e09..ba1fa0805db 100644
--- a/platform/android/DEVELOPING.md
+++ b/docs/mdbook/src/android/README.md
@@ -1,4 +1,4 @@
-# Developing - MapLibre Native for Android
+# MapLibre Android Developer Guide
These instructions are for developers interested in making code-level contributions to MapLibre Native for Android.
@@ -33,34 +33,6 @@ Run the configuration for the `MapLibreAndroidTestApp` module and select a devic
-## Render Tests
-
-To run the render tests for Android, run the configuration for the `androidRenderTest.app` module.
-
-More information on working on the render tests can be found [in the wiki](https://github.com/maplibre/maplibre-native/wiki/Working-on-Android-Render-Tests).
-
-## Instrumentation Tests
-
-To run the instrumentation tests, choose the "Instrumentation Tests" run configuration.
-
-Your device needs remain unlocked for the duration of the tests.
-
-## C++ Unit Tests
-
-There is a separate Gradle project that contains a test app which runs the C++ Unit Tests. It does not depend on the Android platform implementations.
-
-You can find the project in `test/android.` You can open this project in Android Studio and run the C++ Tests on an Android device or Simulator.
-
-To run a particular set of tests you can modify the `--gtest_filter` flag in `platform/android/src/test/test_runner.cpp`. See the [GoogleTest documentation](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) for details how to use this flag.
-
-### AWS Device Farm
-
-The instrumentation tests and C++ unit tests are running on AWS Device Farm. To see the results and the logs, go to:
-
-https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs
-
-You can log in with the `maplibre` alias, with `maplibre` as username and `maplibre` as password (this is a read-only account).
-
## Kotlin
All new code should be written in [Kotlin](https://kotlinlang.org/).
@@ -81,21 +53,6 @@ To format all Kotlin source files, use:
$ ./gradlew formatKotlin
```
-## Benchmarks in Pull Request
-
-To run the benchmarks (for Android) include the following line on a PR comment:
-
-```
-!benchmark android
-```
-
## Profiling
-[maplibre-native/docs/mdbook](https://maplibre.org/maplibre-native/docs/book/) describes how Tracy can be used for profiling.
-
-
-## Documentation
-
-We use Dokka for the API documentation.
-
-The documentation site with examples uses MkDocs along with Material for MkDocs. For more information on how to work on the examples, see [`docs/README.md`](./docs/REAME.md`).
\ No newline at end of file
+See [Tracy Profiling](/profiling/tracy-profiling.md) to understand how Tracy can be used for profiling.
diff --git a/docs/mdbook/src/android/android-documentation.md b/docs/mdbook/src/android/android-documentation.md
new file mode 100644
index 00000000000..988180b7751
--- /dev/null
+++ b/docs/mdbook/src/android/android-documentation.md
@@ -0,0 +1,49 @@
+# Documentation for MapLibre Android
+
+## API Documentation
+
+We use Dokka for the MapLibre Android API documentation. The live documentation site can be found [here](https://maplibre.org/maplibre-native/android/api/).
+
+## Examples Documentation
+
+The documentation site with examples uses MkDocs along with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). You can check out the site [here](https://maplibre.org/maplibre-native/android/examples/).
+
+### Building
+
+To build the Examples Documentation you need to have Docker installed.
+
+From `platform/android`, run:
+
+```
+make mkdocs
+```
+
+Next, visit [`http://localhost:8000/maplibre-native/android/examples/`](http://localhost:8000/maplibre-native/android/examples/).
+
+### Snippets
+
+We use [a Markdown extension for snippets](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/#snippet-sections). This way code can be referenced instead of copy pasted into the documentation. This avoids code examples from becoming out of date or failing to compile. The syntax is as follows:
+
+````kotlin
+// --8<-- [start:fun]
+fun double(x: Int): Int {
+ return 2 * x
+}
+// --8<-- [end:fun]
+````
+
+Next, you'll be able to reference that piece of code in Markdown like so:
+
+```
+--8<-- "example.kt:fun"
+```
+
+Where `example.kt` is the path to the file.
+
+### Static Assets
+
+Static assets are ideally uploaded to the [MapLibre Native S3 Bucket](https://maplibre-native.s3.eu-central-1.amazonaws.com/index.html#android-documentation-resources/).
+
+Please open an issue with the ARN of your AWS account to get upload privileges.
+
+You can use the macro `{{ s3_url("filename.example") }}` which will use a CDN instead of linking to the S3 bucket directly.
diff --git a/docs/mdbook/src/android/android-tests.md b/docs/mdbook/src/android/android-tests.md
new file mode 100644
index 00000000000..6e7e971195a
--- /dev/null
+++ b/docs/mdbook/src/android/android-tests.md
@@ -0,0 +1,91 @@
+# MapLibre Android Tests
+
+## Render Tests
+
+To run the render tests for Android, run the configuration for the `androidRenderTest.app` module.
+
+### Filtering Render Tests
+
+You can filter the tests to run by passing a flag to the file `platform/android/src/test/render_test_runner.cpp`:
+
+```cpp
+std::vector arguments = {..., "-f", "background-color/literal"};
+```
+
+### Viewing the Results
+
+Once the application quits, use the Device Explorer to navigate to `/data/data/org.maplibre.render_test_runner/files`.
+
+
+
+Double click `android-render-test-runner-style.html`. Right click on the opened tab and select _Open In > Browser_. You should see that a single render test passed.
+
+
+
+Alternatively to download (and open) the results from the command line, use:
+
+```
+adb shell "run-as org.maplibre.render_test_runner cat files/metrics/android-render-test-runner-style.html" > android-render-test-runner-style.html
+open android-render-test-runner-style.html
+```
+
+### Updating the Render Tests
+
+Now let's edit `metrics/integration/render-tests/background-color/literal/style.json`, change this line:
+
+```
+ "background-color": "red"
+```
+
+to
+
+```
+ "background-color": "yellow"
+```
+
+We need to make sure that the new `data.zip` with the data for the render tests is installed on the device. You can use the following commands:
+
+```
+tar chf render-test/android/app/src/main/assets/data.zip --format=zip --files-from=render-test/android/app/src/main/assets/to_zip.txt
+adb push render-test/android/app/src/main/assets/data.zip /data/local/tmp/data.zip
+adb shell chmod 777 /data/local/tmp/data.zip
+adb shell "run-as org.maplibre.render_test_runner unzip -o /data/local/tmp/data.zip -d files"
+```
+
+Rerun the render test app and reload the Device Explorer. When you re-open the HTML file with the results you should now see a failing test:
+
+
+
+Now download the `actual.png` in `metrics/integration/render-tests/background-color/literal` with the Device Explorer. Replace the corresponding `expected.png` on your local file system. Upload the new render test data again and run the test app once more.
+
+
+
+Of we don't want to commit this change. But know you can add and debug (Android) render tests.
+
+## Instrumentation Tests
+
+To run the instrumentation tests, choose the "Instrumentation Tests" run configuration.
+
+Your device needs remain unlocked for the duration of the tests.
+
+## C++ Unit Tests
+
+There is a separate Gradle project that contains a test app which runs the C++ Unit Tests. It does not depend on the Android platform implementations.
+
+You can find the project in `test/android.` You can open this project in Android Studio and run the C++ Tests on an Android device or Simulator.
+
+To run a particular set of tests you can modify the `--gtest_filter` flag in `platform/android/src/test/test_runner.cpp`. See the [GoogleTest documentation](https://google.github.io/googletest/advanced.html#running-a-subset-of-the-tests) for details how to use this flag.
+
+### AWS Device Farm
+
+The instrumentation tests and C++ unit tests are running on AWS Device Farm. To see the results and the logs, go to:
+
+[https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs](https://us-west-2.console.aws.amazon.com/devicefarm/home?region=us-east-1#/mobile/projects/20687d72-0e46-403e-8f03-0941850665bc/runs).
+
+Use the following login details (this is a read-only account):
+
+| | |
+|------------|------------|
+| Alias | `maplibre` |
+| Username | `maplibre` |
+| Password | `maplibre` |
diff --git a/docs/mdbook/src/android/benchmark.md b/docs/mdbook/src/android/benchmark.md
new file mode 100644
index 00000000000..3f0248f061d
--- /dev/null
+++ b/docs/mdbook/src/android/benchmark.md
@@ -0,0 +1,102 @@
+# Benchmark
+
+We have created a rendering performance benchmark for Android. The logic for this benchmark is encapsulated in `BenchMarkActivity.kt`.
+
+## Styles
+
+We have hardcoded various styles, which you can override with a `developer-config.xml` by adding some XML with the following structure:
+
+```
+
+ - Americana
+
+
+ - https://americanamap.org/style.json
+
+```
+
+## Retrieving Results
+
+Results are logged to the console as they come in. After the benchmark is done running a `benchmark_results.json` file is generated. You can pull it off the device with for example adb:
+
+```
+adb shell "run-as org.maplibre.android.testapp cat files/benchmark_results.json" \
+ > benchmark_results.json
+```
+
+## Results
+
+The `benchmark_results.json` containing the benchmark results will have the following structure.
+
+```json
+{
+ "results": [
+ {
+ "styleName": "AWS Open Data Standard Light",
+ "syncRendering": true,
+ "thermalState": 0,
+ "fps": 34.70237085812839,
+ "avgEncodingTime": 19.818289053808947,
+ "avgRenderingTime": 7.7432454899654255,
+ "low1pEncodingTime": 91.72538138784371,
+ "low1pRenderingTime": 26.573758581509203
+ },
+ ],
+ "deviceManufacturer": "samsung",
+ "model": "SM-G973F",
+ "renderer": "drawable",
+ "debugBuild": true,
+ "gitRevision": "fc95b79880223e34c2ce80339f698d095e3d63cd",
+ "timestamp": 1736454325393
+}
+```
+
+The meaning of the keys is as follows.
+
+| Key | Description |
+|---|---|
+| styleName | Name of the style being benchmarked |
+| syncRendering | Whether synchronous rendering was used |
+| thermalState | Thermal state of the device during benchmark |
+| fps | Average frames per second achieved during the benchmark |
+| avgEncodingTime | Average time taken for encoding in milliseconds |
+| avgRenderingTime | Average time taken for rendering in milliseconds |
+| low1pEncodingTime | 1st percentile (worst case) encoding time in milliseconds |
+| low1pRenderingTime | 1st percentile (worst case) rendering time in milliseconds |
+| deviceManufacturer | Manufacturer of the test device |
+| model | Model number/name of the test device |
+| renderer | Type of renderer used (`drawable` for Open GL ES, `vulkan` for Vulkan, `legacy` for the legacy Open GL ES rendering backend) |
+| debugBuild | Whether the build was a debug build |
+| gitRevision | Git commit hash of the code version |
+| timestamp | Unix timestamp of when the benchmark was run |
+
+## Large Scale Benchmarks on AWS Device Farm
+
+Sometimes we do a large scale benchmark across a variety of devices on AWS Device Farm. We ran one such test in [November 2024](https://github.com/maplibre/maplibre-native/issues/2787#issuecomment-2466948888) to compare the performance of the then new Vulkan rendering backend against the OpenGL ES backend. There are some scripts in the repo to kick off the tests and to collect and plot the results:
+
+```
+scripts/aws-device-farm/aws-device-farm-run.sh
+scripts/aws-device-farm/collect-benchmark-outputs.mjs
+scripts/aws-device-farm/update-benchmark-db.mjs
+scripts/aws-device-farm/plot-android-benchmark-results.py
+```
+
+## Continuous Benchmarking
+
+We are running the Android benchmark on every merge with `main`.
+
+You can find the results per commit [here](https://maplibre-native.s3.eu-central-1.amazonaws.com/index.html#android-benchmark-render/) or pull them from our public S3 bucket:
+
+```
+aws s3 sync s3://maplibre-native/android-benchmark-render/ .
+```
+
+## Benchmarks in Pull Request
+
+To run the benchmarks (for Android) include the following line on a PR comment:
+
+```
+!benchmark android
+```
+
+A file with the benchmark results will be added to the workflow summary, which you can compare with the previous results in the bucket.
diff --git a/docs/mdbook/src/design/README.md b/docs/mdbook/src/design/README.md
index f4af5367d00..02dec693c00 100644
--- a/docs/mdbook/src/design/README.md
+++ b/docs/mdbook/src/design/README.md
@@ -1,3 +1,6 @@
+> [!NOTE]
+> These notes are partially outdated since the [renderer modularization](https://github.com/maplibre/maplibre-native/blob/main/design-proposals/2022-10-27-rendering-modularization.md).
+
# Design
-This section is dedicated to documenting current state of MapLibre Native. [Architectural Problems and Recommendations](./archictural-problems-and-recommendations.md) section notes recommendations for future improvements from an architectural perspective.
+This section is dedicated to documenting current state of MapLibre Native as of end 2022. [Architectural Problems and Recommendations](./archictural-problems-and-recommendations.md) section notes recommendations for future improvements from an architectural perspective.
diff --git a/docs/mdbook/src/introduction.md b/docs/mdbook/src/introduction.md
index b7c27c66915..43db78c31c5 100644
--- a/docs/mdbook/src/introduction.md
+++ b/docs/mdbook/src/introduction.md
@@ -3,3 +3,5 @@
*[MapLibre Native](https://github.com/maplibre/maplibre-native)* is a community led fork of *Mapbox GL Native*. It's a C++ library that powers
vector maps in native applications on multiple platforms by taking stylesheets that conform to the *[MapLibre Style Specification](https://maplibre.org/maplibre-style-spec/)*, a fork of the
Mapbox Style Spec. Since it is derived from Mapbox's original work it also uses *Mapbox Vector Tile Specification* as its choice of vector tile format.
+
+This documentation is intended for developers of MapLibre Native. If you are interested in *using* MapLibre Native, check out the [main `README.md`](https://github.com/maplibre/maplibre-native?tab=readme-ov-file#maplibre-native) on GitHub.
diff --git a/platform/ios/CONTRIBUTING.md b/docs/mdbook/src/ios/README.md
similarity index 56%
rename from platform/ios/CONTRIBUTING.md
rename to docs/mdbook/src/ios/README.md
index b17b955329c..4a6306bc28a 100644
--- a/platform/ios/CONTRIBUTING.md
+++ b/docs/mdbook/src/ios/README.md
@@ -1,13 +1,4 @@
-# Contributing
-
-## Downloading Source
-
-Download the source and install all submodules if you have not already, by running the following from the root of the repository.
-
-```
-git clone --recurse-submodules git@github.com:maplibre/maplibre-native.git
-cd maplibre-native
-```
+# MapLibre iOS Developer Guide
## Bazel
@@ -56,91 +47,32 @@ Try to run the example App in the simulator and on a device to confirm your setu
> [!IMPORTANT]
> The Bazel configuration files are the source of truth of the build configuration. All changes to the build settings need to be done through Bazel, not in Xcode.
-### Troubleshooting Provisioning Profiles
+### Troubleshooting
+
+#### Provisioning Profiles
If you get a Python `KeyError` when processing provisioning profiles, you probably have some _really_ old or corrupted profiles.
Have a look through `~/Library/MobileDevice/Provisioning\ Profiles` and remove any expired profiles. Removing all profiles here can also resolve some issues.
-## Using Bazel from the Command Line
+#### Cleaning Bazel environments
-It is also possible to build and run the test application in a simulator from the command line without opening Xcode.
+You should almost never have to do this, but sometimes problems can be solved with:
```
-bazel run //platform/ios:App --//:renderer=metal
+bazel clean --expunge
```
-You can also build targets from the command line. For example, if you want to build your own XCFramework, see the 'Build XCFramework' step in the [iOS CI workflow](../../.github/workflows/ios-ci.yml).
-
-## Render Tests
-
-To run the render tests, run the `RenderTest` target from iOS.
+## Using Bazel from the Command Line
-When running in a simulator, use
+It is also possible to build and run the test application in a simulator from the command line without opening Xcode.
```
-# check for 'DataContainer' of the app with `*.maplibre.RenderTestApp` id
-xcrun simctl listapps booted
+bazel run //platform/ios:App --//:renderer=metal
```
-to get the data directory of the render test app. This allows you to inspect test results. When adding new tests, the generated expectations and `actual.png` file can be copied into the source directory from here.
-
-## C++ Unit Tests
-
-Run the tests from the `CppUnitTests` target in Xcode to run the C++ Unit Tests on iOS.
+You can also build targets from the command line. For example, if you want to build your own XCFramework, see the 'Build XCFramework' step in the [iOS CI workflow](../../.github/workflows/ios-ci.yml).
## Swift App
There is also an example app built with Swift instead of Objective-C. The target is called `MapLibreApp` and the source code lives in `platform/ios/app-swift`.
-
-## Documentation
-
-We use [DocC](https://www.swift.org/documentation/docc) for documentation. You need to have [aws-cli](https://github.com/aws/aws-cli) installed to download the resources from S3 (see below). Run the following command:
-
-```
-aws s3 sync --no-sign-request "s3://maplibre-native/ios-documentation-resources" "platform/ios/MapLibre.docc/Resources"
-```
-
-Then, to build the documentation locally, run the following command:
-
-```
-platform/ios/scripts/docc.sh preview
-```
-
-### Resources
-
-Resources like images should not be checked in but should be uploaded to the [S3 Bucket](https://s3.eu-central-1.amazonaws.com/maplibre-native/index.html#ios-documentation-resources/). You can share a `.zip` with all files that should be added in the PR.
-
-If you want to get direct access you need an AWS account to get permissions to upload files. Create an account and authenticate with aws-cli. Share the account ARN that you can get with
-
-```
-aws sts get-caller-identity
-```
-
-### Examples
-
-The code samples in the documentation should ideally be compiled on CI so they do not go out of date.
-
-Fence your example code with
-
-```swift
-// #-example-code(LineTapMap)
-...
-// #-end-example-code
-```
-
-Prefix your documentation code block with
-
-````md
-
-
-```swift
-...
-```
-````
-
-Then the code block will be updated when you run:
-
-```sh
-node scripts/update-ios-examples.mjs
-```
diff --git a/docs/mdbook/src/ios/ios-documentation.md b/docs/mdbook/src/ios/ios-documentation.md
new file mode 100644
index 00000000000..5e4371c5c3d
--- /dev/null
+++ b/docs/mdbook/src/ios/ios-documentation.md
@@ -0,0 +1,53 @@
+# iOS Documentation
+
+We use [DocC](https://www.swift.org/documentation/docc) for the MapLibre iOS documentation. The live documentation site can be found [here](https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre/).
+
+## Resources
+
+You need to have [aws-cli](https://github.com/aws/aws-cli) installed to download the resources from S3 (see below). Run the following command:
+
+```
+aws s3 sync --no-sign-request "s3://maplibre-native/ios-documentation-resources" "platform/ios/MapLibre.docc/Resources"
+```
+
+Then, to build the documentation locally, run the following command:
+
+```
+platform/ios/scripts/docc.sh preview
+```
+
+Resources like images should not be checked in but should be uploaded to the [S3 Bucket](https://s3.eu-central-1.amazonaws.com/maplibre-native/index.html#ios-documentation-resources/). You can share a `.zip` with all files that should be added in the PR.
+
+If you want to get direct access you need an AWS account to get permissions to upload files. Create an account and authenticate with aws-cli. Share the account ARN that you can get with
+
+```
+aws sts get-caller-identity
+```
+
+## Examples
+
+The code samples in the documentation should ideally be compiled on CI so they do not go out of date.
+
+Fence your example code with
+
+```swift
+// #-example-code(LineTapMap)
+...
+// #-end-example-code
+```
+
+Prefix your documentation code block with
+
+````md
+
+
+```swift
+...
+```
+````
+
+Then the code block will be updated when you run:
+
+```sh
+node scripts/update-ios-examples.mjs
+```
diff --git a/docs/mdbook/src/ios/ios-tests.md b/docs/mdbook/src/ios/ios-tests.md
new file mode 100644
index 00000000000..05c929c0ac0
--- /dev/null
+++ b/docs/mdbook/src/ios/ios-tests.md
@@ -0,0 +1,18 @@
+# iOS Tests
+
+## Render Tests
+
+To run the render tests, run the `RenderTest` target from iOS.
+
+When running in a simulator, use
+
+```
+# check for 'DataContainer' of the app with `*.maplibre.RenderTestApp` id
+xcrun simctl listapps booted
+```
+
+to get the data directory of the render test app. This allows you to inspect test results. When adding new tests, the generated expectations and `actual.png` file can be copied into the source directory from here.
+
+## C++ Unit Tests
+
+Run the tests from the `CppUnitTests` target in Xcode to run the C++ Unit Tests on iOS.
diff --git a/docs/mdbook/src/platforms.md b/docs/mdbook/src/platforms.md
new file mode 100644
index 00000000000..20a83499e4c
--- /dev/null
+++ b/docs/mdbook/src/platforms.md
@@ -0,0 +1,56 @@
+
+# Platforms
+
+This page describes the platforms that MapLibre Native is available on.
+
+## Overview
+
+MapLibre Native uses a monorepo. Source code for all platforms lives in [`maplibre/maplibre-native`](https://github.com/maplibre/maplibre-native) on GitHub.
+
+| Platform | Source | Notes |
+|---|---|---|
+| Android | [`platform/android`](https://github.com/maplibre/maplibre-native/tree/main/platform/android) | Integrates with the C++ core via JNI. |
+| iOS | [`platform/ios`](https://github.com/maplibre/maplibre-native/tree/main/platform/ios), [`platform/darwin`](https://github.com/maplibre/maplibre-native/tree/main/platform/darwin) | Integrates with the C++ core via Objective-C++. |
+| Linux | [`platform/linux`](https://github.com/maplibre/maplibre-native/tree/main/platform/linux) | Used for development. Also widely used in production for raster tile generation. |
+| Windows | [`platform/windows`](https://github.com/maplibre/maplibre-native/tree/main/platform/windows) | |
+| macOS | [`platform/macos`](https://github.com/maplibre/maplibre-native/tree/main/platform/macos), [`platform/darwin`](https://github.com/maplibre/maplibre-native/tree/main/platform/darwin) | Mainly used for development. There is some legacy AppKit code. |
+| Node.js | [`platform/node`](https://github.com/maplibre/maplibre-native/tree/main/platform/node) | Uses [NAN](https://github.com/nodejs/nan). Available as [@maplibre/maplibre-gl-native](https://www.npmjs.com/package/@maplibre/maplibre-gl-native) on npm. |
+| Qt | [maplibre/maplibre-qt](https://github.com/maplibre/maplibre-native/tree/main/platform/qt), [`platform/qt`](https://github.com/maplibre/maplibre-native) | Only platform that partially split to another repository. |
+
+Of these, **Android** and **iOS** are considered [core projects](https://github.com/maplibre/maplibre/blob/main/PROJECT_TIERS.md) of the MapLibre Organization.
+### GLFW
+
+You can find an app that uses GLFW in [`platform/glfw`](https://github.com/maplibre/maplibre-native/tree/main/platform/glfw). It works on macOS, Linux and Windows. The app shows an interactive map that can be interacted with. Since GLFW adds relatively little complexity this app is used a lot for development. You can also learn about the C++ API by studying the source code of the GLFW app.
+
+## Rendering Backends
+
+Originally the project only supported OpenGL 2.0. In 2023, the [renderer was modularized](https://github.com/maplibre/maplibre-native/blob/main/design-proposals/2022-10-27-rendering-modularization.md) allowing for the implementation of alternate rendering backends. The first alternate rendering backend that was implemented was [Metal](https://maplibre.org/news/2024-01-19-metal-support-for-maplibre-native-ios-is-here/), followed by [Vulkan](https://maplibre.org/news/2024-12-12-maplibre-android-vulkan/). In the future other rendering backends could be implemented such as WebGPU.
+
+What platforms support which rendering backend can be found below.
+
+| Platform | OpenGL ES 3.0 | Vulkan 1.0 | Metal |
+|---|---|---|---|
+| Android | ✅ | ✅ | ❌ |
+| iOS | ❌ | ❌ | ✅ |
+| Linux | ✅ | ✅ | ❌ |
+| Windows | ✅ | ❌ | ❌ |
+| macOS | ❌ | ✅ | ✅[^1] |
+| Node.js | ✅ | ❌ | ✅ [^2] |
+| Qt | ✅ | ❌ | ❌ |
+
+[^1]: Requires MoltenVK. Only available when built via CMake.
+[^2]: Issue reported, see [#2928](https://github.com/maplibre/maplibre-native/issues/2928).
+
+## Build Tooling
+
+In 2023 we co-opted Bazel as a build tool (generator), mostly due to it having better support for iOS compared to CMake. Some platforms can use CMake as well as Bazel.
+
+| Platform | CMake | Bazel |
+|---|---|---|
+| Android | ✅ (via Gradle) | ❌ |
+| iOS | ❌ | ✅ |
+| Linux | ✅ | ✅ |
+| Windows | ✅ | ❌ |
+| macOS | ✅ | ✅ |
+| Node.js | ✅ | ❌ |
+| Qt | ✅ | ❌ |
diff --git a/docs/mdbook/src/profiling/README.md b/docs/mdbook/src/profiling/README.md
index 969978eed45..18a7b196f68 100644
--- a/docs/mdbook/src/profiling/README.md
+++ b/docs/mdbook/src/profiling/README.md
@@ -1,3 +1,3 @@
# MapLibre Native profiling
-MabLibre Native integrates [Tracy profiler](https://github.com/wolfpld/tracy) which offers an easy way to understand and optimize your application's CPU and GPU performance
\ No newline at end of file
+MabLibre Native integrates [Tracy profiler](https://github.com/wolfpld/tracy) which offers an easy way to understand and optimize your application's CPU and GPU performance
diff --git a/docs/mdbook/src/rust.md b/docs/mdbook/src/rust.md
new file mode 100644
index 00000000000..30980cd57ce
--- /dev/null
+++ b/docs/mdbook/src/rust.md
@@ -0,0 +1,67 @@
+# Rust
+
+We have added experimental support for intergrating Rust code into the source tree.
+
+## Rust Bridge
+
+The Rust bridge lives in the root `rustutils` directory.
+
+We use [CXX](https://cxx.rs/) to allow interop between Rust and C++.
+
+## Building
+
+### CMake
+
+When building with CMake, need to have the correct Rust toolchain(s) installed. See [Install Rust](https://www.rust-lang.org/tools/install) to install Rust.
+
+You can use `rustup` to manage toolchains. Which toolchain you needs depends on your host platform and for what platform you are trying to build. If your host and target platform are the same, you probably have the correct toolchain installed after installing Rust. For example when building for **Android** and building on a **x84 Linux** host you would use the following command:
+
+```
+rustup target add --toolchain stable-x86_64-unknown-linux-gnu aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
+```
+
+See [Platform Support](https://doc.rust-lang.org/nightly/rustc/platform-support.html) in the Rust documentation for more details. You will get a descriptive error message when the correct toolchain is not available, so we don't list all possible combinations here.
+
+You also need to have cxxbridge installed:
+
+```
+cargo install cxxbridge-cmd
+```
+
+Set `-DMLN_USE_RUST=ON` when generating a configuration with CMake.
+
+### Bazel
+
+Pass the `--//:use_rust` flag to Bazel commands.
+
+Note that when [generating an Xcode project](./ios/README.md) you should not pass this option to Bazel directly, but as follows:
+
+```
+bazel run //platform/ios:xcodeproj --@rules_xcodeproj//xcodeproj:extra_common_flags="--//:renderer=metal --//:use_rust"
+```
+
+## Creating a new Module
+
+To create a new module:
+
+1. Add a new source file to `rustutils/src/example.rs`.
+2. Implement it, see the [CXX documentation](https://cxx.rs/index.html) or see `rustutils/src/color.rs` for an example.
+3. Create a C++ source file that will use the generated C++ header. See `src/mbgl/util/color.rs.cpp` for an example. Import the generated header with
+ ```
+ #include
+ ```
+4. Conditionally include either the `*.rs.cpp` file or the `*.cpp` file it replaces in CMake and Bazel. Here is what it looks like for CMake:
+ ```
+ ${PROJECT_SOURCE_DIR}/src/mbgl/util/color$,.rs.cpp,.cpp>
+ ```
+ And here for Bazel:
+ ```
+ select({
+ "//:rust": [
+ "src/mbgl/util/color.rs.cpp",
+ ],
+ "//conditions:default": [
+ "src/mbgl/util/color.cpp",
+ ],
+ })
+ ```
diff --git a/expression-test/expression_test_parser.hpp b/expression-test/expression_test_parser.hpp
index 3cfe2489622..a2abe9f85a3 100644
--- a/expression-test/expression_test_parser.hpp
+++ b/expression-test/expression_test_parser.hpp
@@ -95,4 +95,4 @@ std::unique_ptr parseExpression(const JSValue&,
TestResult&);
std::unique_ptr parseExpression(const std::optional&,
std::optional&,
- TestResult&);
\ No newline at end of file
+ TestResult&);
diff --git a/include/mbgl/gfx/context.hpp b/include/mbgl/gfx/context.hpp
index 8e21265098f..abfdd383e95 100644
--- a/include/mbgl/gfx/context.hpp
+++ b/include/mbgl/gfx/context.hpp
@@ -125,7 +125,10 @@ class Context {
/// @param data The data to copy, may be `nullptr`
/// @param size The size of the buffer
/// @param persistent Performance hint, optimize for few or many uses
- virtual UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent = false) = 0;
+ virtual UniformBufferPtr createUniformBuffer(const void* data,
+ std::size_t size,
+ bool persistent = false,
+ bool ssbo = false) = 0;
/// Get the generic shader with the specified name
virtual gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) = 0;
diff --git a/include/mbgl/gfx/drawable.hpp b/include/mbgl/gfx/drawable.hpp
index 5d4f324fa1a..d820040dbea 100644
--- a/include/mbgl/gfx/drawable.hpp
+++ b/include/mbgl/gfx/drawable.hpp
@@ -251,6 +251,9 @@ class Drawable {
/// Get drawable user-defined type
size_t getType() const { return type; }
+ void setUBOIndex(uint32_t uboIndex_) { uboIndex = uboIndex_; }
+ uint32_t getUBOIndex() const { return uboIndex; }
+
/// Associate the drawable with a layer tweaker. This is used to manage the lifetime of the tweaker.
void setLayerTweaker(LayerTweakerPtr tweaker) { layerTweaker = std::move(tweaker); }
const LayerTweakerPtr& getLayerTweaker() const { return layerTweaker; }
@@ -305,6 +308,7 @@ class Drawable {
std::size_t type = 0;
std::optional> origin;
+ uint32_t uboIndex = 0;
};
using DrawablePtr = std::shared_ptr;
diff --git a/include/mbgl/gfx/drawable_atlases_tweaker.hpp b/include/mbgl/gfx/drawable_atlases_tweaker.hpp
index f988c697efe..ac83b14f822 100644
--- a/include/mbgl/gfx/drawable_atlases_tweaker.hpp
+++ b/include/mbgl/gfx/drawable_atlases_tweaker.hpp
@@ -44,7 +44,7 @@ class DrawableAtlasesTweaker : public gfx::DrawableTweaker {
void init(Drawable&) override;
- void execute(Drawable&, const PaintParameters&) override;
+ void execute(Drawable&, PaintParameters&) override;
protected:
void setupTextures(Drawable&, const bool);
diff --git a/include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp b/include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp
index 217f8658a8e..ea075358e31 100644
--- a/include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp
+++ b/include/mbgl/gfx/drawable_custom_layer_host_tweaker.hpp
@@ -25,7 +25,7 @@ class DrawableCustomLayerHostTweaker : public gfx::DrawableTweaker {
void init(Drawable&) override {};
- void execute(Drawable&, const PaintParameters&) override;
+ void execute(Drawable&, PaintParameters&) override;
protected:
std::shared_ptr host;
diff --git a/include/mbgl/gfx/drawable_tweaker.hpp b/include/mbgl/gfx/drawable_tweaker.hpp
index 97b8ff1ef3d..60206c7c417 100644
--- a/include/mbgl/gfx/drawable_tweaker.hpp
+++ b/include/mbgl/gfx/drawable_tweaker.hpp
@@ -24,7 +24,7 @@ class DrawableTweaker {
virtual void init(Drawable&) = 0;
/// Called just before rendering
- virtual void execute(Drawable&, const PaintParameters&) = 0;
+ virtual void execute(Drawable&, PaintParameters&) = 0;
};
using DrawableTweakerPtr = std::shared_ptr;
diff --git a/include/mbgl/gfx/uniform_block.hpp b/include/mbgl/gfx/uniform_block.hpp
deleted file mode 100644
index bbfd1f2fcb4..00000000000
--- a/include/mbgl/gfx/uniform_block.hpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-namespace mbgl {
-namespace gfx {
-
-class UniformBuffer;
-class UniformBlock;
-
-using UniqueUniformBlock = std::unique_ptr;
-
-/// @brief This class represents an uniform block
-class UniformBlock {
-public:
- /// @brief Constructor
- /// @param index_
- /// @param size_
- UniformBlock(int index_, std::size_t size_)
- : index(index_),
- size(size_) {}
- UniformBlock(const UniformBlock&) = default;
- UniformBlock(UniformBlock&& other)
- : index(other.index),
- size(other.size) {}
- /// @brief Destructor
- virtual ~UniformBlock() = default;
-
- /// @brief Retrieves the index of this uniform block
- /// @return int
- int getIndex() const { return index; }
-
- /// @brief Get the size of the uniform block
- /// @return std::size_t
- std::size_t getSize() const { return size; }
-
- /// @brief Binds the buffer
- /// @param uniformBuffer
- virtual void bindBuffer(const UniformBuffer& uniformBuffer) = 0;
-
- /// @brief Unbinds the uniform buffer
- virtual void unbindBuffer() = 0;
-
-protected:
- UniformBlock& operator=(const UniformBlock&) = default;
- UniformBlock& operator=(UniformBlock&& other) {
- index = other.index;
- size = other.size;
- return *this;
- }
-
-protected:
- int index;
- std::size_t size;
-};
-
-/// Stores a collection of uniform blocks by id
-class UniformBlockArray {
-public:
- /// @brief Constructor
- UniformBlockArray() = default;
-
- /// @brief Move constructor
- UniformBlockArray(UniformBlockArray&&);
-
- /// @brief Copy constructor. Would need to use the virtual assignment operator
- UniformBlockArray(const UniformBlockArray&) = delete;
-
- /// @brief Destructor
- virtual ~UniformBlockArray() = default;
-
- /// @brief Number of maximum allocated elements
- std::size_t allocatedSize() const { return uniformBlockVector.size(); }
-
- /// @brief Get an uniform block element.
- /// @return Pointer to the element on success, or null if the uniform block doesn't exists.
- const std::unique_ptr& get(const size_t id) const;
-
- /// @brief Set a new uniform block element.
- /// @param id
- /// @param index
- /// @param size
- /// @return Pointer to the new element on success, or null if the uniform block already exists.
- const std::unique_ptr& set(const size_t id, const size_t index, std::size_t size);
-
- /// @brief Move assignment operator
- UniformBlockArray& operator=(UniformBlockArray&&);
-
- /// @brief Copy assignment operator
- UniformBlockArray& operator=(const UniformBlockArray&);
-
- /// Do something with each block
- template
- void visit(Func f) {
- std::for_each(uniformBlockVector.begin(), uniformBlockVector.end(), [&](const auto& block) {
- if (block) {
- f(*block);
- }
- });
- }
-
-protected:
- virtual std::unique_ptr create(int index, std::size_t size) = 0;
- virtual std::unique_ptr copy(const UniformBlock& uniformBlock) = 0;
-
-protected:
- std::array uniformBlockVector;
- static std::unique_ptr nullref;
-};
-
-} // namespace gfx
-} // namespace mbgl
diff --git a/include/mbgl/gfx/uniform_buffer.hpp b/include/mbgl/gfx/uniform_buffer.hpp
index d1acdc94ae2..390459c5748 100644
--- a/include/mbgl/gfx/uniform_buffer.hpp
+++ b/include/mbgl/gfx/uniform_buffer.hpp
@@ -29,7 +29,7 @@ class UniformBuffer {
public:
virtual ~UniformBuffer() = default;
- virtual void update(const void* data, std::size_t size_) = 0;
+ virtual void update(const void* data, std::size_t dataSize) = 0;
std::size_t getSize() const { return size; }
diff --git a/include/mbgl/gl/drawable_gl.hpp b/include/mbgl/gl/drawable_gl.hpp
index f088003dca1..2aad6c4d8b1 100644
--- a/include/mbgl/gl/drawable_gl.hpp
+++ b/include/mbgl/gl/drawable_gl.hpp
@@ -68,9 +68,6 @@ class DrawableGL : public gfx::Drawable {
void uploadTextures() const;
- void bindUniformBuffers() const;
- void unbindUniformBuffers() const;
-
void bindTextures() const;
void unbindTextures() const;
};
diff --git a/include/mbgl/gl/layer_group_gl.hpp b/include/mbgl/gl/layer_group_gl.hpp
index 0250a854580..5a4553d1d5e 100644
--- a/include/mbgl/gl/layer_group_gl.hpp
+++ b/include/mbgl/gl/layer_group_gl.hpp
@@ -24,9 +24,6 @@ class TileLayerGroupGL : public TileLayerGroup {
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
- void bindUniformBuffers() const;
- void unbindUniformBuffers() const;
-
protected:
UniformBufferArrayGL uniformBuffers;
};
@@ -46,9 +43,6 @@ class LayerGroupGL : public LayerGroup {
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
- void bindUniformBuffers() const;
- void unbindUniformBuffers() const;
-
protected:
UniformBufferArrayGL uniformBuffers;
};
diff --git a/include/mbgl/gl/uniform_block_gl.hpp b/include/mbgl/gl/uniform_block_gl.hpp
deleted file mode 100644
index c91cfc55f96..00000000000
--- a/include/mbgl/gl/uniform_block_gl.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-
-#include
-#include
-
-namespace mbgl {
-namespace gl {
-
-class UniformBlockGL final : public gfx::UniformBlock {
-public:
- UniformBlockGL(int index_, std::size_t size_)
- : UniformBlock(index_, size_) {}
- UniformBlockGL(const UniformBlockGL& other)
- : UniformBlock(other) {}
- UniformBlockGL(UniformBlockGL&& other)
- : UniformBlock(std::move(other)) {}
- ~UniformBlockGL() override = default;
- void bindBuffer(const gfx::UniformBuffer& uniformBuffer) override;
- void unbindBuffer() override;
-};
-
-/// Stores a collection of uniform blocks by name
-class UniformBlockArrayGL final : public gfx::UniformBlockArray {
-public:
- UniformBlockArrayGL() = default;
- UniformBlockArrayGL(UniformBlockArrayGL&& other)
- : UniformBlockArray(std::move(other)) {}
- UniformBlockArrayGL(const UniformBlockArrayGL&) = delete;
-
- UniformBlockArrayGL& operator=(UniformBlockArrayGL&& other) {
- UniformBlockArray::operator=(std::move(other));
- return *this;
- }
- UniformBlockArrayGL& operator=(const UniformBlockArrayGL& other) {
- UniformBlockArray::operator=(other);
- return *this;
- }
-
-private:
- std::unique_ptr create(int index, std::size_t size) override {
- return std::make_unique(index, size);
- }
- std::unique_ptr copy(const gfx::UniformBlock& uniformBlocks) override {
- return std::make_unique(static_cast(uniformBlocks));
- }
-};
-
-} // namespace gl
-} // namespace mbgl
diff --git a/include/mbgl/gl/uniform_buffer_gl.hpp b/include/mbgl/gl/uniform_buffer_gl.hpp
index 870b2d4333d..b186715e9c5 100644
--- a/include/mbgl/gl/uniform_buffer_gl.hpp
+++ b/include/mbgl/gl/uniform_buffer_gl.hpp
@@ -24,7 +24,7 @@ class UniformBufferGL final : public gfx::UniformBuffer {
UniformBufferGL clone() const { return {*this}; }
// gfx::UniformBuffer
- void update(const void* data, std::size_t size_) override;
+ void update(const void* data, std::size_t dataSize) override;
private:
// unique id used for debugging and profiling purposes
@@ -59,6 +59,9 @@ class UniformBufferArrayGL final : public gfx::UniformBufferArray {
return *this;
}
+ void bind() const;
+ void unbind() const;
+
private:
std::unique_ptr copy(const gfx::UniformBuffer& uniformBuffers) override {
return std::make_unique(static_cast(uniformBuffers).clone());
diff --git a/include/mbgl/map/bound_options.hpp b/include/mbgl/map/bound_options.hpp
index 5901a252cfa..00383af5649 100644
--- a/include/mbgl/map/bound_options.hpp
+++ b/include/mbgl/map/bound_options.hpp
@@ -12,6 +12,7 @@ namespace mbgl {
*/
struct BoundOptions {
/// Sets the latitude and longitude bounds to which the camera center are constrained
+ /// If ConstrainMode is set to Screen these bounds describe what can be shown on screen.
BoundOptions& withLatLngBounds(LatLngBounds b) {
bounds = b;
return *this;
@@ -38,6 +39,7 @@ struct BoundOptions {
}
/// Constrain the center of the camera to be within these bounds.
+ /// If ConstrainMode is set to Screen these bounds describe what can be shown on screen.
std::optional bounds;
/// Maximum zoom level allowed.
diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp
index 5835cf8df22..9c5219fb74d 100644
--- a/include/mbgl/map/mode.hpp
+++ b/include/mbgl/map/mode.hpp
@@ -19,12 +19,13 @@ enum class MapMode : EnumType {
Tile ///< a once-off still image of a single tile
};
-/// We can choose to constrain the map both horizontally or vertically, or only
-/// vertically e.g. while panning.
+/// We can choose to constrain the map both horizontally or vertically, only
+/// vertically e.g. while panning, or screen to the specified bounds.
enum class ConstrainMode : EnumType {
None,
HeightOnly,
WidthAndHeight,
+ Screen,
};
/// Satisfies embedding platforms that requires the viewport coordinate systems
diff --git a/include/mbgl/mtl/context.hpp b/include/mbgl/mtl/context.hpp
index cf1be121ee5..41c354b4dde 100644
--- a/include/mbgl/mtl/context.hpp
+++ b/include/mbgl/mtl/context.hpp
@@ -83,7 +83,10 @@ class Context final : public gfx::Context {
void reduceMemoryUsage() override {}
gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override;
- gfx::UniformBufferPtr createUniformBuffer(const void* data, std::size_t size, bool persistent) override;
+ gfx::UniformBufferPtr createUniformBuffer(const void* data,
+ std::size_t size,
+ bool persistent = false,
+ bool ssbo = false) override;
gfx::ShaderProgramBasePtr getGenericShader(gfx::ShaderRegistry&, const std::string& name) override;
diff --git a/include/mbgl/mtl/drawable.hpp b/include/mbgl/mtl/drawable.hpp
index 7abc899197a..b40c87b76e1 100644
--- a/include/mbgl/mtl/drawable.hpp
+++ b/include/mbgl/mtl/drawable.hpp
@@ -73,9 +73,6 @@ class Drawable : public gfx::Drawable {
void bindInstanceAttributes(RenderPass&) const noexcept;
- void bindUniformBuffers(RenderPass&) const noexcept;
- void unbindUniformBuffers(RenderPass&) const noexcept {}
-
void bindTextures(RenderPass&) const noexcept;
void unbindTextures(RenderPass&) const noexcept;
diff --git a/include/mbgl/mtl/layer_group.hpp b/include/mbgl/mtl/layer_group.hpp
index 90f742942c6..818ebb53322 100644
--- a/include/mbgl/mtl/layer_group.hpp
+++ b/include/mbgl/mtl/layer_group.hpp
@@ -26,9 +26,6 @@ class LayerGroup : public mbgl::LayerGroup {
gfx::UniformBufferArray& mutableUniformBuffers() override { return uniformBuffers; };
- void bindUniformBuffers(RenderPass&) const noexcept;
- void unbindUniformBuffers(RenderPass&) const noexcept {}
-
protected:
UniformBufferArray uniformBuffers;
};
diff --git a/include/mbgl/mtl/render_pass.hpp b/include/mbgl/mtl/render_pass.hpp
index e13d6b5f576..35ae8ffd2f3 100644
--- a/include/mbgl/mtl/render_pass.hpp
+++ b/include/mbgl/mtl/render_pass.hpp
@@ -45,8 +45,9 @@ class RenderPass final : public gfx::RenderPass {
void addDebugSignpost(const char* name) override;
void bindVertex(const BufferResource&, std::size_t offset, std::size_t index, std::size_t size = 0);
-
+ void unbindVertex(std::size_t index);
void bindFragment(const BufferResource&, std::size_t offset, std::size_t index, std::size_t size = 0);
+ void unbindFragment(std::size_t index);
private:
void pushDebugGroup(const char* name) override;
diff --git a/include/mbgl/mtl/uniform_block.hpp b/include/mbgl/mtl/uniform_block.hpp
deleted file mode 100644
index dcfef87f7c0..00000000000
--- a/include/mbgl/mtl/uniform_block.hpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-
-#include
-#include
-
-namespace mbgl {
-namespace mtl {
-
-class UniformBlock final : public gfx::UniformBlock {
-public:
- UniformBlock(int index_, std::size_t size_)
- : gfx::UniformBlock(index_, size_) {}
- UniformBlock(const UniformBlock& other)
- : gfx::UniformBlock(other) {}
- UniformBlock(UniformBlock&& other)
- : gfx::UniformBlock(std::move(other)) {}
- ~UniformBlock() override = default;
- void bindBuffer(const gfx::UniformBuffer& uniformBuffer) override;
- void unbindBuffer() override;
-
- bool getBindVertex() const { return bindVertex; }
- void setBindVertex(bool value) { bindVertex = value; }
-
- bool getBindFragment() const { return bindFragment; }
- void setBindFragment(bool value) { bindFragment = value; }
-
-protected:
- bool bindVertex = false;
- bool bindFragment = false;
-};
-
-/// Stores a collection of uniform blocks by name
-class UniformBlockArray final : public gfx::UniformBlockArray {
-public:
- UniformBlockArray() = default;
- UniformBlockArray(UniformBlockArray&& other)
- : gfx::UniformBlockArray(std::move(other)) {}
- UniformBlockArray(const UniformBlockArray&) = delete;
-
- UniformBlockArray& operator=(UniformBlockArray&& other) {
- gfx::UniformBlockArray::operator=(std::move(other));
- return *this;
- }
- UniformBlockArray& operator=(const UniformBlockArray& other) {
- gfx::UniformBlockArray::operator=(other);
- return *this;
- }
-
-private:
- std::unique_ptr create(int index, std::size_t size) override {
- return std::make_unique(index, size);
- }
- std::unique_ptr copy(const gfx::UniformBlock& uniformBlocks) override {
- return std::make_unique(static_cast(uniformBlocks));
- }
-};
-
-} // namespace mtl
-} // namespace mbgl
diff --git a/include/mbgl/mtl/uniform_buffer.hpp b/include/mbgl/mtl/uniform_buffer.hpp
index 8e5c9735684..9dfbdb1a8ab 100644
--- a/include/mbgl/mtl/uniform_buffer.hpp
+++ b/include/mbgl/mtl/uniform_buffer.hpp
@@ -6,6 +6,8 @@
namespace mbgl {
namespace mtl {
+class RenderPass;
+
class UniformBuffer final : public gfx::UniformBuffer {
public:
UniformBuffer(BufferResource&&);
@@ -17,7 +19,7 @@ class UniformBuffer final : public gfx::UniformBuffer {
UniformBuffer clone() const { return {buffer.clone()}; }
- void update(const void* data, std::size_t size_) override;
+ void update(const void* data, std::size_t dataSize) override;
protected:
BufferResource buffer;
@@ -40,6 +42,9 @@ class UniformBufferArray final : public gfx::UniformBufferArray {
return *this;
}
+ void bind(RenderPass& renderPass) const noexcept;
+ void unbind(RenderPass& renderPass) const noexcept {};
+
private:
gfx::UniqueUniformBuffer copy(const gfx::UniformBuffer& buffer) override {
return std::make_unique(static_cast(buffer).clone());
diff --git a/include/mbgl/shaders/background_layer_ubo.hpp b/include/mbgl/shaders/background_layer_ubo.hpp
index 9f31256e0a9..7c0e19aa27e 100644
--- a/include/mbgl/shaders/background_layer_ubo.hpp
+++ b/include/mbgl/shaders/background_layer_ubo.hpp
@@ -11,31 +11,39 @@ namespace shaders {
// Background
struct alignas(16) BackgroundDrawableUBO {
- std::array matrix;
+ /* 0 */ std::array matrix;
+ /* 64 */
};
-static_assert(sizeof(BackgroundDrawableUBO) == 64);
+static_assert(sizeof(BackgroundDrawableUBO) == 4 * 16);
-struct alignas(16) BackgroundLayerUBO {
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) BackgroundPropsUBO {
/* 0 */ Color color;
/* 16 */ float opacity;
- /* 24 */ float pad1, pad2, pad3;
+ /* 20 */ float pad1;
+ /* 24 */ float pad2;
+ /* 28 */ float pad3;
/* 32 */
};
-static_assert(sizeof(BackgroundLayerUBO) == 32);
+static_assert(sizeof(BackgroundPropsUBO) == 2 * 16);
//
// Background pattern
struct alignas(16) BackgroundPatternDrawableUBO {
- std::array matrix;
- std::array pixel_coord_upper;
- std::array pixel_coord_lower;
- float tile_units_to_pixels;
- float pad1, pad2, pad3;
+ /* 0 */ std::array matrix;
+ /* 64 */ std::array pixel_coord_upper;
+ /* 72 */ std::array pixel_coord_lower;
+ /* 80 */ float tile_units_to_pixels;
+ /* 84 */ float pad1;
+ /* 88 */ float pad2;
+ /* 92 */ float pad3;
+ /* 96 */
};
-static_assert(sizeof(BackgroundPatternDrawableUBO) == 96);
+static_assert(sizeof(BackgroundPatternDrawableUBO) == 6 * 16);
-struct alignas(16) BackgroundPatternLayerUBO {
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) BackgroundPatternPropsUBO {
/* 0 */ std::array pattern_tl_a;
/* 8 */ std::array pattern_br_a;
/* 16 */ std::array pattern_tl_b;
@@ -48,7 +56,16 @@ struct alignas(16) BackgroundPatternLayerUBO {
/* 60 */ float opacity;
/* 64 */
};
-static_assert(sizeof(BackgroundPatternLayerUBO) == 64);
+static_assert(sizeof(BackgroundPatternPropsUBO) == 4 * 16);
+
+#if MLN_UBO_CONSOLIDATION
+
+union BackgroundDrawableUnionUBO {
+ BackgroundDrawableUBO backgroundDrawableUBO;
+ BackgroundPatternDrawableUBO backgroundPatternDrawableUBO;
+};
+
+#endif
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/circle_layer_ubo.hpp b/include/mbgl/shaders/circle_layer_ubo.hpp
index 9c347b807e1..27a7a5d87e6 100644
--- a/include/mbgl/shaders/circle_layer_ubo.hpp
+++ b/include/mbgl/shaders/circle_layer_ubo.hpp
@@ -6,45 +6,39 @@ namespace mbgl {
namespace shaders {
struct alignas(16) CircleDrawableUBO {
- /* 0 */ std::array matrix; // composite model-view-projection matrix
- /* 64 */ std::array extrude_scale;
- /* 72 */ float pad;
- /* 80 */
-};
-static_assert(sizeof(CircleDrawableUBO) == 5 * 16);
+ /* 0 */ std::array matrix;
+ /* 64 */ std::array extrude_scale;
-struct alignas(16) CirclePaintParamsUBO {
- /* 0 */ float camera_to_center_distance;
- /* 4 */ float pad1, pad2, pad3;
- /* 16 */
+ // Interpolations
+ /* 72 */ float color_t;
+ /* 76 */ float radius_t;
+ /* 80 */ float blur_t;
+ /* 84 */ float opacity_t;
+ /* 88 */ float stroke_color_t;
+ /* 92 */ float stroke_width_t;
+ /* 96 */ float stroke_opacity_t;
+ /* 100 */ float pad1;
+ /* 104 */ float pad2;
+ /* 108 */ float pad3;
+ /* 112 */
};
-static_assert(sizeof(CirclePaintParamsUBO) == 1 * 16);
+static_assert(sizeof(CircleDrawableUBO) == 7 * 16);
+/// Evaluated properties that do not depend on the tile
struct alignas(16) CircleEvaluatedPropsUBO {
- Color color;
- Color stroke_color;
- float radius;
- float blur;
- float opacity;
- float stroke_width;
- float stroke_opacity;
- int scale_with_map;
- int pitch_with_map;
- float padding;
-};
-static_assert(sizeof(CircleEvaluatedPropsUBO) % 16 == 0);
-
-struct alignas(16) CircleInterpolateUBO {
- float color_t;
- float radius_t;
- float blur_t;
- float opacity_t;
- float stroke_color_t;
- float stroke_width_t;
- float stroke_opacity_t;
- float padding;
+ /* 0 */ Color color;
+ /* 16 */ Color stroke_color;
+ /* 32 */ float radius;
+ /* 36 */ float blur;
+ /* 40 */ float opacity;
+ /* 44 */ float stroke_width;
+ /* 48 */ float stroke_opacity;
+ /* 52 */ int scale_with_map;
+ /* 56 */ int pitch_with_map;
+ /* 60 */ float pad1;
+ /* 64 */
};
-static_assert(sizeof(CircleInterpolateUBO) % 16 == 0);
+static_assert(sizeof(CircleEvaluatedPropsUBO) == 4 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/collision_layer_ubo.hpp b/include/mbgl/shaders/collision_layer_ubo.hpp
index d185fa0c031..3bd073c7302 100644
--- a/include/mbgl/shaders/collision_layer_ubo.hpp
+++ b/include/mbgl/shaders/collision_layer_ubo.hpp
@@ -5,14 +5,19 @@
namespace mbgl {
namespace shaders {
-struct alignas(16) CollisionUBO {
- std::array matrix;
- std::array extrude_scale;
- float overscale_factor;
- float pad;
+struct alignas(16) CollisionDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */
};
-static_assert(sizeof(CollisionUBO) % 16 == 0);
-static_assert(sizeof(CollisionUBO) == 80);
+static_assert(sizeof(CollisionDrawableUBO) == 4 * 16);
+
+struct alignas(16) CollisionTilePropsUBO {
+ /* 0 */ std::array extrude_scale;
+ /* 8 */ float overscale_factor;
+ /* 12 */ float pad1;
+ /* 16 */
+};
+static_assert(sizeof(CollisionTilePropsUBO) == 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/common_ubo.hpp b/include/mbgl/shaders/common_ubo.hpp
deleted file mode 100644
index cb97cbfbdbe..00000000000
--- a/include/mbgl/shaders/common_ubo.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include
-
-namespace mbgl {
-namespace shaders {
-
-struct alignas(16) CommonUBO {
- std::array matrix;
- Color color;
-};
-static_assert(sizeof(CommonUBO) % 16 == 0);
-
-} // namespace shaders
-} // namespace mbgl
diff --git a/include/mbgl/shaders/custom_drawable_layer_ubo.hpp b/include/mbgl/shaders/custom_drawable_layer_ubo.hpp
index b022a52b90c..81cea47a546 100644
--- a/include/mbgl/shaders/custom_drawable_layer_ubo.hpp
+++ b/include/mbgl/shaders/custom_drawable_layer_ubo.hpp
@@ -5,26 +5,21 @@
namespace mbgl {
namespace shaders {
-/// Custom Symbol Icon matrix
struct alignas(16) CustomSymbolIconDrawableUBO {
/* 0 */ std::array matrix;
- /* 64 */
+ /* 64 */ std::array extrude_scale;
+ /* 72 */ std::array anchor;
+ /* 80 */ float angle_degrees;
+ /* 84 */ uint32_t scale_with_map;
+ /* 88 */ uint32_t pitch_with_map;
+ /* 92 */ float camera_to_center_distance;
+ /* 96 */ float aspect_ratio;
+ /* 100 */ float pad1;
+ /* 104 */ float pad2;
+ /* 108 */ float pad3;
+ /* 112 */
};
-static_assert(sizeof(CustomSymbolIconDrawableUBO) == 4 * 16);
-
-/// Custom Symbol Icon Parameters
-struct alignas(16) CustomSymbolIconParametersUBO {
- /* 0 */ std::array extrude_scale;
- /* 8 */ std::array anchor;
- /* 16 */ float angle_degrees;
- /* 20 */ uint32_t scale_with_map;
- /* 24 */ uint32_t pitch_with_map;
- /* 28 */ float camera_to_center_distance;
- /* 32 */ float aspect_ratio;
- /* 36 */ float pad0, pad1, pad2;
- /* 48 */
-};
-static_assert(sizeof(CustomSymbolIconParametersUBO) == 3 * 16);
+static_assert(sizeof(CustomSymbolIconDrawableUBO) == 7 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/debug_layer_ubo.hpp b/include/mbgl/shaders/debug_layer_ubo.hpp
index d0f6adffa38..577be4c9d5a 100644
--- a/include/mbgl/shaders/debug_layer_ubo.hpp
+++ b/include/mbgl/shaders/debug_layer_ubo.hpp
@@ -6,12 +6,15 @@ namespace mbgl {
namespace shaders {
struct alignas(16) DebugUBO {
- std::array matrix;
- Color color;
- float overlay_scale;
- float pad1, pad2, pad3;
+ /* 0 */ std::array matrix;
+ /* 64 */ Color color;
+ /* 80 */ float overlay_scale;
+ /* 84 */ float pad1;
+ /* 88 */ float pad2;
+ /* 92 */ float pad3;
+ /* 96 */
};
-static_assert(sizeof(DebugUBO) % 16 == 0);
+static_assert(sizeof(DebugUBO) == 6 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp b/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp
index 2a748fbc305..a87eddc0dde 100644
--- a/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp
+++ b/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp
@@ -8,15 +8,32 @@ namespace mbgl {
namespace shaders {
struct alignas(16) FillExtrusionDrawableUBO {
- /* 0 */ std::array matrix;
- /* 64 */ std::array texsize;
- /* 72 */ std::array pixel_coord_upper;
- /* 80 */ std::array pixel_coord_lower;
- /* 88 */ float height_factor;
- /* 92 */ float tile_ratio;
- /* 96 */
+ /* 0 */ std::array matrix;
+ /* 64 */ std::array pixel_coord_upper;
+ /* 72 */ std::array pixel_coord_lower;
+ /* 80 */ float height_factor;
+ /* 84 */ float tile_ratio;
+
+ // Interpolations
+ /* 88 */ float base_t;
+ /* 92 */ float height_t;
+ /* 96 */ float color_t;
+ /* 100 */ float pattern_from_t;
+ /* 104 */ float pattern_to_t;
+ /* 108 */ float pad1;
+ /* 112 */
};
-static_assert(sizeof(FillExtrusionDrawableUBO) == 6 * 16);
+static_assert(sizeof(FillExtrusionDrawableUBO) == 7 * 16);
+
+struct alignas(16) FillExtrusionTilePropsUBO {
+ /* 0 */ std::array pattern_from;
+ /* 16 */ std::array pattern_to;
+ /* 32 */ std::array texsize;
+ /* 40 */ float pad1;
+ /* 44 */ float pad2;
+ /* 48 */
+};
+static_assert(sizeof(FillExtrusionTilePropsUBO) == 3 * 16);
/// Evaluated properties that do not depend on the tile
struct alignas(16) FillExtrusionPropsUBO {
@@ -37,25 +54,5 @@ struct alignas(16) FillExtrusionPropsUBO {
};
static_assert(sizeof(FillExtrusionPropsUBO) == 5 * 16);
-/// Evaluated properties that depend on the tile
-struct alignas(16) FillExtrusionTilePropsUBO {
- /* 0 */ std::array pattern_from;
- /* 16 */ std::array pattern_to;
- /* 32 */
-};
-static_assert(sizeof(FillExtrusionTilePropsUBO) == 2 * 16);
-
-/// Attribute interpolations
-struct alignas(16) FillExtrusionInterpolateUBO {
- /* 0 */ float base_t;
- /* 4 */ float height_t;
- /* 8 */ float color_t;
- /* 12 */ float pattern_from_t;
- /* 16 */ float pattern_to_t;
- /* 20 */ float pad1, pad2, pad3;
- /* 32 */
-};
-static_assert(sizeof(FillExtrusionInterpolateUBO) == 2 * 16);
-
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/fill_layer_ubo.hpp b/include/mbgl/shaders/fill_layer_ubo.hpp
index bcfd34ef933..959c1aa1067 100644
--- a/include/mbgl/shaders/fill_layer_ubo.hpp
+++ b/include/mbgl/shaders/fill_layer_ubo.hpp
@@ -9,112 +9,127 @@ namespace shaders {
// Fill
struct alignas(16) FillDrawableUBO {
- /* 0 */ std::array matrix; // composite model-view-projection matrix
- /* 64 */
+ /* 0 */ std::array matrix;
+
+ // Interpolations
+ /* 64 */ float color_t;
+ /* 68 */ float opacity_t;
+ /* 72 */ float pad1;
+ /* 76 */ float pad2;
+ /* 80 */
};
-static_assert(sizeof(FillDrawableUBO) == 4 * 16);
-
-struct alignas(16) FillInterpolateUBO {
- float color_t;
- float opacity_t;
- float pad1, pad2;
-};
-static_assert(sizeof(FillInterpolateUBO) % 16 == 0);
+static_assert(sizeof(FillDrawableUBO) == 5 * 16);
//
// Fill outline
struct alignas(16) FillOutlineDrawableUBO {
- /* 0 */ std::array matrix; // composite model-view-projection matrix
- /* 64 */
-};
-static_assert(sizeof(FillOutlineDrawableUBO) == 4 * 16);
-
-struct alignas(16) FillOutlineInterpolateUBO {
- float outline_color_t;
- float opacity_t;
- float pad1, pad2;
+ /* 0 */ std::array matrix;
+
+ // Interpolations
+ /* 64 */ float outline_color_t;
+ /* 68 */ float opacity_t;
+ /* 72 */ float pad1;
+ /* 76 */ float pad2;
+ /* 80 */
};
-static_assert(sizeof(FillOutlineInterpolateUBO) == 1 * 16);
+static_assert(sizeof(FillOutlineDrawableUBO) == 5 * 16);
//
-// Fill Pattern
+// Fill pattern
struct alignas(16) FillPatternDrawableUBO {
- /* 0 */ std::array matrix; // composite model-view-projection matrix
+ /* 0 */ std::array matrix;
/* 64 */ std::array pixel_coord_upper;
/* 72 */ std::array pixel_coord_lower;
- /* 80 */ std::array texsize;
- /* 88 */ float tile_ratio;
- /* 92 */ float pad;
+ /* 80 */ float tile_ratio;
+
+ // Interpolations
+ /* 84 */ float pattern_from_t;
+ /* 88 */ float pattern_to_t;
+ /* 92 */ float opacity_t;
/* 96 */
};
static_assert(sizeof(FillPatternDrawableUBO) == 6 * 16);
struct alignas(16) FillPatternTilePropsUBO {
- std::array pattern_from;
- std::array pattern_to;
+ /* 0 */ std::array pattern_from;
+ /* 16 */ std::array pattern_to;
+ /* 32 */ std::array texsize;
+ /* 40 */ float pad1;
+ /* 44 */ float pad2;
+ /* 48 */
};
-static_assert(sizeof(FillPatternTilePropsUBO) == 2 * 16);
-
-struct alignas(16) FillPatternInterpolateUBO {
- float pattern_from_t;
- float pattern_to_t;
- float opacity_t;
- float pad1;
-};
-static_assert(sizeof(FillPatternInterpolateUBO) == 1 * 16);
+static_assert(sizeof(FillPatternTilePropsUBO) == 3 * 16);
//
// Fill pattern outline
struct alignas(16) FillOutlinePatternDrawableUBO {
- /* 0 */ std::array matrix; // composite model-view-projection matrix
- /* 64 */ std::array pixel_coord_upper;
- /* 72 */ std::array pixel_coord_lower;
- /* 80 */ std::array texsize;
- /* 88 */ float tile_ratio;
- /* 92 */ float pad;
- /* 96 */
+ /* 0 */ std::array matrix;
+ /* 64 */ std::array pixel_coord_upper;
+ /* 72 */ std::array pixel_coord_lower;
+ /* 80 */ float tile_ratio;
+
+ // Interpolations
+ /* 84 */ float pattern_from_t;
+ /* 88 */ float pattern_to_t;
+ /* 92 */ float opacity_t;
+ /* 96 */
};
static_assert(sizeof(FillOutlinePatternDrawableUBO) == 6 * 16);
struct alignas(16) FillOutlinePatternTilePropsUBO {
- std::array pattern_from;
- std::array pattern_to;
+ /* 0 */ std::array pattern_from;
+ /* 16 */ std::array pattern_to;
+ /* 32 */ std::array texsize;
+ /* 40 */ float pad1;
+ /* 44 */ float pad2;
+ /* 48 */
};
-static_assert(sizeof(FillOutlinePatternTilePropsUBO) == 2 * 16);
-
-struct alignas(16) FillOutlinePatternInterpolateUBO {
- float pattern_from_t;
- float pattern_to_t;
- float opacity_t;
- float pad;
-};
-static_assert(sizeof(FillOutlinePatternInterpolateUBO) == 1 * 16);
+static_assert(sizeof(FillOutlinePatternTilePropsUBO) == 3 * 16);
//
// Fill outline triangulated
struct alignas(16) FillOutlineTriangulatedDrawableUBO {
- std::array matrix;
- float ratio;
- float pad1, pad2, pad3;
+ /* 0 */ std::array matrix;
+ /* 64 */ float ratio;
+ /* 68 */ float pad1;
+ /* 72 */ float pad2;
+ /* 76 */ float pad3;
+ /* 80 */
};
-static_assert(sizeof(FillOutlineTriangulatedDrawableUBO) % 16 == 0);
-
-//
-// Fill evaluated properties
+static_assert(sizeof(FillOutlineTriangulatedDrawableUBO) == 5 * 16);
+/// Evaluated properties that do not depend on the tile
struct alignas(16) FillEvaluatedPropsUBO {
- Color color;
- Color outline_color;
- float opacity;
- float fade;
- float from_scale;
- float to_scale;
+ /* 0 */ Color color;
+ /* 16 */ Color outline_color;
+ /* 32 */ float opacity;
+ /* 36 */ float fade;
+ /* 40 */ float from_scale;
+ /* 44 */ float to_scale;
+ /* 48 */
};
static_assert(sizeof(FillEvaluatedPropsUBO) == 3 * 16);
+#if MLN_UBO_CONSOLIDATION
+
+union FillDrawableUnionUBO {
+ FillDrawableUBO fillDrawableUBO;
+ FillOutlineDrawableUBO fillOutlineDrawableUBO;
+ FillPatternDrawableUBO fillPatternDrawableUBO;
+ FillOutlinePatternDrawableUBO fillOutlinePatternDrawableUBO;
+ FillOutlineTriangulatedDrawableUBO fillOutlineTriangulatedDrawableUBO;
+};
+
+union FillTilePropsUnionUBO {
+ FillPatternTilePropsUBO fillPatternTilePropsUBO;
+ FillOutlinePatternTilePropsUBO fillOutlinePatternTilePropsUBO;
+};
+
+#endif
+
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/gl/drawable_background.hpp b/include/mbgl/shaders/gl/drawable_background.hpp
index e7abe2b9300..9e7e233a1df 100644
--- a/include/mbgl/shaders/gl/drawable_background.hpp
+++ b/include/mbgl/shaders/gl/drawable_background.hpp
@@ -17,10 +17,12 @@ void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform BackgroundLayerUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform BackgroundPropsUBO {
highp vec4 u_color;
highp float u_opacity;
- highp float layer_pad1, layer_pad2, layer_pad3;
+ lowp float props_pad1;
+ lowp float props_pad2;
+ lowp float props_pad3;
};
void main() {
diff --git a/include/mbgl/shaders/gl/drawable_background_pattern.hpp b/include/mbgl/shaders/gl/drawable_background_pattern.hpp
index d8edc98c143..94cacec93d8 100644
--- a/include/mbgl/shaders/gl/drawable_background_pattern.hpp
+++ b/include/mbgl/shaders/gl/drawable_background_pattern.hpp
@@ -13,9 +13,12 @@ struct ShaderSource {
static constexpr const char* name = "FillShader";
static constexpr const char* vertex = R"(layout (std140) uniform FillDrawableUBO {
highp mat4 u_matrix;
-};
-layout (std140) uniform FillInterpolateUBO {
+ // Interpolations
highp float u_color_t;
highp float u_opacity_t;
- highp float interp_pad1, interp_pad2;
+ lowp float drawable_pad1;
+ lowp float drawable_pad2;
};
+
layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
@@ -51,12 +52,7 @@ lowp float opacity = u_opacity;
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform FillInterpolateUBO {
- highp float u_color_t;
- highp float u_opacity_t;
- highp float interp_pad1, interp_pad2;
-};
-layout (std140) uniform FillEvaluatedPropsUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
highp float u_opacity;
diff --git a/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp b/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp
index 76b83e8fc40..10a7d912fb9 100644
--- a/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp
+++ b/include/mbgl/shaders/gl/drawable_fill_extrusion.hpp
@@ -14,16 +14,31 @@ out vec4 v_color;
layout (std140) uniform FillExtrusionDrawableUBO {
highp mat4 u_matrix;
- highp vec2 u_texsize;
highp vec2 u_pixel_coord_upper;
highp vec2 u_pixel_coord_lower;
highp float u_height_factor;
highp float u_tile_ratio;
+ // Interpolations
+ highp float u_base_t;
+ highp float u_height_t;
+ highp float u_color_t;
+ highp float u_pattern_from_t;
+ highp float u_pattern_to_t;
+ lowp float drawable_pad1;
+};
+
+layout (std140) uniform FillExtrusionTilePropsUBO {
+ highp vec4 u_pattern_from;
+ highp vec4 u_pattern_to;
+ highp vec2 u_texsize;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
+
layout (std140) uniform FillExtrusionPropsUBO {
highp vec4 u_color;
highp vec3 u_lightcolor;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec3 u_lightpos;
highp float u_base;
highp float u_height;
@@ -33,20 +48,9 @@ layout (std140) uniform FillExtrusionPropsUBO {
highp float u_fade;
highp float u_from_scale;
highp float u_to_scale;
- highp float props_pad2;
-};
-layout (std140) uniform FillExtrusionTilePropsUBO {
- highp vec4 u_pattern_from;
- highp vec4 u_pattern_to;
-};
-layout (std140) uniform FillExtrusionInterpolateUBO {
- highp float u_base_t;
- highp float u_height_t;
- highp float u_color_t;
- highp float u_pattern_from_t;
- highp float u_pattern_to_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
+ lowp float props_pad2;
};
+
#ifndef HAS_UNIFORM_u_base
layout (location = 2) in highp vec2 a_base;
#endif
diff --git a/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp
index df273b63d75..11f7e40c42e 100644
--- a/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp
+++ b/include/mbgl/shaders/gl/drawable_fill_extrusion_pattern.hpp
@@ -23,21 +23,37 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform FillExtrusionDrawableUBO {
highp mat4 u_matrix;
- highp vec2 u_texsize;
highp vec2 u_pixel_coord_upper;
highp vec2 u_pixel_coord_lower;
highp float u_height_factor;
highp float u_tile_ratio;
+ // Interpolations
+ highp float u_base_t;
+ highp float u_height_t;
+ highp float u_color_t;
+ highp float u_pattern_from_t;
+ highp float u_pattern_to_t;
+ lowp float drawable_pad1;
+};
+
+layout (std140) uniform FillExtrusionTilePropsUBO {
+ highp vec4 u_pattern_from;
+ highp vec4 u_pattern_to;
+ highp vec2 u_texsize;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
+
layout (std140) uniform FillExtrusionPropsUBO {
highp vec4 u_color;
highp vec3 u_lightcolor;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec3 u_lightpos;
highp float u_base;
highp float u_height;
@@ -47,19 +63,7 @@ layout (std140) uniform FillExtrusionPropsUBO {
highp float u_fade;
highp float u_from_scale;
highp float u_to_scale;
- highp float props_pad2;
-};
-layout (std140) uniform FillExtrusionTilePropsUBO {
- highp vec4 u_pattern_from;
- highp vec4 u_pattern_to;
-};
-layout (std140) uniform FillExtrusionInterpolateUBO {
- highp float u_base_t;
- highp float u_height_t;
- highp float u_color_t;
- highp float u_pattern_from_t;
- highp float u_pattern_to_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
+ lowp float props_pad2;
};
#ifndef HAS_UNIFORM_u_base
@@ -152,18 +156,18 @@ mediump vec4 pattern_to = u_pattern_to;
in vec2 v_pos_b;
in vec4 v_lighting;
-layout (std140) uniform FillExtrusionDrawableUBO {
- highp mat4 u_matrix;
+layout (std140) uniform FillExtrusionTilePropsUBO {
+ highp vec4 u_pattern_from;
+ highp vec4 u_pattern_to;
highp vec2 u_texsize;
- highp vec2 u_pixel_coord_upper;
- highp vec2 u_pixel_coord_lower;
- highp float u_height_factor;
- highp float u_tile_ratio;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
+
layout (std140) uniform FillExtrusionPropsUBO {
highp vec4 u_color;
highp vec3 u_lightcolor;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec3 u_lightpos;
highp float u_base;
highp float u_height;
@@ -173,19 +177,7 @@ layout (std140) uniform FillExtrusionPropsUBO {
highp float u_fade;
highp float u_from_scale;
highp float u_to_scale;
- highp float props_pad2;
-};
-layout (std140) uniform FillExtrusionTilePropsUBO {
- highp vec4 u_pattern_from;
- highp vec4 u_pattern_to;
-};
-layout (std140) uniform FillExtrusionInterpolateUBO {
- highp float u_base_t;
- highp float u_height_t;
- highp float u_color_t;
- highp float u_pattern_from_t;
- highp float u_pattern_to_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
+ lowp float props_pad2;
};
uniform sampler2D u_image;
diff --git a/include/mbgl/shaders/gl/drawable_fill_outline.hpp b/include/mbgl/shaders/gl/drawable_fill_outline.hpp
index 08082a443a9..ae157ae5f4b 100644
--- a/include/mbgl/shaders/gl/drawable_fill_outline.hpp
+++ b/include/mbgl/shaders/gl/drawable_fill_outline.hpp
@@ -16,17 +16,19 @@ struct ShaderSource {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
+
layout (std140) uniform FillOutlineDrawableUBO {
highp mat4 u_matrix;
-};
-layout (std140) uniform FillOutlineInterpolateUBO {
+ // Interpolations
highp float u_outline_color_t;
highp float u_opacity_t;
- highp float interp_pad1;
- highp float interp_pad2;
+ lowp float drawable_pad1;
+ lowp float drawable_pad2;
};
+
layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
@@ -65,13 +67,7 @@ lowp float opacity = u_opacity;
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world_size;
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform FillOutlineInterpolateUBO {
- highp float u_outline_color_t;
- highp float u_opacity_t;
- highp float interp_pad1;
- highp float interp_pad2;
-};
-layout (std140) uniform FillEvaluatedPropsUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
highp float u_opacity;
diff --git a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp b/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp
index caaac380308..f197a56318f 100644
--- a/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp
+++ b/include/mbgl/shaders/gl/drawable_fill_outline_pattern.hpp
@@ -16,26 +16,29 @@ struct ShaderSource {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
+
layout (std140) uniform FillPatternDrawableUBO {
highp mat4 u_matrix;
highp vec2 u_pixel_coord_upper;
highp vec2 u_pixel_coord_lower;
- highp vec2 u_texsize;
highp float u_tile_ratio;
- highp float drawable_pad1;
+ // Interpolations
+ highp float u_pattern_from_t;
+ highp float u_pattern_to_t;
+ highp float u_opacity_t;
};
+
layout (std140) uniform FillPatternTilePropsUBO {
highp vec4 u_pattern_from;
highp vec4 u_pattern_to;
+ highp vec2 u_texsize;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
-layout (std140) uniform FillPatternInterpolateUBO {
- highp float u_pattern_from_t;
- highp float u_pattern_to_t;
- highp float u_opacity_t;
- highp float interp_pad1;
-};
+
layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
@@ -98,24 +101,14 @@ mediump vec4 pattern_to = u_pattern_to;
v_pos_b = get_pattern_pos(u_pixel_coord_upper, u_pixel_coord_lower, toScale * display_size_b, tileZoomRatio, a_pos);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform FillPatternDrawableUBO {
- highp mat4 u_matrix;
- highp vec2 u_pixel_coord_upper;
- highp vec2 u_pixel_coord_lower;
- highp vec2 u_texsize;
- highp float u_tile_ratio;
- highp float drawable_pad1;
-};
-layout (std140) uniform FillPatternTilePropsUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform FillPatternTilePropsUBO {
highp vec4 u_pattern_from;
highp vec4 u_pattern_to;
+ highp vec2 u_texsize;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
-layout (std140) uniform FillPatternInterpolateUBO {
- highp float u_pattern_from_t;
- highp float u_pattern_to_t;
- highp float u_opacity_t;
- highp float interp_pad1;
-};
+
layout (std140) uniform FillEvaluatedPropsUBO {
highp vec4 u_color;
highp vec4 u_outline_color;
diff --git a/include/mbgl/shaders/gl/drawable_heatmap.hpp b/include/mbgl/shaders/gl/drawable_heatmap.hpp
index ebec009db5d..9b93c798e12 100644
--- a/include/mbgl/shaders/gl/drawable_heatmap.hpp
+++ b/include/mbgl/shaders/gl/drawable_heatmap.hpp
@@ -14,8 +14,10 @@ out vec2 v_extrude;
layout (std140) uniform HeatmapDrawableUBO {
highp mat4 u_matrix;
highp float u_extrude_scale;
+ // Interpolations
+ lowp float u_weight_t;
+ lowp float u_radius_t;
lowp float drawable_pad1;
- lowp vec2 drawable_pad2;
};
layout (std140) uniform HeatmapEvaluatedPropsUBO {
@@ -25,12 +27,6 @@ layout (std140) uniform HeatmapEvaluatedPropsUBO {
lowp float props_pad1;
};
-layout (std140) uniform HeatmapInterpolateUBO {
- lowp float u_weight_t;
- lowp float u_radius_t;
- lowp vec2 interp_pad1;
-};
-
#ifndef HAS_UNIFORM_u_weight
layout (location = 1) in highp vec2 a_weight;
out highp float weight;
diff --git a/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp b/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp
index c1593d0059f..19317a2d6c6 100644
--- a/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp
+++ b/include/mbgl/shaders/gl/drawable_heatmap_texture.hpp
@@ -19,12 +19,16 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
+
layout (std140) uniform HeatmapTexturePropsUBO {
highp mat4 u_matrix;
highp float u_opacity;
- lowp float props_pad1, props_pad2, props_pad3;
+ lowp float props_pad1;
+ lowp float props_pad2;
+ lowp float props_pad3;
};
void main() {
@@ -41,7 +45,9 @@ uniform sampler2D u_color_ramp;
layout (std140) uniform HeatmapTexturePropsUBO {
highp mat4 u_matrix;
highp float u_opacity;
- lowp float props_pad1, props_pad2, props_pad3;
+ lowp float props_pad1;
+ lowp float props_pad2;
+ lowp float props_pad3;
};
void main() {
diff --git a/include/mbgl/shaders/gl/drawable_hillshade.hpp b/include/mbgl/shaders/gl/drawable_hillshade.hpp
index 3d706de1a5f..8d186538040 100644
--- a/include/mbgl/shaders/gl/drawable_hillshade.hpp
+++ b/include/mbgl/shaders/gl/drawable_hillshade.hpp
@@ -13,8 +13,6 @@ layout (location = 1) in vec2 a_texture_pos;
layout (std140) uniform HillshadeDrawableUBO {
highp mat4 u_matrix;
- highp vec2 u_latrange;
- highp vec2 u_light;
};
out vec2 v_pos;
@@ -27,8 +25,7 @@ void main() {
static constexpr const char* fragment = R"(in vec2 v_pos;
uniform sampler2D u_image;
-layout (std140) uniform HillshadeDrawableUBO {
- highp mat4 u_matrix;
+layout (std140) uniform HillshadeTilePropsUBO {
highp vec2 u_latrange;
highp vec2 u_light;
};
diff --git a/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp b/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp
index 76335aed366..2a2bf01b533 100644
--- a/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp
+++ b/include/mbgl/shaders/gl/drawable_hillshade_prepare.hpp
@@ -13,6 +13,9 @@ layout (location = 1) in vec2 a_texture_pos;
layout (std140) uniform HillshadePrepareDrawableUBO {
highp mat4 u_matrix;
+};
+
+layout (std140) uniform HillshadePrepareTilePropsUBO {
highp vec4 u_unpack;
highp vec2 u_dimension;
highp float u_zoom;
@@ -36,8 +39,7 @@ precision highp float;
in vec2 v_pos;
uniform sampler2D u_image;
-layout (std140) uniform HillshadePrepareDrawableUBO {
- highp mat4 u_matrix;
+layout (std140) uniform HillshadePrepareTilePropsUBO {
highp vec4 u_unpack;
highp vec2 u_dimension;
highp float u_zoom;
diff --git a/include/mbgl/shaders/gl/drawable_line.hpp b/include/mbgl/shaders/gl/drawable_line.hpp
index ac8a9cabfb9..1f093581782 100644
--- a/include/mbgl/shaders/gl/drawable_line.hpp
+++ b/include/mbgl/shaders/gl/drawable_line.hpp
@@ -27,23 +27,21 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform LineDrawableUBO {
highp mat4 u_matrix;
mediump float u_ratio;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineInterpolationUBO {
+ // Interpolations
lowp float u_color_t;
lowp float u_blur_t;
lowp float u_opacity_t;
lowp float u_gapwidth_t;
lowp float u_offset_t;
lowp float u_width_t;
- highp vec2 interp_pad1;
+ lowp float drawable_pad1;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -54,8 +52,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
out vec2 v_normal;
@@ -167,23 +165,7 @@ mediump float width = u_width;
v_width2 = vec2(outset, inset);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform LineDrawableUBO {
- highp mat4 u_matrix;
- mediump float u_ratio;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineInterpolationUBO {
- lowp float u_color_t;
- lowp float u_blur_t;
- lowp float u_opacity_t;
- lowp float u_gapwidth_t;
- lowp float u_offset_t;
- lowp float u_width_t;
- highp vec2 interp_pad1;
-};
-
-layout (std140) uniform LineEvaluatedPropsUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
highp vec4 u_color;
lowp float u_blur;
lowp float u_opacity;
@@ -191,8 +173,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
in vec2 v_width2;
diff --git a/include/mbgl/shaders/gl/drawable_line_gradient.hpp b/include/mbgl/shaders/gl/drawable_line_gradient.hpp
index 0ddae503a60..c77e020c44a 100644
--- a/include/mbgl/shaders/gl/drawable_line_gradient.hpp
+++ b/include/mbgl/shaders/gl/drawable_line_gradient.hpp
@@ -31,23 +31,21 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform LineGradientDrawableUBO {
highp mat4 u_matrix;
mediump float u_ratio;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineGradientInterpolationUBO {
+ // Interpolations
lowp float u_blur_t;
lowp float u_opacity_t;
lowp float u_gapwidth_t;
lowp float u_offset_t;
lowp float u_width_t;
- highp float interp_pad1;
- highp vec2 interp_pad2;
+ lowp float drawable_pad1;
+ lowp float drawable_pad2;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -58,8 +56,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
out vec2 v_normal;
@@ -162,23 +160,7 @@ mediump float width = u_width;
v_width2 = vec2(outset, inset);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform LineGradientDrawableUBO {
- highp mat4 u_matrix;
- mediump float u_ratio;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineGradientInterpolationUBO {
- lowp float u_blur_t;
- lowp float u_opacity_t;
- lowp float u_gapwidth_t;
- lowp float u_offset_t;
- lowp float u_width_t;
- highp float interp_pad1;
- highp vec2 interp_pad2;
-};
-
-layout (std140) uniform LineEvaluatedPropsUBO {
+ static constexpr const char* fragment = R"(layout (std140) uniform LineEvaluatedPropsUBO {
highp vec4 u_color;
lowp float u_blur;
lowp float u_opacity;
@@ -186,8 +168,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
uniform sampler2D u_image;
diff --git a/include/mbgl/shaders/gl/drawable_line_pattern.hpp b/include/mbgl/shaders/gl/drawable_line_pattern.hpp
index cc03b8ffce4..ea4b8809f80 100644
--- a/include/mbgl/shaders/gl/drawable_line_pattern.hpp
+++ b/include/mbgl/shaders/gl/drawable_line_pattern.hpp
@@ -31,18 +31,13 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
-
layout (std140) uniform LinePatternDrawableUBO {
highp mat4 u_matrix;
- mediump vec4 u_scale;
- highp vec2 u_texsize;
mediump float u_ratio;
- highp float u_fade;
-};
-
-layout (std140) uniform LinePatternInterpolationUBO {
+ // Interpolations
lowp float u_blur_t;
lowp float u_opacity_t;
lowp float u_offset_t;
@@ -50,12 +45,15 @@ layout (std140) uniform LinePatternInterpolationUBO {
lowp float u_width_t;
lowp float u_pattern_from_t;
lowp float u_pattern_to_t;
- highp float interp_pad1;
};
-layout (std140) uniform LinePatternTilePropertiesUBO {
+layout (std140) uniform LinePatternTilePropsUBO {
lowp vec4 u_pattern_from;
lowp vec4 u_pattern_to;
+ mediump vec4 u_scale;
+ highp vec2 u_texsize;
+ highp float u_fade;
+ lowp float tileprops_pad1;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -66,8 +64,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
out vec2 v_normal;
@@ -188,28 +186,13 @@ mediump vec4 pattern_to = u_pattern_to;
v_width2 = vec2(outset, inset);
}
)";
- static constexpr const char* fragment = R"(layout (std140) uniform LinePatternDrawableUBO {
- highp mat4 u_matrix;
+ static constexpr const char* fragment = R"(layout (std140) uniform LinePatternTilePropsUBO {
+ lowp vec4 u_pattern_from;
+ lowp vec4 u_pattern_to;
mediump vec4 u_scale;
highp vec2 u_texsize;
- mediump float u_ratio;
highp float u_fade;
-};
-
-layout (std140) uniform LinePatternInterpolationUBO {
- lowp float u_blur_t;
- lowp float u_opacity_t;
- lowp float u_offset_t;
- lowp float u_gapwidth_t;
- lowp float u_width_t;
- lowp float u_pattern_from_t;
- lowp float u_pattern_to_t;
- highp float interp_pad1;
-};
-
-layout (std140) uniform LinePatternTilePropertiesUBO {
- lowp vec4 u_pattern_from;
- lowp vec4 u_pattern_to;
+ lowp float tileprops_pad1;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -220,8 +203,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
uniform sampler2D u_image;
diff --git a/include/mbgl/shaders/gl/drawable_line_sdf.hpp b/include/mbgl/shaders/gl/drawable_line_sdf.hpp
index 7fef18b0780..7772658f2c2 100644
--- a/include/mbgl/shaders/gl/drawable_line_sdf.hpp
+++ b/include/mbgl/shaders/gl/drawable_line_sdf.hpp
@@ -31,22 +31,18 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform LineSDFDrawableUBO {
highp mat4 u_matrix;
highp vec2 u_patternscale_a;
highp vec2 u_patternscale_b;
- mediump float u_ratio;
highp float u_tex_y_a;
highp float u_tex_y_b;
- highp float u_sdfgamma;
- highp float u_mix;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineSDFInterpolationUBO {
+ mediump float u_ratio;
+ // Interpolations
lowp float u_color_t;
lowp float u_blur_t;
lowp float u_opacity_t;
@@ -54,7 +50,8 @@ layout (std140) uniform LineSDFInterpolationUBO {
lowp float u_offset_t;
lowp float u_width_t;
lowp float u_floorwidth_t;
- highp float interp_pad1;
+ lowp float drawable_pad1;
+ lowp float drawable_pad2;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -65,8 +62,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
out vec2 v_normal;
@@ -191,28 +188,11 @@ lowp float floorwidth = u_floorwidth;
v_width2 = vec2(outset, inset);
}
)";
- static constexpr const char* fragment = R"(
-layout (std140) uniform LineSDFDrawableUBO {
- highp mat4 u_matrix;
- highp vec2 u_patternscale_a;
- highp vec2 u_patternscale_b;
- mediump float u_ratio;
- highp float u_tex_y_a;
- highp float u_tex_y_b;
+ static constexpr const char* fragment = R"(layout (std140) uniform LineSDFTilePropsUBO {
highp float u_sdfgamma;
highp float u_mix;
- lowp float drawable_pad1, drawable_pad2, drawable_pad3;
-};
-
-layout (std140) uniform LineSDFInterpolationUBO {
- lowp float u_color_t;
- lowp float u_blur_t;
- lowp float u_opacity_t;
- lowp float u_gapwidth_t;
- lowp float u_offset_t;
- lowp float u_width_t;
- lowp float u_floorwidth_t;
- highp float interp_pad1;
+ lowp float tileprops_pad1;
+ lowp float tileprops_pad2;
};
layout (std140) uniform LineEvaluatedPropsUBO {
@@ -223,8 +203,8 @@ layout (std140) uniform LineEvaluatedPropsUBO {
lowp float u_offset;
mediump float u_width;
lowp float u_floorwidth;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
uniform sampler2D u_image;
diff --git a/include/mbgl/shaders/gl/drawable_location_indicator.hpp b/include/mbgl/shaders/gl/drawable_location_indicator.hpp
new file mode 100644
index 00000000000..af1c0d5c465
--- /dev/null
+++ b/include/mbgl/shaders/gl/drawable_location_indicator.hpp
@@ -0,0 +1,16 @@
+// Generated code, do not modify this file!
+#pragma once
+#include
+
+namespace mbgl {
+namespace shaders {
+
+template <>
+struct ShaderSource {
+ static constexpr const char* name = "LocationIndicatorShader";
+ static constexpr const char* vertex = R"()";
+ static constexpr const char* fragment = R"()";
+};
+
+} // namespace shaders
+} // namespace mbgl
diff --git a/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp b/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp
new file mode 100644
index 00000000000..cc26f8711af
--- /dev/null
+++ b/include/mbgl/shaders/gl/drawable_location_indicator_textured.hpp
@@ -0,0 +1,16 @@
+// Generated code, do not modify this file!
+#pragma once
+#include
+
+namespace mbgl {
+namespace shaders {
+
+template <>
+struct ShaderSource {
+ static constexpr const char* name = "LocationIndicatorTexturedShader";
+ static constexpr const char* vertex = R"()";
+ static constexpr const char* fragment = R"()";
+};
+
+} // namespace shaders
+} // namespace mbgl
diff --git a/include/mbgl/shaders/gl/drawable_raster.hpp b/include/mbgl/shaders/gl/drawable_raster.hpp
index 36eea70f8d9..ee2865764d1 100644
--- a/include/mbgl/shaders/gl/drawable_raster.hpp
+++ b/include/mbgl/shaders/gl/drawable_raster.hpp
@@ -22,8 +22,8 @@ layout (std140) uniform RasterEvaluatedPropsUBO {
highp float u_brightness_high;
highp float u_saturation_factor;
highp float u_contrast_factor;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
layout (location = 0) in vec2 a_pos;
@@ -54,8 +54,8 @@ void main() {
highp float u_brightness_high;
highp float u_saturation_factor;
highp float u_contrast_factor;
- highp float props_pad1;
- highp float props_pad2;
+ lowp float props_pad1;
+ lowp float props_pad2;
};
uniform sampler2D u_image0;
uniform sampler2D u_image1;
diff --git a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
index ecc372e8a15..9ac73b34aa4 100644
--- a/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
+++ b/include/mbgl/shaders/gl/drawable_symbol_icon.hpp
@@ -22,7 +22,8 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform SymbolDrawableUBO {
@@ -33,29 +34,21 @@ layout (std140) uniform SymbolDrawableUBO {
highp vec2 u_texsize;
highp vec2 u_texsize_icon;
- highp float u_gamma_scale;
+ bool u_is_text_prop;
bool u_rotate_symbol;
- highp vec2 drawable_pad1;
-};
-
-layout (std140) uniform SymbolTilePropsUBO {
- bool u_is_text;
- bool u_is_halo;
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
+
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
-};
-layout (std140) uniform SymbolInterpolateUBO {
+ // Interpolations
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -64,13 +57,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
out vec2 v_tex;
@@ -82,7 +75,7 @@ out lowp float opacity;
#endif
void main() {
- highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
+ highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
@@ -124,7 +117,7 @@ lowp float opacity = u_opacity;
size *= perspective_ratio;
- float fontScale = u_is_text ? size / 24.0 : size;
+ float fontScale = u_is_text_prop ? size / 24.0 : size;
highp float symbol_rotation = 0.0;
if (u_rotate_symbol) {
@@ -155,12 +148,8 @@ lowp float opacity = u_opacity;
layout (std140) uniform SymbolTilePropsUBO {
bool u_is_text;
bool u_is_halo;
- bool u_pitch_with_map;
- bool u_is_size_zoom_constant;
- bool u_is_size_feature_constant;
- highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
- highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
+ highp float u_gamma_scale;
+ lowp float tileprops_pad1;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -169,13 +158,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
in vec2 v_tex;
diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp b/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
index 4b75ae40823..12d88136a7c 100644
--- a/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
+++ b/include/mbgl/shaders/gl/drawable_symbol_sdf.hpp
@@ -30,7 +30,8 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform SymbolDrawableUBO {
@@ -41,29 +42,21 @@ layout (std140) uniform SymbolDrawableUBO {
highp vec2 u_texsize;
highp vec2 u_texsize_icon;
- highp float u_gamma_scale;
+ bool u_is_text_prop;
bool u_rotate_symbol;
- highp vec2 drawable_pad1;
-};
-
-layout (std140) uniform SymbolTilePropsUBO {
- bool u_is_text;
- bool u_is_halo;
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
+
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
-};
-layout (std140) uniform SymbolInterpolateUBO {
+ // Interpolations
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -72,13 +65,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
out vec2 v_data0;
@@ -106,11 +99,11 @@ out lowp float halo_blur;
#endif
void main() {
- highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color;
- highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color;
- highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
- highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width;
- highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur;
+ highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color;
+ highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color;
+ highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
+ highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width;
+ highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur;
#ifndef HAS_UNIFORM_u_fill_color
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
@@ -176,7 +169,7 @@ lowp float halo_blur = u_halo_blur;
size *= perspective_ratio;
- float fontScale = u_is_text ? size / 24.0 : size;
+ float fontScale = u_is_text_prop ? size / 24.0 : size;
highp float symbol_rotation = 0.0;
if (u_rotate_symbol) {
@@ -209,28 +202,11 @@ lowp float halo_blur = u_halo_blur;
)";
static constexpr const char* fragment = R"(#define SDF_PX 8.0
-layout (std140) uniform SymbolDrawableUBO {
- highp mat4 u_matrix;
- highp mat4 u_label_plane_matrix;
- highp mat4 u_coord_matrix;
-
- highp vec2 u_texsize;
- highp vec2 u_texsize_icon;
-
- highp float u_gamma_scale;
- bool u_rotate_symbol;
- highp vec2 drawable_pad1;
-};
-
layout (std140) uniform SymbolTilePropsUBO {
bool u_is_text;
bool u_is_halo;
- bool u_pitch_with_map;
- bool u_is_size_zoom_constant;
- bool u_is_size_feature_constant;
- highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
- highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
+ highp float u_gamma_scale;
+ lowp float tileprops_pad1;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -239,13 +215,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
uniform sampler2D u_texture;
diff --git a/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp b/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp
deleted file mode 100644
index 7dbcfb10f69..00000000000
--- a/include/mbgl/shaders/gl/drawable_symbol_sdf_text.hpp
+++ /dev/null
@@ -1,323 +0,0 @@
-// Generated code, do not modify this file!
-#pragma once
-#include
-
-namespace mbgl {
-namespace shaders {
-
-template <>
-struct ShaderSource {
- static constexpr const char* name = "SymbolSDFTextShader";
- static constexpr const char* vertex = R"(layout (location = 0) in vec4 a_pos_offset;
-layout (location = 1) in vec4 a_data;
-layout (location = 2) in vec4 a_pixeloffset;
-layout (location = 3) in vec3 a_projected_pos;
-layout (location = 4) in float a_fade_opacity;
-
-// contents of a_size vary based on the type of property value
-// used for {text,icon}-size.
-// For constants, a_size is disabled.
-// For source functions, we bind only one value per vertex: the value of {text,icon}-size evaluated for the current feature.
-// For composite functions:
-// [ text-size(lowerZoomStop, feature),
-// text-size(upperZoomStop, feature) ]
-
-layout (std140) uniform SymbolDrawableUBO {
- highp mat4 u_matrix;
- highp mat4 u_label_plane_matrix;
- highp mat4 u_coord_matrix;
-
- highp vec2 u_texsize;
- highp vec2 u_texsize_icon;
-
- highp float u_gamma_scale;
- highp float u_device_pixel_ratio;
-
- highp float u_camera_to_center_distance;
- highp float u_pitch;
- bool u_rotate_symbol;
- highp float u_aspect_ratio;
- highp vec2 u_pad1;
-};
-
-layout (std140) uniform SymbolDynamicUBO {
- highp float u_fade_change;
- highp float u_pad7;
- highp vec2 u_pad8;
-};
-
-layout (std140) uniform SymbolDrawablePaintUBO {
- highp vec4 u_fill_color;
- highp vec4 u_halo_color;
- highp float u_opacity;
- highp float u_halo_width;
- highp float u_halo_blur;
- highp float u_padding;
-};
-
-layout (std140) uniform SymbolDrawableTilePropsUBO {
- bool u_is_text;
- bool u_is_halo;
- bool u_pitch_with_map;
- bool u_is_size_zoom_constant;
- bool u_is_size_feature_constant;
- highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
- highp float u_size; // used when size is both zoom and feature constant
- bool u_pad3;
-};
-
-layout (std140) uniform SymbolDrawableInterpolateUBO {
- highp float u_fill_color_t;
- highp float u_halo_color_t;
- highp float u_opacity_t;
- highp float u_halo_width_t;
- highp float u_halo_blur_t;
- highp float u_pad4,u_pad5,u_pad6;
-};
-
-out vec2 v_data0;
-out vec3 v_data1;
-
-#ifndef HAS_UNIFORM_u_fill_color
-layout (location = 5) in highp vec4 a_fill_color;
-out highp vec4 fill_color;
-#endif
-#ifndef HAS_UNIFORM_u_halo_color
-layout (location = 6) in highp vec4 a_halo_color;
-out highp vec4 halo_color;
-#endif
-#ifndef HAS_UNIFORM_u_opacity
-layout (location = 7) in lowp vec2 a_opacity;
-out lowp float opacity;
-#endif
-#ifndef HAS_UNIFORM_u_halo_width
-layout (location = 8) in lowp vec2 a_halo_width;
-out lowp float halo_width;
-#endif
-#ifndef HAS_UNIFORM_u_halo_blur
-layout (location = 9) in lowp vec2 a_halo_blur;
-out lowp float halo_blur;
-#endif
-
-void main() {
- #ifndef HAS_UNIFORM_u_fill_color
-fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
-#else
-highp vec4 fill_color = u_fill_color;
-#endif
- #ifndef HAS_UNIFORM_u_halo_color
-halo_color = unpack_mix_color(a_halo_color, u_halo_color_t);
-#else
-highp vec4 halo_color = u_halo_color;
-#endif
- #ifndef HAS_UNIFORM_u_opacity
-opacity = unpack_mix_vec2(a_opacity, u_opacity_t);
-#else
-lowp float opacity = u_opacity;
-#endif
- #ifndef HAS_UNIFORM_u_halo_width
-halo_width = unpack_mix_vec2(a_halo_width, u_halo_width_t);
-#else
-lowp float halo_width = u_halo_width;
-#endif
- #ifndef HAS_UNIFORM_u_halo_blur
-halo_blur = unpack_mix_vec2(a_halo_blur, u_halo_blur_t);
-#else
-lowp float halo_blur = u_halo_blur;
-#endif
-
- vec2 a_pos = a_pos_offset.xy;
- vec2 a_offset = a_pos_offset.zw;
-
- vec2 a_tex = a_data.xy;
- vec2 a_size = a_data.zw;
-
- float a_size_min = floor(a_size[0] * 0.5);
- vec2 a_pxoffset = a_pixeloffset.xy;
-
- highp float segment_angle = -a_projected_pos[2];
- float size;
-
- if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {
- size = mix(a_size_min, a_size[1], u_size_t) / 128.0;
- } else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {
- size = a_size_min / 128.0;
- } else {
- size = u_size;
- }
-
- vec4 projectedPoint = u_matrix * vec4(a_pos, 0, 1);
- highp float camera_to_anchor_distance = projectedPoint.w;
- // If the label is pitched with the map, layout is done in pitched space,
- // which makes labels in the distance smaller relative to viewport space.
- // We counteract part of that effect by multiplying by the perspective ratio.
- // If the label isn't pitched with the map, we do layout in viewport space,
- // which makes labels in the distance larger relative to the features around
- // them. We counteract part of that effect by dividing by the perspective ratio.
- highp float distance_ratio = u_pitch_with_map ?
- camera_to_anchor_distance / u_camera_to_center_distance :
- u_camera_to_center_distance / camera_to_anchor_distance;
- highp float perspective_ratio = clamp(
- 0.5 + 0.5 * distance_ratio,
- 0.0, // Prevents oversized near-field symbols in pitched/overzoomed tiles
- 4.0);
-
- size *= perspective_ratio;
-
- float fontScale = u_is_text ? size / 24.0 : size;
-
- highp float symbol_rotation = 0.0;
- if (u_rotate_symbol) {
- // Point labels with 'rotation-alignment: map' are horizontal with respect to tile units
- // To figure out that angle in projected space, we draw a short horizontal line in tile
- // space, project it, and measure its angle in projected space.
- vec4 offsetProjectedPoint = u_matrix * vec4(a_pos + vec2(1, 0), 0, 1);
-
- vec2 a = projectedPoint.xy / projectedPoint.w;
- vec2 b = offsetProjectedPoint.xy / offsetProjectedPoint.w;
-
- symbol_rotation = atan((b.y - a.y) / u_aspect_ratio, b.x - a.x);
- }
-
- highp float angle_sin = sin(segment_angle + symbol_rotation);
- highp float angle_cos = cos(segment_angle + symbol_rotation);
- mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);
-
- vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
- gl_Position = u_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale + a_pxoffset), 0.0, 1.0);
- float gamma_scale = gl_Position.w;
-
- vec2 fade_opacity = unpack_opacity(a_fade_opacity);
- float fade_change = fade_opacity[1] > 0.5 ? u_fade_change : -u_fade_change;
- float interpolated_fade_opacity = max(0.0, min(1.0, fade_opacity[0] + fade_change));
-
- v_data0 = a_tex / u_texsize;
- v_data1 = vec3(gamma_scale, size, interpolated_fade_opacity);
-}
-)";
- static constexpr const char* fragment = R"(#define SDF_PX 8.0
-
-layout (std140) uniform SymbolDrawableUBO {
- highp mat4 u_matrix;
- highp mat4 u_label_plane_matrix;
- highp mat4 u_coord_matrix;
-
- highp vec2 u_texsize;
- highp vec2 u_texsize_icon;
-
- highp float u_gamma_scale;
- highp float u_device_pixel_ratio;
-
- highp float u_camera_to_center_distance;
- highp float u_pitch;
- bool u_rotate_symbol;
- highp float u_aspect_ratio;
- highp vec2 u_pad1;
-};
-
-layout (std140) uniform SymbolDynamicUBO {
- highp float u_fade_change;
- highp float u_pad7;
- highp vec2 u_pad8;
-};
-
-layout (std140) uniform SymbolDrawablePaintUBO {
- highp vec4 u_fill_color;
- highp vec4 u_halo_color;
- highp float u_opacity;
- highp float u_halo_width;
- highp float u_halo_blur;
- highp float u_padding;
-};
-
-layout (std140) uniform SymbolDrawableTilePropsUBO {
- bool u_is_text;
- bool u_is_halo;
- bool u_pitch_with_map;
- bool u_is_size_zoom_constant;
- bool u_is_size_feature_constant;
- highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
- highp float u_size; // used when size is both zoom and feature constant
- bool u_pad3;
-};
-
-layout (std140) uniform SymbolDrawableInterpolateUBO {
- highp float u_fill_color_t;
- highp float u_halo_color_t;
- highp float u_opacity_t;
- highp float u_halo_width_t;
- highp float u_halo_blur_t;
- highp float u_pad4,u_pad5,u_pad6;
-};
-
-uniform sampler2D u_texture;
-
-in vec2 v_data0;
-in vec3 v_data1;
-
-#ifndef HAS_UNIFORM_u_fill_color
-in highp vec4 fill_color;
-#endif
-#ifndef HAS_UNIFORM_u_halo_color
-in highp vec4 halo_color;
-#endif
-#ifndef HAS_UNIFORM_u_opacity
-in lowp float opacity;
-#endif
-#ifndef HAS_UNIFORM_u_halo_width
-in lowp float halo_width;
-#endif
-#ifndef HAS_UNIFORM_u_halo_blur
-in lowp float halo_blur;
-#endif
-
-void main() {
- #ifdef HAS_UNIFORM_u_fill_color
-highp vec4 fill_color = u_fill_color;
-#endif
- #ifdef HAS_UNIFORM_u_halo_color
-highp vec4 halo_color = u_halo_color;
-#endif
- #ifdef HAS_UNIFORM_u_opacity
-lowp float opacity = u_opacity;
-#endif
- #ifdef HAS_UNIFORM_u_halo_width
-lowp float halo_width = u_halo_width;
-#endif
- #ifdef HAS_UNIFORM_u_halo_blur
-lowp float halo_blur = u_halo_blur;
-#endif
-
- float EDGE_GAMMA = 0.105 / u_device_pixel_ratio;
-
- vec2 tex = v_data0.xy;
- float gamma_scale = v_data1.x;
- float size = v_data1.y;
- float fade_opacity = v_data1[2];
-
- float fontScale = u_is_text ? size / 24.0 : size;
-
- lowp vec4 color = fill_color;
- highp float gamma = EDGE_GAMMA / (fontScale * u_gamma_scale);
- lowp float buff = (256.0 - 64.0) / 256.0;
- if (u_is_halo) {
- color = halo_color;
- gamma = (halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (fontScale * u_gamma_scale);
- buff = (6.0 - halo_width / fontScale) / SDF_PX;
- }
-
- lowp float dist = texture(u_texture, tex).a;
- highp float gamma_scaled = gamma * gamma_scale;
- highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);
-
- fragColor = color * (alpha * opacity * fade_opacity);
-
-#ifdef OVERDRAW_INSPECTOR
- fragColor = vec4(1.0);
-#endif
-}
-)";
-};
-
-} // namespace shaders
-} // namespace mbgl
diff --git a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp
index 8f47d12c073..4b55116f129 100644
--- a/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp
+++ b/include/mbgl/shaders/gl/drawable_symbol_text_and_icon.hpp
@@ -29,7 +29,8 @@ layout (std140) uniform GlobalPaintParamsUBO {
highp float u_symbol_fade_change;
highp float u_aspect_ratio;
highp float u_pixel_ratio;
- highp float global_pad1, global_pad2;
+ highp float u_map_zoom;
+ lowp float global_pad1;
};
layout (std140) uniform SymbolDrawableUBO {
@@ -40,29 +41,21 @@ layout (std140) uniform SymbolDrawableUBO {
highp vec2 u_texsize;
highp vec2 u_texsize_icon;
- highp float u_gamma_scale;
+ bool u_is_text_prop;
bool u_rotate_symbol;
- highp vec2 drawable_pad1;
-};
-
-layout (std140) uniform SymbolTilePropsUBO {
- bool u_is_text;
- bool u_is_halo;
bool u_pitch_with_map;
bool u_is_size_zoom_constant;
bool u_is_size_feature_constant;
+
highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
-};
-layout (std140) uniform SymbolInterpolateUBO {
+ // Interpolations
highp float u_fill_color_t;
highp float u_halo_color_t;
highp float u_opacity_t;
highp float u_halo_width_t;
highp float u_halo_blur_t;
- highp float interp_pad1, interp_pad2, interp_pad3;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -71,13 +64,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
out vec4 v_data0;
@@ -105,11 +98,11 @@ out lowp float halo_blur;
#endif
void main() {
- highp vec4 u_fill_color = u_is_text ? u_text_fill_color : u_icon_fill_color;
- highp vec4 u_halo_color = u_is_text ? u_text_halo_color : u_icon_halo_color;
- highp float u_opacity = u_is_text ? u_text_opacity : u_icon_opacity;
- highp float u_halo_width = u_is_text ? u_text_halo_width : u_icon_halo_width;
- highp float u_halo_blur = u_is_text ? u_text_halo_blur : u_icon_halo_blur;
+ highp vec4 u_fill_color = u_is_text_prop ? u_text_fill_color : u_icon_fill_color;
+ highp vec4 u_halo_color = u_is_text_prop ? u_text_halo_color : u_icon_halo_color;
+ highp float u_opacity = u_is_text_prop ? u_text_opacity : u_icon_opacity;
+ highp float u_halo_width = u_is_text_prop ? u_text_halo_width : u_icon_halo_width;
+ highp float u_halo_blur = u_is_text_prop ? u_text_halo_blur : u_icon_halo_blur;
#ifndef HAS_UNIFORM_u_fill_color
fill_color = unpack_mix_color(a_fill_color, u_fill_color_t);
@@ -212,28 +205,11 @@ lowp float halo_blur = u_halo_blur;
#define SDF 1.0
#define ICON 0.0
-layout (std140) uniform SymbolDrawableUBO {
- highp mat4 u_matrix;
- highp mat4 u_label_plane_matrix;
- highp mat4 u_coord_matrix;
-
- highp vec2 u_texsize;
- highp vec2 u_texsize_icon;
-
- highp float u_gamma_scale;
- bool u_rotate_symbol;
- highp vec2 drawable_pad1;
-};
-
layout (std140) uniform SymbolTilePropsUBO {
bool u_is_text;
bool u_is_halo;
- bool u_pitch_with_map;
- bool u_is_size_zoom_constant;
- bool u_is_size_feature_constant;
- highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
- highp float u_size; // used when size is both zoom and feature constant
- bool tileprops_pad1;
+ highp float u_gamma_scale;
+ lowp float tileprops_pad1;
};
layout (std140) uniform SymbolEvaluatedPropsUBO {
@@ -242,13 +218,13 @@ layout (std140) uniform SymbolEvaluatedPropsUBO {
highp float u_text_opacity;
highp float u_text_halo_width;
highp float u_text_halo_blur;
- highp float props_pad1;
+ lowp float props_pad1;
highp vec4 u_icon_fill_color;
highp vec4 u_icon_halo_color;
highp float u_icon_opacity;
highp float u_icon_halo_width;
highp float u_icon_halo_blur;
- highp float props_pad2;
+ lowp float props_pad2;
};
uniform sampler2D u_texture;
diff --git a/include/mbgl/shaders/gl/shader_program_gl.hpp b/include/mbgl/shaders/gl/shader_program_gl.hpp
index 8e625fb7b89..df370fa17b2 100644
--- a/include/mbgl/shaders/gl/shader_program_gl.hpp
+++ b/include/mbgl/shaders/gl/shader_program_gl.hpp
@@ -1,7 +1,6 @@
#pragma once
#include
-#include
#include
#include
#include
@@ -20,10 +19,7 @@ class ShaderProgramGL final : public gfx::ShaderProgramBase {
using SamplerLocationArray = std::array, shaders::maxTextureCountPerShader>;
ShaderProgramGL(UniqueProgram&& glProgram_);
- ShaderProgramGL(UniqueProgram&&,
- UniformBlockArrayGL&& uniformBlocks,
- VertexAttributeArrayGL&& attributes,
- SamplerLocationArray&& samplerLocations);
+ ShaderProgramGL(UniqueProgram&&, VertexAttributeArrayGL&& attributes, SamplerLocationArray&& samplerLocations);
ShaderProgramGL(ShaderProgramGL&& other);
~ShaderProgramGL() noexcept override = default;
@@ -42,21 +38,15 @@ class ShaderProgramGL final : public gfx::ShaderProgramBase {
std::optional getSamplerLocation(const size_t id) const override;
- const gfx::UniformBlockArray& getUniformBlocks() const override { return uniformBlocks; }
-
const gfx::VertexAttributeArray& getVertexAttributes() const override { return vertexAttributes; }
const gfx::VertexAttributeArray& getInstanceAttributes() const override { return instanceAttributes; }
ProgramID getGLProgramID() const { return glProgram; }
-protected:
- gfx::UniformBlockArray& mutableUniformBlocks() override { return uniformBlocks; }
-
protected:
UniqueProgram glProgram;
- UniformBlockArrayGL uniformBlocks;
VertexAttributeArrayGL vertexAttributes;
VertexAttributeArrayGL instanceAttributes;
SamplerLocationArray samplerLocations;
diff --git a/include/mbgl/shaders/heatmap_layer_ubo.hpp b/include/mbgl/shaders/heatmap_layer_ubo.hpp
index 68ac43ea8c9..16a3704fe16 100644
--- a/include/mbgl/shaders/heatmap_layer_ubo.hpp
+++ b/include/mbgl/shaders/heatmap_layer_ubo.hpp
@@ -6,26 +6,26 @@ namespace mbgl {
namespace shaders {
struct alignas(16) HeatmapDrawableUBO {
- std::array matrix;
- float extrude_scale;
- std::array padding;
-};
-static_assert(sizeof(HeatmapDrawableUBO) % 16 == 0);
+ /* 0 */ std::array matrix;
+ /* 64 */ float extrude_scale;
-struct alignas(16) HeatmapEvaluatedPropsUBO {
- float weight;
- float radius;
- float intensity;
- float padding;
+ // Interpolations
+ /* 68 */ float weight_t;
+ /* 72 */ float radius_t;
+ /* 76 */ float pad1;
+ /* 80 */
};
-static_assert(sizeof(HeatmapEvaluatedPropsUBO) % 16 == 0);
+static_assert(sizeof(HeatmapDrawableUBO) == 5 * 16);
-struct alignas(16) HeatmapInterpolateUBO {
- float weight_t;
- float radius_t;
- std::array padding;
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) HeatmapEvaluatedPropsUBO {
+ /* 0 */ float weight;
+ /* 4 */ float radius;
+ /* 8 */ float intensity;
+ /* 12 */ float padding;
+ /* 16 */
};
-static_assert(sizeof(HeatmapInterpolateUBO) % 16 == 0);
+static_assert(sizeof(HeatmapEvaluatedPropsUBO) == 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp b/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp
index a4888dbcf0e..e94351e06f0 100644
--- a/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp
+++ b/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp
@@ -6,11 +6,14 @@ namespace mbgl {
namespace shaders {
struct alignas(16) HeatmapTexturePropsUBO {
- std::array matrix;
- float opacity;
- float pad1, pad2, pad3;
+ /* 0 */ std::array matrix;
+ /* 64 */ float opacity;
+ /* 68 */ float pad1;
+ /* 72 */ float pad2;
+ /* 76 */ float pad3;
+ /* 80 */
};
-static_assert(sizeof(HeatmapTexturePropsUBO) % 16 == 0);
+static_assert(sizeof(HeatmapTexturePropsUBO) == 5 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/hillshade_layer_ubo.hpp b/include/mbgl/shaders/hillshade_layer_ubo.hpp
index 77fd1a993ee..7edee8f7729 100644
--- a/include/mbgl/shaders/hillshade_layer_ubo.hpp
+++ b/include/mbgl/shaders/hillshade_layer_ubo.hpp
@@ -6,18 +6,26 @@ namespace mbgl {
namespace shaders {
struct alignas(16) HillshadeDrawableUBO {
- std::array matrix;
- std::array latrange;
- std::array light;
+ /* 0 */ std::array matrix;
+ /* 64 */
};
-static_assert(sizeof(HillshadeDrawableUBO) == 16 * 5);
+static_assert(sizeof(HillshadeDrawableUBO) == 4 * 16);
+struct alignas(16) HillshadeTilePropsUBO {
+ /* 0 */ std::array latrange;
+ /* 8 */ std::array light;
+ /* 16 */
+};
+static_assert(sizeof(HillshadeTilePropsUBO) == 16);
+
+/// Evaluated properties that do not depend on the tile
struct alignas(16) HillshadeEvaluatedPropsUBO {
- Color highlight;
- Color shadow;
- Color accent;
+ /* 0 */ Color highlight;
+ /* 16 */ Color shadow;
+ /* 32 */ Color accent;
+ /* 48 */
};
-static_assert(sizeof(HillshadeEvaluatedPropsUBO) % 16 == 0);
+static_assert(sizeof(HillshadeEvaluatedPropsUBO) == 3 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp b/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp
index 57ac65f3e97..a00cdc6e7c0 100644
--- a/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp
+++ b/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp
@@ -6,13 +6,19 @@ namespace mbgl {
namespace shaders {
struct alignas(16) HillshadePrepareDrawableUBO {
- std::array matrix;
- std::array unpack;
- std::array dimension;
- float zoom;
- float maxzoom;
+ /* 0 */ std::array matrix;
+ /* 64 */
};
-static_assert(sizeof(HillshadePrepareDrawableUBO) % 16 == 0);
+static_assert(sizeof(HillshadePrepareDrawableUBO) == 4 * 16);
+
+struct alignas(16) HillshadePrepareTilePropsUBO {
+ /* 0 */ std::array unpack;
+ /* 16 */ std::array dimension;
+ /* 24 */ float zoom;
+ /* 28 */ float maxzoom;
+ /* 32 */
+};
+static_assert(sizeof(HillshadePrepareTilePropsUBO) == 2 * 16);
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/layer_ubo.hpp b/include/mbgl/shaders/layer_ubo.hpp
index d46d16104b6..1f3d97887c0 100644
--- a/include/mbgl/shaders/layer_ubo.hpp
+++ b/include/mbgl/shaders/layer_ubo.hpp
@@ -37,25 +37,45 @@ static_assert(sizeof(Attribute) == 8);
// Global UBOs
struct alignas(16) GlobalPaintParamsUBO {
- std::array pattern_atlas_texsize;
- std::array units_to_pixels;
- std::array world_size;
- float camera_to_center_distance;
- float symbol_fade_change;
- float aspect_ratio;
- float pixel_ratio;
- float zoom;
- float pad1;
+ /* 0 */ std::array pattern_atlas_texsize;
+ /* 8 */ std::array units_to_pixels;
+ /* 16 */ std::array world_size;
+ /* 24 */ float camera_to_center_distance;
+ /* 28 */ float symbol_fade_change;
+ /* 32 */ float aspect_ratio;
+ /* 36 */ float pixel_ratio;
+ /* 40 */ float map_zoom;
+ /* 44 */ float pad1;
+ /* 48 */
};
static_assert(sizeof(GlobalPaintParamsUBO) == 3 * 16);
+#if MLN_RENDER_BACKEND_VULKAN
+struct alignas(16) GlobalPlatformParamsUBO {
+ /* 0 */ alignas(16) std::array rotation0;
+ /* 16 */ alignas(16) std::array rotation1;
+ /* 32 */
+};
+static_assert(sizeof(GlobalPlatformParamsUBO) == 2 * 16);
+#endif
+
enum {
idGlobalPaintParamsUBO,
-#if MLN_RENDER_BACKEND_VULKAN
- PlatformParamsUBO,
+#if MLN_RENDER_BACKEND_METAL
+ idGlobalUBOIndex,
+#elif MLN_RENDER_BACKEND_VULKAN
+ idGlobalPlatformParamsUBO,
#endif
globalUBOCount
};
+enum {
+ idDrawableReservedVertexOnlyUBO = globalUBOCount,
+ idDrawableReservedFragmentOnlyUBO,
+ drawableReservedUBOCount
+};
+
+#define MLN_UBO_CONSOLIDATION (MLN_RENDER_BACKEND_METAL || MLN_RENDER_BACKEND_VULKAN)
+
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/line_layer_ubo.hpp b/include/mbgl/shaders/line_layer_ubo.hpp
index 82b22842ad5..34a713f40ab 100644
--- a/include/mbgl/shaders/line_layer_ubo.hpp
+++ b/include/mbgl/shaders/line_layer_ubo.hpp
@@ -11,6 +11,109 @@
namespace mbgl {
namespace shaders {
+//
+// Line
+
+struct alignas(16) LineDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */ float ratio;
+
+ // Interpolations
+ /* 68 */ float color_t;
+ /* 72 */ float blur_t;
+ /* 76 */ float opacity_t;
+ /* 80 */ float gapwidth_t;
+ /* 84 */ float offset_t;
+ /* 88 */ float width_t;
+ /* 92 */ float pad1;
+ /* 96 */
+};
+static_assert(sizeof(LineDrawableUBO) == 6 * 16);
+
+//
+// Line gradient
+
+struct alignas(16) LineGradientDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */ float ratio;
+
+ // Interpolations
+ /* 68 */ float blur_t;
+ /* 72 */ float opacity_t;
+ /* 76 */ float gapwidth_t;
+ /* 80 */ float offset_t;
+ /* 84 */ float width_t;
+ /* 88 */ float pad1;
+ /* 92 */ float pad2;
+ /* 96 */
+};
+static_assert(sizeof(LineGradientDrawableUBO) == 6 * 16);
+
+//
+// Line pattern
+
+struct alignas(16) LinePatternDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */ float ratio;
+
+ // Interpolations
+ /* 68 */ float blur_t;
+ /* 72 */ float opacity_t;
+ /* 76 */ float gapwidth_t;
+ /* 80 */ float offset_t;
+ /* 84 */ float width_t;
+ /* 88 */ float pattern_from_t;
+ /* 92 */ float pattern_to_t;
+ /* 96 */
+};
+static_assert(sizeof(LinePatternDrawableUBO) == 6 * 16);
+
+struct alignas(16) LinePatternTilePropsUBO {
+ /* 0 */ std::array pattern_from;
+ /* 16 */ std::array pattern_to;
+ /* 32 */ std::array scale;
+ /* 48 */ std::array texsize;
+ /* 56 */ float fade;
+ /* 60 */ float pad1;
+ /* 64 */
+};
+static_assert(sizeof(LinePatternTilePropsUBO) == 4 * 16);
+
+//
+// Line SDF
+
+struct alignas(16) LineSDFDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */ std::array patternscale_a;
+ /* 72 */ std::array patternscale_b;
+ /* 80 */ float tex_y_a;
+ /* 84 */ float tex_y_b;
+ /* 88 */ float ratio;
+
+ // Interpolations
+ /* 92 */ float color_t;
+ /* 96 */ float blur_t;
+ /* 100 */ float opacity_t;
+ /* 104 */ float gapwidth_t;
+ /* 108 */ float offset_t;
+ /* 112 */ float width_t;
+ /* 116 */ float floorwidth_t;
+ /* 120 */ float pad1;
+ /* 124 */ float pad2;
+ /* 128 */
+};
+static_assert(sizeof(LineSDFDrawableUBO) == 8 * 16);
+
+struct alignas(16) LineSDFTilePropsUBO {
+ /* 0 */ float sdfgamma;
+ /* 4 */ float mix;
+ /* 8 */ float pad1;
+ /* 12 */ float pad2;
+ /* 16 */
+};
+static_assert(sizeof(LineSDFTilePropsUBO) == 16);
+
+/// Expression properties that do not depend on the tile
enum class LineExpressionMask : uint32_t {
None = 0,
Color = 1 << 0,
@@ -22,27 +125,6 @@ enum class LineExpressionMask : uint32_t {
Offset = 1 << 6,
};
-//
-// Line
-
-struct alignas(16) LineDrawableUBO {
- std::array matrix;
- float ratio;
- float pad1, pad2, pad3;
-};
-static_assert(sizeof(LineDrawableUBO) % 16 == 0);
-
-struct alignas(16) LineInterpolationUBO {
- float color_t;
- float blur_t;
- float opacity_t;
- float gapwidth_t;
- float offset_t;
- float width_t;
- float pad1, pad2;
-};
-static_assert(sizeof(LineInterpolationUBO) % 16 == 0);
-
struct alignas(16) LineExpressionUBO {
gfx::GPUExpression color;
gfx::GPUExpression blur;
@@ -54,94 +136,36 @@ struct alignas(16) LineExpressionUBO {
};
static_assert(sizeof(LineExpressionUBO) % 16 == 0);
-//
-// Line gradient
-
-using LineGradientDrawableUBO = LineDrawableUBO;
-
-struct alignas(16) LineGradientInterpolationUBO {
- float blur_t;
- float opacity_t;
- float gapwidth_t;
- float offset_t;
- float width_t;
- float pad1, pad2, pad3;
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) LineEvaluatedPropsUBO {
+ /* 0 */ Color color;
+ /* 16 */ float blur;
+ /* 20 */ float opacity;
+ /* 24 */ float gapwidth;
+ /* 28 */ float offset;
+ /* 32 */ float width;
+ /* 36 */ float floorwidth;
+ /* 40 */ LineExpressionMask expressionMask;
+ /* 44 */ float pad1;
+ /* 48 */
};
-static_assert(sizeof(LineGradientInterpolationUBO) % 16 == 0);
-
-//
-// Line pattern
+static_assert(sizeof(LineEvaluatedPropsUBO) == 3 * 16);
-struct alignas(16) LinePatternDrawableUBO {
- std::array matrix;
- std::array scale;
- std::array texsize;
- float ratio;
- float fade;
-};
-static_assert(sizeof(LinePatternDrawableUBO) % 16 == 0);
-
-struct alignas(16) LinePatternInterpolationUBO {
- float blur_t;
- float opacity_t;
- float offset_t;
- float gapwidth_t;
- float width_t;
- float pattern_from_t;
- float pattern_to_t;
- float pad1;
-};
-static_assert(sizeof(LinePatternInterpolationUBO) % 16 == 0);
+#if MLN_UBO_CONSOLIDATION
-struct alignas(16) LinePatternTilePropertiesUBO {
- std::array pattern_from;
- std::array pattern_to;
+union LineDrawableUnionUBO {
+ LineDrawableUBO lineDrawableUBO;
+ LineGradientDrawableUBO lineGradientDrawableUBO;
+ LinePatternDrawableUBO linePatternDrawableUBO;
+ LineSDFDrawableUBO lineSDFDrawableUBO;
};
-static_assert(sizeof(LinePatternTilePropertiesUBO) % 16 == 0);
-
-//
-// Line SDF
-struct alignas(16) LineSDFDrawableUBO {
- std::array matrix;
- std::array patternscale_a;
- std::array patternscale_b;
- float ratio;
- float tex_y_a;
- float tex_y_b;
- float sdfgamma;
- float mix;
- float pad1, pad2, pad3;
-};
-static_assert(sizeof(LineSDFDrawableUBO) % 16 == 0);
-
-struct alignas(16) LineSDFInterpolationUBO {
- float color_t;
- float blur_t;
- float opacity_t;
- float gapwidth_t;
- float offset_t;
- float width_t;
- float floorwidth_t;
- float pad1;
+union LineTilePropsUnionUBO {
+ LinePatternTilePropsUBO linePatternTilePropsUBO;
+ LineSDFTilePropsUBO lineSDFTilePropsUBO;
};
-static_assert(sizeof(LineSDFInterpolationUBO) % 16 == 0);
-
-//
-// Line evaluated properties
-struct alignas(16) LineEvaluatedPropsUBO {
- Color color;
- float blur;
- float opacity;
- float gapwidth;
- float offset;
- float width;
- float floorwidth;
- LineExpressionMask expressionMask;
- float pad1;
-};
-static_assert(sizeof(LineEvaluatedPropsUBO) % 16 == 0);
+#endif
} // namespace shaders
} // namespace mbgl
diff --git a/include/mbgl/shaders/location_indicator_ubo.hpp b/include/mbgl/shaders/location_indicator_ubo.hpp
new file mode 100644
index 00000000000..797550ee70e
--- /dev/null
+++ b/include/mbgl/shaders/location_indicator_ubo.hpp
@@ -0,0 +1,16 @@
+#pragma once
+
+#include
+
+namespace mbgl {
+namespace shaders {
+
+struct alignas(16) LocationIndicatorDrawableUBO {
+ /* 0 */ std::array matrix;
+ /* 64 */ Color color;
+ /* 80 */
+};
+static_assert(sizeof(LocationIndicatorDrawableUBO) == 5 * 16);
+
+} // namespace shaders
+} // namespace mbgl
diff --git a/include/mbgl/shaders/mtl/background.hpp b/include/mbgl/shaders/mtl/background.hpp
index 45211edbdf8..ad414accc28 100644
--- a/include/mbgl/shaders/mtl/background.hpp
+++ b/include/mbgl/shaders/mtl/background.hpp
@@ -2,58 +2,186 @@
#include
#include
-#include
#include
namespace mbgl {
namespace shaders {
+constexpr auto backgroundShaderPrelude = R"(
+
+enum {
+ idBackgroundDrawableUBO = idDrawableReservedVertexOnlyUBO,
+ idBackgroundPropsUBO = drawableReservedUBOCount,
+ backgroundUBOCount
+};
+
+//
+// Background
+
+struct alignas(16) BackgroundDrawableUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */
+};
+static_assert(sizeof(BackgroundDrawableUBO) == 4 * 16, "wrong size");
+
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) BackgroundPropsUBO {
+ /* 0 */ float4 color;
+ /* 16 */ float opacity;
+ /* 20 */ float pad1;
+ /* 24 */ float pad2;
+ /* 28 */ float pad3;
+ /* 32 */
+};
+static_assert(sizeof(BackgroundPropsUBO) == 2 * 16, "wrong size");
+
+//
+// Background pattern
+
+struct alignas(16) BackgroundPatternDrawableUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */ float2 pixel_coord_upper;
+ /* 72 */ float2 pixel_coord_lower;
+ /* 80 */ float tile_units_to_pixels;
+ /* 84 */ float pad1;
+ /* 88 */ float pad2;
+ /* 92 */ float pad3;
+ /* 96 */
+};
+static_assert(sizeof(BackgroundPatternDrawableUBO) == 6 * 16, "wrong size");
+
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) BackgroundPatternPropsUBO {
+ /* 0 */ float2 pattern_tl_a;
+ /* 8 */ float2 pattern_br_a;
+ /* 16 */ float2 pattern_tl_b;
+ /* 24 */ float2 pattern_br_b;
+ /* 32 */ float2 pattern_size_a;
+ /* 40 */ float2 pattern_size_b;
+ /* 48 */ float scale_a;
+ /* 52 */ float scale_b;
+ /* 56 */ float mix;
+ /* 60 */ float opacity;
+ /* 64 */
+};
+static_assert(sizeof(BackgroundPatternPropsUBO) == 4 * 16, "wrong size");
+
+union BackgroundDrawableUnionUBO {
+ BackgroundDrawableUBO backgroundDrawableUBO;
+ BackgroundPatternDrawableUBO backgroundPatternDrawableUBO;
+};
+
+)";
+
template <>
struct ShaderSource {
static constexpr auto name = "BackgroundShader";
static constexpr auto vertexMainFunction = "vertexMain";
static constexpr auto fragmentMainFunction = "fragmentMain";
- static const std::array uniforms;
static const std::array attributes;
static constexpr std::array instanceAttributes{};
static const std::array textures;
+ static constexpr auto prelude = backgroundShaderPrelude;
static constexpr auto source = R"(
-#include
-using namespace metal;
struct VertexStage {
- short2 position [[attribute(3)]];
+ short2 position [[attribute(backgroundUBOCount + 0)]];
};
struct FragmentStage {
float4 position [[position, invariant]];
};
-struct alignas(16) BackgroundDrawableUBO {
- float4x4 matrix;
+FragmentStage vertex vertexMain(VertexStage in [[stage_in]],
+ device const uint32_t& uboIndex [[buffer(idGlobalUBOIndex)]],
+ device const BackgroundDrawableUnionUBO* drawableVector [[buffer(idBackgroundDrawableUBO)]]) {
+
+ device const BackgroundDrawableUBO& drawable = drawableVector[uboIndex].backgroundDrawableUBO;
+
+ return {
+ .position = drawable.matrix * float4(float2(in.position.xy), 0, 1)
+ };
+}
+
+half4 fragment fragmentMain(FragmentStage in [[stage_in]],
+ device const BackgroundPropsUBO& props [[buffer(idBackgroundPropsUBO)]]) {
+#if defined(OVERDRAW_INSPECTOR)
+ return half4(1.0);
+#endif
+
+ return half4(props.color * props.opacity);
+}
+)";
};
-struct alignas(16) BackgroundLayerUBO {
- float4 color;
- float opacity;
- float pad1, pad2, pad3;
+
+template <>
+struct ShaderSource {
+ static constexpr auto name = "BackgroundPatternShader";
+ static constexpr auto vertexMainFunction = "vertexMain";
+ static constexpr auto fragmentMainFunction = "fragmentMain";
+
+ static const std::array attributes;
+ static constexpr std::array instanceAttributes{};
+ static const std::array textures;
+
+ static constexpr auto prelude = backgroundShaderPrelude;
+ static constexpr auto source = R"(
+
+struct VertexStage {
+ short2 position [[attribute(backgroundUBOCount + 0)]];
+};
+
+struct FragmentStage {
+ float4 position [[position, invariant]];
+ float2 pos_a;
+ float2 pos_b;
};
FragmentStage vertex vertexMain(VertexStage in [[stage_in]],
- device const BackgroundDrawableUBO& drawableUBO [[buffer(1)]]) {
+ device const uint32_t& uboIndex [[buffer(idGlobalUBOIndex)]],
+ device const BackgroundDrawableUnionUBO* drawableVector [[buffer(idBackgroundDrawableUBO)]],
+ device const BackgroundPatternPropsUBO& props [[buffer(idBackgroundPropsUBO)]]) {
+
+ device const BackgroundPatternDrawableUBO& drawable = drawableVector[uboIndex].backgroundPatternDrawableUBO;
+
+ const float2 pos = float2(in.position);
+ const float2 pos_a = get_pattern_pos(drawable.pixel_coord_upper,
+ drawable.pixel_coord_lower,
+ props.scale_a * props.pattern_size_a,
+ drawable.tile_units_to_pixels,
+ pos);
+ const float2 pos_b = get_pattern_pos(drawable.pixel_coord_upper,
+ drawable.pixel_coord_lower,
+ props.scale_b * props.pattern_size_b,
+ drawable.tile_units_to_pixels,
+ pos);
return {
- .position = drawableUBO.matrix * float4(float2(in.position.xy), 0, 1)
+ .position = drawable.matrix * float4(float2(in.position.xy), 0, 1),
+ .pos_a = pos_a,
+ .pos_b = pos_b,
};
}
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
- device const BackgroundLayerUBO& layerUBO [[buffer(2)]]) {
+ device const GlobalPaintParamsUBO& paintParamsUBO [[buffer(idGlobalPaintParamsUBO)]],
+ device const BackgroundPatternPropsUBO& props [[buffer(idBackgroundPropsUBO)]],
+ texture2d image [[texture(0)]],
+ sampler image_sampler [[sampler(0)]]) {
#if defined(OVERDRAW_INSPECTOR)
return half4(1.0);
#endif
- return half4(layerUBO.color * layerUBO.opacity);
+ const float2 texsize = paintParamsUBO.pattern_atlas_texsize;
+ const float2 imagecoord = glMod(float2(in.pos_a), 1.0);
+ const float2 pos = mix(props.pattern_tl_a / texsize, props.pattern_br_a / texsize, imagecoord);
+ const float4 color1 = image.sample(image_sampler, pos);
+ const float2 imagecoord_b = glMod(float2(in.pos_b), 1.0);
+ const float2 pos2 = mix(props.pattern_tl_b / texsize, props.pattern_br_b / texsize, imagecoord_b);
+ const float4 color2 = image.sample(image_sampler, pos2);
+
+ return half4(mix(color1, color2, props.mix) * props.opacity);
}
)";
};
diff --git a/include/mbgl/shaders/mtl/background_pattern.hpp b/include/mbgl/shaders/mtl/background_pattern.hpp
deleted file mode 100644
index 408cbd2fe4e..00000000000
--- a/include/mbgl/shaders/mtl/background_pattern.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#pragma once
-
-#include
-
-namespace mbgl {
-namespace shaders {
-
-template <>
-struct ShaderSource {
- static constexpr auto name = "BackgroundPatternShader";
- static constexpr auto vertexMainFunction = "vertexMain";
- static constexpr auto fragmentMainFunction = "fragmentMain";
-
- static const std::array uniforms;
- static const std::array attributes;
- static constexpr std::array instanceAttributes{};
- static const std::array textures;
-
- static constexpr auto source = R"(
-#include
-using namespace metal;
-
-struct VertexStage {
- short2 position [[attribute(3)]];
-};
-
-struct FragmentStage {
- float4 position [[position, invariant]];
- float2 pos_a;
- float2 pos_b;
-};
-
-struct alignas(16) BackgroundPatternDrawableUBO {
- float4x4 matrix;
- float2 pixel_coord_upper;
- float2 pixel_coord_lower;
- float tile_units_to_pixels;
- float pad1, pad2, pad3;
-};
-struct alignas(16) BackgroundPatternLayerUBO {
- float2 pattern_tl_a;
- float2 pattern_br_a;
- float2 pattern_tl_b;
- float2 pattern_br_b;
- float2 pattern_size_a;
- float2 pattern_size_b;
- float scale_a;
- float scale_b;
- float mix;
- float opacity;
-};
-
-FragmentStage vertex vertexMain(VertexStage in [[stage_in]],
- device const BackgroundPatternDrawableUBO& drawableUBO [[buffer(1)]],
- device const BackgroundPatternLayerUBO& layerUBO [[buffer(2)]]) {
- const float2 pos = float2(in.position);
- const float2 pos_a = get_pattern_pos(drawableUBO.pixel_coord_upper,
- drawableUBO.pixel_coord_lower,
- layerUBO.scale_a * layerUBO.pattern_size_a,
- drawableUBO.tile_units_to_pixels,
- pos);
- const float2 pos_b = get_pattern_pos(drawableUBO.pixel_coord_upper,
- drawableUBO.pixel_coord_lower,
- layerUBO.scale_b * layerUBO.pattern_size_b,
- drawableUBO.tile_units_to_pixels,
- pos);
- return {
- .position = drawableUBO.matrix * float4(float2(in.position.xy), 0, 1),
- .pos_a = pos_a,
- .pos_b = pos_b,
- };
-}
-
-half4 fragment fragmentMain(FragmentStage in [[stage_in]],
- device const GlobalPaintParamsUBO& paintParamsUBO [[buffer(0)]],
- device const BackgroundPatternLayerUBO& layerUBO [[buffer(2)]],
- texture2d image [[texture(0)]],
- sampler image_sampler [[sampler(0)]]) {
-#if defined(OVERDRAW_INSPECTOR)
- return half4(1.0);
-#endif
-
- const float2 texsize = paintParamsUBO.pattern_atlas_texsize;
- const float2 imagecoord = glMod(float2(in.pos_a), 1.0);
- const float2 pos = mix(layerUBO.pattern_tl_a / texsize, layerUBO.pattern_br_a / texsize, imagecoord);
- const float4 color1 = image.sample(image_sampler, pos);
- const float2 imagecoord_b = glMod(float2(in.pos_b), 1.0);
- const float2 pos2 = mix(layerUBO.pattern_tl_b / texsize, layerUBO.pattern_br_b / texsize, imagecoord_b);
- const float4 color2 = image.sample(image_sampler, pos2);
-
- return half4(mix(color1, color2, layerUBO.mix) * layerUBO.opacity);
-}
-)";
-};
-
-} // namespace shaders
-} // namespace mbgl
diff --git a/include/mbgl/shaders/mtl/circle.hpp b/include/mbgl/shaders/mtl/circle.hpp
index 94b22fb1523..7575f39bd83 100644
--- a/include/mbgl/shaders/mtl/circle.hpp
+++ b/include/mbgl/shaders/mtl/circle.hpp
@@ -2,47 +2,92 @@
#include
#include
-#include
#include
namespace mbgl {
namespace shaders {
+constexpr auto circleShaderPrelude = R"(
+
+enum {
+ idCircleDrawableUBO = idDrawableReservedVertexOnlyUBO,
+ idCircleEvaluatedPropsUBO = drawableReservedUBOCount,
+ circleUBOCount
+};
+
+struct alignas(16) CircleDrawableUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */ float2 extrude_scale;
+
+ // Interpolations
+ /* 72 */ float color_t;
+ /* 76 */ float radius_t;
+ /* 80 */ float blur_t;
+ /* 84 */ float opacity_t;
+ /* 88 */ float stroke_color_t;
+ /* 92 */ float stroke_width_t;
+ /* 96 */ float stroke_opacity_t;
+ /* 100 */ float pad1;
+ /* 104 */ float pad2;
+ /* 108 */ float pad3;
+ /* 112 */
+};
+static_assert(sizeof(CircleDrawableUBO) == 7 * 16, "wrong size");
+
+/// Evaluated properties that do not depend on the tile
+struct alignas(16) CircleEvaluatedPropsUBO {
+ /* 0 */ float4 color;
+ /* 16 */ float4 stroke_color;
+ /* 32 */ float radius;
+ /* 36 */ float blur;
+ /* 40 */ float opacity;
+ /* 44 */ float stroke_width;
+ /* 48 */ float stroke_opacity;
+ /* 52 */ int scale_with_map;
+ /* 56 */ int pitch_with_map;
+ /* 60 */ float pad1;
+ /* 64 */
+};
+static_assert(sizeof(CircleEvaluatedPropsUBO) == 4 * 16, "wrong size");
+
+)";
+
template <>
struct ShaderSource {
static constexpr auto name = "CircleShader";
static constexpr auto vertexMainFunction = "vertexMain";
static constexpr auto fragmentMainFunction = "fragmentMain";
- static const std::array uniforms;
static const std::array attributes;
static constexpr std::array instanceAttributes{};
static const std::array textures;
+ static constexpr auto prelude = circleShaderPrelude;
static constexpr auto source = R"(
+
struct VertexStage {
- short2 position [[attribute(4)]];
+ short2 position [[attribute(circleUBOCount + 0)]];
#if !defined(HAS_UNIFORM_u_color)
- float4 color [[attribute(5)]];
+ float4 color [[attribute(circleUBOCount + 1)]];
#endif
#if !defined(HAS_UNIFORM_u_radius)
- float2 radius [[attribute(6)]];
+ float2 radius [[attribute(circleUBOCount + 2)]];
#endif
#if !defined(HAS_UNIFORM_u_blur)
- float2 blur [[attribute(7)]];
+ float2 blur [[attribute(circleUBOCount + 3)]];
#endif
#if !defined(HAS_UNIFORM_u_opacity)
- float2 opacity [[attribute(8)]];
+ float2 opacity [[attribute(circleUBOCount + 4)]];
#endif
#if !defined(HAS_UNIFORM_u_stroke_color)
- float4 stroke_color [[attribute(9)]];
+ float4 stroke_color [[attribute(circleUBOCount + 5)]];
#endif
#if !defined(HAS_UNIFORM_u_stroke_width)
- float2 stroke_width [[attribute(10)]];
+ float2 stroke_width [[attribute(circleUBOCount + 6)]];
#endif
#if !defined(HAS_UNIFORM_u_stroke_opacity)
- float2 stroke_opacity [[attribute(11)]];
+ float2 stroke_opacity [[attribute(circleUBOCount + 7)]];
#endif
};
@@ -74,55 +119,24 @@ struct FragmentStage {
#endif
};
-struct alignas(16) CircleDrawableUBO {
- float4x4 matrix;
- float2 extrude_scale;
- float2 padding;
-};
-struct alignas(16) CirclePaintParamsUBO {
- float camera_to_center_distance;
- float pad1,pad2,pad3;
-};
-struct alignas(16) CircleEvaluatedPropsUBO {
- float4 color;
- float4 stroke_color;
- float radius;
- float blur;
- float opacity;
- float stroke_width;
- float stroke_opacity;
- int scale_with_map;
- int pitch_with_map;
- float padding;
-};
-
-struct alignas(16) CircleInterpolateUBO {
- float color_t;
- float radius_t;
- float blur_t;
- float opacity_t;
- float stroke_color_t;
- float stroke_width_t;
- float stroke_opacity_t;
- float pad1_;
-};
-
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
- device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
- device const CircleDrawableUBO& drawable [[buffer(1)]],
- device const CircleInterpolateUBO& interp [[buffer(2)]],
- device const CircleEvaluatedPropsUBO& props [[buffer(3)]]) {
+ device const GlobalPaintParamsUBO& paintParams [[buffer(idGlobalPaintParamsUBO)]],
+ device const uint32_t& uboIndex [[buffer(idGlobalUBOIndex)]],
+ device const CircleDrawableUBO* drawableVector [[buffer(idCircleDrawableUBO)]],
+ device const CircleEvaluatedPropsUBO& props [[buffer(idCircleEvaluatedPropsUBO)]]) {
+
+ device const CircleDrawableUBO& drawable = drawableVector[uboIndex];
#if defined(HAS_UNIFORM_u_radius)
const auto radius = props.radius;
#else
- const auto radius = unpack_mix_float(vertx.radius, interp.radius_t);
+ const auto radius = unpack_mix_float(vertx.radius, drawable.radius_t);
#endif
#if defined(HAS_UNIFORM_u_stroke_width)
const auto stroke_width = props.stroke_width;
#else
- const auto stroke_width = unpack_mix_float(vertx.stroke_width, interp.stroke_width_t);
+ const auto stroke_width = unpack_mix_float(vertx.stroke_width, drawable.stroke_width_t);
#endif
// unencode the extrusion vector that we snuck into the a_pos vector
@@ -165,31 +179,31 @@ FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
.antialiasblur = antialiasblur,
#if !defined(HAS_UNIFORM_u_color)
- .color = half4(unpack_mix_color(vertx.color, interp.color_t)),
+ .color = half4(unpack_mix_color(vertx.color, drawable.color_t)),
#endif
#if !defined(HAS_UNIFORM_u_radius)
.radius = radius,
#endif
#if !defined(HAS_UNIFORM_u_blur)
- .blur = half(unpack_mix_float(vertx.blur, interp.blur_t)),
+ .blur = half(unpack_mix_float(vertx.blur, drawable.blur_t)),
#endif
#if !defined(HAS_UNIFORM_u_opacity)
- .opacity = half(unpack_mix_float(vertx.opacity, interp.opacity_t)),
+ .opacity = half(unpack_mix_float(vertx.opacity, drawable.opacity_t)),
#endif
#if !defined(HAS_UNIFORM_u_stroke_color)
- .stroke_color = half4(unpack_mix_color(vertx.stroke_color, interp.stroke_color_t)),
+ .stroke_color = half4(unpack_mix_color(vertx.stroke_color, drawable.stroke_color_t)),
#endif
#if !defined(HAS_UNIFORM_u_stroke_width)
.stroke_width = half(stroke_width),
#endif
#if !defined(HAS_UNIFORM_u_stroke_opacity)
- .stroke_opacity = half(unpack_mix_float(vertx.stroke_opacity, interp.stroke_opacity_t)),
+ .stroke_opacity = half(unpack_mix_float(vertx.stroke_opacity, drawable.stroke_opacity_t)),
#endif
};
}
half4 fragment fragmentMain(FragmentStage in [[stage_in]],
- device const CircleEvaluatedPropsUBO& props [[buffer(3)]]) {
+ device const CircleEvaluatedPropsUBO& props [[buffer(idCircleEvaluatedPropsUBO)]]) {
#if defined(OVERDRAW_INSPECTOR)
return half4(1.0);
#endif
diff --git a/include/mbgl/shaders/mtl/clipping_mask.hpp b/include/mbgl/shaders/mtl/clipping_mask.hpp
index 6791cd46c8a..e0f5d8b6173 100644
--- a/include/mbgl/shaders/mtl/clipping_mask.hpp
+++ b/include/mbgl/shaders/mtl/clipping_mask.hpp
@@ -9,36 +9,47 @@ namespace shaders {
struct alignas(16) ClipUBO {
/* 0 */ std::array matrix;
/* 64 */ std::uint32_t stencil_ref;
- /* 68 */ std::uint32_t pad1, pad2, pad3;
+ /* 68 */ float pad1;
+ /* 72 */ float pad2;
+ /* 76 */ float pad3;
/* 80 */
};
static_assert(sizeof(ClipUBO) == 5 * 16);
+constexpr auto clippingMaskShaderPrelude = R"(
+
+enum {
+ idClippingMaskUBO = idDrawableReservedVertexOnlyUBO,
+ clippingMaskUBOCount = drawableReservedUBOCount
+};
+
+struct alignas(16) ClipUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */ uint32_t stencil_ref;
+ /* 68 */ float pad1;
+ /* 72 */ float pad2;
+ /* 76 */ float pad3;
+ /* 80 */
+};
+static_assert(sizeof(ClipUBO) == 5 * 16, "wrong size");
+
+)";
+
template <>
struct ShaderSource {
static constexpr auto name = "ClippingMaskProgram";
static constexpr auto vertexMainFunction = "vertexMain";
static constexpr auto fragmentMainFunction = "fragmentMain";
- static const std::array uniforms;
static const std::array attributes;
static constexpr std::array instanceAttributes{};
static const std::array textures;
+ static constexpr auto prelude = clippingMaskShaderPrelude;
static constexpr auto source = R"(
-#include
-using namespace metal;
-
-struct alignas(16) ClipUBO {
- /* 0 */ float4x4 matrix;
- /* 64 */ uint32_t stencil_ref;
- /* 68 */ uint32_t pad1, pad2, pad3;
- /* 80 */
-};
-static_assert(sizeof(ClipUBO) == 5 * 16, "unexpected padding");
struct VertexStage {
- short2 position [[attribute(2)]];
+ short2 position [[attribute(clippingMaskUBOCount + 0)]];
};
struct FragmentStage {
@@ -51,7 +62,7 @@ struct FragmentResult {
};
FragmentStage vertex vertexMain(VertexStage in [[stage_in]],
- device const ClipUBO& clipUBO [[buffer(1)]]) {
+ device const ClipUBO& clipUBO [[buffer(idClippingMaskUBO)]]) {
return { clipUBO.matrix * float4(float2(in.position.xy), 0, 1) };
}
diff --git a/include/mbgl/shaders/mtl/collision.hpp b/include/mbgl/shaders/mtl/collision.hpp
new file mode 100644
index 00000000000..79a21da87db
--- /dev/null
+++ b/include/mbgl/shaders/mtl/collision.hpp
@@ -0,0 +1,203 @@
+#pragma once
+
+#include
+#include
+#include
+
+namespace mbgl {
+namespace shaders {
+
+constexpr auto collisionShaderPrelude = R"(
+
+enum {
+ idCollisionDrawableUBO = idDrawableReservedVertexOnlyUBO,
+ idCollisionTilePropsUBO = drawableReservedUBOCount,
+ collisionUBOCount
+};
+
+struct alignas(16) CollisionDrawableUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */
+};
+static_assert(sizeof(CollisionDrawableUBO) == 4 * 16, "wrong size");
+
+struct alignas(16) CollisionTilePropsUBO {
+ /* 0 */ float2 extrude_scale;
+ /* 8 */ float overscale_factor;
+ /* 12 */ float pad1;
+ /* 16 */
+};
+static_assert(sizeof(CollisionTilePropsUBO) == 16, "wrong size");
+
+)";
+
+template <>
+struct ShaderSource {
+ static constexpr auto name = "CollisionBoxShader";
+ static constexpr auto vertexMainFunction = "vertexMain";
+ static constexpr auto fragmentMainFunction = "fragmentMain";
+
+ static const std::array attributes;
+ static constexpr std::array instanceAttributes{};
+ static const std::array textures;
+
+ static constexpr auto prelude = collisionShaderPrelude;
+ static constexpr auto source = R"(
+
+struct VertexStage {
+ short2 pos [[attribute(collisionUBOCount + 0)]];
+ short2 anchor_pos [[attribute(collisionUBOCount + 1)]];
+ short2 extrude [[attribute(collisionUBOCount + 2)]];
+ ushort2 placed [[attribute(collisionUBOCount + 3)]];
+ float2 shift [[attribute(collisionUBOCount + 4)]];
+};
+
+struct FragmentStage {
+ float4 position [[position, invariant]];
+ float placed;
+ float notUsed;
+};
+
+FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
+ device const GlobalPaintParamsUBO& paintParams [[buffer(idGlobalPaintParamsUBO)]],
+ device const CollisionDrawableUBO& drawable [[buffer(idCollisionDrawableUBO)]],
+ device const CollisionTilePropsUBO& tileProps [[buffer(idCollisionTilePropsUBO)]]) {
+
+ float4 projectedPoint = drawable.matrix * float4(float2(vertx.anchor_pos), 0, 1);
+ float camera_to_anchor_distance = projectedPoint.w;
+ float collision_perspective_ratio = clamp(
+ 0.5 + 0.5 * (paintParams.camera_to_center_distance / camera_to_anchor_distance),
+ 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles
+ 4.0);
+
+ float4 position = drawable.matrix * float4(float2(vertx.pos), 0.0, 1.0);
+ position.xy += (float2(vertx.extrude) + vertx.shift) * tileProps.extrude_scale * position.w * collision_perspective_ratio;
+
+ float placed = float(vertx.placed.x);
+ float notUsed = float(vertx.placed.y);
+
+ return {
+ .position = position,
+ .placed = placed,
+ .notUsed = notUsed,
+ };
+}
+
+half4 fragment fragmentMain(FragmentStage in [[stage_in]]) {
+
+ float alpha = 0.5;
+
+ // Red = collision, hide label
+ float4 color = float4(1.0, 0.0, 0.0, 1.0) * alpha;
+
+ // Blue = no collision, label is showing
+ if (in.placed > 0.5) {
+ color = float4(0.0, 0.0, 1.0, 0.5) * alpha;
+ }
+
+ if (in.notUsed > 0.5) {
+ // This box not used, fade it out
+ color *= 0.1;
+ }
+
+ return half4(color);
+}
+)";
+};
+
+template <>
+struct ShaderSource {
+ static constexpr auto name = "CollisionCircleShader";
+ static constexpr auto vertexMainFunction = "vertexMain";
+ static constexpr auto fragmentMainFunction = "fragmentMain";
+
+ static const std::array attributes;
+ static constexpr std::array instanceAttributes{};
+ static const std::array textures;
+
+ static constexpr auto prelude = collisionShaderPrelude;
+ static constexpr auto source = R"(
+
+struct VertexStage {
+ short2 pos [[attribute(collisionUBOCount + 0)]];
+ short2 anchor_pos [[attribute(collisionUBOCount + 1)]];
+ short2 extrude [[attribute(collisionUBOCount + 2)]];
+ ushort2 placed [[attribute(collisionUBOCount + 3)]];
+};
+
+struct FragmentStage {
+ float4 position [[position, invariant]];
+ float placed;
+ float notUsed;
+ float radius;
+ float2 extrude;
+ float2 extrude_scale;
+};
+
+FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
+ device const GlobalPaintParamsUBO& paintParams [[buffer(idGlobalPaintParamsUBO)]],
+ device const CollisionDrawableUBO& drawable [[buffer(idCollisionDrawableUBO)]],
+ device const CollisionTilePropsUBO& tileProps [[buffer(idCollisionTilePropsUBO)]]) {
+
+ float4 projectedPoint = drawable.matrix * float4(float2(vertx.anchor_pos), 0, 1);
+ float camera_to_anchor_distance = projectedPoint.w;
+ float collision_perspective_ratio = clamp(
+ 0.5 + 0.5 * (paintParams.camera_to_center_distance / camera_to_anchor_distance),
+ 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles
+ 4.0);
+
+ float4 position = drawable.matrix * float4(float2(vertx.pos), 0.0, 1.0);
+
+ float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur
+ position.xy += float2(vertx.extrude) * tileProps.extrude_scale * padding_factor * position.w * collision_perspective_ratio;
+
+ float placed = float(vertx.placed.x);
+ float notUsed = float(vertx.placed.y);
+ float radius = abs(float(vertx.extrude.y)); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius
+
+ float2 extrude = float2(vertx.extrude) * padding_factor;
+ float2 extrude_scale = tileProps.extrude_scale * paintParams.camera_to_center_distance * collision_perspective_ratio;
+
+ return {
+ .position = position,
+ .placed = placed,
+ .notUsed = notUsed,
+ .radius = radius,
+ .extrude = extrude,
+ .extrude_scale = extrude_scale,
+ };
+}
+
+half4 fragment fragmentMain(FragmentStage in [[stage_in]],
+ device const CollisionTilePropsUBO& tileProps [[buffer(idCollisionTilePropsUBO)]]) {
+
+ float alpha = 0.5;
+
+ // Red = collision, hide label
+ float4 color = float4(1.0, 0.0, 0.0, 1.0) * alpha;
+
+ // Blue = no collision, label is showing
+ if (in.placed > 0.5) {
+ color = float4(0.0, 0.0, 1.0, 0.5) * alpha;
+ }
+
+ if (in.notUsed > 0.5) {
+ // This box not used, fade it out
+ color *= 0.2;
+ }
+
+ float extrude_scale_length = length(in.extrude_scale);
+ float extrude_length = length(in.extrude) * extrude_scale_length;
+ float stroke_width = 15.0 * extrude_scale_length / tileProps.overscale_factor;
+ float radius = in.radius * extrude_scale_length;
+
+ float distance_to_edge = abs(extrude_length - radius);
+ float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);
+
+ return half4(opacity_t * color);
+}
+)";
+};
+
+} // namespace shaders
+} // namespace mbgl
diff --git a/include/mbgl/shaders/mtl/collision_box.hpp b/include/mbgl/shaders/mtl/collision_box.hpp
deleted file mode 100644
index 1ae672a0740..00000000000
--- a/include/mbgl/shaders/mtl/collision_box.hpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-namespace mbgl {
-namespace shaders {
-
-template <>
-struct ShaderSource {
- static constexpr auto name = "CollisionBoxShader";
- static constexpr auto vertexMainFunction = "vertexMain";
- static constexpr auto fragmentMainFunction = "fragmentMain";
-
- static const std::array uniforms;
- static const std::array attributes;
- static constexpr std::array instanceAttributes{};
- static const std::array textures;
-
- static constexpr auto source = R"(
-
-struct VertexStage {
- short2 pos [[attribute(2)]];
- short2 anchor_pos [[attribute(3)]];
- short2 extrude [[attribute(4)]];
- ushort2 placed [[attribute(5)]];
- float2 shift [[attribute(6)]];
-};
-
-struct FragmentStage {
- float4 position [[position, invariant]];
- float placed;
- float notUsed;
-};
-
-struct alignas(16) CollisionBoxUBO {
- float4x4 matrix;
- float2 extrude_scale;
- float overscale_factor;
- float pad1;
-};
-
-FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
- device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
- device const CollisionBoxUBO& drawable [[buffer(1)]]) {
-
- float4 projectedPoint = drawable.matrix * float4(float2(vertx.anchor_pos), 0, 1);
- float camera_to_anchor_distance = projectedPoint.w;
- float collision_perspective_ratio = clamp(
- 0.5 + 0.5 * (paintParams.camera_to_center_distance / camera_to_anchor_distance),
- 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles
- 4.0);
-
- float4 position = drawable.matrix * float4(float2(vertx.pos), 0.0, 1.0);
- position.xy += (float2(vertx.extrude) + vertx.shift) * drawable.extrude_scale * position.w * collision_perspective_ratio;
-
- float placed = float(vertx.placed.x);
- float notUsed = float(vertx.placed.y);
-
- return {
- .position = position,
- .placed = placed,
- .notUsed = notUsed,
- };
-}
-
-half4 fragment fragmentMain(FragmentStage in [[stage_in]],
- device const CollisionBoxUBO& drawable [[buffer(1)]]) {
-
- float alpha = 0.5;
-
- // Red = collision, hide label
- float4 color = float4(1.0, 0.0, 0.0, 1.0) * alpha;
-
- // Blue = no collision, label is showing
- if (in.placed > 0.5) {
- color = float4(0.0, 0.0, 1.0, 0.5) * alpha;
- }
-
- if (in.notUsed > 0.5) {
- // This box not used, fade it out
- color *= 0.1;
- }
-
- return half4(color);
-}
-)";
-};
-
-} // namespace shaders
-} // namespace mbgl
diff --git a/include/mbgl/shaders/mtl/collision_circle.hpp b/include/mbgl/shaders/mtl/collision_circle.hpp
deleted file mode 100644
index ecd009bc987..00000000000
--- a/include/mbgl/shaders/mtl/collision_circle.hpp
+++ /dev/null
@@ -1,112 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-#include
-
-namespace mbgl {
-namespace shaders {
-
-template <>
-struct ShaderSource {
- static constexpr auto name = "CollisionCircleShader";
- static constexpr auto vertexMainFunction = "vertexMain";
- static constexpr auto fragmentMainFunction = "fragmentMain";
-
- static const std::array uniforms;
- static const std::array attributes;
- static constexpr std::array instanceAttributes{};
- static const std::array textures;
-
- static constexpr auto source = R"(
-
-struct VertexStage {
- short2 pos [[attribute(2)]];
- short2 anchor_pos [[attribute(3)]];
- short2 extrude [[attribute(4)]];
- ushort2 placed [[attribute(5)]];
-};
-
-struct FragmentStage {
- float4 position [[position, invariant]];
- float placed;
- float notUsed;
- float radius;
- float2 extrude;
- float2 extrude_scale;
-};
-
-struct alignas(16) CollisionCircleUBO {
- float4x4 matrix;
- float2 extrude_scale;
- float overscale_factor;
- float pad1;
-};
-
-FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
- device const GlobalPaintParamsUBO& paintParams [[buffer(0)]],
- device const CollisionCircleUBO& drawable [[buffer(1)]]) {
-
- float4 projectedPoint = drawable.matrix * float4(float2(vertx.anchor_pos), 0, 1);
- float camera_to_anchor_distance = projectedPoint.w;
- float collision_perspective_ratio = clamp(
- 0.5 + 0.5 * (paintParams.camera_to_center_distance / camera_to_anchor_distance),
- 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles
- 4.0);
-
- float4 position = drawable.matrix * float4(float2(vertx.pos), 0.0, 1.0);
-
- float padding_factor = 1.2; // Pad the vertices slightly to make room for anti-alias blur
- position.xy += float2(vertx.extrude) * drawable.extrude_scale * padding_factor * position.w * collision_perspective_ratio;
-
- float placed = float(vertx.placed.x);
- float notUsed = float(vertx.placed.y);
- float radius = abs(float(vertx.extrude.y)); // We don't pitch the circles, so both units of the extrusion vector are equal in magnitude to the radius
-
- float2 extrude = float2(vertx.extrude) * padding_factor;
- float2 extrude_scale = drawable.extrude_scale * paintParams.camera_to_center_distance * collision_perspective_ratio;
-
- return {
- .position = position,
- .placed = placed,
- .notUsed = notUsed,
- .radius = radius,
- .extrude = extrude,
- .extrude_scale = extrude_scale,
- };
-}
-
-half4 fragment fragmentMain(FragmentStage in [[stage_in]],
- device const CollisionCircleUBO& drawable [[buffer(1)]]) {
-
- float alpha = 0.5;
-
- // Red = collision, hide label
- float4 color = float4(1.0, 0.0, 0.0, 1.0) * alpha;
-
- // Blue = no collision, label is showing
- if (in.placed > 0.5) {
- color = float4(0.0, 0.0, 1.0, 0.5) * alpha;
- }
-
- if (in.notUsed > 0.5) {
- // This box not used, fade it out
- color *= 0.2;
- }
-
- float extrude_scale_length = length(in.extrude_scale);
- float extrude_length = length(in.extrude) * extrude_scale_length;
- float stroke_width = 15.0 * extrude_scale_length / drawable.overscale_factor;
- float radius = in.radius * extrude_scale_length;
-
- float distance_to_edge = abs(extrude_length - radius);
- float opacity_t = smoothstep(-stroke_width, 0.0, -distance_to_edge);
-
- return half4(opacity_t * color);
-}
-)";
-};
-
-} // namespace shaders
-} // namespace mbgl
diff --git a/include/mbgl/shaders/mtl/common.hpp b/include/mbgl/shaders/mtl/common.hpp
index fc093b704b7..4e20dc9313c 100644
--- a/include/mbgl/shaders/mtl/common.hpp
+++ b/include/mbgl/shaders/mtl/common.hpp
@@ -54,7 +54,12 @@ float4 unpack_mix_color(const float4 packedColors, const float t) {
decode_color(float2(packedColors[2], packedColors[3])), t);
}
-
+// Unpack pattern position
+inline float2 get_pattern_pos(const float2 pixel_coord_upper, const float2 pixel_coord_lower,
+ const float2 pattern_size, const float tile_units_to_pixels, const float2 pos) {
+ const float2 offset = glMod(glMod(glMod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size);
+ return (tile_units_to_pixels * pos + offset) / pattern_size;
+}
template
ForwardIt upper_bound(ForwardIt first, ForwardIt last, thread const T& value)
@@ -196,49 +201,9 @@ struct alignas(16) GPUExpression {
float4 getColor(size_t index) device const { return decode_color(stops.colors[index]); }
};
-static_assert(sizeof(GPUExpression) == 32 + (4 + 8) * maxExprStops, "wrong alignment");
+static_assert(sizeof(GPUExpression) == 32 + (4 + 8) * maxExprStops, "wrong size");
static_assert(sizeof(GPUExpression) % 16 == 0, "wrong alignment");
-
-enum {
- idGlobalPaintParamsUBO,
- globalUBOCount
-};
-
-enum {
- idLineDrawableUBO = globalUBOCount,
- idLineInterpolationUBO,
- idLineTilePropertiesUBO,
- idLineEvaluatedPropsUBO,
- idLineExpressionUBO,
- lineUBOCount
-};
-
-
-enum class LineExpressionMask : uint32_t {
- None = 0,
- Color = 1 << 0,
- Opacity = 1 << 1,
- Blur = 1 << 2,
- Width = 1 << 3,
- GapWidth = 1 << 4,
- FloorWidth = 1 << 5,
- Offset = 1 << 6,
-};
-bool operator&(LineExpressionMask a, LineExpressionMask b) { return (uint32_t)a & (uint32_t)b; }
-
-struct alignas(16) LineExpressionUBO {
- GPUExpression color;
- GPUExpression blur;
- GPUExpression opacity;
- GPUExpression gapwidth;
- GPUExpression offset;
- GPUExpression width;
- GPUExpression floorwidth;
-};
-static_assert(sizeof(LineExpressionUBO) % 16 == 0, "wrong alignment");
-
-
struct alignas(16) GlobalPaintParamsUBO {
/* 0 */ float2 pattern_atlas_texsize;
/* 8 */ float2 units_to_pixels;
@@ -247,136 +212,23 @@ struct alignas(16) GlobalPaintParamsUBO {
/* 28 */ float symbol_fade_change;
/* 32 */ float aspect_ratio;
/* 36 */ float pixel_ratio;
- /* 40 */ float zoom;
+ /* 40 */ float map_zoom;
/* 44 */ float pad1;
/* 48 */
};
-static_assert(sizeof(GlobalPaintParamsUBO) == 3 * 16, "unexpected padding");
-
-struct alignas(16) FillEvaluatedPropsUBO {
- float4 color;
- float4 outline_color;
- float opacity;
- float fade;
- float from_scale;
- float to_scale;
-};
-
-struct alignas(16) FillExtrusionDrawableUBO {
- /* 0 */ float4x4 matrix;
- /* 64 */ float2 texsize;
- /* 72 */ float2 pixel_coord_upper;
- /* 80 */ float2 pixel_coord_lower;
- /* 88 */ float height_factor;
- /* 92 */ float tile_ratio;
- /* 96 */
-};
-static_assert(sizeof(FillExtrusionDrawableUBO) == 6 * 16, "unexpected padding");
+static_assert(sizeof(GlobalPaintParamsUBO) == 3 * 16, "wrong size");
-struct alignas(16) FillExtrusionPropsUBO {
- /* 0 */ float4 color;
- /* 16 */ float4 light_color_pad;
- /* 32 */ float4 light_position_base;
- /* 48 */ float height;
- /* 52 */ float light_intensity;
- /* 56 */ float vertical_gradient;
- /* 60 */ float opacity;
- /* 64 */ float fade;
- /* 68 */ float from_scale;
- /* 72 */ float to_scale;
- /* 76 */ float pad2;
- /* 80 */
-};
-static_assert(sizeof(FillExtrusionPropsUBO) == 5 * 16, "unexpected padding");
-
-struct alignas(16) FillExtrusionTilePropsUBO {
- /* 0 */ float4 pattern_from;
- /* 16 */ float4 pattern_to;
- /* 32 */
-};
-static_assert(sizeof(FillExtrusionTilePropsUBO) == 2 * 16, "unexpected padding");
-
-struct alignas(16) FillExtrusionInterpolateUBO {
- /* 0 */ float base_t;
- /* 4 */ float height_t;
- /* 8 */ float color_t;
- /* 12 */ float pattern_from_t;
- /* 16 */ float pattern_to_t;
- /* 20 */ float pad1, pad2, pad3;
- /* 32 */
-};
-static_assert(sizeof(FillExtrusionInterpolateUBO) == 2 * 16, "unexpected padding");
-
-struct alignas(16) LineEvaluatedPropsUBO {
- float4 color;
- float blur;
- float opacity;
- float gapwidth;
- float offset;
- float width;
- float floorwidth;
- LineExpressionMask expressionMask;
- float pad1;
-};
-
-struct alignas(16) SymbolDrawableUBO {
- float4x4 matrix;
- float4x4 label_plane_matrix;
- float4x4 coord_matrix;
-
- float2 texsize;
- float2 texsize_icon;
-
- float gamma_scale;
- /*bool*/ int rotate_symbol;
- float2 pad;
-};
-static_assert(sizeof(SymbolDrawableUBO) == 14 * 16, "unexpected padding");
-
-struct alignas(16) SymbolTilePropsUBO {
- /*bool*/ int is_text;
- /*bool*/ int is_halo;
- /*bool*/ int pitch_with_map;
- /*bool*/ int is_size_zoom_constant;
- /*bool*/ int is_size_feature_constant;
- float size_t;
- float size;
- float padding;
-};
-static_assert(sizeof(SymbolTilePropsUBO) == 2 * 16, "unexpected padding");
-
-struct alignas(16) SymbolInterpolateUBO {
- float fill_color_t;
- float halo_color_t;
- float opacity_t;
- float halo_width_t;
- float halo_blur_t;
- float pad1, pad2, pad3;
+enum {
+ idGlobalPaintParamsUBO,
+ idGlobalUBOIndex,
+ globalUBOCount,
};
-static_assert(sizeof(SymbolInterpolateUBO) == 32, "unexpected padding");
-struct alignas(16) SymbolEvaluatedPropsUBO {
- float4 text_fill_color;
- float4 text_halo_color;
- float text_opacity;
- float text_halo_width;
- float text_halo_blur;
- float pad1;
- float4 icon_fill_color;
- float4 icon_halo_color;
- float icon_opacity;
- float icon_halo_width;
- float icon_halo_blur;
- float pad2;
+enum {
+ idDrawableReservedVertexOnlyUBO = globalUBOCount,
+ idDrawableReservedFragmentOnlyUBO,
+ drawableReservedUBOCount
};
-static_assert(sizeof(SymbolEvaluatedPropsUBO) == 6 * 16, "unexpected padding");
-
-// unpack pattern position
-inline float2 get_pattern_pos(const float2 pixel_coord_upper, const float2 pixel_coord_lower,
- const float2 pattern_size, const float tile_units_to_pixels, const float2 pos) {
- const float2 offset = glMod(glMod(glMod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size);
- return (tile_units_to_pixels * pos + offset) / pattern_size;
-}
)";
diff --git a/include/mbgl/shaders/mtl/custom_symbol_icon.hpp b/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
index eec04b8161d..a497f9fdaa2 100644
--- a/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
+++ b/include/mbgl/shaders/mtl/custom_symbol_icon.hpp
@@ -1,43 +1,53 @@
#pragma once
-#include
-#include
-#include
#include
+#include
+#include
namespace mbgl {
namespace shaders {
+constexpr auto customSymbolIconShaderPrelude = R"(
+
+enum {
+ idCustomSymbolDrawableUBO = idDrawableReservedVertexOnlyUBO,
+ customSymbolUBOCount = drawableReservedUBOCount
+};
+
+struct alignas(16) CustomSymbolIconDrawableUBO {
+ /* 0 */ float4x4 matrix;
+ /* 64 */ float2 extrude_scale;
+ /* 72 */ float2 anchor;
+ /* 80 */ float angle_degrees;
+ /* 84 */ uint32_t scale_with_map;
+ /* 88 */ uint32_t pitch_with_map;
+ /* 92 */ float camera_to_center_distance;
+ /* 96 */ float aspect_ratio;
+ /* 100 */ float pad1;
+ /* 104 */ float pad2;
+ /* 108 */ float pad3;
+ /* 112 */
+};
+static_assert(sizeof(CustomSymbolIconDrawableUBO) == 7 * 16, "wrong size");
+
+)";
+
template <>
struct ShaderSource {
static constexpr auto name = "CustomSymbolIconShader";
static constexpr auto vertexMainFunction = "vertexMain";
static constexpr auto fragmentMainFunction = "fragmentMain";
- static const std::array uniforms;
static const std::array attributes;
static constexpr std::array instanceAttributes{};
static const std::array textures;
+ static constexpr auto prelude = customSymbolIconShaderPrelude;
static constexpr auto source = R"(
-struct alignas(16) CustomSymbolIconDrawableUBO {
- float4x4 matrix;
-};
-
-struct alignas(16) CustomSymbolIconParametersUBO {
- float2 extrude_scale;
- float2 anchor;
- float angle_degrees;
- int scale_with_map;
- int pitch_with_map;
- float camera_to_center_distance;
- float aspect_ratio;
- float pad0, pad1, pad3;
-};
struct VertexStage {
- float2 a_pos [[attribute(3)]];
- float2 a_tex [[attribute(4)]];
+ float2 a_pos [[attribute(customSymbolUBOCount + 0)]];
+ float2 a_tex [[attribute(customSymbolUBOCount + 1)]];
};
struct FragmentStage {
@@ -59,29 +69,28 @@ float2 ellipseRotateVec2(float2 v, float angle, float radiusRatio /* A/B */) {
}
FragmentStage vertex vertexMain(thread const VertexStage vertx [[stage_in]],
- device const CustomSymbolIconDrawableUBO& drawable [[buffer(1)]],
- device const CustomSymbolIconParametersUBO& parameters [[buffer(2)]]) {
+ device const CustomSymbolIconDrawableUBO& drawable [[buffer(idCustomSymbolDrawableUBO)]]) {
const float2 extrude = glMod(float2(vertx.a_pos), 2.0) * 2.0 - 1.0;
- const float2 anchor = (parameters.anchor - float2(0.5, 0.5)) * 2.0;
+ const float2 anchor = (drawable.anchor - float2(0.5, 0.5)) * 2.0;
const float2 center = floor(float2(vertx.a_pos) * 0.5);
- const float angle = radians(-parameters.angle_degrees);
+ const float angle = radians(-drawable.angle_degrees);
float2 corner = extrude - anchor;
float4 position;
- if (parameters.pitch_with_map) {
- if (parameters.scale_with_map) {
- corner *= parameters.extrude_scale;
+ if (drawable.pitch_with_map) {
+ if (drawable.scale_with_map) {
+ corner *= drawable.extrude_scale;
} else {
float4 projected_center = drawable.matrix * float4(center, 0, 1);
- corner *= parameters.extrude_scale * (projected_center.w / parameters.camera_to_center_distance);
+ corner *= drawable.extrude_scale * (projected_center.w / drawable.camera_to_center_distance);
}
corner = center + rotateVec2(corner, angle);
position = drawable.matrix * float4(corner, 0, 1);
} else {
position = drawable.matrix * float4(center, 0, 1);
- const float factor = parameters.scale_with_map ? parameters.camera_to_center_distance : position.w;
- position.xy += ellipseRotateVec2(corner * parameters.extrude_scale * factor, angle, parameters.aspect_ratio);
+ const float factor = drawable.scale_with_map ? drawable.camera_to_center_distance : position.w;
+ position.xy += ellipseRotateVec2(corner * drawable.extrude_scale * factor, angle, drawable.aspect_ratio);
}
return {
diff --git a/include/mbgl/shaders/mtl/debug.hpp b/include/mbgl/shaders/mtl/debug.hpp
index 162b480037f..e252f38636a 100644
--- a/include/mbgl/shaders/mtl/debug.hpp
+++ b/include/mbgl/shaders/mtl/debug.hpp
@@ -2,27 +2,46 @@
#include
#include