Add Tracy instrumentation for CPU and GPU in OpenGL mode. (#2417)

This commit is contained in:
alasram
2024-06-17 10:20:14 -07:00
committed by GitHub
parent 30484d8f50
commit 4f0f3bac51
45 changed files with 1091 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
#include <mbgl/tile/geometry_tile_data.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/math/clamp.hpp>
#include <mbgl/util/instrumentation.hpp>
#ifdef _MSC_VER
#pragma warning(push)
@@ -28,6 +29,8 @@ static double signedArea(const GeometryCoordinates& ring) {
}
static LinearRing<int32_t> toWagyuPath(const GeometryCoordinates& ring) {
MLN_TRACE_FUNC();
LinearRing<int32_t> result;
result.reserve(ring.size());
for (const auto& p : ring) {
@@ -37,6 +40,8 @@ static LinearRing<int32_t> toWagyuPath(const GeometryCoordinates& ring) {
}
static GeometryCollection toGeometryCollection(MultiPolygon<int16_t>&& multipolygon) {
MLN_TRACE_FUNC();
GeometryCollection result;
for (auto& polygon : multipolygon) {
for (auto& ring : polygon) {
@@ -47,6 +52,8 @@ static GeometryCollection toGeometryCollection(MultiPolygon<int16_t>&& multipoly
}
GeometryCollection fixupPolygons(const GeometryCollection& rings) {
MLN_TRACE_FUNC();
using namespace mapbox::geometry::wagyu;
wagyu<int32_t> clipper;
@@ -62,6 +69,8 @@ GeometryCollection fixupPolygons(const GeometryCollection& rings) {
}
std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) {
MLN_TRACE_FUNC();
std::vector<GeometryCollection> polygons;
std::size_t len = rings.size();
@@ -98,6 +107,8 @@ std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) {
}
void limitHoles(GeometryCollection& polygon, uint32_t maxHoles) {
MLN_TRACE_FUNC();
if (polygon.size() > 1 + maxHoles) {
std::nth_element(
polygon.begin() + 1, polygon.begin() + 1 + maxHoles, polygon.end(), [](const auto& a, const auto& b) {
@@ -108,6 +119,8 @@ void limitHoles(GeometryCollection& polygon, uint32_t maxHoles) {
}
Feature::geometry_type convertGeometry(const GeometryTileFeature& geometryTileFeature, const CanonicalTileID& tileID) {
MLN_TRACE_FUNC();
const double size = util::EXTENT * std::pow(2, tileID.z);
const double x0 = util::EXTENT * static_cast<double>(tileID.x);
const double y0 = util::EXTENT * static_cast<double>(tileID.y);
@@ -179,6 +192,8 @@ Feature::geometry_type convertGeometry(const GeometryTileFeature& geometryTileFe
}
GeometryCollection convertGeometry(const Feature::geometry_type& geometryTileFeature, const CanonicalTileID& tileID) {
MLN_TRACE_FUNC();
const double size = util::EXTENT * std::pow(2, tileID.z);
const double x0 = util::EXTENT * static_cast<double>(tileID.x);
const double y0 = util::EXTENT * static_cast<double>(tileID.y);
@@ -260,6 +275,8 @@ GeometryCollection convertGeometry(const Feature::geometry_type& geometryTileFea
}
Feature convertFeature(const GeometryTileFeature& geometryTileFeature, const CanonicalTileID& tileID) {
MLN_TRACE_FUNC();
Feature feature{convertGeometry(geometryTileFeature, tileID)};
feature.properties = geometryTileFeature.getProperties();
feature.id = geometryTileFeature.getID();