[core] use unique IDs for DrawScopes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
|
||||
optional<gfx::VertexBuffer<RasterLayoutVertex>> vertexBuffer;
|
||||
optional<gfx::IndexBuffer> indexBuffer;
|
||||
const std::string drawScopeID;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -151,7 +151,7 @@ void PaintParameters::renderTileClippingMasks(const std::vector<std::reference_w
|
||||
properties
|
||||
),
|
||||
ClippingMaskProgram::TextureBindings{},
|
||||
"clipping"
|
||||
"clipping/" + util::toString(stencilID)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/mbgl/util/id.cpp
Normal file
14
src/mbgl/util/id.cpp
Normal file
@@ -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
|
||||
11
src/mbgl/util/id.hpp
Normal file
11
src/mbgl/util/id.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
uint64_t nextID();
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user