Remove legacy renderer from source, build files and CI (#3384)

This commit is contained in:
Bart Louwers
2025-04-15 19:48:31 +02:00
committed by GitHub
parent fbfc3c5b12
commit 88fd774e67
130 changed files with 279 additions and 3139 deletions

View File

@@ -12,12 +12,6 @@ switch ($env:RENDERER)
'osmesa' { $compile_flags += '-DMLN_WITH_OSMESA=ON'; break; } 'osmesa' { $compile_flags += '-DMLN_WITH_OSMESA=ON'; break; }
} }
switch ($env:RENDERING_MODE)
{
'legacy' { $compile_flags += '-DMLN_LEGACY_RENDERER=ON' ; break; }
'drawable' { $compile_flags += '-DMLN_DRAWABLE_RENDERER=ON'; break; }
}
Write-Host 'Compile flags: ' $compile_flags Write-Host 'Compile flags: ' $compile_flags
& cmake -B build -G Ninja $($compile_flags) & cmake -B build -G Ninja $($compile_flags)

View File

@@ -187,9 +187,9 @@ jobs:
- name: Build Instrumentation Tests, copy to platform/android - name: Build Instrumentation Tests, copy to platform/android
run: | run: |
./gradlew assembleLegacyDebug assembleLegacyDebugAndroidTest -PtestBuildType=debug ./gradlew assembleDrawableDebug assembleDrawableDebugAndroidTest -PtestBuildType=debug
cp MapLibreAndroidTestApp/build/outputs/apk/legacy/debug/MapLibreAndroidTestApp-legacy-debug.apk InstrumentationTestApp.apk cp MapLibreAndroidTestApp/build/outputs/apk/drawable/debug/MapLibreAndroidTestApp-drawable-debug.apk InstrumentationTestApp.apk
cp MapLibreAndroidTestApp/build/outputs/apk/androidTest/legacy/debug/MapLibreAndroidTestApp-legacy-debug-androidTest.apk InstrumentationTests.apk cp MapLibreAndroidTestApp/build/outputs/apk/androidTest/drawable/debug/MapLibreAndroidTestApp-drawable-debug-androidTest.apk InstrumentationTests.apk
- name: Upload android-ui-test - name: Upload android-ui-test
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -53,7 +53,7 @@ jobs:
strategy: strategy:
fail-fast: true fail-fast: true
matrix: matrix:
renderer: [legacy, drawable, vulkan, drawable-rust] renderer: [vulkan, drawable]
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -79,19 +79,13 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: .github/scripts/install-linux-deps run: .github/scripts/install-linux-deps
- if: matrix.renderer == 'drawable' - if: matrix.renderer == 'drawable'
run: echo renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV"
- if: matrix.renderer == 'drawable-rust'
run: | run: |
echo "renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON -DMLN_USE_RUST=ON" >> "$GITHUB_ENV" echo "-DMLN_WITH_OPENGL=ON" >> "$GITHUB_ENV"
cargo install cxxbridge-cmd
- if: matrix.renderer == 'legacy'
run: echo renderer_flag_cmake=-DMLN_LEGACY_RENDERER=ON >> "$GITHUB_ENV"
- if: matrix.renderer == 'vulkan' - if: matrix.renderer == 'vulkan'
run: echo renderer_flag_cmake="-DMLN_DRAWABLE_RENDERER=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF" >> "$GITHUB_ENV" run: echo renderer_flag_cmake="-DMLN_WITH_VULKAN=ON -DMLN_WITH_OPENGL=OFF" >> "$GITHUB_ENV"
- name: Build MapLibre Native Core - name: Build MapLibre Native Core
env: env:

View File

@@ -136,7 +136,6 @@ jobs:
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libglfw3-dev \ libglfw3-dev \
libuv1-dev \ libuv1-dev \
g++-12 \
libjpeg-dev \ libjpeg-dev \
libpng-dev \ libpng-dev \
libwebp-dev libwebp-dev
@@ -214,7 +213,6 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \ -DCMAKE_BUILD_TYPE=${{ env.BUILDTYPE }} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=gcc-12 \ -DCMAKE_C_COMPILER=gcc-12 \
-DCMAKE_CXX_COMPILER=g++-12 \
-DMLN_WITH_NODE=ON -DMLN_WITH_NODE=ON
- name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)" - name: "Create directory '${{ github.workspace }}/platform/windows/vendor/vcpkg/bincache' (Windows)"

View File

@@ -181,8 +181,6 @@ jobs:
-DMLN_WITH_NODE=ON \ -DMLN_WITH_NODE=ON \
-DMLN_WITH_OPENGL=OFF \ -DMLN_WITH_OPENGL=OFF \
-DMLN_WITH_METAL=ON \ -DMLN_WITH_METAL=ON \
-DMLN_LEGACY_RENDERER=OFF \
-DMLN_DRAWABLE_RENDERER=ON \
-DMLN_WITH_WERROR=OFF -DMLN_WITH_WERROR=OFF
- name: Configure maplibre-native (Linux) - name: Configure maplibre-native (Linux)

View File

@@ -88,12 +88,6 @@ jobs:
strategy: strategy:
matrix: matrix:
renderer: [opengl, egl, vulkan, osmesa] renderer: [opengl, egl, vulkan, osmesa]
rendering_mode: [legacy, drawable]
exclude:
- renderer: egl
rendering_mode: drawable
- renderer: vulkan
rendering_mode: legacy
runs-on: windows-2022 runs-on: windows-2022
steps: steps:
- run: | - run: |
@@ -133,7 +127,6 @@ jobs:
CMAKE_C_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" CMAKE_C_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}"
CMAKE_CXX_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}" CMAKE_CXX_COMPILER_LAUNCHER: "${{ env.SCCACHE_PATH }}"
RENDERER: "${{ matrix.renderer }}" RENDERER: "${{ matrix.renderer }}"
RENDERING_MODE: "${{ matrix.rendering_mode }}"
timeout-minutes: 60 timeout-minutes: 60
run: | run: |
cmake --version cmake --version

View File

@@ -1,6 +1,7 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary") load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag") load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@npm//:defs.bzl", "npm_link_all_packages") load("@npm//:defs.bzl", "npm_link_all_packages")
load("@rules_cc//cc:defs.bzl", "cc_library")
load( load(
"//bazel:core.bzl", "//bazel:core.bzl",
"MLN_CORE_HEADERS", "MLN_CORE_HEADERS",
@@ -76,32 +77,21 @@ cc_library(
srcs = MLN_CORE_SOURCE + srcs = MLN_CORE_SOURCE +
MLN_GENERATED_STYLE_SOURCE + select({ MLN_GENERATED_STYLE_SOURCE + select({
":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE, ":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE,
":legacy_renderer": MLN_OPENGL_SOURCE,
":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE, ":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE,
"//conditions:default": [], "//conditions:default": [],
}), }),
hdrs = MLN_CORE_HEADERS + select({ hdrs = MLN_CORE_HEADERS + select({
":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS, ":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS,
":legacy_renderer": MLN_OPENGL_HEADERS,
":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS, ":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS,
"//conditions:default": [], "//conditions:default": [],
}), }),
copts = CPP_FLAGS + MAPLIBRE_FLAGS, copts = CPP_FLAGS + MAPLIBRE_FLAGS,
defines = select({ defines = select({
":legacy_renderer": [
"MLN_RENDER_BACKEND_OPENGL=1",
"MLN_LEGACY_RENDERER=1",
"MLN_DRAWABLE_RENDERER=0",
],
":drawable_renderer": [ ":drawable_renderer": [
"MLN_RENDER_BACKEND_OPENGL=1", "MLN_RENDER_BACKEND_OPENGL=1",
"MLN_LEGACY_RENDERER=0",
"MLN_DRAWABLE_RENDERER=1",
], ],
":metal_renderer": [ ":metal_renderer": [
"MLN_RENDER_BACKEND_METAL=1", "MLN_RENDER_BACKEND_METAL=1",
"MLN_LEGACY_RENDERER=0",
"MLN_DRAWABLE_RENDERER=1",
], ],
}) + select({ }) + select({
"@platforms//os:ios": ["GLES_SILENCE_DEPRECATION=1"], "@platforms//os:ios": ["GLES_SILENCE_DEPRECATION=1"],
@@ -172,21 +162,13 @@ genrule(
string_flag( string_flag(
name = "renderer", name = "renderer",
build_setting_default = "legacy", build_setting_default = "drawable",
values = [ values = [
"legacy",
"drawable", "drawable",
"metal", "metal",
], ],
) )
config_setting(
name = "legacy_renderer",
flag_values = {
":renderer": "legacy",
},
)
config_setting( config_setting(
name = "drawable_renderer", name = "drawable_renderer",
flag_values = { flag_values = {

View File

@@ -14,13 +14,20 @@ option(MLN_WITH_VULKAN "Build with Vulkan renderer" OFF)
option(MLN_WITH_OSMESA "Build with OSMesa (Software) renderer" OFF) option(MLN_WITH_OSMESA "Build with OSMesa (Software) renderer" OFF)
option(MLN_WITH_PMTILES "Build with PMTiles support" ON) option(MLN_WITH_PMTILES "Build with PMTiles support" ON)
option(MLN_WITH_WERROR "Make all compilation warnings errors" 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_UNORDERED_DENSE "Use ankerl dense containers for performance" ON)
option(MLN_USE_TRACY "Enable Tracy instrumentation" OFF) option(MLN_USE_TRACY "Enable Tracy instrumentation" OFF)
option(MLN_USE_RUST "Use components in Rust" OFF) option(MLN_USE_RUST "Use components in Rust" OFF)
option(MLN_CORE_INCLUDE_DEPS "Include depdendencies in static build of core" OFF) option(MLN_CORE_INCLUDE_DEPS "Include depdendencies in static build of core" OFF)
if (MLN_LEGACY_RENDERER)
message(FATAL "The legacy renderer is no longer supported")
endif()
if (MLN_DRAWABLE_RENDERER)
message(FATAL "Do not pass MLN_DRAWABLE_RENDERER, the drawable renderer is now the default")
endif()
if (MLN_WITH_CLANG_TIDY) if (MLN_WITH_CLANG_TIDY)
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy) find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
if(NOT CLANG_TIDY_COMMAND) if(NOT CLANG_TIDY_COMMAND)
@@ -64,10 +71,6 @@ add_library(
set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist) set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist)
if (MLN_DRAWABLE_RENDERER)
set(MLN_LEGACY_RENDERER OFF)
endif()
target_compile_options( target_compile_options(
mbgl-compiler-options mbgl-compiler-options
INTERFACE INTERFACE
@@ -146,82 +149,74 @@ else()
add_library(mbgl-core STATIC) add_library(mbgl-core STATIC)
endif() endif()
if(MLN_DRAWABLE_RENDERER) list(APPEND INCLUDE_FILES
list(APPEND INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/context.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/context.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_data.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_data.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_impl.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_impl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_builder.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_builder.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_tweaker.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_tweaker.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/drawable_atlases_tweaker.hpp
${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/drawable_custom_layer_host_tweaker.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/gpu_expression.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/gpu_expression.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/uniform_buffer.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/vertex_attribute.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gfx/texture2d.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gfx/texture2d.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/change_request.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/renderer/change_request.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/layer_group.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/renderer/layer_group.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/renderer/layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/renderer/render_target.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/renderer/render_target.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_program_base.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_program_base.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/util/suppress_copies.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/util/suppress_copies.hpp )
) list(APPEND SRC_FILES
list(APPEND SRC_FILES ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder_impl.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder_impl.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder_impl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_builder_impl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_atlases_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_atlases_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_custom_layer_host_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/drawable_custom_layer_host_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/gpu_expression.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/gpu_expression.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/hillshade_prepare_drawable_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/hillshade_prepare_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/image_drawable_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/image_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/line_drawable_data.hpp
${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/symbol_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/collision_drawable_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/collision_drawable_data.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/uniform_buffer.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/uniform_buffer.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gfx/vertex_attribute.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gfx/vertex_attribute.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/render_target.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/render_target.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/change_request.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/change_request.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layer_group.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layer_group.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/tile_layer_group.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/tile_layer_group.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/background_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/background_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/background_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/background_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/circle_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/circle_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/circle_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/circle_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/fill_extrusion_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/line_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/line_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/line_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/line_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/location_indicator_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/location_indicator_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/location_indicator_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/raster_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/raster_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/raster_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/raster_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/symbol_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/symbol_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/collision_layer_tweaker.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/shader_program_base.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/shader_program_base.cpp )
)
target_compile_definitions(
mbgl-core
PUBLIC
"MLN_DRAWABLE_RENDERER=$<BOOL:${MLN_DRAWABLE_RENDERER}>"
)
endif()
list(APPEND INCLUDE_FILES list(APPEND INCLUDE_FILES
${PROJECT_SOURCE_DIR}/include/mbgl/actor/actor.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/actor/actor.hpp
@@ -1018,8 +1013,6 @@ if(MLN_WITH_OPENGL)
mbgl-core mbgl-core
PRIVATE MLN_RENDER_BACKEND_OPENGL=1 PRIVATE MLN_RENDER_BACKEND_OPENGL=1
PUBLIC PUBLIC
"MLN_LEGACY_RENDERER=$<BOOL:${MLN_LEGACY_RENDERER}>"
"MLN_DRAWABLE_RENDERER=$<BOOL:${MLN_DRAWABLE_RENDERER}>"
"MLN_USE_UNORDERED_DENSE=$<BOOL:${MLN_USE_UNORDERED_DENSE}>" "MLN_USE_UNORDERED_DENSE=$<BOOL:${MLN_USE_UNORDERED_DENSE}>"
) )
list(APPEND list(APPEND
@@ -1141,50 +1134,48 @@ if(MLN_WITH_OPENGL)
${PROJECT_SOURCE_DIR}/src/mbgl/platform/gl_functions.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/platform/gl_functions.cpp
) )
if(MLN_DRAWABLE_RENDERER) list(APPEND INCLUDE_FILES
list(APPEND INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/background_layer_ubo.hpp
${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/circle_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/collision_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/collision_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/custom_drawable_layer_ubo.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/debug_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/fill_extrusion_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/heatmap_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/heatmap_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/heatmap_texture_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/hillshade_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/hillshade_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/hillshade_prepare_layer_ubo.hpp
${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/layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/line_layer_ubo.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/shaders/line_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/location_indicator_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/raster_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/shader_defines.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/symbol_layer_ubo.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/shaders/widevector_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/style/layers/custom_drawable_layer.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/layermanager/custom_drawable_layer_factory.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/shaders/gl/shader_program_gl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gl/buffer_allocator.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.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gl/drawable_gl_builder.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/layer_group_gl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gl/uniform_buffer_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/vertex_attribute_gl.hpp ${PROJECT_SOURCE_DIR}/include/mbgl/gl/texture2d.hpp
${PROJECT_SOURCE_DIR}/include/mbgl/gl/texture2d.hpp )
) list(APPEND SRC_FILES
list(APPEND SRC_FILES ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_info.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_info.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_program_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/shaders/gl/shader_program_gl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/buffer_allocator.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/buffer_allocator.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_builder.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_builder.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/drawable_gl_impl.hpp
${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/layer_group_gl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture2d.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/texture2d.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_buffer_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/uniform_buffer_gl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_attribute_gl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/gl/vertex_attribute_gl.cpp )
)
endif()
endif() endif()
if(MLN_WITH_METAL) if(MLN_WITH_METAL)
@@ -1379,8 +1370,7 @@ if(MLN_WITH_VULKAN)
) )
endif() endif()
if(MLN_DRAWABLE_RENDERER) list(APPEND
list(APPEND
SRC_FILES SRC_FILES
${PROJECT_SOURCE_DIR}/src/mbgl/layermanager/custom_drawable_layer_factory.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/layermanager/custom_drawable_layer_factory.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_custom_drawable_layer.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/renderer/layers/render_custom_drawable_layer.cpp
@@ -1388,8 +1378,7 @@ if(MLN_DRAWABLE_RENDERER)
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer_impl.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer_impl.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer_impl.hpp ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer_impl.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer.cpp ${PROJECT_SOURCE_DIR}/src/mbgl/style/layers/custom_drawable_layer.cpp
) )
endif()
target_sources( target_sources(
mbgl-core PRIVATE mbgl-core PRIVATE

View File

@@ -16,8 +16,7 @@
"CMAKE_SYSTEM_NAME": "iOS", "CMAKE_SYSTEM_NAME": "iOS",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"MLN_WITH_METAL": "ON", "MLN_WITH_METAL": "ON",
"MLN_WITH_OPENGL": "OFF", "MLN_WITH_OPENGL": "OFF"
"MLN_DRAWABLE_RENDERER": "ON"
} }
}, },
{ {
@@ -29,8 +28,7 @@
"CMAKE_SYSTEM_NAME": "Darwin", "CMAKE_SYSTEM_NAME": "Darwin",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"MLN_WITH_METAL": "ON", "MLN_WITH_METAL": "ON",
"MLN_WITH_OPENGL": "OFF", "MLN_WITH_OPENGL": "OFF"
"MLN_DRAWABLE_RENDERER": "ON"
} }
}, },
{ {
@@ -42,8 +40,7 @@
"CMAKE_SYSTEM_NAME": "Darwin", "CMAKE_SYSTEM_NAME": "Darwin",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"MLN_WITH_VULKAN": "ON", "MLN_WITH_VULKAN": "ON",
"MLN_WITH_OPENGL": "OFF", "MLN_WITH_OPENGL": "OFF"
"MLN_DRAWABLE_RENDERER": "ON"
} }
}, },
{ {
@@ -72,7 +69,6 @@
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"MLN_WITH_METAL": "OFF", "MLN_WITH_METAL": "OFF",
"MLN_WITH_OPENGL": "ON", "MLN_WITH_OPENGL": "ON",
"MLN_DRAWABLE_RENDERER": "ON",
"CMAKE_C_COMPILER": "clang", "CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++" "CMAKE_CXX_COMPILER": "clang++"
} }

View File

@@ -8,6 +8,8 @@ bazel_dep(name = "rules_xcodeproj", version = "2.11.1")
bazel_dep(name = "aspect_rules_js", version = "2.3.3") bazel_dep(name = "aspect_rules_js", version = "2.3.3")
bazel_dep(name = "rules_nodejs", version = "6.3.4") bazel_dep(name = "rules_nodejs", version = "6.3.4")
bazel_dep(name = "libuv", version = "1.48.0") bazel_dep(name = "libuv", version = "1.48.0")
bazel_dep(name = "apple_support", version = "1.21.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "rules_cc", version = "0.1.1")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True) node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "20.14.0") node.toolchain(node_version = "20.14.0")
@@ -58,8 +60,8 @@ new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl"
new_git_repository( new_git_repository(
name = "tinyobjloader", name = "tinyobjloader",
remote = "https://github.com/tinyobjloader/tinyobjloader.git",
branch = "release", branch = "release",
remote = "https://github.com/tinyobjloader/tinyobjloader.git",
) )
darwin_config = use_repo_rule("//platform/darwin:bazel/darwin_config_repository_rule.bzl", "darwin_config") darwin_config = use_repo_rule("//platform/darwin:bazel/darwin_config_repository_rule.bzl", "darwin_config")

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
cc_binary( cc_binary(

View File

@@ -92,7 +92,7 @@ As an example, the glfw sample is used.
With CMake, in MapLibre repository root do With CMake, in MapLibre repository root do
~~~bash ~~~bash
# generate project # generate project
cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_WITH_CLANG_TIDY=OFF -DMLN_WITH_COVERAGE=OFF -DMLN_DRAWABLE_RENDERER=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DMLN_USE_TRACY=ON cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_WITH_CLANG_TIDY=OFF -DMLN_WITH_COVERAGE=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DMLN_USE_TRACY=ON
# build # build
cmake --build build --target mbgl-glfw -j 8 cmake --build build --target mbgl-glfw -j 8
# run # run

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
cc_library( cc_library(

View File

@@ -11,9 +11,7 @@
#include <mbgl/gfx/texture.hpp> #include <mbgl/gfx/texture.hpp>
#include <mbgl/gfx/types.hpp> #include <mbgl/gfx/types.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/uniform_buffer.hpp> #include <mbgl/gfx/uniform_buffer.hpp>
#endif
#include <memory> #include <memory>
#include <string> #include <string>
@@ -23,21 +21,18 @@ namespace mbgl {
class PaintParameters; class PaintParameters;
class ProgramParameters; class ProgramParameters;
#if MLN_DRAWABLE_RENDERER
class TileLayerGroup; class TileLayerGroup;
class LayerGroup; class LayerGroup;
class RenderTarget; class RenderTarget;
using TileLayerGroupPtr = std::shared_ptr<TileLayerGroup>; using TileLayerGroupPtr = std::shared_ptr<TileLayerGroup>;
using LayerGroupPtr = std::shared_ptr<LayerGroup>; using LayerGroupPtr = std::shared_ptr<LayerGroup>;
using RenderTargetPtr = std::shared_ptr<RenderTarget>; using RenderTargetPtr = std::shared_ptr<RenderTarget>;
#endif
namespace gfx { namespace gfx {
class OffscreenTexture; class OffscreenTexture;
class ShaderRegistry; class ShaderRegistry;
#if MLN_DRAWABLE_RENDERER
class Drawable; class Drawable;
class DrawableBuilder; class DrawableBuilder;
class ShaderProgramBase; class ShaderProgramBase;
@@ -50,7 +45,6 @@ using Texture2DPtr = std::shared_ptr<Texture2D>;
using UniformBufferPtr = std::shared_ptr<UniformBuffer>; using UniformBufferPtr = std::shared_ptr<UniformBuffer>;
using UniqueDrawableBuilder = std::unique_ptr<DrawableBuilder>; using UniqueDrawableBuilder = std::unique_ptr<DrawableBuilder>;
using VertexAttributeArrayPtr = std::shared_ptr<VertexAttributeArray>; using VertexAttributeArrayPtr = std::shared_ptr<VertexAttributeArray>;
#endif
namespace { namespace {
ContextObserver nullObserver; ContextObserver nullObserver;
@@ -114,7 +108,6 @@ public:
/// Sets dirty state /// Sets dirty state
virtual void setDirtyState() = 0; virtual void setDirtyState() = 0;
#if MLN_DRAWABLE_RENDERER
/// Create a new vertex attribute array /// Create a new vertex attribute array
virtual gfx::VertexAttributeArrayPtr createVertexAttributeArray() const = 0; virtual gfx::VertexAttributeArrayPtr createVertexAttributeArray() const = 0;
@@ -178,7 +171,6 @@ public:
/// Unbind the global uniform buffers /// Unbind the global uniform buffers
virtual void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept = 0; virtual void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept = 0;
#endif
protected: protected:
virtual std::unique_ptr<TextureResource> createTextureResource(Size, TexturePixelType, TextureChannelDataType) = 0; virtual std::unique_ptr<TextureResource> createTextureResource(Size, TexturePixelType, TextureChannelDataType) = 0;

View File

@@ -5,8 +5,6 @@
#include <optional> #include <optional>
#if MLN_DRAWABLE_RENDERER
namespace mbgl { namespace mbgl {
namespace style { namespace style {
namespace expression { namespace expression {
@@ -104,5 +102,3 @@ inline auto GPUExpression::evaluate<float>(const float zoom) const {
} // namespace gfx } // namespace gfx
} // namespace mbgl } // namespace mbgl
#endif

View File

@@ -50,10 +50,8 @@ public:
/// Returns a reference to the default surface that should be rendered on. /// Returns a reference to the default surface that should be rendered on.
virtual Renderable& getDefaultRenderable() = 0; virtual Renderable& getDefaultRenderable() = 0;
#if MLN_DRAWABLE_RENDERER
/// One-time shader initialization /// One-time shader initialization
virtual void initShaders(gfx::ShaderRegistry&, const ProgramParameters&) = 0; virtual void initShaders(gfx::ShaderRegistry&, const ProgramParameters&) = 0;
#endif
const mbgl::util::SimpleIdentity uniqueID; const mbgl::util::SimpleIdentity uniqueID;
protected: protected:

View File

@@ -23,10 +23,8 @@ public:
/// Called prior to rendering to update the internally assumed OpenGL state. /// Called prior to rendering to update the internally assumed OpenGL state.
virtual void updateAssumedState() = 0; virtual void updateAssumedState() = 0;
#if MLN_DRAWABLE_RENDERER
/// One-time shader initialization /// One-time shader initialization
void initShaders(gfx::ShaderRegistry&, const ProgramParameters& programParameters) override; void initShaders(gfx::ShaderRegistry&, const ProgramParameters& programParameters) override;
#endif
protected: protected:
std::unique_ptr<gfx::Context> createContext() override; std::unique_ptr<gfx::Context> createContext() override;

View File

@@ -1,12 +1,10 @@
#pragma once #pragma once
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable.hpp>
#endif
#include <mbgl/actor/scheduler.hpp>
#include <memory> #include <memory>
#include <mbgl/gfx/drawable.hpp>
#include <mbgl/actor/scheduler.hpp>
namespace mbgl { namespace mbgl {
class RendererObserver; class RendererObserver;

View File

@@ -3,10 +3,7 @@
#include <mbgl/shaders/layer_ubo.hpp> #include <mbgl/shaders/layer_ubo.hpp>
#include <mbgl/style/property_expression.hpp> #include <mbgl/style/property_expression.hpp>
#include <mbgl/util/bitmask_operations.hpp> #include <mbgl/util/bitmask_operations.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/gpu_expression.hpp> #include <mbgl/gfx/gpu_expression.hpp>
#endif // MLN_DRAWABLE_RENDERER
namespace mbgl { namespace mbgl {
namespace shaders { namespace shaders {

View File

@@ -7,10 +7,7 @@
#include <mbgl/style/expression/find_zoom_curve.hpp> #include <mbgl/style/expression/find_zoom_curve.hpp>
#include <mbgl/util/bitmask_operations.hpp> #include <mbgl/util/bitmask_operations.hpp>
#include <mbgl/util/range.hpp> #include <mbgl/util/range.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/gpu_expression.hpp> #include <mbgl/gfx/gpu_expression.hpp>
#endif // MLN_DRAWABLE_RENDERER
#include <optional> #include <optional>
@@ -52,10 +49,8 @@ public:
/// expression. May be removed if a better way of aggregation is found. /// expression. May be removed if a better way of aggregation is found.
std::shared_ptr<const Expression> getSharedExpression() const noexcept; std::shared_ptr<const Expression> getSharedExpression() const noexcept;
#if MLN_DRAWABLE_RENDERER
/// Build a cached GPU representation of the expression, with the same lifetime as this object. /// Build a cached GPU representation of the expression, with the same lifetime as this object.
gfx::UniqueGPUExpression getGPUExpression(bool intZoom) const; gfx::UniqueGPUExpression getGPUExpression(bool intZoom) const;
#endif // MLN_DRAWABLE_RENDERER
Dependency getDependencies() const noexcept { return expression ? expression->dependencies : Dependency::None; } Dependency getDependencies() const noexcept { return expression ? expression->dependencies : Dependency::None; }

View File

@@ -1,4 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary") load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS", "WARNING_FLAGS")
objc_library( objc_library(
@@ -88,7 +89,6 @@ objc_library(
"//platform/ios:ios_public_hdrs", "//platform/ios:ios_public_hdrs",
"//platform/ios:ios_sdk_hdrs", "//platform/ios:ios_sdk_hdrs",
] + select({ ] + select({
"//:legacy_renderer": [],
"//conditions:default": [ "//conditions:default": [
"//platform/darwin:darwin_objcpp_custom_drawable_srcs", "//platform/darwin:darwin_objcpp_custom_drawable_srcs",
], ],
@@ -288,7 +288,6 @@ objc_library(
deps = [ deps = [
":ios-sdk", ":ios-sdk",
] + select({ ] + select({
"//:legacy_renderer": [],
"//conditions:default": [ "//conditions:default": [
":app_custom_drawable_layer_objcpp_srcs", ":app_custom_drawable_layer_objcpp_srcs",
], ],

View File

@@ -15,10 +15,9 @@ else
endif endif
ifeq ($(RENDERER), drawable) ifeq ($(RENDERER), drawable)
else ifeq ($(RENDERER), legacy)
else ifeq ($(RENDERER), vulkan) else ifeq ($(RENDERER), vulkan)
else else
$(error RENDERER must be 'legacy' (OpenGL), 'drawable' (OpenGL) or 'vulkan') $(error RENDERER must be 'drawable' (OpenGL) or 'vulkan')
endif endif
buildtype := $(shell echo "$(BUILDTYPE)" | tr "[A-Z]" "[a-z]") buildtype := $(shell echo "$(BUILDTYPE)" | tr "[A-Z]" "[a-z]")
@@ -219,9 +218,9 @@ run-android-ui-test-%: run-android-ui-test-arm-v7-%
# Run Java Unit tests on the JVM of the development machine executing this # Run Java Unit tests on the JVM of the development machine executing this
.PHONY: run-android-unit-test .PHONY: run-android-unit-test
run-android-unit-test: run-android-unit-test:
$(MLN_ANDROID_GRADLE) -Pmaplibre.abis=none :MapLibreAndroid:testLegacyDebugUnitTest --info $(MLN_ANDROID_GRADLE) -Pmaplibre.abis=none :MapLibreAndroid:testDrawableDebugUnitTest --info
run-android-unit-test-%: run-android-unit-test-%:
$(MLN_ANDROID_GRADLE) -Pmaplibre.abis=none :MapLibreAndroid:testLegacyDebugUnitTest --info --tests "$*" $(MLN_ANDROID_GRADLE) -Pmaplibre.abis=none :MapLibreAndroid:testDrawableDebugUnitTest --info --tests "$*"
DEBUG_TAR_FILE_NAME := $(if $(findstring drawable,$(RENDERER)),debug-symbols-opengl.tar.gz,debug-symbols-$(RENDERER).tar.gz) DEBUG_TAR_FILE_NAME := $(if $(findstring drawable,$(RENDERER)),debug-symbols-opengl.tar.gz,debug-symbols-$(RENDERER).tar.gz)

View File

@@ -70,37 +70,17 @@ android {
"\"MapLibre Native/${project.property("VERSION_NAME")}\"" "\"MapLibre Native/${project.property("VERSION_NAME")}\""
) )
consumerProguardFiles("proguard-rules.pro") consumerProguardFiles("proguard-rules.pro")
externalNativeBuild {
cmake {
arguments("-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF")
}
}
} }
flavorDimensions += "renderer" flavorDimensions += "renderer"
productFlavors { productFlavors {
create("legacy") {
dimension = "renderer"
externalNativeBuild {
cmake {
arguments("-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF")
}
}
}
create("drawable") { create("drawable") {
dimension = "renderer" dimension = "renderer"
externalNativeBuild {
cmake {
arguments("-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON")
}
}
} }
create("vulkan") { create("vulkan") {
dimension = "renderer" dimension = "renderer"
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments("-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON")
arguments("-DMLN_WITH_OPENGL=OFF", "-DMLN_WITH_VULKAN=ON") arguments("-DMLN_WITH_OPENGL=OFF", "-DMLN_WITH_VULKAN=ON")
} }
} }
@@ -108,9 +88,6 @@ android {
} }
sourceSets { sourceSets {
getByName("legacy") {
java.srcDirs("src/opengl/java/")
}
getByName("drawable") { getByName("drawable") {
java.srcDirs("src/opengl/java/") java.srcDirs("src/opengl/java/")
} }

View File

@@ -1,4 +1,5 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary") load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library", "js_run_binary")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
load( load(
"@rules_swift//swift:swift.bzl", "@rules_swift//swift:swift.bzl",
"swift_library", "swift_library",
@@ -337,7 +338,6 @@ js_library(
":generated_style_hdrs", ":generated_style_hdrs",
":generated_style_srcs", ":generated_style_srcs",
] + select({ ] + select({
"//:legacy_renderer": [],
"//conditions:default": [ "//conditions:default": [
":darwin_objcpp_custom_drawable_srcs", ":darwin_objcpp_custom_drawable_srcs",
], ],

View File

@@ -11,9 +11,7 @@
#import "MLNSymbolStyleLayer_Private.h" #import "MLNSymbolStyleLayer_Private.h"
#import "MLNCustomStyleLayer_Private.h" #import "MLNCustomStyleLayer_Private.h"
#if MLN_DRAWABLE_RENDERER
#import "MLNCustomDrawableStyleLayer_Private.h" #import "MLNCustomDrawableStyleLayer_Private.h"
#endif
#include <vector> #include <vector>
@@ -71,13 +69,11 @@ LayerManagerDarwin::LayerManagerDarwin() {
addLayerType(std::make_unique<CustomStyleLayerPeerFactory>()); addLayerType(std::make_unique<CustomStyleLayerPeerFactory>());
#endif #endif
#if MLN_DRAWABLE_RENDERER
#if defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_RUNTIME) #if defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_RUNTIME)
addLayerTypeCoreOnly(std::make_unique<CustomDrawableLayerFactory>()); addLayerTypeCoreOnly(std::make_unique<CustomDrawableLayerFactory>());
#elif !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL) #elif !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL)
addLayerType(std::make_unique<CustomDrawableStyleLayerPeerFactory>()); addLayerType(std::make_unique<CustomDrawableStyleLayerPeerFactory>());
#endif #endif
#endif
} }
LayerManagerDarwin::~LayerManagerDarwin() = default; LayerManagerDarwin::~LayerManagerDarwin() = default;

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
cc_library( cc_library(

View File

@@ -12,10 +12,7 @@
#include <mbgl/layermanager/raster_layer_factory.hpp> #include <mbgl/layermanager/raster_layer_factory.hpp>
#include <mbgl/layermanager/symbol_layer_factory.hpp> #include <mbgl/layermanager/symbol_layer_factory.hpp>
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/layermanager/custom_drawable_layer_factory.hpp> #include <mbgl/layermanager/custom_drawable_layer_factory.hpp>
#endif
#include <map> #include <map>
#include <memory> #include <memory>
@@ -73,11 +70,9 @@ LayerManagerDefault::LayerManagerDefault() {
#if !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL) #if !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL)
addLayerType(std::make_unique<LocationIndicatorLayerFactory>()); addLayerType(std::make_unique<LocationIndicatorLayerFactory>());
#endif #endif
#if MLN_DRAWABLE_RENDERER
#if !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL) #if !defined(MLN_LAYER_CUSTOM_DRAWABLE_DISABLE_ALL)
addLayerType(std::make_unique<CustomDrawableLayerFactory>()); addLayerType(std::make_unique<CustomDrawableLayerFactory>());
#endif #endif
#endif
} }
void LayerManagerDefault::addLayerType(std::unique_ptr<LayerFactory> factory) { void LayerManagerDefault::addLayerType(std::unique_ptr<LayerFactory> factory) {

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "objc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
objc_library( objc_library(

View File

@@ -1,7 +1,5 @@
#include "example_custom_drawable_style_layer.hpp" #include "example_custom_drawable_style_layer.hpp"
#if MLN_DRAWABLE_RENDERER
#include <mbgl/style/layer.hpp> #include <mbgl/style/layer.hpp>
#include <mbgl/style/layers/custom_drawable_layer.hpp> #include <mbgl/style/layers/custom_drawable_layer.hpp>
#include <mbgl/util/io.hpp> #include <mbgl/util/io.hpp>
@@ -271,8 +269,9 @@ void ExampleCustomDrawableStyleLayerHost::createDrawables(Interface& interface)
Interface::SymbolOptions options; Interface::SymbolOptions options;
options.texture = interface.context.createTexture2D(); options.texture = interface.context.createTexture2D();
options.texture->setImage(image); options.texture->setImage(image);
options.texture->setSamplerConfiguration( options.texture->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Repeat}); .wrapU = gfx::TextureWrapType::Repeat,
.wrapV = gfx::TextureWrapType::Repeat});
const std::array<std::array<float, 2>, 2> textureCoordinates = {{{0.0f, 0.0f}, {10.0f, 10.0f}}}; const std::array<std::array<float, 2>, 2> textureCoordinates = {{{0.0f, 0.0f}, {10.0f, 10.0f}}};
options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)}; options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)};
@@ -300,8 +299,9 @@ void ExampleCustomDrawableStyleLayerHost::createDrawables(Interface& interface)
Interface::SymbolOptions options; Interface::SymbolOptions options;
options.texture = interface.context.createTexture2D(); options.texture = interface.context.createTexture2D();
options.texture->setImage(image); options.texture->setImage(image);
options.texture->setSamplerConfiguration( options.texture->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); .wrapU = gfx::TextureWrapType::Clamp,
.wrapV = gfx::TextureWrapType::Clamp});
options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)}; options.size = {static_cast<uint32_t>(image->size.width), static_cast<uint32_t>(image->size.height)};
@@ -414,8 +414,9 @@ void ExampleCustomDrawableStyleLayerHost::generateGeometry(Interface& interface)
options.texture = interface.context.createTexture2D(); options.texture = interface.context.createTexture2D();
options.texture->setImage(image); options.texture->setImage(image);
options.texture->setSamplerConfiguration( options.texture->setSamplerConfiguration({.filter = mbgl::gfx::TextureFilterType::Linear,
{mbgl::gfx::TextureFilterType::Linear, mbgl::gfx::TextureWrapType::Clamp, mbgl::gfx::TextureWrapType::Clamp}); .wrapU = mbgl::gfx::TextureWrapType::Clamp,
.wrapV = mbgl::gfx::TextureWrapType::Clamp});
const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>(); const std::shared_ptr<VertexVector> sharedVertices = std::make_shared<VertexVector>();
VertexVector& vertices = *sharedVertices; VertexVector& vertices = *sharedVertices;
@@ -426,7 +427,7 @@ void ExampleCustomDrawableStyleLayerHost::generateGeometry(Interface& interface)
const unsigned long numVtxCircumference = 72; const unsigned long numVtxCircumference = 72;
const float bearingStep = 360.0f / static_cast<float>(numVtxCircumference - 1); const float bearingStep = 360.0f / static_cast<float>(numVtxCircumference - 1);
vertices.emplace_back(Interface::GeometryVertex{{0.0f, 0.0f, 0.0f}, {0.5f, 0.5f}}); vertices.emplace_back(Interface::GeometryVertex{.position = {0.0f, 0.0f, 0.0f}, .texcoords = {0.5f, 0.5f}});
for (unsigned long i = 1; i <= numVtxCircumference; ++i) { for (unsigned long i = 1; i <= numVtxCircumference; ++i) {
const float rad = mbgl::util::deg2radf((i - 1) * bearingStep); const float rad = mbgl::util::deg2radf((i - 1) * bearingStep);
@@ -596,11 +597,10 @@ mbgl::gfx::Texture2DPtr ExampleCustomDrawableStyleLayerHost::createCheckerboardT
} }
auto texture = interface.context.createTexture2D(); auto texture = interface.context.createTexture2D();
texture->setSamplerConfiguration( texture->setSamplerConfiguration({.filter = mbgl::gfx::TextureFilterType::Linear,
{mbgl::gfx::TextureFilterType::Linear, mbgl::gfx::TextureWrapType::Clamp, mbgl::gfx::TextureWrapType::Clamp}); .wrapU = mbgl::gfx::TextureWrapType::Clamp,
.wrapV = mbgl::gfx::TextureWrapType::Clamp});
texture->setImage(std::move(image)); texture->setImage(std::move(image));
return texture; return texture;
} }
#endif

View File

@@ -2,8 +2,6 @@
#include <mbgl/style/layers/custom_drawable_layer.hpp> #include <mbgl/style/layers/custom_drawable_layer.hpp>
#if MLN_DRAWABLE_RENDERER
class ExampleCustomDrawableStyleLayerHost : public mbgl::style::CustomDrawableLayerHost { class ExampleCustomDrawableStyleLayerHost : public mbgl::style::CustomDrawableLayerHost {
public: public:
using VertexVector = mbgl::gfx::VertexVector<Interface::GeometryVertex>; using VertexVector = mbgl::gfx::VertexVector<Interface::GeometryVertex>;
@@ -39,5 +37,3 @@ protected:
protected: protected:
const std::string assetsPath; const std::string assetsPath;
}; };
#endif

View File

@@ -28,7 +28,7 @@
#include <mbgl/util/platform.hpp> #include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp> #include <mbgl/util/string.hpp>
#if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) && MLN_DRAWABLE_RENDERER #if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
#include "example_custom_drawable_style_layer.hpp" #include "example_custom_drawable_style_layer.hpp"
#endif #endif
@@ -829,7 +829,7 @@ void GLFWView::popAnnotation() {
} }
void GLFWView::toggleCustomDrawableStyle() { void GLFWView::toggleCustomDrawableStyle() {
#if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL) && MLN_DRAWABLE_RENDERER #if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
auto &style = map->getStyle(); auto &style = map->getStyle();
const std::string identifier = "ExampleCustomDrawableStyleLayer"; const std::string identifier = "ExampleCustomDrawableStyleLayer";

View File

@@ -17,9 +17,7 @@
#import "CustomStyleLayerExample.h" #import "CustomStyleLayerExample.h"
#if MLN_DRAWABLE_RENDERER
#import "ExampleCustomDrawableStyleLayer.h" #import "ExampleCustomDrawableStyleLayer.h"
#endif
#import "MBXFrameTimeGraphView.h" #import "MBXFrameTimeGraphView.h"
#import "MLNMapView_Experimental.h" #import "MLNMapView_Experimental.h"
@@ -105,9 +103,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsRuntimeStylingRows) {
MBXSettingsRuntimeStylingDDSPolygon, MBXSettingsRuntimeStylingDDSPolygon,
MBXSettingsRuntimeStylingCustomLatLonGrid, MBXSettingsRuntimeStylingCustomLatLonGrid,
MBXSettingsRuntimeStylingLineGradient, MBXSettingsRuntimeStylingLineGradient,
#if MLN_DRAWABLE_RENDERER
MBXSettingsRuntimeStylingCustomDrawableLayer, MBXSettingsRuntimeStylingCustomDrawableLayer,
#endif
MBXSettingsRuntimeStylingAddFoursquarePOIsPMTiles MBXSettingsRuntimeStylingAddFoursquarePOIsPMTiles
}; };
@@ -458,9 +454,7 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
@"Dynamically Style Polygon", @"Dynamically Style Polygon",
@"Add Custom Lat/Lon Grid", @"Add Custom Lat/Lon Grid",
@"Style Route line with gradient", @"Style Route line with gradient",
#if MLN_DRAWABLE_RENDERER
@"Add Custom Drawable Layer", @"Add Custom Drawable Layer",
#endif
@"Add FourSquare POIs PMTiles Layer" @"Add FourSquare POIs PMTiles Layer"
]]; ]];
break; break;
@@ -684,11 +678,9 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
case MBXSettingsRuntimeStylingLineGradient: case MBXSettingsRuntimeStylingLineGradient:
[self styleLineGradient]; [self styleLineGradient];
break; break;
#if MLN_DRAWABLE_RENDERER
case MBXSettingsRuntimeStylingCustomDrawableLayer: case MBXSettingsRuntimeStylingCustomDrawableLayer:
[self addCustomDrawableLayer]; [self addCustomDrawableLayer];
break; break;
#endif
case MBXSettingsRuntimeStylingAddFoursquarePOIsPMTiles: case MBXSettingsRuntimeStylingAddFoursquarePOIsPMTiles:
[self addFoursquarePOIsPMTilesLayer]; [self addFoursquarePOIsPMTilesLayer];
break; break;
@@ -1678,7 +1670,6 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
[self.mapView.style addLayer:routeLayer]; [self.mapView.style addLayer:routeLayer];
} }
#if MLN_DRAWABLE_RENDERER
- (void)addCustomDrawableLayer - (void)addCustomDrawableLayer
{ {
// Create a CustomLayer that uses the Drawable/Builder toolkit to generate and render geometry // Create a CustomLayer that uses the Drawable/Builder toolkit to generate and render geometry
@@ -1688,7 +1679,6 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
[self.mapView.style addLayer:layer]; [self.mapView.style addLayer:layer];
} }
} }
#endif
- (void)removeSource:(NSString*)ident - (void)removeSource:(NSString*)ident
{ {

View File

@@ -1,4 +1,5 @@
load("@rules_apple//apple:ios.bzl", "ios_unit_test") load("@rules_apple//apple:ios.bzl", "ios_unit_test")
load("@rules_cc//cc:defs.bzl", "objc_library")
load( load(
"@rules_swift//swift:swift.bzl", "@rules_swift//swift:swift.bzl",
"swift_library", "swift_library",

View File

@@ -1,5 +1,6 @@
load("@darwin_config//:config.bzl", "BUNDLE_ID_PREFIX") load("@darwin_config//:config.bzl", "BUNDLE_ID_PREFIX")
load("@rules_apple//apple:ios.bzl", "ios_application") load("@rules_apple//apple:ios.bzl", "ios_application")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
cc_library( cc_library(
name = "ios_test_runner_lib", name = "ios_test_runner_lib",

View File

@@ -1,6 +1,7 @@
load("@darwin_config//:config.bzl", "BUNDLE_ID_PREFIX") load("@darwin_config//:config.bzl", "BUNDLE_ID_PREFIX")
load("@rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test") load("@rules_apple//apple:ios.bzl", "ios_application", "ios_unit_test")
load("@rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@rules_apple//apple:resources.bzl", "apple_resource_bundle")
load("@rules_cc//cc:defs.bzl", "cc_library", "objc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
cc_library( cc_library(

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//bazel:flags.bzl", "WARNING_FLAGS") load("//bazel:flags.bzl", "WARNING_FLAGS")
# SMCalloutView # SMCalloutView

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
ICU_FLAGS = [ ICU_FLAGS = [

View File

@@ -33,7 +33,7 @@ See instructions in [docker/README.md](../../docker/README.md) to build in a doc
```bash ```bash
# Run from the root of the project to init the build # Run from the root of the project to init the build
cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_WITH_CLANG_TIDY=OFF -DMLN_WITH_COVERAGE=OFF -DMLN_DRAWABLE_RENDERER=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_WITH_CLANG_TIDY=OFF -DMLN_WITH_COVERAGE=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
# Build mbgl-render using all available CPUs # Build mbgl-render using all available CPUs
cmake --build build --target mbgl-render -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null) cmake --build build --target mbgl-render -j $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null)

View File

@@ -1,4 +1,5 @@
load("@rules_apple//apple:macos.bzl", "macos_application") load("@rules_apple//apple:macos.bzl", "macos_application")
load("@rules_cc//cc:defs.bzl", "objc_library")
objc_library( objc_library(
name = "macos_app_lib", name = "macos_app_lib",

View File

@@ -51,7 +51,7 @@ To compile the Node.js bindings and install module dependencies, from the reposi
#### MacOS #### MacOS
```bash ```bash
cmake . -B build -G Ninja -DMLN_WITH_NODE=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release -DMLN_WITH_OPENGL=OFF -DMLN_WITH_METAL=ON -DMLN_LEGACY_RENDERER=OFF -DMLN_DRAWABLE_RENDERER=ON -DMLN_WITH_WERROR=OFF cmake . -B build -G Ninja -DMLN_WITH_NODE=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release -DMLN_WITH_OPENGL=OFF -DMLN_WITH_METAL=ON -DMLN_WITH_WERROR=OFF
``` ```
#### Linux #### Linux

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
cc_library( cc_library(

View File

@@ -35,7 +35,6 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments("-DANDROID_STL=c++_static") arguments("-DANDROID_STL=c++_static")
arguments("-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON")
targets.add("mbgl-render-test-runner") targets.add("mbgl-render-test-runner")
} }
} }

View File

@@ -1,5 +1,6 @@
load("@rules_apple//apple:ios.bzl", "ios_unit_test") load("@rules_apple//apple:ios.bzl", "ios_unit_test")
load("@rules_apple//apple:resources.bzl", "apple_resource_bundle") load("@rules_apple//apple:resources.bzl", "apple_resource_bundle")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS") load("//bazel:flags.bzl", "CPP_FLAGS", "MAPLIBRE_FLAGS")
apple_resource_bundle( apple_resource_bundle(

View File

@@ -152,11 +152,7 @@ struct TestMetadata {
// error message: "Failed to find expectations for..., to prevent // error message: "Failed to find expectations for..., to prevent
// unit test error by missing metric.json, can turn on 'ignoreProbing' // unit test error by missing metric.json, can turn on 'ignoreProbing'
// to prevent the unit test fail, and just verify the render result. // to prevent the unit test fail, and just verify the render result.
#if MLN_LEGACY_RENDERER
bool ignoreProbing = false;
#else
bool ignoreProbing = true; bool ignoreProbing = true;
#endif
mbgl::Size size{512u, 512u}; mbgl::Size size{512u, 512u};
float pixelRatio = 1.0f; float pixelRatio = 1.0f;

View File

@@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_static_library") load("@rules_rust//rust:defs.bzl", "rust_static_library")
genrule( genrule(

View File

@@ -207,7 +207,6 @@ DashPatternTexture::DashPatternTexture(const std::vector<float>& from_,
} }
void DashPatternTexture::upload(gfx::UploadPass& uploadPass) { void DashPatternTexture::upload(gfx::UploadPass& uploadPass) {
#if MLN_DRAWABLE_RENDERER
if (std::holds_alternative<AlphaImage>(texture)) { if (std::holds_alternative<AlphaImage>(texture)) {
auto tempTexture = uploadPass.getContext().createTexture2D(); auto tempTexture = uploadPass.getContext().createTexture2D();
tempTexture->upload(std::get<AlphaImage>(texture)); tempTexture->upload(std::get<AlphaImage>(texture));
@@ -215,41 +214,18 @@ void DashPatternTexture::upload(gfx::UploadPass& uploadPass) {
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp}); {gfx::TextureFilterType::Linear, gfx::TextureWrapType::Repeat, gfx::TextureWrapType::Clamp});
texture = std::move(tempTexture); texture = std::move(tempTexture);
} }
#else
if (texture.is<AlphaImage>()) {
texture = uploadPass.createTexture(texture.get<AlphaImage>());
}
#endif
} }
#if MLN_LEGACY_RENDERER
gfx::TextureBinding DashPatternTexture::textureBinding() const {
// The texture needs to have been uploaded already.
assert(texture.is<gfx::Texture>());
return {texture.get<gfx::Texture>().getResource(),
gfx::TextureFilterType::Linear,
gfx::TextureMipMapType::No,
gfx::TextureWrapType::Repeat,
gfx::TextureWrapType::Clamp};
}
#endif
#if MLN_DRAWABLE_RENDERER
static const gfx::Texture2DPtr noTexture; static const gfx::Texture2DPtr noTexture;
const std::shared_ptr<gfx::Texture2D>& DashPatternTexture::getTexture() const { const std::shared_ptr<gfx::Texture2D>& DashPatternTexture::getTexture() const {
return (std::holds_alternative<gfx::Texture2DPtr>(texture)) ? std::get<gfx::Texture2DPtr>(texture) : noTexture; return (std::holds_alternative<gfx::Texture2DPtr>(texture)) ? std::get<gfx::Texture2DPtr>(texture) : noTexture;
} }
#endif
Size DashPatternTexture::getSize() const { Size DashPatternTexture::getSize() const {
#if MLN_DRAWABLE_RENDERER
if (std::holds_alternative<AlphaImage>(texture)) { if (std::holds_alternative<AlphaImage>(texture)) {
return std::get<AlphaImage>(texture).size; return std::get<AlphaImage>(texture).size;
} }
return std::get<gfx::Texture2DPtr>(texture)->getSize(); return std::get<gfx::Texture2DPtr>(texture)->getSize();
#else
return texture.match([](const auto& obj) { return obj.size; });
#endif
} }
LineAtlas::LineAtlas() = default; LineAtlas::LineAtlas() = default;

View File

@@ -3,15 +3,9 @@
#include <mbgl/gfx/texture.hpp> #include <mbgl/gfx/texture.hpp>
#include <mbgl/gfx/context.hpp> #include <mbgl/gfx/context.hpp>
#include <mbgl/util/image.hpp> #include <mbgl/util/image.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/texture2d.hpp> #include <mbgl/gfx/texture2d.hpp>
#include <variant>
#else
#include <mbgl/util/variant.hpp>
#include <optional>
#endif
#include <variant>
#include <map> #include <map>
#include <memory> #include <memory>
#include <vector> #include <vector>
@@ -51,11 +45,7 @@ public:
void upload(gfx::UploadPass&); void upload(gfx::UploadPass&);
// Binds the atlas texture to the GPU, and uploads data if it is out of date. // Binds the atlas texture to the GPU, and uploads data if it is out of date.
#if MLN_DRAWABLE_RENDERER
const std::shared_ptr<gfx::Texture2D>& getTexture() const; const std::shared_ptr<gfx::Texture2D>& getTexture() const;
#else
gfx::TextureBinding textureBinding() const;
#endif
// Returns the size of the texture image. // Returns the size of the texture image.
Size getSize() const; Size getSize() const;
@@ -66,11 +56,7 @@ public:
private: private:
LinePatternPos from, to; LinePatternPos from, to;
#if MLN_DRAWABLE_RENDERER
std::variant<AlphaImage, gfx::Texture2DPtr> texture; std::variant<AlphaImage, gfx::Texture2DPtr> texture;
#else
variant<AlphaImage, gfx::Texture> texture;
#endif
}; };
class LineAtlas { class LineAtlas {

View File

@@ -27,18 +27,13 @@ public:
: v(other.v) {} // buffer is not copied : v(other.v) {} // buffer is not copied
IndexVectorBase(IndexVectorBase&& other) IndexVectorBase(IndexVectorBase&& other)
: v(std::move(other.v)), : v(std::move(other.v)),
#if MLN_DRAWABLE_RENDERER
buffer(std::move(other.buffer)), buffer(std::move(other.buffer)),
#endif // MLN_DRAWABLE_RENDERER
dirty(other.dirty), dirty(other.dirty),
released(other.released) { released(other.released) {}
}
virtual ~IndexVectorBase() = default; virtual ~IndexVectorBase() = default;
#if MLN_DRAWABLE_RENDERER
IndexBufferBase* getBuffer() const { return buffer.get(); } IndexBufferBase* getBuffer() const { return buffer.get(); }
void setBuffer(std::unique_ptr<IndexBufferBase>&& value) { buffer = std::move(value); } void setBuffer(std::unique_ptr<IndexBufferBase>&& value) { buffer = std::move(value); }
#endif // MLN_DRAWABLE_RENDERER
bool getDirty() const { return dirty; } bool getDirty() const { return dirty; }
void setDirty(bool value = true) { dirty = value; } void setDirty(bool value = true) { dirty = value; }
@@ -73,19 +68,15 @@ public:
void clear() { void clear() {
dirty = true; dirty = true;
v.clear(); v.clear();
#if MLN_DRAWABLE_RENDERER
buffer.reset(); buffer.reset();
#endif // MLN_DRAWABLE_RENDERER
} }
/// Indicate that this shared index vector will no longer be updated. /// Indicate that this shared index vector will no longer be updated.
void release() { void release() {
#if MLN_DRAWABLE_RENDERER
// If we've already created a buffer, we don't need the raw data any more. // If we've already created a buffer, we don't need the raw data any more.
if (buffer) { if (buffer) {
v.clear(); v.clear();
} }
#endif // MLN_DRAWABLE_RENDERER
released = true; released = true;
} }
@@ -94,9 +85,7 @@ public:
const std::vector<uint16_t>& vector() const { return v; } const std::vector<uint16_t>& vector() const { return v; }
protected: protected:
#if MLN_DRAWABLE_RENDERER
std::unique_ptr<IndexBufferBase> buffer; std::unique_ptr<IndexBufferBase> buffer;
#endif // MLN_DRAWABLE_RENDERER
bool dirty = true; bool dirty = true;
bool released = false; bool released = false;
}; };

View File

@@ -22,11 +22,7 @@ public:
virtual PremultipliedImage readStillImage() = 0; virtual PremultipliedImage readStillImage() = 0;
#if MLN_LEGACY_RENDERER
virtual gfx::Texture& getTexture() = 0;
#else
virtual const gfx::Texture2DPtr& getTexture() = 0; virtual const gfx::Texture2DPtr& getTexture() = 0;
#endif
}; };
} // namespace gfx } // namespace gfx

View File

@@ -3,12 +3,9 @@
#include <mbgl/style/types.hpp> #include <mbgl/style/types.hpp>
#include <mbgl/util/constants.hpp> #include <mbgl/util/constants.hpp>
#include <mbgl/programs/line_program.hpp> #include <mbgl/programs/line_program.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/gfx/drawable_builder_impl.hpp> #include <mbgl/gfx/drawable_builder_impl.hpp>
#include <mbgl/gfx/drawable_impl.hpp> #include <mbgl/gfx/drawable_impl.hpp>
#endif
#include <memory> #include <memory>
#include <numbers> #include <numbers>
@@ -637,10 +634,8 @@ void PolylineGenerator<PLV, PS>::addPieSliceVertex(const GeometryCoordinate& cur
} }
} }
#if MLN_DRAWABLE_RENDERER
template class PolylineGenerator<gfx::DrawableBuilder::Impl::LineLayoutVertex, template class PolylineGenerator<gfx::DrawableBuilder::Impl::LineLayoutVertex,
std::unique_ptr<gfx::Drawable::DrawSegment>>; std::unique_ptr<gfx::Drawable::DrawSegment>>;
#endif
template class PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>>; template class PolylineGenerator<LineLayoutVertex, Segment<LineAttributes>>;

View File

@@ -10,9 +10,7 @@
#include <mbgl/util/size.hpp> #include <mbgl/util/size.hpp>
#include <mbgl/util/image.hpp> #include <mbgl/util/image.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/texture2d.hpp> #include <mbgl/gfx/texture2d.hpp>
#endif
#include <optional> #include <optional>
#include <string> #include <string>
@@ -21,14 +19,12 @@
namespace mbgl { namespace mbgl {
namespace gfx { namespace gfx {
#if MLN_DRAWABLE_RENDERER
class Conext; class Conext;
class Texture2D; class Texture2D;
class VertexAttributeArray; class VertexAttributeArray;
using AttributeBindingArray = std::vector<std::optional<gfx::AttributeBinding>>; using AttributeBindingArray = std::vector<std::optional<gfx::AttributeBinding>>;
using Texture2DPtr = std::shared_ptr<Texture2D>; using Texture2DPtr = std::shared_ptr<Texture2D>;
#endif
class UploadPass { class UploadPass {
protected: protected:
@@ -47,10 +43,8 @@ public:
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage) // NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
DebugGroup<UploadPass> createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); } DebugGroup<UploadPass> createDebugGroup(std::string_view name) { return createDebugGroup(name.data()); }
#if MLN_DRAWABLE_RENDERER
virtual Context& getContext() = 0; virtual Context& getContext() = 0;
virtual const Context& getContext() const = 0; virtual const Context& getContext() const = 0;
#endif
public: public:
template <class Vertex> template <class Vertex>
@@ -79,7 +73,6 @@ public:
updateIndexBufferResource(buffer.getResource(), v.data(), v.bytes()); updateIndexBufferResource(buffer.getResource(), v.data(), v.bytes());
} }
#if MLN_DRAWABLE_RENDERER
virtual gfx::AttributeBindingArray buildAttributeBindings( virtual gfx::AttributeBindingArray buildAttributeBindings(
const std::size_t vertexCount, const std::size_t vertexCount,
const gfx::AttributeDataType vertexType, const gfx::AttributeDataType vertexType,
@@ -90,7 +83,6 @@ public:
gfx::BufferUsageType, gfx::BufferUsageType,
const std::optional<std::chrono::duration<double>> lastUpdate, const std::optional<std::chrono::duration<double>> lastUpdate,
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) = 0; /*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) = 0;
#endif
protected: protected:
virtual std::unique_ptr<VertexBufferResource> createVertexBufferResource(const void* data, virtual std::unique_ptr<VertexBufferResource> createVertexBufferResource(const void* data,

View File

@@ -18,23 +18,17 @@ public:
VertexVectorBase() = default; VertexVectorBase() = default;
VertexVectorBase(const VertexVectorBase&) {} // buffer is not copied VertexVectorBase(const VertexVectorBase&) {} // buffer is not copied
VertexVectorBase(VertexVectorBase&& other) VertexVectorBase(VertexVectorBase&& other)
: : buffer(std::move(other.buffer)),
#if MLN_DRAWABLE_RENDERER
buffer(std::move(other.buffer)),
#endif // MLN_DRAWABLE_RENDERER
dirty(other.dirty), dirty(other.dirty),
released(other.released) { released(other.released) {}
}
virtual ~VertexVectorBase() = default; virtual ~VertexVectorBase() = default;
virtual const void* getRawData() const = 0; virtual const void* getRawData() const = 0;
virtual std::size_t getRawSize() const = 0; virtual std::size_t getRawSize() const = 0;
virtual std::size_t getRawCount() const = 0; virtual std::size_t getRawCount() const = 0;
#if MLN_DRAWABLE_RENDERER
VertexBufferBase* getBuffer() const { return buffer.get(); } VertexBufferBase* getBuffer() const { return buffer.get(); }
void setBuffer(std::unique_ptr<VertexBufferBase>&& value) { buffer = std::move(value); } void setBuffer(std::unique_ptr<VertexBufferBase>&& value) { buffer = std::move(value); }
#endif // MLN_DRAWABLE_RENDERER
std::chrono::duration<double> getLastModified() const { return lastModified; } std::chrono::duration<double> getLastModified() const { return lastModified; }
bool isModifiedAfter(std::chrono::duration<double> t) const { return t < lastModified; } bool isModifiedAfter(std::chrono::duration<double> t) const { return t < lastModified; }
@@ -50,9 +44,7 @@ public:
bool isReleased() const { return released; } bool isReleased() const { return released; }
protected: protected:
#if MLN_DRAWABLE_RENDERER
std::unique_ptr<VertexBufferBase> buffer; std::unique_ptr<VertexBufferBase> buffer;
#endif // MLN_DRAWABLE_RENDERER
bool dirty = true; bool dirty = true;
bool released = false; bool released = false;
@@ -113,12 +105,10 @@ public:
/// Indicate that this shared vertex vector instance will no longer be updated. /// Indicate that this shared vertex vector instance will no longer be updated.
void release() { void release() {
#if MLN_DRAWABLE_RENDERER
// If we've already created a buffer, we don't need the raw data any more. // If we've already created a buffer, we don't need the raw data any more.
if (buffer) { if (buffer) {
v.clear(); v.clear();
} }
#endif // MLN_DRAWABLE_RENDERER
released = true; released = true;
} }

View File

@@ -19,7 +19,6 @@
#include <mbgl/util/instrumentation.hpp> #include <mbgl/util/instrumentation.hpp>
#include <mbgl/util/thread_pool.hpp> #include <mbgl/util/thread_pool.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gl/drawable_gl.hpp> #include <mbgl/gl/drawable_gl.hpp>
#include <mbgl/gl/drawable_gl_builder.hpp> #include <mbgl/gl/drawable_gl_builder.hpp>
#include <mbgl/gl/layer_group_gl.hpp> #include <mbgl/gl/layer_group_gl.hpp>
@@ -27,7 +26,6 @@
#include <mbgl/gl/texture2d.hpp> #include <mbgl/gl/texture2d.hpp>
#include <mbgl/renderer/render_target.hpp> #include <mbgl/renderer/render_target.hpp>
#include <mbgl/shaders/gl/shader_program_gl.hpp> #include <mbgl/shaders/gl/shader_program_gl.hpp>
#endif
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
@@ -95,9 +93,7 @@ constexpr size_t renderBufferByteSize(const gfx::RenderbufferPixelType type, con
Context::Context(RendererBackend& backend_) Context::Context(RendererBackend& backend_)
: gfx::Context(/*maximumVertexBindingCount=*/getMaxVertexAttribs()), : gfx::Context(/*maximumVertexBindingCount=*/getMaxVertexAttribs()),
backend(backend_) { backend(backend_) {
#if MLN_DRAWABLE_RENDERER
uboAllocator = std::make_unique<gl::UniformBufferAllocator>(); uboAllocator = std::make_unique<gl::UniformBufferAllocator>();
#endif
texturePool = std::make_unique<Texture2DPool>(this); texturePool = std::make_unique<Texture2DPool>(this);
} }
@@ -123,7 +119,6 @@ void Context::beginFrame() {
backend.getThreadPool().runRenderJobs(); backend.getThreadPool().runRenderJobs();
#if MLN_DRAWABLE_RENDERER
frameInFlightFence = std::make_shared<gl::Fence>(); frameInFlightFence = std::make_shared<gl::Fence>();
// Run allocator defragmentation on this frame interval. // Run allocator defragmentation on this frame interval.
@@ -135,19 +130,16 @@ void Context::beginFrame() {
} else { } else {
frameNum++; frameNum++;
} }
#endif
} }
void Context::endFrame() { void Context::endFrame() {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();
#if MLN_DRAWABLE_RENDERER
if (!frameInFlightFence) { if (!frameInFlightFence) {
return; return;
} }
frameInFlightFence->insert(); frameInFlightFence->insert();
#endif
} }
void Context::initializeExtensions(const std::function<gl::ProcAddress(const char*)>& getProcAddress) { void Context::initializeExtensions(const std::function<gl::ProcAddress(const char*)>& getProcAddress) {
@@ -524,7 +516,6 @@ void Context::reset() {
texturePool->shrink(); texturePool->shrink();
} }
#if MLN_DRAWABLE_RENDERER
void Context::resetState(gfx::DepthMode depthMode, gfx::ColorMode colorMode) { void Context::resetState(gfx::DepthMode depthMode, gfx::ColorMode colorMode) {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();
MLN_TRACE_FUNC_GL(); MLN_TRACE_FUNC_GL();
@@ -563,7 +554,6 @@ void Context::unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept {
globalUniformBuffers.unbind(); globalUniformBuffers.unbind();
} }
#endif
void Context::setDirtyState() { void Context::setDirtyState() {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();
@@ -604,7 +594,6 @@ void Context::setDirtyState() {
globalVertexArrayState.setDirty(); globalVertexArrayState.setDirty();
} }
#if MLN_DRAWABLE_RENDERER
gfx::UniqueDrawableBuilder Context::createDrawableBuilder(std::string name) { gfx::UniqueDrawableBuilder Context::createDrawableBuilder(std::string name) {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();
@@ -676,8 +665,6 @@ gfx::VertexAttributeArrayPtr Context::createVertexAttributeArray() const {
return std::make_shared<VertexAttributeArrayGL>(); return std::make_shared<VertexAttributeArrayGL>();
} }
#endif
void Context::clear(std::optional<mbgl::Color> color, std::optional<float> depth, std::optional<int32_t> stencil) { void Context::clear(std::optional<mbgl::Color> color, std::optional<float> depth, std::optional<int32_t> stencil) {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();
MLN_TRACE_FUNC_GL(); MLN_TRACE_FUNC_GL();
@@ -785,11 +772,9 @@ void Context::finish() {
MBGL_CHECK_ERROR(glFinish()); MBGL_CHECK_ERROR(glFinish());
} }
#if MLN_DRAWABLE_RENDERER
std::shared_ptr<gl::Fence> Context::getCurrentFrameFence() const { std::shared_ptr<gl::Fence> Context::getCurrentFrameFence() const {
return frameInFlightFence; return frameInFlightFence;
} }
#endif
void Context::draw(const gfx::DrawMode& drawMode, std::size_t indexOffset, std::size_t indexLength) { void Context::draw(const gfx::DrawMode& drawMode, std::size_t indexOffset, std::size_t indexLength) {
MLN_TRACE_FUNC(); MLN_TRACE_FUNC();

View File

@@ -16,12 +16,10 @@
#include <mbgl/platform/gl_functions.hpp> #include <mbgl/platform/gl_functions.hpp>
#include <mbgl/util/noncopyable.hpp> #include <mbgl/util/noncopyable.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gl/fence.hpp> #include <mbgl/gl/fence.hpp>
#include <mbgl/gl/buffer_allocator.hpp> #include <mbgl/gl/buffer_allocator.hpp>
#include <mbgl/gfx/texture2d.hpp> #include <mbgl/gfx/texture2d.hpp>
#include <mbgl/gl/uniform_buffer_gl.hpp> #include <mbgl/gl/uniform_buffer_gl.hpp>
#endif
#include <array> #include <array>
#include <functional> #include <functional>
@@ -89,9 +87,7 @@ public:
void finish(); void finish();
#if MLN_DRAWABLE_RENDERER
std::shared_ptr<gl::Fence> getCurrentFrameFence() const; std::shared_ptr<gl::Fence> getCurrentFrameFence() const;
#endif
// Actually remove the objects we marked as abandoned with the above methods. // Actually remove the objects we marked as abandoned with the above methods.
// Only call this while the OpenGL context is exclusive to this thread. // Only call this while the OpenGL context is exclusive to this thread.
@@ -118,7 +114,6 @@ public:
void setCleanupOnDestruction(bool cleanup) { cleanupOnDestruction = cleanup; } void setCleanupOnDestruction(bool cleanup) { cleanupOnDestruction = cleanup; }
#if MLN_DRAWABLE_RENDERER
gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override; gfx::UniqueDrawableBuilder createDrawableBuilder(std::string name) override;
gfx::UniformBufferPtr createUniformBuffer(const void* data, gfx::UniformBufferPtr createUniformBuffer(const void* data,
std::size_t size, std::size_t size,
@@ -159,7 +154,6 @@ public:
/// Unbind the global uniform buffers /// Unbind the global uniform buffers
void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept override; void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept override;
#endif
void setDirtyState() override; void setDirtyState() override;
@@ -170,12 +164,10 @@ private:
bool cleanupOnDestruction = true; bool cleanupOnDestruction = true;
std::unique_ptr<extension::Debugging> debugging; std::unique_ptr<extension::Debugging> debugging;
#if MLN_DRAWABLE_RENDERER
std::shared_ptr<gl::Fence> frameInFlightFence; std::shared_ptr<gl::Fence> frameInFlightFence;
std::unique_ptr<gl::UniformBufferAllocator> uboAllocator; std::unique_ptr<gl::UniformBufferAllocator> uboAllocator;
size_t frameNum = 0; size_t frameNum = 0;
UniformBufferArrayGL globalUniformBuffers; UniformBufferArrayGL globalUniformBuffers;
#endif
public: public:
State<value::ActiveTextureUnit> activeTextureUnit; State<value::ActiveTextureUnit> activeTextureUnit;

View File

@@ -13,35 +13,28 @@ public:
size(size_), size(size_),
type(type_) { type(type_) {
assert(!size.isEmpty()); assert(!size.isEmpty());
#if MLN_DRAWABLE_RENDERER
texture = context.createTexture2D(); texture = context.createTexture2D();
texture->setSize(size); texture->setSize(size);
texture->setFormat(gfx::TexturePixelType::RGBA, type); texture->setFormat(gfx::TexturePixelType::RGBA, type);
texture->setSamplerConfiguration( texture->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); .wrapU = gfx::TextureWrapType::Clamp,
#endif .wrapV = gfx::TextureWrapType::Clamp});
} }
~OffscreenTextureResource() noexcept override = default; ~OffscreenTextureResource() noexcept override = default;
void bind() override { void bind() override {
if (!framebuffer) { if (!framebuffer) {
#if MLN_LEGACY_RENDERER
assert(!texture);
texture = context.createTexture(size, gfx::TexturePixelType::RGBA, type);
framebuffer = context.createFramebuffer(*texture);
#else
assert(texture); assert(texture);
texture->create(); texture->create();
framebuffer = context.createFramebuffer(*texture); framebuffer = context.createFramebuffer(*texture);
#endif
} else { } else {
context.bindFramebuffer = framebuffer->framebuffer; context.bindFramebuffer = framebuffer->framebuffer;
} }
context.activeTextureUnit = 0; context.activeTextureUnit = 0;
context.scissorTest = false; context.scissorTest = false;
context.viewport = {0, 0, size}; context.viewport = {.x = 0, .y = 0, .size = size};
} }
PremultipliedImage readStillImage() { PremultipliedImage readStillImage() {
@@ -50,26 +43,15 @@ public:
return context.readFramebuffer<PremultipliedImage>(size); return context.readFramebuffer<PremultipliedImage>(size);
} }
#if MLN_LEGACY_RENDERER
gfx::Texture& getTexture() {
assert(texture);
return *texture;
}
#else
gfx::Texture2DPtr& getTexture() { gfx::Texture2DPtr& getTexture() {
assert(texture); assert(texture);
return texture; return texture;
} }
#endif
private: private:
gl::Context& context; gl::Context& context;
const Size size; const Size size;
#if MLN_LEGACY_RENDERER
std::optional<gfx::Texture> texture;
#else
gfx::Texture2DPtr texture; gfx::Texture2DPtr texture;
#endif
const gfx::TextureChannelDataType type; const gfx::TextureChannelDataType type;
std::optional<gl::Framebuffer> framebuffer; std::optional<gl::Framebuffer> framebuffer;
}; };
@@ -90,15 +72,9 @@ PremultipliedImage OffscreenTexture::readStillImage() {
return getResource<OffscreenTextureResource>().readStillImage(); return getResource<OffscreenTextureResource>().readStillImage();
} }
#if MLN_LEGACY_RENDERER
gfx::Texture& OffscreenTexture::getTexture() {
return getResource<OffscreenTextureResource>().getTexture();
}
#else
const gfx::Texture2DPtr& OffscreenTexture::getTexture() { const gfx::Texture2DPtr& OffscreenTexture::getTexture() {
return getResource<OffscreenTextureResource>().getTexture(); return getResource<OffscreenTextureResource>().getTexture();
} }
#endif
} // namespace gl } // namespace gl
} // namespace mbgl } // namespace mbgl

View File

@@ -17,12 +17,7 @@ public:
bool isRenderable() override; bool isRenderable() override;
PremultipliedImage readStillImage() override; PremultipliedImage readStillImage() override;
#if MLN_LEGACY_RENDERER
gfx::Texture& getTexture() override;
#else
const gfx::Texture2DPtr& getTexture() override; const gfx::Texture2DPtr& getTexture() override;
#endif
}; };
} // namespace gl } // namespace gl

View File

@@ -7,9 +7,7 @@
#include <mbgl/util/instrumentation.hpp> #include <mbgl/util/instrumentation.hpp>
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/shaders/gl/shader_group_gl.hpp> #include <mbgl/shaders/gl/shader_group_gl.hpp>
#endif
#include <cassert> #include <cassert>
@@ -92,7 +90,6 @@ void RendererBackend::setScissorTest(bool enabled) {
RendererBackend::~RendererBackend() = default; RendererBackend::~RendererBackend() = default;
#if MLN_DRAWABLE_RENDERER
/// @brief Register a list of types with a shader registry instance /// @brief Register a list of types with a shader registry instance
/// @tparam ...ShaderID Pack of BuiltIn:: shader IDs /// @tparam ...ShaderID Pack of BuiltIn:: shader IDs
/// @param registry A shader registry instance /// @param registry A shader registry instance
@@ -150,7 +147,6 @@ void RendererBackend::initShaders(gfx::ShaderRegistry& shaders, const ProgramPar
shaders::BuiltIn::SymbolSDFIconShader, shaders::BuiltIn::SymbolSDFIconShader,
shaders::BuiltIn::SymbolTextAndIconShader>(shaders, programParameters); shaders::BuiltIn::SymbolTextAndIconShader>(shaders, programParameters);
} }
#endif
} // namespace gl } // namespace gl
} // namespace mbgl } // namespace mbgl

View File

@@ -12,10 +12,8 @@
#include <mbgl/util/instrumentation.hpp> #include <mbgl/util/instrumentation.hpp>
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gl/vertex_attribute_gl.hpp> #include <mbgl/gl/vertex_attribute_gl.hpp>
#include <mbgl/gl/texture2d.hpp> #include <mbgl/gl/texture2d.hpp>
#endif
#include <algorithm> #include <algorithm>
@@ -140,7 +138,6 @@ struct VertexBufferGL : public gfx::VertexBufferBase {
std::unique_ptr<gfx::VertexBufferResource> resource; std::unique_ptr<gfx::VertexBufferResource> resource;
}; };
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
const std::unique_ptr<gfx::VertexBufferResource> noBuffer; const std::unique_ptr<gfx::VertexBufferResource> noBuffer;
} }
@@ -315,7 +312,6 @@ gfx::AttributeBindingArray UploadPass::buildAttributeBindings(
return bindings; return bindings;
} }
#endif
void UploadPass::pushDebugGroup(const char* name) { void UploadPass::pushDebugGroup(const char* name) {
commandEncoder.pushDebugGroup(name); commandEncoder.pushDebugGroup(name);
@@ -325,7 +321,6 @@ void UploadPass::popDebugGroup() {
commandEncoder.popDebugGroup(); commandEncoder.popDebugGroup();
} }
#if MLN_DRAWABLE_RENDERER
gfx::Context& UploadPass::getContext() { gfx::Context& UploadPass::getContext() {
return commandEncoder.context; return commandEncoder.context;
} }
@@ -333,7 +328,6 @@ gfx::Context& UploadPass::getContext() {
const gfx::Context& UploadPass::getContext() const { const gfx::Context& UploadPass::getContext() const {
return commandEncoder.context; return commandEncoder.context;
} }
#endif
} // namespace gl } // namespace gl
} // namespace mbgl } // namespace mbgl

View File

@@ -28,10 +28,8 @@ private:
void popDebugGroup() override; void popDebugGroup() override;
public: public:
#if MLN_DRAWABLE_RENDERER
gfx::Context& getContext() override; gfx::Context& getContext() override;
const gfx::Context& getContext() const override; const gfx::Context& getContext() const override;
#endif
std::unique_ptr<gfx::VertexBufferResource> createVertexBufferResource(const void* data, std::unique_ptr<gfx::VertexBufferResource> createVertexBufferResource(const void* data,
std::size_t size, std::size_t size,
@@ -45,7 +43,6 @@ public:
bool persistent) override; bool persistent) override;
void updateIndexBufferResource(gfx::IndexBufferResource&, const void* data, std::size_t size) override; void updateIndexBufferResource(gfx::IndexBufferResource&, const void* data, std::size_t size) override;
#if MLN_DRAWABLE_RENDERER
const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&, gfx::BufferUsageType); const gfx::UniqueVertexBufferResource& getBuffer(const gfx::VertexVectorBasePtr&, gfx::BufferUsageType);
gfx::AttributeBindingArray buildAttributeBindings( gfx::AttributeBindingArray buildAttributeBindings(
@@ -58,7 +55,6 @@ public:
gfx::BufferUsageType, gfx::BufferUsageType,
const std::optional<std::chrono::duration<double>> lastUpdate, const std::optional<std::chrono::duration<double>> lastUpdate,
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override; /*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override;
#endif
public: public:
std::unique_ptr<gfx::TextureResource> createTextureResource(Size, std::unique_ptr<gfx::TextureResource> createTextureResource(Size,

View File

@@ -40,38 +40,8 @@ void registerTypes(gfx::ShaderRegistry& registry, const ProgramParameters& progr
} }
void Programs::registerWith(gfx::ShaderRegistry& registry) { void Programs::registerWith(gfx::ShaderRegistry& registry) {
#if MLN_LEGACY_RENDERER
/// The following types will be registered
registerTypes<BackgroundProgram,
BackgroundPatternProgram,
RasterProgram,
HeatmapProgram,
HeatmapTextureProgram,
HillshadeProgram,
HillshadePrepareProgram,
FillProgram,
FillPatternProgram,
FillOutlineProgram,
FillOutlinePatternProgram,
FillExtrusionProgram,
FillExtrusionPatternProgram,
CircleProgram,
LineProgram,
LineGradientProgram,
LineSDFProgram,
LinePatternProgram,
SymbolIconProgram,
SymbolSDFIconProgram,
SymbolSDFTextProgram,
SymbolTextAndIconProgram,
CollisionBoxProgram,
CollisionCircleProgram,
DebugProgram,
ClippingMaskProgram>(registry, programParameters);
#else
/// The following types will be registered /// The following types will be registered
registerTypes<DebugProgram, ClippingMaskProgram>(registry, programParameters); registerTypes<DebugProgram, ClippingMaskProgram>(registry, programParameters);
#endif
} }
} // namespace mbgl } // namespace mbgl

View File

@@ -6,9 +6,7 @@
#include <mbgl/style/layer_impl.hpp> #include <mbgl/style/layer_impl.hpp>
#include <mbgl/tile/geometry_tile_data.hpp> #include <mbgl/tile/geometry_tile_data.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/util/identity.hpp> #include <mbgl/util/identity.hpp>
#endif
#include <atomic> #include <atomic>
@@ -71,9 +69,7 @@ public:
virtual void updateVertices( virtual void updateVertices(
const Placement&, bool /*updateOpacities*/, const TransformState&, const RenderTile&, std::set<uint32_t>&) {} const Placement&, bool /*updateOpacities*/, const TransformState&, const RenderTile&, std::set<uint32_t>&) {}
#if MLN_DRAWABLE_RENDERER
const util::SimpleIdentity& getID() const { return bucketID; } const util::SimpleIdentity& getID() const { return bucketID; }
#endif
#if MLN_SYMBOL_GUARDS #if MLN_SYMBOL_GUARDS
virtual bool check(std::source_location) { return true; } virtual bool check(std::source_location) { return true; }
@@ -88,9 +84,7 @@ protected:
Bucket() = default; Bucket() = default;
std::atomic<bool> uploaded{false}; std::atomic<bool> uploaded{false};
#if MLN_DRAWABLE_RENDERER
util::SimpleIdentity bucketID; util::SimpleIdentity bucketID;
#endif
std::optional<std::thread::id> renderThreadID; std::optional<std::thread::id> renderThreadID;
}; };

View File

@@ -26,17 +26,6 @@ CircleBucket::~CircleBucket() {
} }
void CircleBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void CircleBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
if (!uploaded) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
indexBuffer = uploadPass.createIndexBuffer(std::move(triangles));
}
for (auto& pair : paintPropertyBinders) {
pair.second.upload(uploadPass);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }

View File

@@ -40,11 +40,6 @@ public:
SegmentVector<CircleAttributes> segments; SegmentVector<CircleAttributes> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<CircleLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
std::map<std::string, CircleProgram::Binders> paintPropertyBinders; std::map<std::string, CircleProgram::Binders> paintPropertyBinders;
const MapMode mode; const MapMode mode;

View File

@@ -5,7 +5,6 @@
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <vector>
namespace mbgl { namespace mbgl {
@@ -70,18 +69,6 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
segments.emplace_back(0, 0, vertices.elements(), indices.elements()); segments.emplace_back(0, 0, vertices.elements(), indices.elements());
} }
void DebugBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void DebugBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {}
#if MLN_LEGACY_RENDERER
if (!vertices.empty()) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
indexBuffer = uploadPass.createIndexBuffer(std::move(indices));
}
if (!texture) {
std::array<uint8_t, 4> data{{0, 0, 0, 0}};
static const PremultipliedImage emptyImage{Size(1, 1), data.data(), data.size()};
texture = uploadPass.createTexture(emptyImage);
}
#endif // MLN_LEGACY_RENDERER
}
} // namespace mbgl } // namespace mbgl

View File

@@ -76,19 +76,6 @@ void FillBucket::addFeature(const GeometryTileFeature& feature,
#endif // MLN_TRIANGULATE_FILL_OUTLINES #endif // MLN_TRIANGULATE_FILL_OUTLINES
void FillBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void FillBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
if (!uploaded) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
lineIndexBuffer = uploadPass.createIndexBuffer(std::move(basicLines));
triangleIndexBuffer = triangles.empty() ? std::optional<gfx::IndexBuffer>{}
: uploadPass.createIndexBuffer(std::move(triangles));
}
for (auto& pair : paintPropertyBinders) {
pair.second.upload(uploadPass);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }

View File

@@ -8,7 +8,6 @@
#include <mbgl/programs/fill_program.hpp> #include <mbgl/programs/fill_program.hpp>
#include <mbgl/style/layers/fill_layer_properties.hpp> #include <mbgl/style/layers/fill_layer_properties.hpp>
#if MLN_DRAWABLE_RENDERER
/** /**
Control how the fill outlines are being generated: Control how the fill outlines are being generated:
MLN_TRIANGULATE_FILL_OUTLINES = 0 : Simple line primitives will be generated. Draw using gfx::Lines MLN_TRIANGULATE_FILL_OUTLINES = 0 : Simple line primitives will be generated. Draw using gfx::Lines
@@ -16,17 +15,10 @@
*/ */
#define MLN_TRIANGULATE_FILL_OUTLINES (MLN_RENDER_BACKEND_METAL) #define MLN_TRIANGULATE_FILL_OUTLINES (MLN_RENDER_BACKEND_METAL)
#else // MLN_DRAWABLE_RENDERER
// Legacy Renderer is incompatible with triangulated lines
#define MLN_TRIANGULATE_FILL_OUTLINES 0
#endif // MLN_DRAWABLE_RENDERER
#if MLN_TRIANGULATE_FILL_OUTLINES #if MLN_TRIANGULATE_FILL_OUTLINES
#include <mbgl/programs/line_program.hpp> #include <mbgl/programs/line_program.hpp>
#endif #endif
#include <vector>
namespace mbgl { namespace mbgl {
class BucketParameters; class BucketParameters;
@@ -85,12 +77,6 @@ public:
SegmentVector<FillAttributes> triangleSegments; SegmentVector<FillAttributes> triangleSegments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<FillLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> lineIndexBuffer;
std::optional<gfx::IndexBuffer> triangleIndexBuffer;
#endif // MLN_LEGACY_RENDERER
std::map<std::string, FillProgram::Binders> paintPropertyBinders; std::map<std::string, FillProgram::Binders> paintPropertyBinders;
}; };

View File

@@ -172,17 +172,6 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature,
} }
void FillExtrusionBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void FillExtrusionBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
if (!uploaded) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
indexBuffer = uploadPass.createIndexBuffer(std::move(triangles));
}
for (auto& pair : paintPropertyBinders) {
pair.second.upload(uploadPass);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }

View File

@@ -49,11 +49,6 @@ public:
SegmentVector<FillExtrusionAttributes> triangleSegments; SegmentVector<FillExtrusionAttributes> triangleSegments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<FillExtrusionLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
std::unordered_map<std::string, FillExtrusionProgram::Binders> paintPropertyBinders; std::unordered_map<std::string, FillExtrusionProgram::Binders> paintPropertyBinders;
}; };

View File

@@ -26,15 +26,6 @@ HeatmapBucket::~HeatmapBucket() {
} }
void HeatmapBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void HeatmapBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
indexBuffer = uploadPass.createIndexBuffer(std::move(triangles));
for (auto& pair : paintPropertyBinders) {
pair.second.upload(uploadPass);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }

View File

@@ -40,11 +40,6 @@ public:
SegmentVector<HeatmapAttributes> segments; SegmentVector<HeatmapAttributes> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<HeatmapLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
std::map<std::string, HeatmapProgram::Binders> paintPropertyBinders; std::map<std::string, HeatmapProgram::Binders> paintPropertyBinders;
const MapMode mode; const MapMode mode;

View File

@@ -31,27 +31,10 @@ void HillshadeBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
return; return;
} }
#if MLN_LEGACY_RENDERER
const PremultipliedImage* image = demdata.getImage();
dem = uploadPass.createTexture(*image);
if (!vertices.empty()) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
}
if (!indices.empty()) {
indexBuffer = uploadPass.createIndexBuffer(std::move(indices));
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }
void HillshadeBucket::clear() { void HillshadeBucket::clear() {
#if MLN_LEGACY_RENDERER
vertexBuffer = {};
indexBuffer = {};
#endif // MLN_LEGACY_RENDERER
segments.clear(); segments.clear();
vertices.clear(); vertices.clear();
indices.clear(); indices.clear();

View File

@@ -30,10 +30,8 @@ public:
std::optional<gfx::Texture> dem; std::optional<gfx::Texture> dem;
std::optional<gfx::Texture> texture; std::optional<gfx::Texture> texture;
#if MLN_DRAWABLE_RENDERER
RenderTargetPtr renderTarget; RenderTargetPtr renderTarget;
bool renderTargetPrepared = false; bool renderTargetPrepared = false;
#endif
TileMask mask{{0, 0, 0}}; TileMask mask{{0, 0, 0}};
@@ -55,11 +53,6 @@ public:
SegmentVector<HillshadeAttributes> segments; SegmentVector<HillshadeAttributes> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<HillshadeLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
private: private:
DEMData demdata; DEMData demdata;
bool prepared = false; bool prepared = false;

View File

@@ -127,17 +127,6 @@ void LineBucket::addGeometry(const GeometryCoordinates& coordinates,
} }
void LineBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void LineBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
if (!uploaded) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
indexBuffer = uploadPass.createIndexBuffer(std::move(triangles));
}
for (auto& pair : paintPropertyBinders) {
pair.second.upload(uploadPass);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }

View File

@@ -8,8 +8,6 @@
#include <mbgl/style/layers/line_layer_properties.hpp> #include <mbgl/style/layers/line_layer_properties.hpp>
#include <mbgl/style/image_impl.hpp> #include <mbgl/style/image_impl.hpp>
#include <vector>
namespace mbgl { namespace mbgl {
class BucketParameters; class BucketParameters;
@@ -52,11 +50,6 @@ public:
SegmentVector<LineAttributes> segments; SegmentVector<LineAttributes> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<LineLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
std::map<std::string, LineProgram::Binders> paintPropertyBinders; std::map<std::string, LineProgram::Binders> paintPropertyBinders;
private: private:

View File

@@ -22,26 +22,10 @@ void RasterBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
if (!hasData()) { if (!hasData()) {
return; return;
} }
#if MLN_LEGACY_RENDERER
if (!texture) {
texture = uploadPass.createTexture(*image);
}
if (!vertices.empty()) {
vertexBuffer = uploadPass.createVertexBuffer(std::move(vertices));
}
if (!indices.empty()) {
indexBuffer = uploadPass.createIndexBuffer(std::move(indices));
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
} }
void RasterBucket::clear() { void RasterBucket::clear() {
#if MLN_LEGACY_RENDERER
vertexBuffer = {};
indexBuffer = {};
#endif // MLN_LEGACY_RENDERER
segments.clear(); segments.clear();
vertices.clear(); vertices.clear();
indices.clear(); indices.clear();

View File

@@ -48,11 +48,6 @@ public:
TriangleIndexVector& indices = *sharedTriangles; TriangleIndexVector& indices = *sharedTriangles;
SegmentVector<RasterAttributes> segments; SegmentVector<RasterAttributes> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<RasterLayoutVertex>> vertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -52,132 +52,17 @@ SymbolBucket::SymbolBucket(Immutable<style::SymbolLayoutProperties::PossiblyEval
placementModes(std::move(placementModes_)) { placementModes(std::move(placementModes_)) {
for (const auto& pair : paintProperties_) { for (const auto& pair : paintProperties_) {
const auto& evaluated = getEvaluated<SymbolLayerProperties>(pair.second); const auto& evaluated = getEvaluated<SymbolLayerProperties>(pair.second);
paintProperties.emplace( paintProperties.emplace(std::piecewise_construct,
std::piecewise_construct, std::forward_as_tuple(pair.first),
std::forward_as_tuple(pair.first), std::forward_as_tuple(PaintProperties{
std::forward_as_tuple(PaintProperties{{RenderSymbolLayer::iconPaintProperties(evaluated), zoom}, .iconBinders = {RenderSymbolLayer::iconPaintProperties(evaluated), zoom},
{RenderSymbolLayer::textPaintProperties(evaluated), zoom}})); .textBinders = {RenderSymbolLayer::textPaintProperties(evaluated), zoom}}));
} }
} }
SymbolBucket::~SymbolBucket() = default; SymbolBucket::~SymbolBucket() = default;
void SymbolBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) { void SymbolBucket::upload([[maybe_unused]] gfx::UploadPass& uploadPass) {
#if MLN_LEGACY_RENDERER
if (hasTextData()) {
if (!staticUploaded) {
text.indexBuffer = uploadPass.createIndexBuffer(
std::move(text.triangles),
sortFeaturesByY ? gfx::BufferUsageType::StreamDraw : gfx::BufferUsageType::StaticDraw);
text.vertexBuffer = uploadPass.createVertexBuffer(text.vertices());
for (auto& pair : paintProperties) {
pair.second.textBinders.upload(uploadPass);
}
} else if (!sortUploaded) {
uploadPass.updateIndexBuffer(*text.indexBuffer, std::move(text.triangles));
}
if (!dynamicUploaded) {
if (!text.dynamicVertexBuffer) {
text.dynamicVertexBuffer = uploadPass.createVertexBuffer(text.dynamicVertices(),
gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*text.dynamicVertexBuffer, text.dynamicVertices());
}
}
if (!placementChangesUploaded) {
if (!text.opacityVertexBuffer) {
text.opacityVertexBuffer = uploadPass.createVertexBuffer(text.opacityVertices(),
gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*text.opacityVertexBuffer, text.opacityVertices());
}
}
}
auto updateIconBuffer = [&](Buffer& iconBuffer) {
if (!staticUploaded) {
iconBuffer.indexBuffer = uploadPass.createIndexBuffer(
std::move(iconBuffer.triangles),
sortFeaturesByY ? gfx::BufferUsageType::StreamDraw : gfx::BufferUsageType::StaticDraw);
iconBuffer.vertexBuffer = uploadPass.createVertexBuffer(iconBuffer.vertices());
for (auto& pair : paintProperties) {
pair.second.iconBinders.upload(uploadPass);
}
} else if (!sortUploaded) {
uploadPass.updateIndexBuffer(*iconBuffer.indexBuffer, std::move(iconBuffer.triangles));
}
if (!dynamicUploaded) {
if (!iconBuffer.dynamicVertexBuffer) {
iconBuffer.dynamicVertexBuffer = uploadPass.createVertexBuffer(iconBuffer.dynamicVertices(),
gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*iconBuffer.dynamicVertexBuffer, iconBuffer.dynamicVertices());
}
}
if (!placementChangesUploaded) {
if (!iconBuffer.opacityVertexBuffer) {
iconBuffer.opacityVertexBuffer = uploadPass.createVertexBuffer(iconBuffer.opacityVertices(),
gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*iconBuffer.opacityVertexBuffer, iconBuffer.opacityVertices());
}
}
};
if (hasIconData()) {
updateIconBuffer(icon);
}
if (hasSdfIconData()) {
updateIconBuffer(sdfIcon);
}
const auto updateCollisionBox = [&](CollisionBoxBuffer& collisionBox) {
if (!staticUploaded) {
collisionBox.indexBuffer = uploadPass.createIndexBuffer(std::move(collisionBox.lines));
collisionBox.vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionBox.vertices()));
}
if (!placementChangesUploaded) {
if (!collisionBox.dynamicVertexBuffer) {
collisionBox.dynamicVertexBuffer = uploadPass.createVertexBuffer(
std::move(collisionBox.dynamicVertices()), gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*collisionBox.dynamicVertexBuffer,
std::move(collisionBox.dynamicVertices()));
}
}
};
if (hasIconCollisionBoxData()) {
updateCollisionBox(*iconCollisionBox);
}
if (hasTextCollisionBoxData()) {
updateCollisionBox(*textCollisionBox);
}
const auto updateCollisionCircle = [&](CollisionCircleBuffer& collisionCircle) {
if (!staticUploaded) {
collisionCircle.indexBuffer = uploadPass.createIndexBuffer(std::move(collisionCircle.triangles));
collisionCircle.vertexBuffer = uploadPass.createVertexBuffer(std::move(collisionCircle.vertices()));
}
if (!placementChangesUploaded) {
if (!collisionCircle.dynamicVertexBuffer) {
collisionCircle.dynamicVertexBuffer = uploadPass.createVertexBuffer(
std::move(collisionCircle.dynamicVertices()), gfx::BufferUsageType::StreamDraw);
} else {
uploadPass.updateVertexBuffer(*collisionCircle.dynamicVertexBuffer,
std::move(collisionCircle.dynamicVertices()));
}
}
};
if (hasIconCollisionCircleData()) {
updateCollisionCircle(*iconCollisionCircle);
}
if (hasTextCollisionCircleData()) {
updateCollisionCircle(*textCollisionCircle);
}
#endif // MLN_LEGACY_RENDERER
uploaded = true; uploaded = true;
staticUploaded = true; staticUploaded = true;
placementChangesUploaded = true; placementChangesUploaded = true;

View File

@@ -182,13 +182,6 @@ public:
SegmentVector<SymbolTextAttributes> segments; SegmentVector<SymbolTextAttributes> segments;
std::vector<PlacedSymbol> placedSymbols; std::vector<PlacedSymbol> placedSymbols;
#if MLN_LEGACY_RENDERER
std::optional<VertexBuffer> vertexBuffer;
std::optional<DynamicVertexBuffer> dynamicVertexBuffer;
std::optional<OpacityVertexBuffer> opacityVertexBuffer;
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
} text; } text;
std::unique_ptr<SymbolSizeBinder> iconSizeBinder; std::unique_ptr<SymbolSizeBinder> iconSizeBinder;
@@ -210,20 +203,12 @@ public:
const CollisionDynamicVertexVector& dynamicVertices() const { return *sharedDynamicVertices; } const CollisionDynamicVertexVector& dynamicVertices() const { return *sharedDynamicVertices; }
SegmentVector<CollisionBoxProgram::AttributeList> segments; SegmentVector<CollisionBoxProgram::AttributeList> segments;
#if MLN_LEGACY_RENDERER
std::optional<gfx::VertexBuffer<gfx::Vertex<CollisionBoxLayoutAttributes>>> vertexBuffer;
std::optional<gfx::VertexBuffer<gfx::Vertex<CollisionBoxDynamicAttributes>>> dynamicVertexBuffer;
#endif // MLN_LEGACY_RENDERER
}; };
struct CollisionBoxBuffer : public CollisionBuffer { struct CollisionBoxBuffer : public CollisionBuffer {
using LineIndexVector = gfx::IndexVector<gfx::Lines>; using LineIndexVector = gfx::IndexVector<gfx::Lines>;
const std::shared_ptr<LineIndexVector> sharedLines = std::make_shared<LineIndexVector>(); const std::shared_ptr<LineIndexVector> sharedLines = std::make_shared<LineIndexVector>();
LineIndexVector& lines = *sharedLines; LineIndexVector& lines = *sharedLines;
#if MLN_LEGACY_RENDERER
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
}; };
std::unique_ptr<CollisionBoxBuffer> iconCollisionBox; std::unique_ptr<CollisionBoxBuffer> iconCollisionBox;
std::unique_ptr<CollisionBoxBuffer> textCollisionBox; std::unique_ptr<CollisionBoxBuffer> textCollisionBox;
@@ -242,9 +227,6 @@ public:
using TriangleIndexVector = gfx::IndexVector<gfx::Triangles>; using TriangleIndexVector = gfx::IndexVector<gfx::Triangles>;
const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>(); const std::shared_ptr<TriangleIndexVector> sharedTriangles = std::make_shared<TriangleIndexVector>();
TriangleIndexVector& triangles = *sharedTriangles; TriangleIndexVector& triangles = *sharedTriangles;
#if MLN_LEGACY_RENDERER
std::optional<gfx::IndexBuffer> indexBuffer;
#endif // MLN_LEGACY_RENDERER
}; };
std::unique_ptr<CollisionCircleBuffer> iconCollisionCircle; std::unique_ptr<CollisionCircleBuffer> iconCollisionCircle;
std::unique_ptr<CollisionCircleBuffer> textCollisionCircle; std::unique_ptr<CollisionCircleBuffer> textCollisionCircle;

View File

@@ -15,16 +15,12 @@
#include <mbgl/util/convert.hpp> #include <mbgl/util/convert.hpp>
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/renderer/layers/background_layer_tweaker.hpp> #include <mbgl/renderer/layers/background_layer_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/renderer/change_request.hpp> #include <mbgl/renderer/change_request.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif
#include <unordered_set>
namespace mbgl { namespace mbgl {
@@ -70,11 +66,9 @@ void RenderBackgroundLayer::evaluate(const PropertyEvaluationParameters& paramet
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif
} }
bool RenderBackgroundLayer::hasTransition() const { bool RenderBackgroundLayer::hasTransition() const {
@@ -85,102 +79,6 @@ bool RenderBackgroundLayer::hasCrossfade() const {
return getCrossfade<BackgroundLayerProperties>(evaluatedProperties).t != 1; return getCrossfade<BackgroundLayerProperties>(evaluatedProperties).t != 1;
} }
#if MLN_LEGACY_RENDERER
void RenderBackgroundLayer::render(PaintParameters& parameters) {
// Note that for bottommost layers without a pattern, the background color
// is drawn with glClear rather than this method.
// Ensure programs are available
if (!parameters.shaders.getLegacyGroup().populate(backgroundProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(backgroundPatternProgram)) return;
const Properties<>::PossiblyEvaluated properties;
const BackgroundProgram::Binders paintAttributeData(properties, 0);
auto draw = [&](auto& program, auto&& uniformValues, const auto& textureBindings, const uint32_t id) {
const auto allUniformValues = program.computeAllUniformValues(
std::forward<decltype(uniformValues)>(uniformValues),
paintAttributeData,
properties,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = program.computeAllAttributeBindings(
*parameters.staticData.tileVertexBuffer, paintAttributeData, properties);
checkRenderability(parameters, program.activeBindingCount(allAttributeBindings));
program.draw(
parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(
0,
parameters.pass == RenderPass::Opaque ? gfx::DepthMaskType::ReadWrite : gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*parameters.staticData.quadTriangleIndexBuffer,
segments,
allUniformValues,
allAttributeBindings,
textureBindings,
util::toString(id));
};
if (segments.empty()) {
segments = RenderStaticData::tileTriangleSegments();
}
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
const auto& crossfade = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).crossfade;
if (!evaluated.get<BackgroundPattern>().to.empty()) {
std::optional<ImagePosition> imagePosA = parameters.patternAtlas.getPattern(
evaluated.get<BackgroundPattern>().from.id());
std::optional<ImagePosition> imagePosB = parameters.patternAtlas.getPattern(
evaluated.get<BackgroundPattern>().to.id());
if (!imagePosA || !imagePosB) return;
uint32_t i = 0;
for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) {
const UnwrappedTileID unwrappedTileID = tileID.toUnwrapped();
draw(*backgroundPatternProgram,
BackgroundPatternProgram::layoutUniformValues(parameters.matrixForTile(unwrappedTileID),
evaluated.get<BackgroundOpacity>(),
parameters.patternAtlas.getPixelSize(),
*imagePosA,
*imagePosB,
crossfade,
unwrappedTileID,
parameters.state),
BackgroundPatternProgram::TextureBindings{
textures::image::Value{parameters.patternAtlas.textureBinding()},
},
i++);
}
} else {
auto backgroundRenderPass = (evaluated.get<BackgroundColor>().a >= 1.0f &&
evaluated.get<BackgroundOpacity>() >= 1.0f &&
parameters.currentLayer >= parameters.opaquePassCutoff)
? RenderPass::Opaque
: RenderPass::Translucent;
if (parameters.pass != backgroundRenderPass) {
return;
}
uint32_t i = 0;
for (const auto& tileID : util::tileCover(parameters.state, parameters.state.getIntegerZoom())) {
draw(*backgroundProgram,
BackgroundProgram::LayoutUniformValues{
uniforms::matrix::Value(parameters.matrixForTile(tileID.toUnwrapped())),
uniforms::color::Value(evaluated.get<BackgroundColor>()),
uniforms::opacity::Value(evaluated.get<BackgroundOpacity>()),
},
BackgroundProgram::TextureBindings{},
i++);
}
}
}
#endif // MLN_LEGACY_RENDERER
std::optional<Color> RenderBackgroundLayer::getSolidBackground() const { std::optional<Color> RenderBackgroundLayer::getSolidBackground() const {
const auto& evaluated = getEvaluated<BackgroundLayerProperties>(evaluatedProperties); const auto& evaluated = getEvaluated<BackgroundLayerProperties>(evaluatedProperties);
if (!evaluated.get<BackgroundPattern>().from.empty() || evaluated.get<style::BackgroundOpacity>() <= 0.0f) { if (!evaluated.get<BackgroundPattern>().from.empty() || evaluated.get<style::BackgroundOpacity>() <= 0.0f) {
@@ -210,7 +108,6 @@ void RenderBackgroundLayer::prepare(const LayerPrepareParameters& params) {
} }
} }
#if MLN_DRAWABLE_RENDERER
static constexpr std::string_view BackgroundPlainShaderName = "BackgroundShader"; static constexpr std::string_view BackgroundPlainShaderName = "BackgroundShader";
static constexpr std::string_view BackgroundPatternShaderName = "BackgroundPatternShader"; static constexpr std::string_view BackgroundPatternShaderName = "BackgroundPatternShader";
@@ -326,6 +223,5 @@ void RenderBackgroundLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -23,7 +23,6 @@ public:
explicit RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl>); explicit RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl>);
~RenderBackgroundLayer() override; ~RenderBackgroundLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -31,7 +30,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -40,26 +38,15 @@ private:
bool hasCrossfade() const override; bool hasCrossfade() const override;
std::optional<Color> getSolidBackground() const override; std::optional<Color> getSolidBackground() const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
// Paint properties // Paint properties
style::BackgroundPaintProperties::Unevaluated unevaluated; style::BackgroundPaintProperties::Unevaluated unevaluated;
SegmentVector<BackgroundAttributes> segments; SegmentVector<BackgroundAttributes> segments;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<BackgroundProgram> backgroundProgram;
std::shared_ptr<BackgroundPatternProgram> backgroundPatternProgram;
#endif
#if MLN_DRAWABLE_RENDERER
// Drawable shaders // Drawable shaders
gfx::ShaderProgramBasePtr plainShader; gfx::ShaderProgramBasePtr plainShader;
gfx::ShaderProgramBasePtr patternShader; gfx::ShaderProgramBasePtr patternShader;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -15,14 +15,12 @@
#include <mbgl/util/intersection_tests.hpp> #include <mbgl/util/intersection_tests.hpp>
#include <mbgl/util/containers.hpp> #include <mbgl/util/containers.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/renderer/layers/circle_layer_tweaker.hpp> #include <mbgl/renderer/layers/circle_layer_tweaker.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/circle_layer_ubo.hpp> #include <mbgl/shaders/circle_layer_ubo.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -30,29 +28,6 @@ using namespace style;
namespace { namespace {
#if MLN_LEGACY_RENDERER
struct RenderableSegment {
RenderableSegment(const Segment<CircleAttributes>& segment_,
const RenderTile& tile_,
const LayerRenderData* renderData_,
float sortKey_)
: segment(segment_),
tile(tile_),
renderData(renderData_),
sortKey(sortKey_) {}
const Segment<CircleAttributes>& segment;
const RenderTile& tile;
const LayerRenderData* renderData;
const float sortKey;
friend bool operator<(const RenderableSegment& lhs, const RenderableSegment& rhs) {
if (lhs.sortKey == rhs.sortKey) return lhs.tile.id < rhs.tile.id;
return lhs.sortKey < rhs.sortKey;
}
};
#endif
inline const style::CircleLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) { inline const style::CircleLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == CircleLayer::Impl::staticTypeInfo()); assert(impl->getTypeInfo() == CircleLayer::Impl::staticTypeInfo());
return static_cast<const style::CircleLayer::Impl&>(*impl); return static_cast<const style::CircleLayer::Impl&>(*impl);
@@ -89,11 +64,9 @@ void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters)
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif // MLN_DRAWABLE_RENDERER
} }
bool RenderCircleLayer::hasTransition() const { bool RenderCircleLayer::hasTransition() const {
@@ -104,88 +77,6 @@ bool RenderCircleLayer::hasCrossfade() const {
return false; return false;
} }
#if MLN_LEGACY_RENDERER
void RenderCircleLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass == RenderPass::Opaque) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(circleProgram)) return;
const auto drawTile = [&](const RenderTile& tile, const LayerRenderData* data, const auto& segments) {
auto& circleBucket = static_cast<CircleBucket&>(*data->bucket);
const auto& evaluated = getEvaluated<CircleLayerProperties>(data->layerProperties);
const bool scaleWithMap = evaluated.template get<CirclePitchScale>() == CirclePitchScaleType::Map;
const bool pitchWithMap = evaluated.template get<CirclePitchAlignment>() == AlignmentType::Map;
auto& paintPropertyBinders = circleBucket.paintPropertyBinders.at(getID());
using LayoutUniformValues = CircleProgram::LayoutUniformValues;
const auto& allUniformValues = CircleProgram::computeAllUniformValues(
LayoutUniformValues(
uniforms::matrix::Value(tile.translatedMatrix(evaluated.template get<CircleTranslate>(),
evaluated.template get<CircleTranslateAnchor>(),
parameters.state)),
uniforms::scale_with_map::Value(scaleWithMap),
uniforms::extrude_scale::Value(
pitchWithMap ? std::array<float, 2>{{tile.id.pixelsToTileUnits(
1.0f, static_cast<float>(parameters.state.getZoom())),
tile.id.pixelsToTileUnits(
1.0f, static_cast<float>(parameters.state.getZoom()))}}
: parameters.pixelsToGLUnits),
uniforms::device_pixel_ratio::Value(parameters.pixelRatio),
uniforms::camera_to_center_distance::Value(parameters.state.getCameraToCenterDistance()),
uniforms::pitch_with_map::Value(pitchWithMap)),
paintPropertyBinders,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto& allAttributeBindings = CircleProgram::computeAllAttributeBindings(
*circleBucket.vertexBuffer, paintPropertyBinders, evaluated);
checkRenderability(parameters, CircleProgram::activeBindingCount(allAttributeBindings));
circleProgram->draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*circleBucket.indexBuffer,
segments,
allUniformValues,
allAttributeBindings,
CircleProgram::TextureBindings{},
getID());
};
const bool sortFeaturesByKey = !impl_cast(baseImpl).layout.get<CircleSortKey>().isUndefined();
std::multiset<RenderableSegment> renderableSegments;
for (const RenderTile& renderTile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(renderTile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<CircleBucket&>(*renderData->bucket);
if (!sortFeaturesByKey) {
drawTile(renderTile, renderData, bucket.segments);
continue;
}
for (auto& segment : bucket.segments) {
renderableSegments.emplace(segment, renderTile, renderData, segment.sortKey);
}
}
if (sortFeaturesByKey) {
for (const auto& renderable : renderableSegments) {
drawTile(renderable.tile, renderable.renderData, renderable.segment);
}
}
}
#endif // MLN_LEGACY_RENDERER
GeometryCoordinate projectPoint(const GeometryCoordinate& p, const mat4& posMatrix, const Size& size) { GeometryCoordinate projectPoint(const GeometryCoordinate& p, const mat4& posMatrix, const Size& size) {
vec4 pos = {{static_cast<double>(p.x), static_cast<double>(p.y), 0, 1}}; vec4 pos = {{static_cast<double>(p.x), static_cast<double>(p.y), 0, 1}};
matrix::transformMat4(pos, pos, posMatrix); matrix::transformMat4(pos, pos, posMatrix);
@@ -264,7 +155,6 @@ bool RenderCircleLayer::queryIntersectsFeature(const GeometryCoordinates& queryG
return false; return false;
} }
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
constexpr auto CircleShaderGroupName = "CircleShader"; constexpr auto CircleShaderGroupName = "CircleShader";
@@ -403,6 +293,5 @@ void RenderCircleLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -6,21 +6,14 @@
namespace mbgl { namespace mbgl {
#if MLN_LEGACY_RENDERER
class CircleProgram;
#endif // MLN_LEGACY_RENDERER
#if MLN_DRAWABLE_RENDERER
class CircleLayerTweaker; class CircleLayerTweaker;
using CircleLayerTweakerPtr = std::shared_ptr<CircleLayerTweaker>; using CircleLayerTweakerPtr = std::shared_ptr<CircleLayerTweaker>;
#endif // MLN_DRAWABLE_RENDERER
class RenderCircleLayer final : public RenderLayer { class RenderCircleLayer final : public RenderLayer {
public: public:
explicit RenderCircleLayer(Immutable<style::CircleLayer::Impl>); explicit RenderCircleLayer(Immutable<style::CircleLayer::Impl>);
~RenderCircleLayer() final = default; ~RenderCircleLayer() final = default;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -28,7 +21,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -44,22 +36,11 @@ private:
const mat4&, const mat4&,
const FeatureState&) const override; const FeatureState&) const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif // MLN_LEGACY_RENDERER
private: private:
// Paint properties // Paint properties
style::CirclePaintProperties::Unevaluated unevaluated; style::CirclePaintProperties::Unevaluated unevaluated;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<CircleProgram> circleProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr circleShaderGroup; gfx::ShaderGroupPtr circleShaderGroup;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -9,11 +9,9 @@
#include <mbgl/renderer/paint_parameters.hpp> #include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/util/mat4.hpp> #include <mbgl/util/mat4.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/context.hpp> #include <mbgl/gfx/context.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -54,11 +52,6 @@ bool RenderCustomDrawableLayer::hasCrossfade() const {
void RenderCustomDrawableLayer::prepare(const LayerPrepareParameters&) {} void RenderCustomDrawableLayer::prepare(const LayerPrepareParameters&) {}
#if MLN_LEGACY_RENDERER
void RenderCustomDrawableLayer::render(PaintParameters&) {}
#endif
#if MLN_DRAWABLE_RENDERER
void RenderCustomDrawableLayer::update(gfx::ShaderRegistry& shaders, void RenderCustomDrawableLayer::update(gfx::ShaderRegistry& shaders,
gfx::Context& context, gfx::Context& context,
const TransformState& state, const TransformState& state,
@@ -84,6 +77,4 @@ void RenderCustomDrawableLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -10,7 +10,6 @@ public:
explicit RenderCustomDrawableLayer(Immutable<style::CustomDrawableLayer::Impl>); explicit RenderCustomDrawableLayer(Immutable<style::CustomDrawableLayer::Impl>);
~RenderCustomDrawableLayer() override; ~RenderCustomDrawableLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -18,7 +17,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override {} void transition(const TransitionParameters&) override {}
@@ -27,10 +25,6 @@ private:
bool hasCrossfade() const override; bool hasCrossfade() const override;
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
std::shared_ptr<style::CustomDrawableLayerHost> host; std::shared_ptr<style::CustomDrawableLayerHost> host;
}; };

View File

@@ -8,24 +8,13 @@
#include <mbgl/renderer/paint_parameters.hpp> #include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/util/mat4.hpp> #include <mbgl/util/mat4.hpp>
#if MLN_LEGACY_RENDERER
#include <mbgl/platform/gl_functions.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/renderable_resource.hpp>
#include <mbgl/style/layers/custom_layer_render_parameters.hpp>
#endif
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/context.hpp> #include <mbgl/gfx/context.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
#include <mbgl/gfx/drawable_custom_layer_host_tweaker.hpp> #include <mbgl/gfx/drawable_custom_layer_host_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#if !MLN_LEGACY_RENDERER
// TODO: platform agnostic error checks // TODO: platform agnostic error checks
#define MBGL_CHECK_ERROR(cmd) (cmd) #define MBGL_CHECK_ERROR(cmd) (cmd)
#endif
#endif
namespace mbgl { namespace mbgl {
@@ -74,37 +63,6 @@ void RenderCustomLayer::markContextDestroyed() {
void RenderCustomLayer::prepare(const LayerPrepareParameters&) {} void RenderCustomLayer::prepare(const LayerPrepareParameters&) {}
#if MLN_LEGACY_RENDERER
void RenderCustomLayer::render(PaintParameters& paintParameters) {
if (host != impl(baseImpl).host) {
// If the context changed, deinitialize the previous one before initializing the new one.
if (host && !contextDestroyed) {
MBGL_CHECK_ERROR(host->deinitialize());
}
host = impl(baseImpl).host;
MBGL_CHECK_ERROR(host->initialize());
}
// TODO: remove cast
auto& glContext = static_cast<gl::Context&>(paintParameters.context);
// Reset GL state to a known state so the CustomLayer always has a clean slate.
glContext.bindVertexArray = 0;
glContext.setDepthMode(paintParameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly));
glContext.setStencilMode(gfx::StencilMode::disabled());
glContext.setColorMode(paintParameters.colorModeForRenderPass());
glContext.setCullFaceMode(gfx::CullFaceMode::disabled());
MBGL_CHECK_ERROR(host->render(CustomLayerRenderParameters(paintParameters)));
// Reset the view back to our original one, just in case the CustomLayer
// changed the viewport or Framebuffer.
paintParameters.backend.getDefaultRenderable().getResource<gl::RenderableResource>().bind();
glContext.setDirtyState();
}
#endif
#if MLN_DRAWABLE_RENDERER
void RenderCustomLayer::update([[maybe_unused]] gfx::ShaderRegistry& shaders, void RenderCustomLayer::update([[maybe_unused]] gfx::ShaderRegistry& shaders,
gfx::Context& context, gfx::Context& context,
[[maybe_unused]] const TransformState& state, [[maybe_unused]] const TransformState& state,
@@ -152,6 +110,5 @@ void RenderCustomLayer::update([[maybe_unused]] gfx::ShaderRegistry& shaders,
++stats.drawablesAdded; ++stats.drawablesAdded;
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -10,7 +10,6 @@ public:
explicit RenderCustomLayer(Immutable<style::CustomLayer::Impl>); explicit RenderCustomLayer(Immutable<style::CustomLayer::Impl>);
~RenderCustomLayer() override; ~RenderCustomLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -18,7 +17,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override {} void transition(const TransitionParameters&) override {}
@@ -28,10 +26,6 @@ private:
void markContextDestroyed() override; void markContextDestroyed() override;
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
bool contextDestroyed = false; bool contextDestroyed = false;
std::shared_ptr<style::CustomLayerHost> host; std::shared_ptr<style::CustomLayerHost> host;
}; };

View File

@@ -20,7 +20,6 @@
#include <mbgl/util/intersection_tests.hpp> #include <mbgl/util/intersection_tests.hpp>
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_atlases_tweaker.hpp> #include <mbgl/gfx/drawable_atlases_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
@@ -28,7 +27,6 @@
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/fill_extrusion_layer_ubo.hpp> #include <mbgl/shaders/fill_extrusion_layer_ubo.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif // MLN_DRAWABLE_RENDERER
namespace mbgl { namespace mbgl {
@@ -69,11 +67,9 @@ void RenderFillExtrusionLayer::evaluate(const PropertyEvaluationParameters& para
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif // MLN_DRAWABLE_RENDERER
} }
bool RenderFillExtrusionLayer::hasTransition() const { bool RenderFillExtrusionLayer::hasTransition() const {
@@ -88,165 +84,6 @@ bool RenderFillExtrusionLayer::is3D() const {
return true; return true;
} }
#if MLN_LEGACY_RENDERER
void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass != RenderPass::Translucent) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(fillExtrusionProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(fillExtrusionPatternProgram)) return;
const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
const auto& crossfade = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade;
if (evaluatedProperties->renderPasses == mbgl::underlying_type(RenderPass::None)) {
return;
}
const auto depthMode = parameters.depthModeFor3D();
auto draw = [&](auto& programInstance,
const auto& evaluated_,
const auto& crossfade_,
const gfx::StencilMode& stencilMode,
const gfx::ColorMode& colorMode,
auto& tileBucket,
const auto& uniformValues,
const std::optional<ImagePosition>& patternPositionA,
const std::optional<ImagePosition>& patternPositionB,
const auto& textureBindings,
const std::string& uniqueName) {
auto& paintPropertyBinders = tileBucket.paintPropertyBinders.at(getID());
paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade_);
const auto allUniformValues = programInstance.computeAllUniformValues(
uniformValues, paintPropertyBinders, evaluated_, static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
*tileBucket.vertexBuffer, paintPropertyBinders, evaluated_);
checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
programInstance.draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
depthMode,
stencilMode,
colorMode,
gfx::CullFaceMode::backCCW(),
*tileBucket.indexBuffer,
tileBucket.triangleSegments,
allUniformValues,
allAttributeBindings,
textureBindings,
getID() + "/" + uniqueName);
};
if (unevaluated.get<FillExtrusionPattern>().isUndefined()) {
// Draw solid color extrusions
auto drawTiles =
[&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<FillExtrusionBucket&>(*renderData->bucket);
draw(*fillExtrusionProgram,
evaluated,
crossfade,
stencilMode_,
colorMode_,
bucket,
FillExtrusionProgram::layoutUniformValues(
tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(),
evaluated.get<FillExtrusionTranslateAnchor>(),
parameters.state),
parameters.state,
evaluated.get<FillExtrusionOpacity>(),
parameters.evaluatedLight,
evaluated.get<FillExtrusionVerticalGradient>()),
{},
{},
FillExtrusionProgram::TextureBindings{},
name);
}
};
if (evaluated.get<FillExtrusionOpacity>() == 1) {
// Draw opaque extrusions
drawTiles(gfx::StencilMode::disabled(), parameters.colorModeForRenderPass(), "color");
} else {
// Draw transparent buildings in two passes so that only the closest
// surface is drawn. First draw all the extrusions into only the
// depth buffer. No colors are drawn.
drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled(), "depth");
// Then draw all the extrusions a second time, only coloring
// fragments if they have the same depth value as the closest
// fragment in the previous pass. Use the stencil buffer to prevent
// the second draw in cases where we have coincident polygons.
drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass(), "color");
}
} else {
// Draw textured extrusions
const auto fillPatternValue = evaluated.get<FillExtrusionPattern>().constantOr(
mbgl::Faded<expression::Image>{"", ""});
auto drawTiles =
[&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<FillExtrusionBucket&>(*renderData->bucket);
const std::optional<ImagePosition> patternPosA = tile.getPattern(fillPatternValue.from.id());
const std::optional<ImagePosition> patternPosB = tile.getPattern(fillPatternValue.to.id());
const auto numTiles = std::pow(2, tile.id.canonical.z);
const auto heightFactor = static_cast<float>(-numTiles / util::tileSize_D / 8.0);
draw(*fillExtrusionPatternProgram,
evaluated,
crossfade,
stencilMode_,
colorMode_,
bucket,
FillExtrusionPatternProgram::layoutUniformValues(
tile.translatedClipMatrix(evaluated.get<FillExtrusionTranslate>(),
evaluated.get<FillExtrusionTranslateAnchor>(),
parameters.state),
tile.getIconAtlasTexture()->getSize(),
crossfade,
tile.id,
parameters.state,
evaluated.get<FillExtrusionOpacity>(),
heightFactor,
parameters.pixelRatio,
parameters.evaluatedLight,
evaluated.get<FillExtrusionVerticalGradient>()),
patternPosA,
patternPosB,
FillExtrusionPatternProgram::TextureBindings{
textures::image::Value{tile.getIconAtlasTextureBinding(gfx::TextureFilterType::Linear)},
},
name);
}
};
// Draw transparent buildings in two passes so that only the closest
// surface is drawn. First draw all the extrusions into only the depth
// buffer. No colors are drawn.
drawTiles(gfx::StencilMode::disabled(), gfx::ColorMode::disabled(), "depth");
// Then draw all the extrusions a second time, only coloring fragments
// if they have the same depth value as the closest fragment in the
// previous pass. Use the stencil buffer to prevent the second draw in
// cases where we have coincident polygons.
drawTiles(parameters.stencilModeFor3D(), parameters.colorModeForRenderPass(), "color");
}
}
#endif // MLN_LEGACY_RENDERER
bool RenderFillExtrusionLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, bool RenderFillExtrusionLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry,
const GeometryTileFeature& feature, const GeometryTileFeature& feature,
const float, const float,
@@ -266,8 +103,6 @@ bool RenderFillExtrusionLayer::queryIntersectsFeature(const GeometryCoordinates&
feature.getGeometries()); feature.getGeometries());
} }
#if MLN_DRAWABLE_RENDERER
void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders, void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders,
gfx::Context& context, gfx::Context& context,
const TransformState&, const TransformState&,
@@ -496,6 +331,4 @@ void RenderFillExtrusionLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
#endif // MLN_DRAWABLE_RENDERER
} // namespace mbgl } // namespace mbgl

View File

@@ -7,11 +7,6 @@
namespace mbgl { namespace mbgl {
#if MLN_LEGACY_RENDERER
class FillExtrusionProgram;
class FillExtrusionPatternProgram;
#endif // MLN_LEGACY_RENDERER
class RenderFillExtrusionLayer final : public RenderLayer { class RenderFillExtrusionLayer final : public RenderLayer {
public: public:
explicit RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl>); explicit RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl>);
@@ -24,11 +19,6 @@ private:
bool hasCrossfade() const override; bool hasCrossfade() const override;
bool is3D() const override; bool is3D() const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -36,7 +26,6 @@ private:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif // MLN_DRAWABLE_RENDERER
bool queryIntersectsFeature(const GeometryCoordinates&, bool queryIntersectsFeature(const GeometryCoordinates&,
const GeometryTileFeature&, const GeometryTileFeature&,
@@ -49,17 +38,8 @@ private:
// Paint properties // Paint properties
style::FillExtrusionPaintProperties::Unevaluated unevaluated; style::FillExtrusionPaintProperties::Unevaluated unevaluated;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<FillExtrusionProgram> fillExtrusionProgram;
std::shared_ptr<FillExtrusionPatternProgram> fillExtrusionPatternProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr fillExtrusionGroup; gfx::ShaderGroupPtr fillExtrusionGroup;
gfx::ShaderGroupPtr fillExtrusionPatternGroup; gfx::ShaderGroupPtr fillExtrusionPatternGroup;
#endif // MLN_DRAWABLE_RENDERER
std::unique_ptr<gfx::OffscreenTexture> renderTexture; std::unique_ptr<gfx::OffscreenTexture> renderTexture;
}; };

View File

@@ -22,7 +22,6 @@
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#include <mbgl/util/std.hpp> #include <mbgl/util/std.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_atlases_tweaker.hpp> #include <mbgl/gfx/drawable_atlases_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/renderer/layers/fill_layer_tweaker.hpp> #include <mbgl/renderer/layers/fill_layer_tweaker.hpp>
@@ -30,7 +29,6 @@
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/fill_layer_ubo.hpp> #include <mbgl/shaders/fill_layer_ubo.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -39,7 +37,6 @@ using namespace shaders;
namespace { namespace {
#if MLN_DRAWABLE_RENDERER
constexpr auto FillShaderName = "FillShader"; constexpr auto FillShaderName = "FillShader";
constexpr auto FillOutlineShaderName = "FillOutlineShader"; constexpr auto FillOutlineShaderName = "FillOutlineShader";
constexpr auto FillPatternShaderName = "FillPatternShader"; constexpr auto FillPatternShaderName = "FillPatternShader";
@@ -47,7 +44,6 @@ constexpr auto FillOutlinePatternShaderName = "FillOutlinePatternShader";
#if MLN_TRIANGULATE_FILL_OUTLINES #if MLN_TRIANGULATE_FILL_OUTLINES
constexpr auto FillOutlineTriangulatedShaderName = "FillOutlineTriangulatedShader"; constexpr auto FillOutlineTriangulatedShaderName = "FillOutlineTriangulatedShader";
#endif #endif
#endif // MLN_DRAWABLE_RENDERER
inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) { inline const FillLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == FillLayer::Impl::staticTypeInfo()); assert(impl->getTypeInfo() == FillLayer::Impl::staticTypeInfo());
@@ -91,11 +87,9 @@ void RenderFillLayer::evaluate(const PropertyEvaluationParameters& parameters) {
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif
} }
bool RenderFillLayer::hasTransition() const { bool RenderFillLayer::hasTransition() const {
@@ -106,176 +100,6 @@ bool RenderFillLayer::hasCrossfade() const {
return getCrossfade<FillLayerProperties>(evaluatedProperties).t != 1; return getCrossfade<FillLayerProperties>(evaluatedProperties).t != 1;
} }
#if MLN_LEGACY_RENDERER
void RenderFillLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (!parameters.shaders.getLegacyGroup().populate(fillProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(fillPatternProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(fillOutlineProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(fillOutlinePatternProgram)) return;
if (unevaluated.get<FillPattern>().isUndefined()) {
parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
auto draw = [&](auto& programInstance,
const auto& drawMode,
const auto& depthMode,
const auto& indexBuffer,
const auto& segments,
auto&& textureBindings) {
auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
const auto allUniformValues = programInstance.computeAllUniformValues(
FillProgram::LayoutUniformValues{
uniforms::matrix::Value(tile.translatedMatrix(
evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(), parameters.state)),
uniforms::world::Value(parameters.backend.getDefaultRenderable().getSize()),
},
paintPropertyBinders,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
*bucket.vertexBuffer, paintPropertyBinders, evaluated);
checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
programInstance.draw(parameters.context,
*parameters.renderPass,
drawMode,
depthMode,
parameters.stencilModeForClipping(tile.id),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
indexBuffer,
segments,
allUniformValues,
allAttributeBindings,
std::forward<decltype(textureBindings)>(textureBindings),
getID());
};
auto fillRenderPass = (evaluated.get<FillColor>().constantOr(Color()).a >= 1.0f &&
evaluated.get<FillOpacity>().constantOr(0) >= 1.0f &&
parameters.currentLayer >= parameters.opaquePassCutoff)
? RenderPass::Opaque
: RenderPass::Translucent;
if (bucket.triangleIndexBuffer && parameters.pass == fillRenderPass) {
draw(*fillProgram,
gfx::Triangles(),
parameters.depthModeForSublayer(1,
parameters.pass == RenderPass::Opaque
? gfx::DepthMaskType::ReadWrite
: gfx::DepthMaskType::ReadOnly),
*bucket.triangleIndexBuffer,
bucket.triangleSegments,
FillProgram::TextureBindings{});
}
if (evaluated.get<FillAntialias>() && parameters.pass == RenderPass::Translucent) {
draw(*fillOutlineProgram,
gfx::Lines{2.0f},
parameters.depthModeForSublayer(unevaluated.get<FillOutlineColor>().isUndefined() ? 2 : 0,
gfx::DepthMaskType::ReadOnly),
*bucket.lineIndexBuffer,
bucket.basicLineSegments,
FillOutlineProgram::TextureBindings{});
}
}
} else {
if (parameters.pass != RenderPass::Translucent) {
return;
}
parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<FillBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
const auto& crossfade = getCrossfade<FillLayerProperties>(renderData->layerProperties);
const auto& fillPatternValue = evaluated.get<FillPattern>().constantOr(Faded<expression::Image>{"", ""});
std::optional<ImagePosition> patternPosA = tile.getPattern(fillPatternValue.from.id());
std::optional<ImagePosition> patternPosB = tile.getPattern(fillPatternValue.to.id());
auto draw = [&](auto& programInstance,
const auto& drawMode,
const auto& depthMode,
const auto& indexBuffer,
const auto& segments,
auto&& textureBindings) {
auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
paintPropertyBinders.setPatternParameters(patternPosA, patternPosB, crossfade);
const auto allUniformValues = programInstance.computeAllUniformValues(
FillPatternProgram::layoutUniformValues(
tile.translatedMatrix(
evaluated.get<FillTranslate>(), evaluated.get<FillTranslateAnchor>(), parameters.state),
parameters.backend.getDefaultRenderable().getSize(),
tile.getIconAtlasTexture()->getSize(),
crossfade,
tile.id,
parameters.state,
parameters.pixelRatio),
paintPropertyBinders,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
*bucket.vertexBuffer, paintPropertyBinders, evaluated);
checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
programInstance.draw(parameters.context,
*parameters.renderPass,
drawMode,
depthMode,
parameters.stencilModeForClipping(tile.id),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
indexBuffer,
segments,
allUniformValues,
allAttributeBindings,
std::forward<decltype(textureBindings)>(textureBindings),
getID());
};
if (bucket.triangleIndexBuffer) {
draw(*fillPatternProgram,
gfx::Triangles(),
parameters.depthModeForSublayer(1, gfx::DepthMaskType::ReadWrite),
*bucket.triangleIndexBuffer,
bucket.triangleSegments,
FillPatternProgram::TextureBindings{
tile.getIconAtlasTextureBinding(gfx::TextureFilterType::Linear),
});
}
if (evaluated.get<FillAntialias>() && unevaluated.get<FillOutlineColor>().isUndefined()) {
draw(*fillOutlinePatternProgram,
gfx::Lines{2.0f},
parameters.depthModeForSublayer(2, gfx::DepthMaskType::ReadOnly),
*bucket.lineIndexBuffer,
bucket.basicLineSegments,
FillOutlinePatternProgram::TextureBindings{
tile.getIconAtlasTextureBinding(gfx::TextureFilterType::Linear),
});
}
}
}
}
#endif // MLN_LEGACY_RENDERER
bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry, bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeometry,
const GeometryTileFeature& feature, const GeometryTileFeature& feature,
const float, const float,
@@ -294,8 +118,6 @@ bool RenderFillLayer::queryIntersectsFeature(const GeometryCoordinates& queryGeo
feature.getGeometries()); feature.getGeometries());
} }
#if MLN_DRAWABLE_RENDERER
void RenderFillLayer::update(gfx::ShaderRegistry& shaders, void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
gfx::Context& context, gfx::Context& context,
const TransformState&, const TransformState&,
@@ -713,6 +535,5 @@ void RenderFillLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -16,10 +16,8 @@ class FillPatternProgram;
class FillOutlineProgram; class FillOutlineProgram;
class FillOutlinePatternProgram; class FillOutlinePatternProgram;
#if MLN_DRAWABLE_RENDERER
class FillLayerTweaker; class FillLayerTweaker;
using FillLayerTweakerPtr = std::shared_ptr<FillLayerTweaker>; using FillLayerTweakerPtr = std::shared_ptr<FillLayerTweaker>;
#endif // MLN_DRAWABLE_RENDERER
class RenderFillLayer final : public RenderLayer { class RenderFillLayer final : public RenderLayer {
public: public:
@@ -36,7 +34,6 @@ public:
explicit RenderFillLayer(Immutable<style::FillLayer::Impl>); explicit RenderFillLayer(Immutable<style::FillLayer::Impl>);
~RenderFillLayer() override; ~RenderFillLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -44,7 +41,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -52,10 +48,6 @@ private:
bool hasTransition() const override; bool hasTransition() const override;
bool hasCrossfade() const override; bool hasCrossfade() const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
bool queryIntersectsFeature(const GeometryCoordinates&, bool queryIntersectsFeature(const GeometryCoordinates&,
const GeometryTileFeature&, const GeometryTileFeature&,
float, float,
@@ -67,15 +59,6 @@ private:
// Paint properties // Paint properties
style::FillPaintProperties::Unevaluated unevaluated; style::FillPaintProperties::Unevaluated unevaluated;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<FillProgram> fillProgram;
std::shared_ptr<FillPatternProgram> fillPatternProgram;
std::shared_ptr<FillOutlineProgram> fillOutlineProgram;
std::shared_ptr<FillOutlinePatternProgram> fillOutlinePatternProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr fillShaderGroup; gfx::ShaderGroupPtr fillShaderGroup;
gfx::ShaderGroupPtr outlineShaderGroup; gfx::ShaderGroupPtr outlineShaderGroup;
gfx::ShaderGroupPtr patternShaderGroup; gfx::ShaderGroupPtr patternShaderGroup;
@@ -84,8 +67,6 @@ private:
#if MLN_TRIANGULATE_FILL_OUTLINES #if MLN_TRIANGULATE_FILL_OUTLINES
gfx::ShaderGroupPtr outlineTriangulatedShaderGroup; gfx::ShaderGroupPtr outlineTriangulatedShaderGroup;
#endif // MLN_TRIANGULATE_FILL_OUTLINES #endif // MLN_TRIANGULATE_FILL_OUTLINES
#endif // MLN_DRAWABLE_RENDERER
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -13,7 +13,6 @@
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#include <mbgl/util/intersection_tests.hpp> #include <mbgl/util/intersection_tests.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/renderer/layers/heatmap_layer_tweaker.hpp> #include <mbgl/renderer/layers/heatmap_layer_tweaker.hpp>
#include <mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp> #include <mbgl/renderer/layers/heatmap_texture_layer_tweaker.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
@@ -24,7 +23,6 @@
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/gfx/shader_group.hpp> #include <mbgl/gfx/shader_group.hpp>
#include <mbgl/gfx/shader_registry.hpp> #include <mbgl/gfx/shader_registry.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -54,14 +52,12 @@ void RenderHeatmapLayer::transition(const TransitionParameters& parameters) {
updateColorRamp(); updateColorRamp();
} }
#if MLN_DRAWABLE_RENDERER
void RenderHeatmapLayer::layerChanged(const TransitionParameters& parameters, void RenderHeatmapLayer::layerChanged(const TransitionParameters& parameters,
const Immutable<style::Layer::Impl>& impl, const Immutable<style::Layer::Impl>& impl,
UniqueChangeRequestVec& changes) { UniqueChangeRequestVec& changes) {
RenderLayer::layerChanged(parameters, impl, changes); RenderLayer::layerChanged(parameters, impl, changes);
textureTweaker.reset(); textureTweaker.reset();
} }
#endif
void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters) { void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters) {
const auto previousProperties = staticImmutableCast<HeatmapLayerProperties>(evaluatedProperties); const auto previousProperties = staticImmutableCast<HeatmapLayerProperties>(evaluatedProperties);
@@ -74,14 +70,12 @@ void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
if (textureTweaker) { if (textureTweaker) {
textureTweaker->updateProperties(evaluatedProperties); textureTweaker->updateProperties(evaluatedProperties);
} }
#endif
} }
bool RenderHeatmapLayer::hasTransition() const { bool RenderHeatmapLayer::hasTransition() const {
@@ -92,123 +86,6 @@ bool RenderHeatmapLayer::hasCrossfade() const {
return false; return false;
} }
#if MLN_LEGACY_RENDERER
void RenderHeatmapLayer::upload(gfx::UploadPass& uploadPass) {
if (!colorRampTexture) {
colorRampTexture = uploadPass.createTexture(*colorRamp, gfx::TextureChannelDataType::UnsignedByte);
}
}
void RenderHeatmapLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass == RenderPass::Opaque) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(heatmapProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(heatmapTextureProgram)) return;
if (parameters.pass == RenderPass::Pass3D) {
const auto& viewportSize = parameters.staticData.backendSize;
const auto size = Size{viewportSize.width / 4, viewportSize.height / 4};
assert(colorRampTexture);
if (!renderTexture || renderTexture->getSize() != size) {
renderTexture = parameters.context.createOffscreenTexture(size, gfx::TextureChannelDataType::HalfFloat);
}
auto renderPass = parameters.encoder->createRenderPass("heatmap texture",
{*renderTexture, Color{0.0f, 0.0f, 0.0f, 1.0f}, {}, {}});
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<HeatmapBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<HeatmapLayerProperties>(renderData->layerProperties);
const auto extrudeScale = tile.id.pixelsToTileUnits(1.0f, static_cast<float>(parameters.state.getZoom()));
auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
const auto allUniformValues = HeatmapProgram::computeAllUniformValues(
HeatmapProgram::LayoutUniformValues{
uniforms::intensity::Value(evaluated.get<style::HeatmapIntensity>()),
uniforms::matrix::Value(tile.matrix),
uniforms::heatmap::extrude_scale::Value(extrudeScale)},
paintPropertyBinders,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = HeatmapProgram::computeAllAttributeBindings(
*bucket.vertexBuffer, paintPropertyBinders, evaluated);
checkRenderability(parameters, HeatmapProgram::activeBindingCount(allAttributeBindings));
heatmapProgram->draw(parameters.context,
*renderPass,
gfx::Triangles(),
gfx::DepthMode::disabled(),
gfx::StencilMode::disabled(),
gfx::ColorMode::additive(),
gfx::CullFaceMode::disabled(),
*bucket.indexBuffer,
bucket.segments,
allUniformValues,
allAttributeBindings,
HeatmapProgram::TextureBindings{},
getID());
}
} else if (parameters.pass == RenderPass::Translucent) {
const auto& size = parameters.staticData.backendSize;
mat4 viewportMat;
matrix::ortho(viewportMat, 0, size.width, size.height, 0, 0, 1);
const Properties<>::PossiblyEvaluated properties;
const HeatmapTextureProgram::Binders paintAttributeData{properties, 0};
const auto allUniformValues = HeatmapTextureProgram::computeAllUniformValues(
HeatmapTextureProgram::LayoutUniformValues{
uniforms::matrix::Value(viewportMat),
uniforms::world::Value(size),
uniforms::opacity::Value(
getEvaluated<HeatmapLayerProperties>(evaluatedProperties).get<HeatmapOpacity>())},
paintAttributeData,
properties,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = HeatmapTextureProgram::computeAllAttributeBindings(
*parameters.staticData.heatmapTextureVertexBuffer, paintAttributeData, properties);
checkRenderability(parameters, HeatmapTextureProgram::activeBindingCount(allAttributeBindings));
if (segments.empty()) {
// Copy over the segments so that we can create our own DrawScopes.
segments = RenderStaticData::heatmapTextureSegments();
}
heatmapTextureProgram->draw(
parameters.context,
*parameters.renderPass,
gfx::Triangles(),
gfx::DepthMode::disabled(),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*parameters.staticData.quadTriangleIndexBuffer,
segments,
allUniformValues,
allAttributeBindings,
HeatmapTextureProgram::TextureBindings{
textures::image::Value{renderTexture->getTexture().getResource(), gfx::TextureFilterType::Linear},
textures::color_ramp::Value{colorRampTexture->getResource(), gfx::TextureFilterType::Linear},
},
getID());
}
}
#endif // MLN_LEGACY_RENDERER
void RenderHeatmapLayer::updateColorRamp() { void RenderHeatmapLayer::updateColorRamp() {
if (colorRamp) { if (colorRamp) {
auto colorValue = unevaluated.get<HeatmapColor>().getValue(); auto colorValue = unevaluated.get<HeatmapColor>().getValue();
@@ -236,7 +113,6 @@ bool RenderHeatmapLayer::queryIntersectsFeature(const GeometryCoordinates& query
return false; return false;
} }
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
void activateRenderTarget(const RenderTargetPtr& renderTarget_, bool activate, UniqueChangeRequestVec& changes) { void activateRenderTarget(const RenderTargetPtr& renderTarget_, bool activate, UniqueChangeRequestVec& changes) {
if (renderTarget_) { if (renderTarget_) {
@@ -505,8 +381,9 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
std::shared_ptr<gfx::Texture2D> texture = context.createTexture2D(); std::shared_ptr<gfx::Texture2D> texture = context.createTexture2D();
texture->setImage(colorRamp); texture->setImage(colorRamp);
texture->setSamplerConfiguration( texture->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); .wrapU = gfx::TextureWrapType::Clamp,
.wrapV = gfx::TextureWrapType::Clamp});
heatmapTextureBuilder->setTexture(std::move(texture), idHeatmapColorRampTexture); heatmapTextureBuilder->setTexture(std::move(texture), idHeatmapColorRampTexture);
heatmapTextureBuilder->flush(context); heatmapTextureBuilder->flush(context);
@@ -517,6 +394,5 @@ void RenderHeatmapLayer::update(gfx::ShaderRegistry& shaders,
++stats.drawablesAdded; ++stats.drawablesAdded;
} }
} }
#endif // MLN_DRAWABLE_RENDERER
} // namespace mbgl } // namespace mbgl

View File

@@ -11,19 +11,16 @@
namespace mbgl { namespace mbgl {
#if MLN_DRAWABLE_RENDERER
class HeatmapLayerTweaker; class HeatmapLayerTweaker;
class HeatmapTextureLayerTweaker; class HeatmapTextureLayerTweaker;
using HeatmapLayerTweakerPtr = std::shared_ptr<HeatmapLayerTweaker>; using HeatmapLayerTweakerPtr = std::shared_ptr<HeatmapLayerTweaker>;
using HeatmapTextureLayerTweakerPtr = std::shared_ptr<HeatmapTextureLayerTweaker>; using HeatmapTextureLayerTweakerPtr = std::shared_ptr<HeatmapTextureLayerTweaker>;
#endif // MLN_DRAWABLE_RENDERER
class RenderHeatmapLayer final : public RenderLayer { class RenderHeatmapLayer final : public RenderLayer {
public: public:
explicit RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl>); explicit RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl>);
~RenderHeatmapLayer() override; ~RenderHeatmapLayer() override;
#if MLN_DRAWABLE_RENDERER
void markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) override; void markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) override;
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
@@ -33,19 +30,12 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
void evaluate(const PropertyEvaluationParameters&) override; void evaluate(const PropertyEvaluationParameters&) override;
bool hasTransition() const override; bool hasTransition() const override;
bool hasCrossfade() const override; bool hasCrossfade() const override;
#if MLN_LEGACY_RENDERER
void upload(gfx::UploadPass&) override;
void render(PaintParameters&) override;
#endif
bool queryIntersectsFeature(const GeometryCoordinates&, bool queryIntersectsFeature(const GeometryCoordinates&,
const GeometryTileFeature&, const GeometryTileFeature&,
float, float,
@@ -55,7 +45,6 @@ private:
const FeatureState&) const override; const FeatureState&) const override;
void updateColorRamp(); void updateColorRamp();
#if MLN_DRAWABLE_RENDERER
void layerChanged(const TransitionParameters& parameters, void layerChanged(const TransitionParameters& parameters,
const Immutable<style::Layer::Impl>& impl, const Immutable<style::Layer::Impl>& impl,
UniqueChangeRequestVec& changes) override; UniqueChangeRequestVec& changes) override;
@@ -68,8 +57,6 @@ private:
/// @return The number of drawables actually removed. /// @return The number of drawables actually removed.
std::size_t removeAllDrawables() override; std::size_t removeAllDrawables() override;
#endif
// Paint properties // Paint properties
style::HeatmapPaintProperties::Unevaluated unevaluated; style::HeatmapPaintProperties::Unevaluated unevaluated;
std::shared_ptr<PremultipliedImage> colorRamp; std::shared_ptr<PremultipliedImage> colorRamp;
@@ -77,13 +64,6 @@ private:
std::optional<gfx::Texture> colorRampTexture; std::optional<gfx::Texture> colorRampTexture;
SegmentVector<HeatmapTextureAttributes> segments; SegmentVector<HeatmapTextureAttributes> segments;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<HeatmapProgram> heatmapProgram;
std::shared_ptr<HeatmapTextureProgram> heatmapTextureProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr heatmapShaderGroup; gfx::ShaderGroupPtr heatmapShaderGroup;
gfx::ShaderProgramBasePtr heatmapTextureShader; gfx::ShaderProgramBasePtr heatmapTextureShader;
RenderTargetPtr renderTarget; RenderTargetPtr renderTarget;
@@ -94,7 +74,6 @@ private:
// This is the layer tweaker for applying the off-screen texture to the framebuffer. // This is the layer tweaker for applying the off-screen texture to the framebuffer.
// The inherited layer tweaker is for applying tiles to the off-screen texture. // The inherited layer tweaker is for applying tiles to the off-screen texture.
LayerTweakerPtr textureTweaker; LayerTweakerPtr textureTweaker;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -13,7 +13,6 @@
#include <mbgl/math/angles.hpp> #include <mbgl/math/angles.hpp>
#include <mbgl/util/geo.hpp> #include <mbgl/util/geo.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/renderer/layers/hillshade_layer_tweaker.hpp> #include <mbgl/renderer/layers/hillshade_layer_tweaker.hpp>
#include <mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp> #include <mbgl/renderer/layers/hillshade_prepare_layer_tweaker.hpp>
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
@@ -25,7 +24,6 @@
#include <mbgl/gfx/hillshade_prepare_drawable_data.hpp> #include <mbgl/gfx/hillshade_prepare_drawable_data.hpp>
#include <mbgl/gfx/shader_group.hpp> #include <mbgl/gfx/shader_group.hpp>
#include <mbgl/gfx/shader_registry.hpp> #include <mbgl/gfx/shader_registry.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -68,14 +66,12 @@ void RenderHillshadeLayer::transition(const TransitionParameters& parameters) {
styleDependencies = unevaluated.getDependencies(); styleDependencies = unevaluated.getDependencies();
} }
#if MLN_DRAWABLE_RENDERER
void RenderHillshadeLayer::layerChanged(const TransitionParameters& parameters, void RenderHillshadeLayer::layerChanged(const TransitionParameters& parameters,
const Immutable<style::Layer::Impl>& impl, const Immutable<style::Layer::Impl>& impl,
UniqueChangeRequestVec& changes) { UniqueChangeRequestVec& changes) {
RenderLayer::layerChanged(parameters, impl, changes); RenderLayer::layerChanged(parameters, impl, changes);
prepareLayerTweaker.reset(); prepareLayerTweaker.reset();
} }
#endif
void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& parameters) { void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& parameters) {
const auto previousProperties = staticImmutableCast<HillshadeLayerProperties>(evaluatedProperties); const auto previousProperties = staticImmutableCast<HillshadeLayerProperties>(evaluatedProperties);
@@ -88,14 +84,12 @@ void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& paramete
: RenderPass::None; : RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
if (prepareLayerTweaker) { if (prepareLayerTweaker) {
prepareLayerTweaker->updateProperties(evaluatedProperties); prepareLayerTweaker->updateProperties(evaluatedProperties);
} }
#endif
} }
bool RenderHillshadeLayer::hasTransition() const { bool RenderHillshadeLayer::hasTransition() const {
@@ -110,158 +104,9 @@ void RenderHillshadeLayer::prepare(const LayerPrepareParameters& params) {
renderTiles = params.source->getRenderTiles(); renderTiles = params.source->getRenderTiles();
maxzoom = params.source->getMaxZoom(); maxzoom = params.source->getMaxZoom();
#if MLN_DRAWABLE_RENDERER
updateRenderTileIDs(); updateRenderTileIDs();
#endif // MLN_DRAWABLE_RENDERER
} }
#if MLN_LEGACY_RENDERER
void RenderHillshadeLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass != RenderPass::Translucent && parameters.pass != RenderPass::Pass3D) return;
if (!parameters.shaders.getLegacyGroup().populate(hillshadeProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(hillshadePrepareProgram)) return;
const auto& evaluated = static_cast<const HillshadeLayerProperties&>(*evaluatedProperties).evaluated;
auto draw = [&](const mat4& matrix,
const auto& vertexBuffer,
const auto& indexBuffer,
const auto& segments,
const UnwrappedTileID& id,
const auto& textureBindings) {
const HillshadeProgram::Binders paintAttributeData{evaluated, 0};
const auto allUniformValues = HillshadeProgram::computeAllUniformValues(
HillshadeProgram::LayoutUniformValues{
uniforms::matrix::Value(matrix),
uniforms::highlight::Value(evaluated.get<HillshadeHighlightColor>()),
uniforms::shadow::Value(evaluated.get<HillshadeShadowColor>()),
uniforms::accent::Value(evaluated.get<HillshadeAccentColor>()),
uniforms::light::Value(getLight(parameters)),
uniforms::latrange::Value(getLatRange(id)),
},
paintAttributeData,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = HillshadeProgram::computeAllAttributeBindings(
vertexBuffer, paintAttributeData, evaluated);
checkRenderability(parameters, HillshadeProgram::activeBindingCount(allAttributeBindings));
hillshadeProgram->draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
indexBuffer,
segments,
allUniformValues,
allAttributeBindings,
textureBindings,
getID());
};
mat4 mat;
matrix::ortho(mat, 0, util::EXTENT, -util::EXTENT, 0, 0, 1);
matrix::translate(mat, mat, 0, -util::EXTENT, 0);
for (const RenderTile& tile : *renderTiles) {
auto* bucket_ = tile.getBucket(*baseImpl);
if (!bucket_) {
continue;
}
auto& bucket = static_cast<HillshadeBucket&>(*bucket_);
if (!bucket.hasData()) {
continue;
}
if (!bucket.isPrepared() && parameters.pass == RenderPass::Pass3D) {
assert(bucket.dem);
const uint16_t stride = bucket.getDEMData().stride;
const uint16_t tilesize = bucket.getDEMData().dim;
auto view = parameters.context.createOffscreenTexture({tilesize, tilesize},
gfx::TextureChannelDataType::UnsignedByte);
auto renderPass = parameters.encoder->createRenderPass("hillshade prepare",
{*view, Color{0.0f, 0.0f, 0.0f, 0.0f}, {}, {}});
const Properties<>::PossiblyEvaluated properties;
const HillshadePrepareProgram::Binders paintAttributeData{properties, 0};
const auto allUniformValues = HillshadePrepareProgram::computeAllUniformValues(
HillshadePrepareProgram::LayoutUniformValues{
uniforms::matrix::Value(mat),
uniforms::dimension::Value({{stride, stride}}),
uniforms::zoom::Value(static_cast<float>(tile.id.canonical.z)),
uniforms::maxzoom::Value(static_cast<float>(maxzoom)),
uniforms::unpack::Value(bucket.getDEMData().getUnpackVector()),
},
paintAttributeData,
properties,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = HillshadePrepareProgram::computeAllAttributeBindings(
*parameters.staticData.rasterVertexBuffer, paintAttributeData, properties);
checkRenderability(parameters, HillshadePrepareProgram::activeBindingCount(allAttributeBindings));
// Copy over the segments so that we can create our own DrawScopes
// that get destroyed after this draw call.
auto segments = RenderStaticData::rasterSegments();
hillshadePrepareProgram->draw(parameters.context,
*renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*parameters.staticData.quadTriangleIndexBuffer,
segments,
allUniformValues,
allAttributeBindings,
HillshadePrepareProgram::TextureBindings{
textures::image::Value{bucket.dem->getResource()},
},
"prepare");
bucket.texture = std::move(view->getTexture());
bucket.setPrepared(true);
} else if (parameters.pass == RenderPass::Translucent) {
assert(bucket.texture);
if (bucket.vertexBuffer && bucket.indexBuffer) {
// Draw only the parts of the tile that aren't drawn by another tile in the layer.
draw(parameters.matrixForTile(tile.id, true),
*bucket.vertexBuffer,
*bucket.indexBuffer,
bucket.segments,
tile.id,
HillshadeProgram::TextureBindings{
textures::image::Value{bucket.texture->getResource(), gfx::TextureFilterType::Linear},
});
} else {
// Draw the full tile.
if (bucket.segments.empty()) {
// Copy over the segments so that we can create our own DrawScopes.
bucket.segments = RenderStaticData::rasterSegments();
}
draw(parameters.matrixForTile(tile.id, true),
*parameters.staticData.rasterVertexBuffer,
*parameters.staticData.quadTriangleIndexBuffer,
bucket.segments,
tile.id,
HillshadeProgram::TextureBindings{
textures::image::Value{bucket.texture->getResource(), gfx::TextureFilterType::Linear},
});
}
}
}
}
#endif // MLN_LEGACY_RENDERER
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
void activateRenderTarget(const RenderTargetPtr& renderTarget_, bool activate, UniqueChangeRequestVec& changes) { void activateRenderTarget(const RenderTargetPtr& renderTarget_, bool activate, UniqueChangeRequestVec& changes) {
if (renderTarget_) { if (renderTarget_) {
@@ -434,8 +279,9 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
std::shared_ptr<gfx::Texture2D> texture = context.createTexture2D(); std::shared_ptr<gfx::Texture2D> texture = context.createTexture2D();
texture->setImage(bucket.getDEMData().getImagePtr()); texture->setImage(bucket.getDEMData().getImagePtr());
texture->setSamplerConfiguration( texture->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); .wrapU = gfx::TextureWrapType::Clamp,
.wrapV = gfx::TextureWrapType::Clamp});
hillshadePrepareBuilder->setTexture(texture, idHillshadeImageTexture); hillshadePrepareBuilder->setTexture(texture, idHillshadeImageTexture);
hillshadePrepareBuilder->flush(context); hillshadePrepareBuilder->flush(context);
@@ -533,6 +379,5 @@ void RenderHillshadeLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif // MLN_DRAWABLE_RENDERER
} // namespace mbgl } // namespace mbgl

View File

@@ -9,17 +9,14 @@
namespace mbgl { namespace mbgl {
#if MLN_DRAWABLE_RENDERER
class HillshadeLayerTweaker; class HillshadeLayerTweaker;
using HillshadeLayerTweakerPtr = std::shared_ptr<HillshadeLayerTweaker>; using HillshadeLayerTweakerPtr = std::shared_ptr<HillshadeLayerTweaker>;
#endif // MLN_DRAWABLE_RENDERER
class RenderHillshadeLayer : public RenderLayer { class RenderHillshadeLayer : public RenderLayer {
public: public:
explicit RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl>); explicit RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl>);
~RenderHillshadeLayer() override; ~RenderHillshadeLayer() override;
#if MLN_DRAWABLE_RENDERER
void markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) override; void markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) override;
void layerRemoved(UniqueChangeRequestVec&) override; void layerRemoved(UniqueChangeRequestVec&) override;
@@ -31,7 +28,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -39,25 +35,16 @@ private:
bool hasTransition() const override; bool hasTransition() const override;
bool hasCrossfade() const override; bool hasCrossfade() const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
#if MLN_DRAWABLE_RENDERER
void updateLayerTweaker(); void updateLayerTweaker();
void layerChanged(const TransitionParameters& parameters, void layerChanged(const TransitionParameters& parameters,
const Immutable<style::Layer::Impl>& impl, const Immutable<style::Layer::Impl>& impl,
UniqueChangeRequestVec& changes) override; UniqueChangeRequestVec& changes) override;
#endif // MLN_DRAWABLE_RENDERER
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
#if MLN_DRAWABLE_RENDERER
void addRenderTarget(const RenderTargetPtr&, UniqueChangeRequestVec&); void addRenderTarget(const RenderTargetPtr&, UniqueChangeRequestVec&);
void removeRenderTargets(UniqueChangeRequestVec&); void removeRenderTargets(UniqueChangeRequestVec&);
#endif
// Paint properties // Paint properties
style::HillshadePaintProperties::Unevaluated unevaluated; style::HillshadePaintProperties::Unevaluated unevaluated;
@@ -66,13 +53,6 @@ private:
std::array<float, 2> getLatRange(const UnwrappedTileID& id); std::array<float, 2> getLatRange(const UnwrappedTileID& id);
std::array<float, 2> getLight(const PaintParameters& parameters); std::array<float, 2> getLight(const PaintParameters& parameters);
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<HillshadeProgram> hillshadeProgram;
std::shared_ptr<HillshadePrepareProgram> hillshadePrepareProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderProgramBasePtr hillshadePrepareShader; gfx::ShaderProgramBasePtr hillshadePrepareShader;
gfx::ShaderProgramBasePtr hillshadeShader; gfx::ShaderProgramBasePtr hillshadeShader;
std::vector<RenderTargetPtr> activatedRenderTargets; std::vector<RenderTargetPtr> activatedRenderTargets;
@@ -81,7 +61,6 @@ private:
std::shared_ptr<HillshadeVertexVector> staticDataSharedVertices; std::shared_ptr<HillshadeVertexVector> staticDataSharedVertices;
LayerTweakerPtr prepareLayerTweaker; LayerTweakerPtr prepareLayerTweaker;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -21,7 +21,6 @@
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_atlases_tweaker.hpp> #include <mbgl/gfx/drawable_atlases_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/gfx/line_drawable_data.hpp> #include <mbgl/gfx/line_drawable_data.hpp>
@@ -30,7 +29,6 @@
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/line_layer_ubo.hpp> #include <mbgl/shaders/line_layer_ubo.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -44,12 +42,8 @@ inline const LineLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& imp
return static_cast<const LineLayer::Impl&>(*impl); return static_cast<const LineLayer::Impl&>(*impl);
} }
#if MLN_DRAWABLE_RENDERER
const auto posNormalAttribName = "a_pos_normal"; const auto posNormalAttribName = "a_pos_normal";
#endif // MLN_DRAWABLE_RENDERER
} // namespace } // namespace
RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl) RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl)
@@ -88,14 +82,12 @@ void RenderLineLayer::evaluate(const PropertyEvaluationParameters& parameters) {
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (auto* tweaker = static_cast<LineLayerTweaker*>(layerTweaker.get())) { if (auto* tweaker = static_cast<LineLayerTweaker*>(layerTweaker.get())) {
tweaker->updateProperties(evaluatedProperties); tweaker->updateProperties(evaluatedProperties);
#if MLN_RENDER_BACKEND_METAL #if MLN_RENDER_BACKEND_METAL
tweaker->updateGPUExpressions(unevaluated, parameters.now); tweaker->updateGPUExpressions(unevaluated, parameters.now);
#endif // MLN_RENDER_BACKEND_METAL #endif // MLN_RENDER_BACKEND_METAL
} }
#endif
} }
bool RenderLineLayer::hasTransition() const { bool RenderLineLayer::hasTransition() const {
@@ -124,134 +116,6 @@ void RenderLineLayer::prepare(const LayerPrepareParameters& params) {
} }
} }
#if MLN_LEGACY_RENDERER
void RenderLineLayer::upload(gfx::UploadPass& uploadPass) {
if (!unevaluated.get<LineGradient>().getValue().isUndefined() && !colorRampTexture) {
colorRampTexture = uploadPass.createTexture(*colorRamp);
}
}
void RenderLineLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass == RenderPass::Opaque) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(lineProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(lineGradientProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(lineSDFProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(linePatternProgram)) return;
parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<LineBucket&>(*renderData->bucket);
const auto& evaluated = getEvaluated<LineLayerProperties>(renderData->layerProperties);
const auto& crossfade = getCrossfade<LineLayerProperties>(renderData->layerProperties);
auto draw = [&](auto& programInstance,
auto&& uniformValues,
const std::optional<ImagePosition>& patternPositionA,
const std::optional<ImagePosition>& patternPositionB,
auto&& textureBindings) {
auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
paintPropertyBinders.setPatternParameters(patternPositionA, patternPositionB, crossfade);
const auto allUniformValues = programInstance.computeAllUniformValues(
std::forward<decltype(uniformValues)>(uniformValues),
paintPropertyBinders,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(
*bucket.vertexBuffer, paintPropertyBinders, evaluated);
checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
programInstance.draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
parameters.stencilModeForClipping(tile.id),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*bucket.indexBuffer,
bucket.segments,
allUniformValues,
allAttributeBindings,
std::forward<decltype(textureBindings)>(textureBindings),
getID());
};
if (!evaluated.get<LineDasharray>().from.empty()) {
const LinePatternCap cap = bucket.layout.get<LineCap>() == LineCapType::Round ? LinePatternCap::Round
: LinePatternCap::Square;
const auto& dashPatternTexture = parameters.lineAtlas.getDashPatternTexture(
evaluated.get<LineDasharray>().from, evaluated.get<LineDasharray>().to, cap);
draw(*lineSDFProgram,
LineSDFProgram::layoutUniformValues(evaluated,
parameters.pixelRatio,
tile,
parameters.state,
parameters.pixelsToGLUnits,
dashPatternTexture.getFrom(),
dashPatternTexture.getTo(),
crossfade,
static_cast<float>(dashPatternTexture.getSize().width)),
{},
{},
LineSDFProgram::TextureBindings{
dashPatternTexture.textureBinding(),
});
} else if (!unevaluated.get<LinePattern>().isUndefined()) {
const auto& linePatternValue = evaluated.get<LinePattern>().constantOr(Faded<expression::Image>{"", ""});
const Size& texsize = tile.getIconAtlasTexture()->getSize();
std::optional<ImagePosition> posA = tile.getPattern(linePatternValue.from.id());
std::optional<ImagePosition> posB = tile.getPattern(linePatternValue.to.id());
draw(*linePatternProgram,
LinePatternProgram::layoutUniformValues(evaluated,
tile,
parameters.state,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
texsize,
crossfade),
posA,
posB,
LinePatternProgram::TextureBindings{
tile.getIconAtlasTextureBinding(gfx::TextureFilterType::Linear),
});
} else if (!unevaluated.get<LineGradient>().getValue().isUndefined()) {
assert(colorRampTexture);
draw(*lineGradientProgram,
LineGradientProgram::layoutUniformValues(
evaluated, tile, parameters.state, parameters.pixelsToGLUnits, parameters.pixelRatio),
{},
{},
LineGradientProgram::TextureBindings{
textures::image::Value{colorRampTexture->getResource(), gfx::TextureFilterType::Linear},
});
} else {
draw(*lineProgram,
LineProgram::layoutUniformValues(
evaluated, tile, parameters.state, parameters.pixelsToGLUnits, parameters.pixelRatio),
{},
{},
LineProgram::TextureBindings{});
}
}
}
#endif // MLN_LEGACY_RENDERER
namespace { namespace {
GeometryCollection offsetLine(const GeometryCollection& rings, double offset) { GeometryCollection offsetLine(const GeometryCollection& rings, double offset) {
@@ -327,7 +191,6 @@ void RenderLineLayer::updateColorRamp() {
colorRampTexture = std::nullopt; colorRampTexture = std::nullopt;
#if MLN_DRAWABLE_RENDERER
if (colorRampTexture2D) { if (colorRampTexture2D) {
colorRampTexture2D.reset(); colorRampTexture2D.reset();
@@ -337,7 +200,6 @@ void RenderLineLayer::updateColorRamp() {
layerGroup->clearDrawables(); layerGroup->clearDrawables();
} }
} }
#endif
} }
float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature, float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature,
@@ -355,7 +217,6 @@ float RenderLineLayer::getLineWidth(const GeometryTileFeature& feature,
} }
} }
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
inline void setSegments(std::unique_ptr<gfx::DrawableBuilder>& builder, const LineBucket& bucket) { inline void setSegments(std::unique_ptr<gfx::DrawableBuilder>& builder, const LineBucket& bucket) {
@@ -603,8 +464,9 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
// create texture. to be reused for all the tiles of the layer // create texture. to be reused for all the tiles of the layer
colorRampTexture2D = context.createTexture2D(); colorRampTexture2D = context.createTexture2D();
colorRampTexture2D->setImage(colorRamp); colorRampTexture2D->setImage(colorRamp);
colorRampTexture2D->setSamplerConfiguration( colorRampTexture2D->setSamplerConfiguration({.filter = gfx::TextureFilterType::Linear,
{gfx::TextureFilterType::Linear, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); .wrapU = gfx::TextureWrapType::Clamp,
.wrapV = gfx::TextureWrapType::Clamp});
} }
if (colorRampTexture2D) { if (colorRampTexture2D) {
@@ -644,6 +506,5 @@ void RenderLineLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif
} // namespace mbgl } // namespace mbgl

View File

@@ -13,14 +13,6 @@
namespace mbgl { namespace mbgl {
#if MLN_LEGACY_RENDERER
class LineProgram;
class LineGradientProgram;
class LineSDFProgram;
class LinePatternProgram;
#endif
#if MLN_DRAWABLE_RENDERER
namespace gfx { namespace gfx {
class ShaderGroup; class ShaderGroup;
class UniformBuffer; class UniformBuffer;
@@ -30,14 +22,12 @@ using UniformBufferPtr = std::shared_ptr<UniformBuffer>;
class LineLayerTweaker; class LineLayerTweaker;
using LineLayerTweakerPtr = std::shared_ptr<LineLayerTweaker>; using LineLayerTweakerPtr = std::shared_ptr<LineLayerTweaker>;
#endif
class RenderLineLayer final : public RenderLayer { class RenderLineLayer final : public RenderLayer {
public: public:
explicit RenderLineLayer(Immutable<style::LineLayer::Impl>); explicit RenderLineLayer(Immutable<style::LineLayer::Impl>);
~RenderLineLayer() override; ~RenderLineLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -45,7 +35,6 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -54,11 +43,6 @@ private:
bool hasCrossfade() const override; bool hasCrossfade() const override;
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
#if MLN_LEGACY_RENDERER
void upload(gfx::UploadPass&) override;
void render(PaintParameters&) override;
#endif
bool queryIntersectsFeature(const GeometryCoordinates&, bool queryIntersectsFeature(const GeometryCoordinates&,
const GeometryTileFeature&, const GeometryTileFeature&,
float, float,
@@ -76,23 +60,12 @@ private:
std::shared_ptr<PremultipliedImage> colorRamp; std::shared_ptr<PremultipliedImage> colorRamp;
std::optional<gfx::Texture> colorRampTexture; std::optional<gfx::Texture> colorRampTexture;
#if MLN_DRAWABLE_RENDERER
gfx::Texture2DPtr colorRampTexture2D; gfx::Texture2DPtr colorRampTexture2D;
#endif
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<LineProgram> lineProgram;
std::shared_ptr<LineGradientProgram> lineGradientProgram;
std::shared_ptr<LineSDFProgram> lineSDFProgram;
std::shared_ptr<LinePatternProgram> linePatternProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr lineShaderGroup; gfx::ShaderGroupPtr lineShaderGroup;
gfx::ShaderGroupPtr lineGradientShaderGroup; gfx::ShaderGroupPtr lineGradientShaderGroup;
gfx::ShaderGroupPtr lineSDFShaderGroup; gfx::ShaderGroupPtr lineSDFShaderGroup;
gfx::ShaderGroupPtr linePatternShaderGroup; gfx::ShaderGroupPtr linePatternShaderGroup;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -13,7 +13,6 @@
#include <mbgl/style/layers/raster_layer_impl.hpp> #include <mbgl/style/layers/raster_layer_impl.hpp>
#include <mbgl/util/logging.hpp> #include <mbgl/util/logging.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/renderer/layers/raster_layer_tweaker.hpp> #include <mbgl/renderer/layers/raster_layer_tweaker.hpp>
#include <mbgl/gfx/image_drawable_data.hpp> #include <mbgl/gfx/image_drawable_data.hpp>
#include <mbgl/gfx/drawable_impl.hpp> #include <mbgl/gfx/drawable_impl.hpp>
@@ -21,7 +20,6 @@
#include <mbgl/renderer/layer_group.hpp> #include <mbgl/renderer/layer_group.hpp>
#include <mbgl/renderer/update_parameters.hpp> #include <mbgl/renderer/update_parameters.hpp>
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#endif
namespace mbgl { namespace mbgl {
@@ -60,11 +58,9 @@ void RenderRasterLayer::evaluate(const PropertyEvaluationParameters& parameters)
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif
} }
bool RenderRasterLayer::hasTransition() const { bool RenderRasterLayer::hasTransition() const {
@@ -75,163 +71,15 @@ bool RenderRasterLayer::hasCrossfade() const {
return false; return false;
} }
#if MLN_LEGACY_RENDERER
static float saturationFactor(float saturation) {
if (saturation > 0) {
return 1.f - 1.f / (1.001f - saturation);
} else {
return -saturation;
}
}
static float contrastFactor(float contrast) {
if (contrast > 0) {
return 1 / (1 - contrast);
} else {
return 1 + contrast;
}
}
static std::array<float, 3> spinWeights(float spin) {
spin = util::deg2radf(spin);
float s = std::sin(spin);
float c = std::cos(spin);
std::array<float, 3> spin_weights = {
{(2 * c + 1) / 3, (-std::sqrt(3.0f) * s - c + 1) / 3, (std::sqrt(3.0f) * s - c + 1) / 3}};
return spin_weights;
}
#endif
void RenderRasterLayer::prepare(const LayerPrepareParameters& params) { void RenderRasterLayer::prepare(const LayerPrepareParameters& params) {
renderTiles = params.source->getRenderTiles(); renderTiles = params.source->getRenderTiles();
imageData = params.source->getImageRenderData(); imageData = params.source->getImageRenderData();
// It is possible image data is not available until the source loads it. // It is possible image data is not available until the source loads it.
assert(renderTiles || imageData || !params.source->isEnabled()); assert(renderTiles || imageData || !params.source->isEnabled());
#if MLN_DRAWABLE_RENDERER
updateRenderTileIDs(); updateRenderTileIDs();
#endif // MLN_DRAWABLE_RENDERER
} }
#if MLN_LEGACY_RENDERER
void RenderRasterLayer::render(PaintParameters& parameters) {
if (parameters.pass != RenderPass::Translucent || (!renderTiles && !imageData)) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(rasterProgram)) return;
const auto& evaluated = static_cast<const RasterLayerProperties&>(*evaluatedProperties).evaluated;
RasterProgram::Binders paintAttributeData{evaluated, 0};
auto draw = [&](const mat4& matrix,
const auto& vertexBuffer,
const auto& indexBuffer,
const auto& segments,
const auto& textureBindings,
const std::string& drawScopeID) {
const auto allUniformValues = RasterProgram::computeAllUniformValues(
RasterProgram::LayoutUniformValues{
uniforms::matrix::Value(matrix),
uniforms::opacity::Value(evaluated.get<RasterOpacity>()),
uniforms::fade_t::Value(1),
uniforms::brightness_low::Value(evaluated.get<RasterBrightnessMin>()),
uniforms::brightness_high::Value(evaluated.get<RasterBrightnessMax>()),
uniforms::saturation_factor::Value(saturationFactor(evaluated.get<RasterSaturation>())),
uniforms::contrast_factor::Value(contrastFactor(evaluated.get<RasterContrast>())),
uniforms::spin_weights::Value(spinWeights(evaluated.get<RasterHueRotate>())),
uniforms::buffer_scale::Value(1.0f),
uniforms::scale_parent::Value(1.0f),
uniforms::tl_parent::Value(std::array<float, 2>{{0.0f, 0.0f}}),
},
paintAttributeData,
evaluated,
static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = RasterProgram::computeAllAttributeBindings(
vertexBuffer, paintAttributeData, evaluated);
checkRenderability(parameters, RasterProgram::activeBindingCount(allAttributeBindings));
rasterProgram->draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
indexBuffer,
segments,
allUniformValues,
allAttributeBindings,
textureBindings,
getID() + "/" + drawScopeID);
};
const gfx::TextureFilterType filter = evaluated.get<RasterResampling>() == RasterResamplingType::Nearest
? gfx::TextureFilterType::Nearest
: gfx::TextureFilterType::Linear;
if (imageData && !imageData->bucket->needsUpload()) {
RasterBucket& bucket = *imageData->bucket;
assert(bucket.texture);
size_t i = 0;
for (const auto& matrix_ : imageData->matrices) {
draw(matrix_,
*bucket.vertexBuffer,
*bucket.indexBuffer,
bucket.segments,
RasterProgram::TextureBindings{
textures::image0::Value{bucket.texture->getResource(), filter},
textures::image1::Value{bucket.texture->getResource(), filter},
},
std::to_string(i++));
}
} else if (renderTiles) {
for (const RenderTile& tile : *renderTiles) {
auto* bucket_ = tile.getBucket(*baseImpl);
if (!bucket_) {
continue;
}
auto& bucket = static_cast<RasterBucket&>(*bucket_);
if (!bucket.hasData()) continue;
assert(bucket.texture);
if (bucket.vertexBuffer && bucket.indexBuffer) {
// Draw only the parts of the tile that aren't drawn by another tile in the layer.
draw(parameters.matrixForTile(tile.id, !parameters.state.isChanging()),
*bucket.vertexBuffer,
*bucket.indexBuffer,
bucket.segments,
RasterProgram::TextureBindings{
textures::image0::Value{bucket.texture->getResource(), filter},
textures::image1::Value{bucket.texture->getResource(), filter},
},
"image");
} else {
// Draw the full tile.
if (bucket.segments.empty()) {
// Copy over the segments so that we can create our own DrawScopes.
bucket.segments = RenderStaticData::rasterSegments();
}
draw(parameters.matrixForTile(tile.id, !parameters.state.isChanging()),
*parameters.staticData.rasterVertexBuffer,
*parameters.staticData.quadTriangleIndexBuffer,
bucket.segments,
RasterProgram::TextureBindings{
textures::image0::Value{bucket.texture->getResource(), filter},
textures::image1::Value{bucket.texture->getResource(), filter},
},
"image");
}
}
}
}
#endif // MLN_LEGACY_RENDERER
#if MLN_DRAWABLE_RENDERER
void RenderRasterLayer::markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) { void RenderRasterLayer::markLayerRenderable(bool willRender, UniqueChangeRequestVec& changes) {
RenderLayer::markLayerRenderable(willRender, changes); RenderLayer::markLayerRenderable(willRender, changes);
if (imageLayerGroup) { if (imageLayerGroup) {
@@ -324,7 +172,7 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
const auto filter = nearest ? gfx::TextureFilterType::Nearest : gfx::TextureFilterType::Linear; const auto filter = nearest ? gfx::TextureFilterType::Nearest : gfx::TextureFilterType::Linear;
bucket.texture2d->setSamplerConfiguration( bucket.texture2d->setSamplerConfiguration(
{filter, gfx::TextureWrapType::Clamp, gfx::TextureWrapType::Clamp}); {.filter = filter, .wrapU = gfx::TextureWrapType::Clamp, .wrapV = gfx::TextureWrapType::Clamp});
builder->setTexture(bucket.texture2d, idRasterImage0Texture); builder->setTexture(bucket.texture2d, idRasterImage0Texture);
builder->setTexture(bucket.texture2d, idRasterImage1Texture); builder->setTexture(bucket.texture2d, idRasterImage1Texture);
@@ -520,6 +368,5 @@ void RenderRasterLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
} }
#endif // MLN_DRAWABLE_RENDERER
} // namespace mbgl } // namespace mbgl

View File

@@ -16,7 +16,6 @@ public:
explicit RenderRasterLayer(Immutable<style::RasterLayer::Impl>); explicit RenderRasterLayer(Immutable<style::RasterLayer::Impl>);
~RenderRasterLayer() override; ~RenderRasterLayer() override;
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -24,10 +23,8 @@ public:
const std::shared_ptr<UpdateParameters>&, const std::shared_ptr<UpdateParameters>&,
const RenderTree&, const RenderTree&,
UniqueChangeRequestVec&) override; UniqueChangeRequestVec&) override;
#endif
protected: protected:
#if MLN_DRAWABLE_RENDERER
/// @brief Called by the RenderOrchestrator during RenderTree construction. /// @brief Called by the RenderOrchestrator during RenderTree construction.
/// This event is run to indicate if the layer should render or not for the current frame. /// This event is run to indicate if the layer should render or not for the current frame.
/// @param willRender Indicates if this layer should render or not /// @param willRender Indicates if this layer should render or not
@@ -42,7 +39,6 @@ protected:
/// Called when the style layer is removed /// Called when the style layer is removed
void layerRemoved(UniqueChangeRequestVec&) override; void layerRemoved(UniqueChangeRequestVec&) override;
#endif // MLN_DRAWABLE_RENDERER
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
@@ -51,20 +47,10 @@ private:
bool hasCrossfade() const override; bool hasCrossfade() const override;
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif
// Paint properties // Paint properties
style::RasterPaintProperties::Unevaluated unevaluated; style::RasterPaintProperties::Unevaluated unevaluated;
const ImageSourceRenderData* imageData = nullptr; const ImageSourceRenderData* imageData = nullptr;
#if MLN_LEGACY_RENDERER
// Programs
std::shared_ptr<RasterProgram> rasterProgram;
#endif
#if MLN_DRAWABLE_RENDERER
gfx::ShaderProgramBasePtr rasterShader; gfx::ShaderProgramBasePtr rasterShader;
LayerGroupPtr imageLayerGroup; LayerGroupPtr imageLayerGroup;
@@ -79,7 +65,6 @@ private:
using RasterSegmentVector = SegmentVector<RasterAttributes>; using RasterSegmentVector = SegmentVector<RasterAttributes>;
using RasterSegmentVectorPtr = std::shared_ptr<RasterSegmentVector>; using RasterSegmentVectorPtr = std::shared_ptr<RasterSegmentVector>;
std::shared_ptr<RasterSegmentVector> staticDataSegments; std::shared_ptr<RasterSegmentVector> staticDataSegments;
#endif
}; };
} // namespace mbgl } // namespace mbgl

View File

@@ -22,7 +22,6 @@
#include <mbgl/util/convert.hpp> #include <mbgl/util/convert.hpp>
#include <mbgl/util/math.hpp> #include <mbgl/util/math.hpp>
#if MLN_DRAWABLE_RENDERER
#include <mbgl/gfx/drawable_atlases_tweaker.hpp> #include <mbgl/gfx/drawable_atlases_tweaker.hpp>
#include <mbgl/gfx/drawable_builder.hpp> #include <mbgl/gfx/drawable_builder.hpp>
#include <mbgl/gfx/symbol_drawable_data.hpp> #include <mbgl/gfx/symbol_drawable_data.hpp>
@@ -33,9 +32,7 @@
#include <mbgl/shaders/shader_program_base.hpp> #include <mbgl/shaders/shader_program_base.hpp>
#include <mbgl/shaders/symbol_layer_ubo.hpp> #include <mbgl/shaders/symbol_layer_ubo.hpp>
#include <mbgl/renderer/layers/collision_layer_tweaker.hpp> #include <mbgl/renderer/layers/collision_layer_tweaker.hpp>
#endif // MLN_DRAWABLE_RENDERER
#include <cmath>
#include <set> #include <set>
namespace mbgl { namespace mbgl {
@@ -44,7 +41,6 @@ using namespace style;
using namespace shaders; using namespace shaders;
namespace { namespace {
#if MLN_DRAWABLE_RENDERER
constexpr std::string_view SymbolIconShaderName = "SymbolIconShader"; constexpr std::string_view SymbolIconShaderName = "SymbolIconShader";
constexpr std::string_view SymbolSDFIconShaderName = "SymbolSDFIconShader"; constexpr std::string_view SymbolSDFIconShaderName = "SymbolSDFIconShader";
@@ -52,30 +48,30 @@ constexpr std::string_view SymbolTextAndIconShaderName = "SymbolTextAndIconShade
constexpr std::string_view CollisionBoxShaderName = "CollisionBoxShader"; constexpr std::string_view CollisionBoxShaderName = "CollisionBoxShader";
constexpr std::string_view CollisionCircleShaderName = "CollisionCircleShader"; constexpr std::string_view CollisionCircleShaderName = "CollisionCircleShader";
#endif // MLN_DRAWABLE_RENDERER
style::SymbolPropertyValues iconPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_, style::SymbolPropertyValues iconPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_,
const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) { const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) {
return style::SymbolPropertyValues{layout_.get<style::IconPitchAlignment>(), return style::SymbolPropertyValues{
layout_.get<style::IconRotationAlignment>(), .pitchAlignment = layout_.get<style::IconPitchAlignment>(),
layout_.get<style::IconKeepUpright>(), .rotationAlignment = layout_.get<style::IconRotationAlignment>(),
evaluated_.get<style::IconTranslate>(), .keepUpright = layout_.get<style::IconKeepUpright>(),
evaluated_.get<style::IconTranslateAnchor>(), .translate = evaluated_.get<style::IconTranslate>(),
evaluated_.get<style::IconHaloColor>().constantOr(Color::black()).a > 0 && .translateAnchor = evaluated_.get<style::IconTranslateAnchor>(),
evaluated_.get<style::IconHaloWidth>().constantOr(1) != 0, .hasHalo = evaluated_.get<style::IconHaloColor>().constantOr(Color::black()).a > 0 &&
evaluated_.get<style::IconColor>().constantOr(Color::black()).a > 0}; evaluated_.get<style::IconHaloWidth>().constantOr(1) != 0,
.hasFill = evaluated_.get<style::IconColor>().constantOr(Color::black()).a > 0};
} }
style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_, style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_,
const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) { const style::SymbolLayoutProperties::PossiblyEvaluated& layout_) {
return style::SymbolPropertyValues{layout_.get<style::TextPitchAlignment>(), return style::SymbolPropertyValues{
layout_.get<style::TextRotationAlignment>(), .pitchAlignment = layout_.get<style::TextPitchAlignment>(),
layout_.get<style::TextKeepUpright>(), .rotationAlignment = layout_.get<style::TextRotationAlignment>(),
evaluated_.get<style::TextTranslate>(), .keepUpright = layout_.get<style::TextKeepUpright>(),
evaluated_.get<style::TextTranslateAnchor>(), .translate = evaluated_.get<style::TextTranslate>(),
evaluated_.get<style::TextHaloColor>().constantOr(Color::black()).a > 0 && .translateAnchor = evaluated_.get<style::TextTranslateAnchor>(),
evaluated_.get<style::TextHaloWidth>().constantOr(1) != 0, .hasHalo = evaluated_.get<style::TextHaloColor>().constantOr(Color::black()).a > 0 &&
evaluated_.get<style::TextColor>().constantOr(Color::black()).a > 0}; evaluated_.get<style::TextHaloWidth>().constantOr(1) != 0,
.hasFill = evaluated_.get<style::TextColor>().constantOr(Color::black()).a > 0};
} }
using SegmentWrapper = std::reference_wrapper<const Segment<SymbolTextAttributes>>; using SegmentWrapper = std::reference_wrapper<const Segment<SymbolTextAttributes>>;
@@ -137,214 +133,6 @@ struct SegmentGroup {
bool operator<(const SegmentGroup& other) const { return renderable < other.renderable; } bool operator<(const SegmentGroup& other) const { return renderable < other.renderable; }
}; };
#if MLN_LEGACY_RENDERER
template <typename DrawFn>
void drawIcon(const RenderSymbolLayer::Programs& programs,
const DrawFn& draw,
const RenderTile& tile,
const LayerRenderData& renderData,
SegmentsWrapper iconSegments,
const SymbolBucket::PaintProperties& bucketPaintProperties,
const PaintParameters& parameters,
const bool sdfIcons) {
auto& bucket = static_cast<SymbolBucket&>(*renderData.bucket);
const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties);
const auto& layout = *bucket.layout;
auto values = iconPropertyValues(evaluated, layout);
const auto& paintPropertyValues = RenderSymbolLayer::iconPaintProperties(evaluated);
const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point &&
layout.get<IconRotationAlignment>() == AlignmentType::Map;
const bool iconScaled = layout.get<IconSize>().constantOr(1.0) != 1.0 || bucket.iconsNeedLinear;
const bool iconTransformed = values.rotationAlignment == AlignmentType::Map || parameters.state.getPitch() != 0;
const bool linear = sdfIcons || parameters.state.isChanging() || iconScaled || iconTransformed;
const auto filterType = linear ? gfx::TextureFilterType::Linear : gfx::TextureFilterType::Nearest;
const gfx::TextureBinding textureBinding = tile.getIconAtlasTextureBinding(filterType);
const Size& iconSize = tile.getIconAtlasTexture()->getSize();
const bool variablePlacedIcon = bucket.hasVariablePlacement && layout.get<IconTextFit>() != IconTextFitType::None;
if (sdfIcons) {
if (values.hasHalo) {
draw(*programs.symbolSDFIconProgram,
SymbolSDFIconProgram::layoutUniformValues(/* isText = */ false,
variablePlacedIcon,
values,
iconSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Halo),
bucket.sdfIcon,
iconSegments,
bucket.iconSizeBinder,
bucketPaintProperties.iconBinders,
paintPropertyValues,
SymbolSDFIconProgram::TextureBindings{textureBinding},
"halo");
}
if (values.hasFill) {
draw(*programs.symbolSDFIconProgram,
SymbolSDFIconProgram::layoutUniformValues(/* isText = */ false,
variablePlacedIcon,
values,
iconSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Fill),
bucket.sdfIcon,
iconSegments,
bucket.iconSizeBinder,
bucketPaintProperties.iconBinders,
paintPropertyValues,
SymbolSDFIconProgram::TextureBindings{textureBinding},
"fill");
}
} else {
draw(*programs.symbolIconProgram,
SymbolIconProgram::layoutUniformValues(/* isText = */ false,
variablePlacedIcon,
values,
iconSize,
parameters.pixelsToGLUnits,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange),
bucket.icon,
iconSegments,
bucket.iconSizeBinder,
bucketPaintProperties.iconBinders,
paintPropertyValues,
SymbolIconProgram::TextureBindings{textureBinding},
"icon");
}
}
template <typename DrawFn>
void drawText(const RenderSymbolLayer::Programs& programs,
const DrawFn& draw,
const RenderTile& tile,
const LayerRenderData& renderData,
SegmentsWrapper textSegments,
const SymbolBucket::PaintProperties& bucketPaintProperties,
const PaintParameters& parameters) {
const auto& bucket = static_cast<SymbolBucket&>(*renderData.bucket);
const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData.layerProperties);
const auto& layout = *bucket.layout;
const auto values = textPropertyValues(evaluated, layout);
const auto& paintPropertyValues = RenderSymbolLayer::textPaintProperties(evaluated);
const bool alongLine = layout.get<SymbolPlacement>() != SymbolPlacementType::Point &&
values.rotationAlignment == AlignmentType::Map;
const Size& glyphTexSize = tile.getGlyphAtlasTexture()->getSize();
const gfx::TextureBinding glyphTextureBinding = tile.getGlyphAtlasTextureBinding(gfx::TextureFilterType::Linear);
const auto drawGlyphs = [&](auto& program, const auto& uniforms, const auto& textures, SymbolSDFPart part) {
draw(program,
uniforms,
bucket.text,
textSegments,
bucket.textSizeBinder,
bucketPaintProperties.textBinders,
paintPropertyValues,
textures,
(part == SymbolSDFPart::Halo) ? "halo" : "fill");
};
if (bucket.iconsInText) {
const ZoomEvaluatedSize partiallyEvaluatedTextSize = bucket.textSizeBinder->evaluateForZoom(
static_cast<float>(parameters.state.getZoom()));
const bool transformed = values.rotationAlignment == AlignmentType::Map || parameters.state.getPitch() != 0;
const Size& iconTexSize = tile.getIconAtlasTexture()->getSize();
const bool linear = parameters.state.isChanging() || transformed || !partiallyEvaluatedTextSize.isZoomConstant;
const auto filterType = linear ? gfx::TextureFilterType::Linear : gfx::TextureFilterType::Nearest;
const gfx::TextureBinding iconTextureBinding = tile.getIconAtlasTextureBinding(filterType);
if (values.hasHalo) {
drawGlyphs(*programs.symbolTextAndIconProgram,
SymbolTextAndIconProgram::layoutUniformValues(bucket.hasVariablePlacement,
values,
glyphTexSize,
iconTexSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Halo),
SymbolTextAndIconProgram::TextureBindings{glyphTextureBinding, iconTextureBinding},
SymbolSDFPart::Halo);
}
if (values.hasFill) {
drawGlyphs(*programs.symbolTextAndIconProgram,
SymbolTextAndIconProgram::layoutUniformValues(bucket.hasVariablePlacement,
values,
glyphTexSize,
iconTexSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Fill),
SymbolTextAndIconProgram::TextureBindings{glyphTextureBinding, iconTextureBinding},
SymbolSDFPart::Fill);
}
} else {
if (values.hasHalo) {
drawGlyphs(*programs.symbolSDFTextProgram,
SymbolSDFTextProgram::layoutUniformValues(/* isText = */ true,
bucket.hasVariablePlacement,
values,
glyphTexSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Halo),
SymbolSDFTextProgram::TextureBindings{glyphTextureBinding},
SymbolSDFPart::Halo);
}
if (values.hasFill) {
drawGlyphs(*programs.symbolSDFTextProgram,
SymbolSDFTextProgram::layoutUniformValues(/* isText = */ true,
bucket.hasVariablePlacement,
values,
glyphTexSize,
parameters.pixelsToGLUnits,
parameters.pixelRatio,
alongLine,
tile,
parameters.state,
parameters.symbolFadeChange,
SymbolSDFPart::Fill),
SymbolSDFTextProgram::TextureBindings{glyphTextureBinding},
SymbolSDFPart::Fill);
}
}
}
#endif // MLN_LEGACY_RENDERER
inline const SymbolLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) { inline const SymbolLayer::Impl& impl_cast(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == SymbolLayer::Impl::staticTypeInfo()); assert(impl->getTypeInfo() == SymbolLayer::Impl::staticTypeInfo());
return static_cast<const SymbolLayer::Impl&>(*impl); return static_cast<const SymbolLayer::Impl&>(*impl);
@@ -392,13 +180,11 @@ void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters)
properties->renderPasses = mbgl::underlying_type(passes); properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties); evaluatedProperties = std::move(properties);
#if MLN_DRAWABLE_RENDERER
// The symbol tweaker supports updating properties. // The symbol tweaker supports updating properties.
// When the style changes, it will be replaced in `RenderLayer::layerChanged` // When the style changes, it will be replaced in `RenderLayer::layerChanged`
if (layerTweaker) { if (layerTweaker) {
layerTweaker->updateProperties(evaluatedProperties); layerTweaker->updateProperties(evaluatedProperties);
} }
#endif // MLN_DRAWABLE_RENDERER
} }
bool RenderSymbolLayer::hasTransition() const { bool RenderSymbolLayer::hasTransition() const {
@@ -409,258 +195,6 @@ bool RenderSymbolLayer::hasCrossfade() const {
return false; return false;
} }
#if MLN_LEGACY_RENDERER
void RenderSymbolLayer::render(PaintParameters& parameters) {
assert(renderTiles);
if (parameters.pass == RenderPass::Opaque) {
return;
}
if (!parameters.shaders.getLegacyGroup().populate(programs.symbolIconProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(programs.symbolSDFIconProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(programs.symbolSDFTextProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(programs.symbolTextAndIconProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(programs.collisionBoxProgram)) return;
if (!parameters.shaders.getLegacyGroup().populate(programs.collisionCircleProgram)) return;
const bool sortFeaturesByKey = !impl_cast(baseImpl).layout.get<SymbolSortKey>().isUndefined();
std::multiset<RenderableSegment> renderableSegments;
const auto draw = [&parameters, this](auto& programInstance,
const auto& uniformValues,
const auto& buffers,
const auto& segments,
const auto& symbolSizeBinder,
const auto& binders,
const auto& paintProperties,
const auto& textureBindings,
const std::string& suffix) {
const auto allUniformValues = programInstance.computeAllUniformValues(
uniformValues, *symbolSizeBinder, binders, paintProperties, static_cast<float>(parameters.state.getZoom()));
const auto allAttributeBindings = programInstance.computeAllAttributeBindings(*buffers.vertexBuffer,
*buffers.dynamicVertexBuffer,
*buffers.opacityVertexBuffer,
binders,
paintProperties);
this->checkRenderability(parameters, programInstance.activeBindingCount(allAttributeBindings));
segments.match(
[&](const SegmentWrapper& segment) {
programInstance.draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*buffers.indexBuffer,
segment,
allUniformValues,
allAttributeBindings,
textureBindings,
this->getID() + "/" + suffix);
},
[&](const SegmentVectorWrapper& segmentVector) {
programInstance.draw(parameters.context,
*parameters.renderPass,
gfx::Triangles(),
parameters.depthModeForSublayer(0, gfx::DepthMaskType::ReadOnly),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
*buffers.indexBuffer,
segmentVector,
allUniformValues,
allAttributeBindings,
textureBindings,
this->getID() + "/" + suffix);
});
};
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
auto& bucket = static_cast<SymbolBucket&>(*renderData->bucket);
assert(bucket.paintProperties.find(getID()) != bucket.paintProperties.end());
const auto& bucketPaintProperties = bucket.paintProperties.at(getID());
if (!static_cast<Bucket&>(bucket).check(SYM_GUARD_LOC)) {
continue;
}
// Prevent a flickering issue when a symbol is moved.
// bucket.justReloaded = false;
auto addRenderables =
[&renderableSegments, &tile, renderData, &bucketPaintProperties, it = renderableSegments.begin()](
auto& segments, const SymbolType type) mutable {
for (auto& segment : segments) {
it = renderableSegments.emplace_hint(it,
SegmentWrapper{std::ref(segment)},
tile,
*renderData,
bucketPaintProperties,
segment.sortKey,
type);
}
};
if (bucket.hasIconData()) {
if (sortFeaturesByKey) {
addRenderables(bucket.icon.segments, SymbolType::IconRGBA);
} else {
drawIcon(programs,
draw,
tile,
*renderData,
std::cref(bucket.icon.segments),
bucketPaintProperties,
parameters,
false /*sdfIcon*/
);
}
}
if (bucket.hasSdfIconData()) {
if (sortFeaturesByKey) {
addRenderables(bucket.sdfIcon.segments, SymbolType::IconSDF);
} else {
drawIcon(programs,
draw,
tile,
*renderData,
std::cref(bucket.sdfIcon.segments),
bucketPaintProperties,
parameters,
true /*sdfIcon*/
);
}
}
if (bucket.hasTextData()) {
if (sortFeaturesByKey) {
addRenderables(bucket.text.segments, SymbolType::Text);
} else {
drawText(programs,
draw,
tile,
*renderData,
std::cref(bucket.text.segments),
bucketPaintProperties,
parameters);
}
}
const auto drawCollisonData = [&](const bool isText,
const bool hasCollisionBox,
const bool hasCollisionCircle) {
if (!hasCollisionBox && !hasCollisionCircle) return;
static const style::Properties<>::PossiblyEvaluated properties{};
static const CollisionBoxProgram::Binders paintAttributeData(properties, 0);
const auto pixelRatio = tile.id.pixelsToTileUnits(1.0f, static_cast<float>(parameters.state.getZoom()));
const auto scale = static_cast<float>(
std::pow(2, parameters.state.getZoom() - tile.getOverscaledTileID().overscaledZ));
std::array<float, 2> extrudeScale = {{parameters.pixelsToGLUnits[0] / (pixelRatio * scale),
parameters.pixelsToGLUnits[1] / (pixelRatio * scale)}};
const auto& evaluated = getEvaluated<SymbolLayerProperties>(renderData->layerProperties);
const auto& layout = *bucket.layout;
const auto values = isText ? textPropertyValues(evaluated, layout) : iconPropertyValues(evaluated, layout);
const bool needTranslate = values.translate[0] != 0 || values.translate[1] != 0;
if (hasCollisionBox) {
const auto& collisionBox = isText ? bucket.textCollisionBox : bucket.iconCollisionBox;
programs.collisionBoxProgram->draw(
parameters.context,
*parameters.renderPass,
gfx::Lines{1.0f},
gfx::DepthMode::disabled(),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
CollisionBoxProgram::LayoutUniformValues{
uniforms::matrix::Value(
(needTranslate
? tile.translatedMatrix(values.translate, values.translateAnchor, parameters.state)
: tile.matrix)),
uniforms::extrude_scale::Value(extrudeScale),
uniforms::camera_to_center_distance::Value(parameters.state.getCameraToCenterDistance())},
*collisionBox->vertexBuffer,
*collisionBox->dynamicVertexBuffer,
*collisionBox->indexBuffer,
collisionBox->segments,
paintAttributeData,
properties,
CollisionBoxProgram::TextureBindings{},
static_cast<float>(parameters.state.getZoom()),
getID());
}
if (hasCollisionCircle) {
const auto& collisionCircle = isText ? bucket.textCollisionCircle : bucket.iconCollisionCircle;
programs.collisionCircleProgram->draw(
parameters.context,
*parameters.renderPass,
gfx::Triangles(),
gfx::DepthMode::disabled(),
gfx::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
gfx::CullFaceMode::disabled(),
CollisionCircleProgram::LayoutUniformValues{
uniforms::matrix::Value(
(needTranslate
? tile.translatedMatrix(values.translate, values.translateAnchor, parameters.state)
: tile.matrix)),
uniforms::extrude_scale::Value(extrudeScale),
uniforms::overscale_factor::Value(
static_cast<float>(tile.getOverscaledTileID().overscaleFactor())),
uniforms::camera_to_center_distance::Value(parameters.state.getCameraToCenterDistance())},
*collisionCircle->vertexBuffer,
*collisionCircle->dynamicVertexBuffer,
*collisionCircle->indexBuffer,
collisionCircle->segments,
paintAttributeData,
properties,
CollisionCircleProgram::TextureBindings{},
static_cast<float>(parameters.state.getZoom()),
getID());
}
};
drawCollisonData(false /*isText*/, bucket.hasIconCollisionBoxData(), bucket.hasIconCollisionCircleData());
drawCollisonData(true /*isText*/, bucket.hasTextCollisionBoxData(), bucket.hasTextCollisionCircleData());
}
if (sortFeaturesByKey) {
for (auto& renderable : renderableSegments) {
if (renderable.type == SymbolType::Text) {
drawText(programs,
draw,
renderable.tile,
renderable.renderData,
renderable.segment,
renderable.bucketPaintProperties,
parameters);
} else {
drawIcon(programs,
draw,
renderable.tile,
renderable.renderData,
renderable.segment,
renderable.bucketPaintProperties,
parameters,
renderable.type == SymbolType::IconSDF);
}
}
}
}
#endif // MLN_LEGACY_RENDERER
// static // static
style::IconPaintProperties::PossiblyEvaluated RenderSymbolLayer::iconPaintProperties( style::IconPaintProperties::PossiblyEvaluated RenderSymbolLayer::iconPaintProperties(
const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_) { const style::SymbolPaintProperties::PossiblyEvaluated& evaluated_) {
@@ -688,10 +222,7 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper
void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) { void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
renderTiles = params.source->getRenderTilesSortedByYPosition(); renderTiles = params.source->getRenderTilesSortedByYPosition();
#if MLN_DRAWABLE_RENDERER
updateRenderTileIDs(); updateRenderTileIDs();
#endif // MLN_DRAWABLE_RENDERER
addRenderPassesFromTiles(); addRenderPassesFromTiles();
placementData.clear(); placementData.clear();
@@ -710,7 +241,11 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
placementData.push_back({*bucket, renderTile, featureIndex, baseImpl->source, std::nullopt}); placementData.push_back({*bucket, renderTile, featureIndex, baseImpl->source, std::nullopt});
} else { } else {
for (const auto& sortKeyRange : bucket->sortKeyRanges) { for (const auto& sortKeyRange : bucket->sortKeyRanges) {
BucketPlacementData layerData{*bucket, renderTile, featureIndex, baseImpl->source, sortKeyRange}; BucketPlacementData layerData{.bucket = *bucket,
.tile = renderTile,
.featureIndex = featureIndex,
.sourceId = baseImpl->source,
.sortKeyRange = sortKeyRange};
auto sortPosition = std::upper_bound( auto sortPosition = std::upper_bound(
placementData.cbegin(), placementData.cend(), layerData, [](const auto& lhs, const auto& rhs) { placementData.cbegin(), placementData.cend(), layerData, [](const auto& lhs, const auto& rhs) {
assert(lhs.sortKeyRange && rhs.sortKeyRange); assert(lhs.sortKeyRange && rhs.sortKeyRange);
@@ -723,8 +258,6 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
} }
} }
#if MLN_DRAWABLE_RENDERER
namespace { namespace {
const SegmentVector<SymbolTextAttributes> emptySegmentVector; const SegmentVector<SymbolTextAttributes> emptySegmentVector;
constexpr auto posOffsetAttribName = "a_pos_offset"; constexpr auto posOffsetAttribName = "a_pos_offset";
@@ -1112,13 +645,15 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
for (const auto& segment : buffer.segments) { for (const auto& segment : buffer.segments) {
assert(segment.vertexOffset + segment.vertexLength <= buffer.vertices().elements()); assert(segment.vertexOffset + segment.vertexLength <= buffer.vertices().elements());
renderableSegments.emplace(SegmentGroup{ renderableSegments.emplace(SegmentGroup{
{segment, tile, renderData, bucketPaintProperties, segment.sortKey, type}, emptySegmentVector}); .renderable = {segment, tile, renderData, bucketPaintProperties, segment.sortKey, type},
.segments = emptySegmentVector});
} }
} else if (!buffer.segments.empty()) { } else if (!buffer.segments.empty()) {
// Features can be rendered in the order produced, and as grouped by the bucket // Features can be rendered in the order produced, and as grouped by the bucket
const auto& firstSeg = buffer.segments.front(); const auto& firstSeg = buffer.segments.front();
renderableSegments.emplace(SegmentGroup{ renderableSegments.emplace(
{firstSeg, tile, renderData, bucketPaintProperties, serialKey, type}, buffer.segments}); SegmentGroup{.renderable = {firstSeg, tile, renderData, bucketPaintProperties, serialKey, type},
.segments = buffer.segments});
serialKey += 1.0; serialKey += 1.0;
} }
}; };
@@ -1325,6 +860,4 @@ void RenderSymbolLayer::update(gfx::ShaderRegistry& shaders,
} }
} }
#endif // MLN_DRAWABLE_RENDERER
} // namespace mbgl } // namespace mbgl

View File

@@ -6,9 +6,7 @@
#include <mbgl/style/layers/symbol_layer_impl.hpp> #include <mbgl/style/layers/symbol_layer_impl.hpp>
#include <mbgl/style/layers/symbol_layer_properties.hpp> #include <mbgl/style/layers/symbol_layer_properties.hpp>
#if MLN_DRAWABLE_RENDERER
#include <unordered_map> #include <unordered_map>
#endif // MLN_DRAWABLE_RENDERER
namespace mbgl { namespace mbgl {
@@ -65,10 +63,8 @@ class SymbolTextAndIconProgram;
class CollisionBoxProgram; class CollisionBoxProgram;
class CollisionCircleProgram; class CollisionCircleProgram;
#if MLN_DRAWABLE_RENDERER
class SymbolLayerTweaker; class SymbolLayerTweaker;
using SymbolLayerTweakerPtr = std::shared_ptr<SymbolLayerTweaker>; using SymbolLayerTweakerPtr = std::shared_ptr<SymbolLayerTweaker>;
#endif // MLN_DRAWABLE_RENDERER
class RenderSymbolLayer final : public RenderLayer { class RenderSymbolLayer final : public RenderLayer {
public: public:
@@ -90,7 +86,6 @@ public:
static style::TextPaintProperties::PossiblyEvaluated textPaintProperties( static style::TextPaintProperties::PossiblyEvaluated textPaintProperties(
const style::SymbolPaintProperties::PossiblyEvaluated&); const style::SymbolPaintProperties::PossiblyEvaluated&);
#if MLN_DRAWABLE_RENDERER
/// Generate any changes needed by the layer /// Generate any changes needed by the layer
void update(gfx::ShaderRegistry&, void update(gfx::ShaderRegistry&,
gfx::Context&, gfx::Context&,
@@ -102,10 +97,7 @@ public:
/// Remove all the drawables for tiles /// Remove all the drawables for tiles
std::size_t removeAllDrawables() override; std::size_t removeAllDrawables() override;
#endif // MLN_DRAWABLE_RENDERER
protected: protected:
#if MLN_DRAWABLE_RENDERER
/// @brief Called by the RenderOrchestrator during RenderTree construction. /// @brief Called by the RenderOrchestrator during RenderTree construction.
/// This event is run to indicate if the layer should render or not for the current frame. /// This event is run to indicate if the layer should render or not for the current frame.
/// @param willRender Indicates if this layer should render or not /// @param willRender Indicates if this layer should render or not
@@ -124,18 +116,12 @@ protected:
/// Remove all drawables for the tile from the layer group /// Remove all drawables for the tile from the layer group
std::size_t removeTile(RenderPass, const OverscaledTileID&) override; std::size_t removeTile(RenderPass, const OverscaledTileID&) override;
#endif // MLN_DRAWABLE_RENDERER
private: private:
void transition(const TransitionParameters&) override; void transition(const TransitionParameters&) override;
void evaluate(const PropertyEvaluationParameters&) override; void evaluate(const PropertyEvaluationParameters&) override;
bool hasTransition() const override; bool hasTransition() const override;
bool hasCrossfade() const override; bool hasCrossfade() const override;
#if MLN_LEGACY_RENDERER
void render(PaintParameters&) override;
#endif // MLN_LEGACY_RENDERER
void prepare(const LayerPrepareParameters&) override; void prepare(const LayerPrepareParameters&) override;
private: private:
@@ -147,12 +133,6 @@ private:
bool hasFormatSectionOverrides = false; bool hasFormatSectionOverrides = false;
#if MLN_LEGACY_RENDERER
// Programs
Programs programs;
#endif // MLN_LEGACY_RENDERER
#if MLN_DRAWABLE_RENDERER
gfx::ShaderGroupPtr symbolIconGroup; gfx::ShaderGroupPtr symbolIconGroup;
gfx::ShaderGroupPtr symbolSDFGroup; gfx::ShaderGroupPtr symbolSDFGroup;
gfx::ShaderGroupPtr symbolTextAndIconGroup; gfx::ShaderGroupPtr symbolTextAndIconGroup;
@@ -162,7 +142,6 @@ private:
std::shared_ptr<TileLayerGroup> collisionTileLayerGroup; std::shared_ptr<TileLayerGroup> collisionTileLayerGroup;
LayerTweakerPtr collisionLayerTweaker; LayerTweakerPtr collisionLayerTweaker;
#endif // MLN_DRAWABLE_RENDERER
}; };
} // namespace mbgl } // namespace mbgl

Some files were not shown because too many files have changed in this diff Show More