-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] TilePyramid has sorted render tiles #13739
Conversation
src/mbgl/renderer/tile_pyramid.cpp
Outdated
std::sort(sortedTiles.begin(), sortedTiles.end(), [](const RenderTile& a, const RenderTile& b) { | ||
return std::tie(a.id.canonical.z, a.id.canonical.y, a.id.wrap, a.id.canonical.x) < | ||
std::tie(b.id.canonical.z, b.id.canonical.y, b.id.wrap, b.id.canonical.x); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sort function sorts differently from the standard UnwrappedTileID's operator<
function: It sorts by (z, y, wrap, x), while UnwrappedTileID::operator<
sorts by (wrap, z, x, y). I'm not sure why we sort this way here, but might be worth investigating how a different sort order affects feature querying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks for pointing that out!
@@ -43,7 +43,7 @@ RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const | |||
} | |||
|
|||
void RenderLayer::sortRenderTiles(const TransformState&) { | |||
std::sort(renderTiles.begin(), renderTiles.end(), [](const auto& a, const auto& b) { return a.get().id < b.get().id; }); | |||
// no-op |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this function is a no-op, we can remove it entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RenderSymbolLayer
still overrides it, however this is something I'd like to change in the following PR.
src/mbgl/renderer/tile_pyramid.cpp
Outdated
@@ -53,7 +53,7 @@ void TilePyramid::finishRender(PaintParameters& parameters) { | |||
} | |||
|
|||
std::vector<std::reference_wrapper<RenderTile>> TilePyramid::getRenderTiles() { | |||
return { renderTiles.begin(), renderTiles.end() }; | |||
return sortedTiles; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of maintaining two vectors in parallel, can we just sort renderTiles
, and create the reference-wrapped copy of the vector in this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RenderTile
does not have a default constructor, so std::swap
cannot handle it, therefore standard algorithms look not applicable there :-/
1ae224e
to
1c18585
Compare
@kkaefer Thanks for your comments! Could you take another look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the spelling error in the commit message?
Thus we obviate unneeded extra sorting of render tiles at each render layer.
1c18585
to
f564baa
Compare
Thus we obviate unneeded extra sorting of render tiles at each render layer.