summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2019-04-02 14:11:37 +0200
committerKonstantin Käfer <mail@kkaefer.com>2019-05-15 11:57:43 -0700
commitda5bd4d6e3a0202cc4f9e4d3d17e159eb90acba6 (patch)
tree9450b28ea53804129de6cc049404bbef2b83778c
parentd5e7fabf455d3e8e6cb852fa544649c8012d70ed (diff)
downloadqtlocation-mapboxgl-da5bd4d6e3a0202cc4f9e4d3d17e159eb90acba6.tar.gz
[core] use unique IDs for DrawScopes
-rw-r--r--include/mbgl/util/string.hpp3
-rw-r--r--src/core-files.json2
-rw-r--r--src/mbgl/programs/gl/shaders.cpp4
-rw-r--r--src/mbgl/programs/program_parameters.cpp2
-rw-r--r--src/mbgl/renderer/buckets/debug_bucket.cpp3
-rw-r--r--src/mbgl/renderer/buckets/raster_bucket.cpp7
-rw-r--r--src/mbgl/renderer/buckets/raster_bucket.hpp1
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp14
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp22
-rw-r--r--src/mbgl/renderer/paint_parameters.cpp2
-rw-r--r--src/mbgl/renderer/render_tile.cpp6
-rw-r--r--src/mbgl/util/id.cpp14
-rw-r--r--src/mbgl/util/id.hpp11
-rw-r--r--src/mbgl/util/string.cpp6
14 files changed, 72 insertions, 25 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp
index 418e1872f3..1e0f512ba8 100644
--- a/include/mbgl/util/string.hpp
+++ b/include/mbgl/util/string.hpp
@@ -70,7 +70,8 @@ std::string toString(std::exception_ptr);
template <class T>
std::string toString(T) = delete;
-std::string toHex(size_t);
+std::string toHex(uint32_t);
+std::string toHex(uint64_t);
inline float stof(const std::string& str) {
return std::stof(str);
diff --git a/src/core-files.json b/src/core-files.json
index d721935268..b5b131461b 100644
--- a/src/core-files.json
+++ b/src/core-files.json
@@ -290,6 +290,7 @@
"src/mbgl/util/http_header.cpp",
"src/mbgl/util/http_timeout.cpp",
"src/mbgl/util/i18n.cpp",
+ "src/mbgl/util/id.cpp",
"src/mbgl/util/interpolate.cpp",
"src/mbgl/util/intersection_tests.cpp",
"src/mbgl/util/io.cpp",
@@ -749,6 +750,7 @@
"mbgl/util/http_header.hpp": "src/mbgl/util/http_header.hpp",
"mbgl/util/http_timeout.hpp": "src/mbgl/util/http_timeout.hpp",
"mbgl/util/i18n.hpp": "src/mbgl/util/i18n.hpp",
+ "mbgl/util/id.hpp": "src/mbgl/util/id.hpp",
"mbgl/util/intersection_tests.hpp": "src/mbgl/util/intersection_tests.hpp",
"mbgl/util/io.hpp": "src/mbgl/util/io.hpp",
"mbgl/util/literal.hpp": "src/mbgl/util/literal.hpp",
diff --git a/src/mbgl/programs/gl/shaders.cpp b/src/mbgl/programs/gl/shaders.cpp
index 6fb4d70db9..e8c9bdfc3c 100644
--- a/src/mbgl/programs/gl/shaders.cpp
+++ b/src/mbgl/programs/gl/shaders.cpp
@@ -16,8 +16,8 @@ std::string programIdentifier(const std::string& defines1,
const uint8_t hash2[8]) {
std::string result;
result.reserve(8 + 8 + (sizeof(size_t) * 2) * 2 + 2);
- result.append(util::toHex(std::hash<std::string>()(defines1)));
- result.append(util::toHex(std::hash<std::string>()(defines2)));
+ result.append(util::toHex(static_cast<uint64_t>(std::hash<std::string>()(defines1))));
+ result.append(util::toHex(static_cast<uint64_t>(std::hash<std::string>()(defines2))));
result.append(hash1, hash2 + 8);
result.append(hash2, hash2 + 8);
result.append("v3");
diff --git a/src/mbgl/programs/program_parameters.cpp b/src/mbgl/programs/program_parameters.cpp
index e692b74e0e..a49dc2bc88 100644
--- a/src/mbgl/programs/program_parameters.cpp
+++ b/src/mbgl/programs/program_parameters.cpp
@@ -34,7 +34,7 @@ optional<std::string> ProgramParameters::cachePath(const char* name) const {
result += "/com.mapbox.gl.shader.";
result += name;
result += '.';
- result += util::toHex(std::hash<std::string>()(defines));
+ result += util::toHex(static_cast<uint64_t>(std::hash<std::string>()(defines)));
result += ".pbf";
return result;
}
diff --git a/src/mbgl/renderer/buckets/debug_bucket.cpp b/src/mbgl/renderer/buckets/debug_bucket.cpp
index 36cc0da188..7b2f5c05ed 100644
--- a/src/mbgl/renderer/buckets/debug_bucket.cpp
+++ b/src/mbgl/renderer/buckets/debug_bucket.cpp
@@ -3,6 +3,7 @@
#include <mbgl/geometry/debug_font_data.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/id.hpp>
#include <cmath>
#include <string>
@@ -22,7 +23,7 @@ DebugBucket::DebugBucket(const OverscaledTileID& id,
modified(std::move(modified_)),
expires(std::move(expires_)),
debugMode(debugMode_),
- drawScopeID("__debug/borders/" + util::toString(id)) {
+ drawScopeID("__debug/" + util::toHex(util::nextID())) {
gfx::VertexVector<FillLayoutVertex> vertices;
gfx::IndexVector<gfx::Lines> indices;
diff --git a/src/mbgl/renderer/buckets/raster_bucket.cpp b/src/mbgl/renderer/buckets/raster_bucket.cpp
index a8cb47d52c..7afb6172f5 100644
--- a/src/mbgl/renderer/buckets/raster_bucket.cpp
+++ b/src/mbgl/renderer/buckets/raster_bucket.cpp
@@ -2,17 +2,20 @@
#include <mbgl/renderer/layers/render_raster_layer.hpp>
#include <mbgl/programs/raster_program.hpp>
#include <mbgl/gfx/context.hpp>
+#include <mbgl/util/id.hpp>
namespace mbgl {
using namespace style;
RasterBucket::RasterBucket(PremultipliedImage&& image_)
- : image(std::make_shared<PremultipliedImage>(std::move(image_))) {
+ : image(std::make_shared<PremultipliedImage>(std::move(image_))),
+ drawScopeID(util::toHex(util::nextID())) {
}
RasterBucket::RasterBucket(std::shared_ptr<PremultipliedImage> image_)
- : image(std::move(image_)) {
+ : image(std::move(image_)),
+ drawScopeID(util::toHex(util::nextID())) {
}
RasterBucket::~RasterBucket() = default;
diff --git a/src/mbgl/renderer/buckets/raster_bucket.hpp b/src/mbgl/renderer/buckets/raster_bucket.hpp
index 143daf3348..db1de4d0d1 100644
--- a/src/mbgl/renderer/buckets/raster_bucket.hpp
+++ b/src/mbgl/renderer/buckets/raster_bucket.hpp
@@ -38,6 +38,7 @@ public:
optional<gfx::VertexBuffer<RasterLayoutVertex>> vertexBuffer;
optional<gfx::IndexBuffer> indexBuffer;
+ const std::string drawScopeID;
};
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index 48ca0584fc..8569303a06 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -83,7 +83,8 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
const auto& vertexBuffer,
const auto& indexBuffer,
const auto& segments,
- const auto& textureBindings) {
+ const auto& textureBindings,
+ const std::string& drawScopeID) {
auto& programInstance = parameters.programs.getRasterLayerPrograms().raster;
const auto allUniformValues = programInstance.computeAllUniformValues(
@@ -125,7 +126,7 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
allUniformValues,
allAttributeBindings,
textureBindings,
- getID()
+ getID() + "/" + drawScopeID
);
};
@@ -144,7 +145,8 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
RasterProgram::TextureBindings{
textures::image0::Value{ bucket.texture->getResource(), filter },
textures::image1::Value{ bucket.texture->getResource(), filter },
- });
+ },
+ bucket.drawScopeID);
}
}
} else {
@@ -168,7 +170,8 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
RasterProgram::TextureBindings{
textures::image0::Value{ bucket.texture->getResource(), filter },
textures::image1::Value{ bucket.texture->getResource(), filter },
- });
+ },
+ bucket.drawScopeID);
} else {
// Draw the full tile.
draw(parameters.matrixForTile(tile.id, true),
@@ -178,7 +181,8 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
RasterProgram::TextureBindings{
textures::image0::Value{ bucket.texture->getResource(), filter },
textures::image1::Value{ bucket.texture->getResource(), filter },
- });
+ },
+ bucket.drawScopeID);
}
}
}
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 5c0aea0eac..9429cff469 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -166,7 +166,8 @@ void drawIcon(const DrawFn& draw,
paintPropertyValues,
SymbolSDFIconProgram::TextureBindings{
textureBinding
- });
+ },
+ "halo");
}
if (values.hasFill) {
@@ -180,7 +181,8 @@ void drawIcon(const DrawFn& draw,
paintPropertyValues,
SymbolSDFIconProgram::TextureBindings{
textureBinding
- });
+ },
+ "fill");
}
} else {
draw(parameters.programs.getSymbolLayerPrograms().symbolIcon,
@@ -193,7 +195,8 @@ void drawIcon(const DrawFn& draw,
paintPropertyValues,
SymbolIconProgram::TextureBindings{
textureBinding
- });
+ },
+ "icon");
}
}
@@ -311,7 +314,8 @@ void drawText(const DrawFn& draw,
paintPropertyValues,
SymbolSDFTextProgram::TextureBindings{
textureBinding
- });
+ },
+ "halo");
}
if (values.hasFill) {
@@ -325,7 +329,8 @@ void drawText(const DrawFn& draw,
paintPropertyValues,
SymbolSDFTextProgram::TextureBindings{
textureBinding
- });
+ },
+ "fill");
}
}
@@ -409,7 +414,8 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
const SymbolPropertyValues& values_,
const auto& binders,
const auto& paintProperties,
- const auto& textureBindings) {
+ const auto& textureBindings,
+ const std::string& suffix) {
const auto allUniformValues = programInstance.computeAllUniformValues(
uniformValues,
*symbolSizeBinder,
@@ -445,7 +451,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
allUniformValues,
allAttributeBindings,
textureBindings,
- this->getID()
+ this->getID() + "/" + suffix
);
},
[&](const std::reference_wrapper<SegmentVector<SymbolTextAttributes>>& segmentVector) {
@@ -464,7 +470,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
allUniformValues,
allAttributeBindings,
textureBindings,
- this->getID()
+ this->getID() + "/" + suffix
);
}
);
diff --git a/src/mbgl/renderer/paint_parameters.cpp b/src/mbgl/renderer/paint_parameters.cpp
index 33a741865e..e31392902e 100644
--- a/src/mbgl/renderer/paint_parameters.cpp
+++ b/src/mbgl/renderer/paint_parameters.cpp
@@ -151,7 +151,7 @@ void PaintParameters::renderTileClippingMasks(const std::vector<std::reference_w
properties
),
ClippingMaskProgram::TextureBindings{},
- "clipping"
+ "clipping/" + util::toString(stencilID)
);
}
}
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index e175b761fe..2c2a82a8a8 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -117,7 +117,7 @@ void RenderTile::finishRender(PaintParameters& parameters) {
),
allAttributeBindings,
DebugProgram::TextureBindings{},
- "__debug/text-outline"
+ "__debug/" + tile.debugBucket->drawScopeID + "/text-outline"
);
program.draw(
@@ -141,7 +141,7 @@ void RenderTile::finishRender(PaintParameters& parameters) {
),
allAttributeBindings,
DebugProgram::TextureBindings{},
- "__debug/text"
+ "__debug/" + tile.debugBucket->drawScopeID + "/text"
);
}
@@ -172,7 +172,7 @@ void RenderTile::finishRender(PaintParameters& parameters) {
properties
),
DebugProgram::TextureBindings{},
- tile.debugBucket->drawScopeID
+ "__debug/" + tile.debugBucket->drawScopeID
);
}
}
diff --git a/src/mbgl/util/id.cpp b/src/mbgl/util/id.cpp
new file mode 100644
index 0000000000..4486194de4
--- /dev/null
+++ b/src/mbgl/util/id.cpp
@@ -0,0 +1,14 @@
+#include <mbgl/util/id.hpp>
+
+#include <atomic>
+
+namespace mbgl {
+namespace util {
+
+uint64_t nextID() {
+ static std::atomic<uint64_t> GUID { 0 };
+ return GUID++;
+}
+
+} // namespace util
+} // namespace mbgl
diff --git a/src/mbgl/util/id.hpp b/src/mbgl/util/id.hpp
new file mode 100644
index 0000000000..12e23dfc2d
--- /dev/null
+++ b/src/mbgl/util/id.hpp
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <cstdint>
+
+namespace mbgl {
+namespace util {
+
+uint64_t nextID();
+
+} // namespace util
+} // namespace mbgl
diff --git a/src/mbgl/util/string.cpp b/src/mbgl/util/string.cpp
index 5d3e44bff6..6f7e02e5e2 100644
--- a/src/mbgl/util/string.cpp
+++ b/src/mbgl/util/string.cpp
@@ -80,7 +80,11 @@ std::string toPaddedHex(T x) {
} // namespace
-std::string toHex(size_t value) {
+std::string toHex(uint32_t value) {
+ return toPaddedHex(value);
+}
+
+std::string toHex(uint64_t value) {
return toPaddedHex(value);
}