[core] RenderTile shall never be created for a not renderable tile

A RenderTile is already never created for a not renderable tile, guarantied by the checks in `updateRenderables()`.

However, the client code had plenty of `isRenderable()` checks in the render path, which complicated the code and affected rendering performance.

This patch removes the unneeded checks from the client code and puts an assertion to `TilePyramid::addRenderTile()`.
This commit is contained in:
Mikhail Pozdnyakov
2019-05-13 11:25:29 +03:00
parent cd24f4c45f
commit 81823e35a6
5 changed files with 11 additions and 19 deletions

View File

@@ -617,8 +617,7 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper
}
void RenderSymbolLayer::setRenderTiles(RenderTiles tiles, const TransformState& state) {
auto filterFn = [](auto& tile){ return !tile.tile.isRenderable(); };
renderTiles = RenderLayer::filterRenderTiles(std::move(tiles), filterFn);
renderTiles = std::move(tiles);
// Sort symbol tiles in opposite y position, so tiles with overlapping symbols are drawn
// on top of each other, with lower symbols being drawn on top of higher symbols.
std::sort(renderTiles.begin(), renderTiles.end(), [&state](const auto& a, const auto& b) {

View File

@@ -40,8 +40,7 @@ bool RenderLayer::supportsZoom(float zoom) const {
}
void RenderLayer::setRenderTiles(RenderTiles tiles, const TransformState&) {
auto filterFn = [](auto& tile){ return !tile.tile.isRenderable() || tile.tile.holdForFade(); };
renderTiles = filterRenderTiles(std::move(tiles), filterFn);
renderTiles = filterRenderTiles(std::move(tiles));
}
const RenderLayerSymbolInterface* RenderLayer::getSymbolInterface() const {
@@ -52,16 +51,16 @@ optional<Color> RenderLayer::getSolidBackground() const {
return nullopt;
}
RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles, FilterFunctionPtr filterFn) const {
assert(filterFn != nullptr);
RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const {
RenderTiles filtered;
for (auto& tileRef : tiles) {
auto& tile = tileRef.get();
if (filterFn(tile)) {
auto& tile = tileRef.get().tile;
assert(tile.isRenderable());
if (tile.holdForFade()) {
continue;
}
filtered.emplace_back(tile);
filtered.emplace_back(tileRef);
}
return filtered;
}

View File

@@ -92,9 +92,6 @@ protected:
// in the console to inform the developer.
void checkRenderability(const PaintParameters&, uint32_t activeBindingCount);
using FilterFunctionPtr = bool (*)(RenderTile&);
RenderTiles filterRenderTiles(RenderTiles, FilterFunctionPtr) const;
protected:
// Stores current set of tiles to be rendered for this layer.
std::vector<std::reference_wrapper<RenderTile>> renderTiles;
@@ -104,6 +101,7 @@ protected:
RenderPass passes = RenderPass::None;
private:
RenderTiles filterRenderTiles(RenderTiles) const;
// Some layers may not render correctly on some hardware when the vertex attribute limit of
// that GPU is exceeded. More attributes are used when adding many data driven paint properties
// to a layer.

View File

@@ -130,7 +130,6 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
// use because they're still loading. In addition to that, we also need to retain all tiles that
// we're actively using, e.g. as a replacement for tile that aren't loaded yet.
std::set<OverscaledTileID> retain;
std::set<UnwrappedTileID> rendered;
auto retainTileFn = [&](Tile& tile, TileNecessity necessity) -> void {
if (retain.emplace(tile.id).second) {
@@ -178,7 +177,6 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
auto renderTileFn = [&](const UnwrappedTileID& tileID, Tile& tile) {
addRenderTile(tileID, tile);
rendered.emplace(tileID);
previouslyRenderedTiles.erase(tileID); // Still rendering this tile, no need for special fading logic.
tile.markRenderedIdeal();
};
@@ -201,7 +199,6 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
// Don't mark the tile "Required" to avoid triggering a new network request
retainTileFn(tile, TileNecessity::Optional);
addRenderTile(previouslyRenderedTile.first, tile);
rendered.emplace(previouslyRenderedTile.first);
}
}
@@ -242,7 +239,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
// Initialize render tiles fields and update the tile contained layer render data.
for (RenderTile& renderTile : renderTiles) {
Tile& tile = renderTile.tile;
if (!tile.isRenderable()) continue;
assert(tile.isRenderable());
const bool holdForFade = tile.holdForFade();
for (const auto& layerProperties : layers) {
@@ -392,6 +389,7 @@ void TilePyramid::clearAll() {
}
void TilePyramid::addRenderTile(const UnwrappedTileID& tileID, Tile& tile) {
assert(tile.isRenderable());
auto it = std::lower_bound(renderTiles.begin(), renderTiles.end(), tileID,
[](const RenderTile& a, const UnwrappedTileID& id) { return a.id < id; });
renderTiles.emplace(it, tileID, tile);

View File

@@ -174,9 +174,7 @@ bool CrossTileSymbolIndex::addLayer(const RenderLayerSymbolInterface& symbolInte
layerIndex.handleWrapJump(lng);
for (const RenderTile& renderTile : symbolInterface.getRenderTiles()) {
if (!renderTile.tile.isRenderable()) {
continue;
}
assert(renderTile.tile.isRenderable());
auto bucket = symbolInterface.getSymbolBucket(renderTile);
if (!bucket) {