Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ cc_library(
"//vendor:unordered_dense",
"//vendor:vector-tile",
"//vendor:wagyu",
"@maplibre_tile_spec//cpp:mlt_cpp",
] + select({
"@platforms//os:ios": [
"//vendor:ghc_filesystem",
Expand Down Expand Up @@ -184,6 +183,7 @@ cc_library(
],
"//conditions:default": [
"//vendor:csscolorparser",
"@maplibre_tile_spec//cpp:mlt_cpp",
],
}),
)
Expand Down
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ list(APPEND SRC_FILES
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_tile.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mlt_tile.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mlt_tile.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mlt_tile_data.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mlt_tile_data$<IF:$<BOOL:${MLN_USE_RUST}>,.rs.cpp,.cpp>
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mlt_tile_data.hpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mvt_tile.cpp
${PROJECT_SOURCE_DIR}/src/mbgl/tile/vector_mvt_tile.hpp
Expand Down Expand Up @@ -1113,7 +1113,9 @@ include(${PROJECT_SOURCE_DIR}/vendor/unordered_dense.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/vector-tile.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/wagyu.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/metal-cpp.cmake)
if(NOT MLN_USE_RUST)
include(${PROJECT_SOURCE_DIR}/vendor/maplibre-tile-spec.cmake)
endif()
include(${PROJECT_SOURCE_DIR}/vendor/supercluster.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/expected-lite.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/kdbush.cmake)
Expand Down Expand Up @@ -1142,7 +1144,7 @@ target_link_libraries(
mbgl-vendor-unique_resource
mbgl-vendor-vector-tile
mbgl-vendor-wagyu
mlt-cpp
$<$<NOT:$<BOOL:${MLN_USE_RUST}>>:mlt-cpp>
$<$<BOOL:${MLN_WITH_METAL}>:mbgl-vendor-metal-cpp>
$<IF:$<BOOL:${MLN_USE_RUST}>,mbgl-rustutils,mbgl-vendor-csscolorparser>
$<$<BOOL:${MLN_TEXT_SHAPING_HARFBUZZ}>:mbgl-freetype>
Expand Down Expand Up @@ -1186,14 +1188,13 @@ set(EXPORT_TARGETS
mbgl-vendor-unique_resource
mbgl-vendor-vector-tile
mbgl-vendor-wagyu
mlt-cpp
unordered_dense
)

if(MLN_USE_RUST)
list(APPEND EXPORT_TARGETS mbgl-rustutils rustutils)
else()
list(APPEND EXPORT_TARGETS mbgl-vendor-csscolorparser)
list(APPEND EXPORT_TARGETS mbgl-vendor-csscolorparser mlt-cpp)
endif()

if(MLN_TEXT_SHAPING_HARFBUZZ)
Expand Down
3 changes: 2 additions & 1 deletion bazel/core.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ MLN_CORE_SOURCE = [
"src/mbgl/tile/vector_tile.hpp",
"src/mbgl/tile/vector_mlt_tile.cpp",
"src/mbgl/tile/vector_mlt_tile.hpp",
"src/mbgl/tile/vector_mlt_tile_data.cpp",
"src/mbgl/tile/vector_mlt_tile_data.hpp",
"src/mbgl/tile/vector_mvt_tile.cpp",
"src/mbgl/tile/vector_mvt_tile.hpp",
Expand Down Expand Up @@ -615,9 +614,11 @@ MLN_CORE_SOURCE = [
"src/mbgl/util/work_request.cpp",
] + select({
"//:rust": [
"src/mbgl/tile/vector_mlt_tile_data.rs.cpp",
"src/mbgl/util/color.rs.cpp",
],
"//conditions:default": [
"src/mbgl/tile/vector_mlt_tile_data.cpp",
"src/mbgl/util/color.cpp",
],
})
Expand Down
1 change: 1 addition & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ add_library(
${PROJECT_SOURCE_DIR}/benchmark/function/composite_function.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/function/source_function.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/parse/filter.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/parse/mlt_tile.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/parse/tile_mask.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/parse/vector_tile.benchmark.cpp
${PROJECT_SOURCE_DIR}/benchmark/renderer/group_layers.benchmark.cpp
Expand Down
76 changes: 76 additions & 0 deletions benchmark/parse/mlt_tile.benchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <benchmark/benchmark.h>

#include <mbgl/tile/vector_mlt_tile_data.hpp>
#include <mbgl/util/io.hpp>

#include <memory>
#include <string>

namespace {

std::shared_ptr<const std::string> fixtureData(bool useFastPFOR) {
static const auto data = std::make_shared<const std::string>(
mbgl::util::read_file("test/fixtures/map/issue12432/0-0-0.mlt"));
static const auto fastPFORData = std::make_shared<const std::string>(
mbgl::util::read_file("test/fixtures/map/issue12432/0-0-0-fastpfor.mlt"));

return useFastPFOR ? fastPFORData : data;
}

std::size_t visitTile(const std::shared_ptr<const std::string>& data, bool fastPFOREnabled) {
mbgl::VectorMLTTileData tile(data, fastPFOREnabled);

std::size_t result = 0;
for (const auto& name : tile.layerNames()) {
auto layer = tile.getLayer(name);
if (!layer) {
continue;
}

const auto featureCount = layer->featureCount();
result += featureCount;
for (std::size_t i = 0; i < featureCount; ++i) {
auto feature = layer->getFeature(i);
result += static_cast<std::size_t>(feature->getType());
result += feature->getProperties().size();

const auto& geometries = feature->getGeometries();
result += geometries.size();
result += geometries.getTriangles().size();
for (const auto& geometry : geometries) {
result += geometry.size();
}
}
}

return result;
}

void Parse_MLTVectorTile(benchmark::State& state) {
const auto data = fixtureData(state.range(0) != 0);

for (auto _ : state) {
mbgl::VectorMLTTileData tile(data, true);
auto layerNames = tile.layerNames();
auto layerNameCount = layerNames.size();
benchmark::DoNotOptimize(layerNameCount);
}

state.SetBytesProcessed(static_cast<int64_t>(state.iterations() * data->size()));
}

void ParseAndAccess_MLTVectorTile(benchmark::State& state) {
const auto data = fixtureData(state.range(0) != 0);

for (auto _ : state) {
auto result = visitTile(data, true);
benchmark::DoNotOptimize(result);
}

state.SetBytesProcessed(static_cast<int64_t>(state.iterations() * data->size()));
}

} // namespace

BENCHMARK(Parse_MLTVectorTile)->Arg(0)->Arg(1)->Unit(benchmark::kMillisecond);
BENCHMARK(ParseAndAccess_MLTVectorTile)->Arg(0)->Arg(1)->Unit(benchmark::kMillisecond);
7 changes: 6 additions & 1 deletion rustutils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ genrule(
name = "cpp_bindings",
srcs = [
"src/color.rs",
"src/mlt.rs",
],
outs = [
"cpp/include/rustutils/color.hpp",
"cpp/include/rustutils/mlt.hpp",
"cpp/src/color.rs.cpp",
"cpp/src/mlt.rs.cpp",
],
cmd = "CXXBRIDGE_CMD=$(location @cxx.rs//:codegen) ./$(location :generate.sh) $(@D) $(SRCS)",
cmd = "CXXBRIDGE_CMD=$(location @cxx.rs//:codegen) bash ./$(location :generate.sh) $(@D) $(SRCS)",
# Using the cxxbridge binary built by Bazel
tools = [
":generate.sh",
Expand All @@ -23,12 +26,14 @@ rust_static_library(
srcs = [
"src/color.rs",
"src/lib.rs",
"src/mlt.rs",
],
crate_name = "rustutils",
visibility = ["//visibility:public"],
deps = [
"@crates//:csscolorparser",
"@crates//:cxx",
"@crates//:mlt_core",
],
)

Expand Down
Loading
Loading