Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Synchronize render passes and render tiles #15092

Merged
merged 2 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/mbgl/style/layer_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class LayerProperties {
// Returns constants mask for the data-driven properties.
virtual unsigned long constantsMask() const { return 0u; }
Immutable<Layer::Impl> baseImpl;
// Contains render passes used by the renderer, see `mbgl::RenderPass`.
uint8_t renderPasses = 0u;

protected:
LayerProperties(Immutable<Layer::Impl> impl) : baseImpl(std::move(impl)) {}
Expand Down
3 changes: 2 additions & 1 deletion platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to

## master

* Performance improvements for queryRenderedFeatures API and optimization that allocates containers based on a number of rendered layers. ([#14930](https://github.com/mapbox/mapbox-gl-native/pull/14930))
- Fixed a map update bug caused by the render tiles and the render passes getting unsynchronized [#15092](https://github.com/mapbox/mapbox-gl-native/pull/15092)
- Performance improvements for queryRenderedFeatures API and optimization that allocates containers based on a number of rendered layers [#14930](https://github.com/mapbox/mapbox-gl-native/pull/14930)
- Fixed rendering layers after fill-extrusion regression caused by optimization of fill-extrusion rendering [#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065)

## 8.2.0-alpha.2 - July 3, 2019
Expand Down
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT

### Styles and rendering

* Fixed a map update bug caused by the render tiles and the render passes getting unsynchronized. ([#15092](https://github.com/mapbox/mapbox-gl-native/pull/15092))
* The `MGLIdeographicFontFamilyName` Info.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value of `NO` to force the SDK to typeset CJK characters in a remote font specified by `MGLSymbolStyleLayer.textFontNames`. ([#14862](https://github.com/mapbox/mapbox-gl-native/pull/14862))
* Hiragana and katakana are now included in the range of CJK glyphs that are rendered locally by default. ([#15009](https://github.com/mapbox/mapbox-gl-native/pull/15009))
* Added the `-[MGLMapViewDelegate mapView:shouldRemoveStyleImage:]` method for optimizing style image caching. ([#14769](https://github.com/mapbox/mapbox-gl-native/pull/14769))
Expand Down
7 changes: 4 additions & 3 deletions src/mbgl/renderer/layers/render_background_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void RenderBackgroundLayer::evaluate(const PropertyEvaluationParameters &paramet

passes = properties->evaluated.get<style::BackgroundOpacity>() > 0 ? RenderPass::Translucent
: RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand Down Expand Up @@ -133,8 +134,8 @@ void RenderBackgroundLayer::render(PaintParameters& parameters) {
}

optional<Color> RenderBackgroundLayer::getSolidBackground() const {
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
if (!evaluated.get<BackgroundPattern>().from.empty()) {
const auto& evaluated = getEvaluated<BackgroundLayerProperties>(evaluatedProperties);
if (!evaluated.get<BackgroundPattern>().from.empty() || evaluated.get<style::BackgroundOpacity>() <= 0.0f) {
return nullopt;
}

Expand All @@ -152,7 +153,7 @@ void addPatternIfNeeded(const std::string& id, const LayerPrepareParameters& par
} // namespace

void RenderBackgroundLayer::prepare(const LayerPrepareParameters& params) {
const auto& evaluated = static_cast<const BackgroundLayerProperties&>(*evaluatedProperties).evaluated;
const auto& evaluated = getEvaluated<BackgroundLayerProperties>(evaluatedProperties);
if (!evaluated.get<BackgroundPattern>().to.empty()) {
// Ensures that the pattern bitmap gets copied to atlas bitmap.
// Atlas bitmap is uploaded to atlas texture in upload.
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/render_circle_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void RenderCircleLayer::evaluate(const PropertyEvaluationParameters& parameters)
&& (evaluated.get<style::CircleOpacity>().constantOr(1) > 0 ||
evaluated.get<style::CircleStrokeOpacity>().constantOr(1) > 0))
? RenderPass::Translucent : RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand All @@ -59,7 +60,7 @@ void RenderCircleLayer::render(PaintParameters& parameters) {
}

for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down
7 changes: 4 additions & 3 deletions src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void RenderFillExtrusionLayer::evaluate(const PropertyEvaluationParameters& para
passes = (properties->evaluated.get<style::FillExtrusionOpacity>() > 0)
? (RenderPass::Translucent | RenderPass::Pass3D)
: RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand All @@ -67,7 +68,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {

const auto& evaluated = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).evaluated;
const auto& crossfade = static_cast<const FillExtrusionLayerProperties&>(*evaluatedProperties).crossfade;
if (evaluated.get<FillExtrusionOpacity>() == 0) {
if (evaluatedProperties->renderPasses == mbgl::underlying_type(RenderPass::None)) {
return;
}

Expand Down Expand Up @@ -121,7 +122,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
// Draw solid color extrusions
auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down Expand Up @@ -168,7 +169,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters) {
const auto fillPatternValue = evaluated.get<FillExtrusionPattern>().constantOr(mbgl::Faded<std::basic_string<char> >{"", ""});
auto drawTiles = [&](const gfx::StencilMode& stencilMode_, const gfx::ColorMode& colorMode_, const std::string& name) {
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/layers/render_fill_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void RenderFillLayer::evaluate(const PropertyEvaluationParameters& parameters) {
} else {
passes |= RenderPass::Opaque;
}

properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand All @@ -77,7 +77,7 @@ void RenderFillLayer::render(PaintParameters& parameters) {
if (unevaluated.get<FillPattern>().isUndefined()) {
parameters.renderTileClippingMasks(renderTiles);
for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ void RenderFillLayer::render(PaintParameters& parameters) {
parameters.renderTileClippingMasks(renderTiles);

for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/layers/render_heatmap_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void RenderHeatmapLayer::evaluate(const PropertyEvaluationParameters& parameters
passes = (properties->evaluated.get<style::HeatmapOpacity>() > 0)
? (RenderPass::Translucent | RenderPass::Pass3D)
: RenderPass::None;

properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand Down Expand Up @@ -95,7 +95,7 @@ void RenderHeatmapLayer::render(PaintParameters& parameters) {
"heatmap texture", { *renderTexture, Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {} });

for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/renderer/layers/render_hillshade_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void RenderHillshadeLayer::evaluate(const PropertyEvaluationParameters& paramete
passes = (properties->evaluated.get<style::HillshadeExaggeration >() > 0)
? (RenderPass::Translucent | RenderPass::Pass3D)
: RenderPass::None;

properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand All @@ -66,7 +66,7 @@ bool RenderHillshadeLayer::hasCrossfade() const {
}

void RenderHillshadeLayer::prepare(const LayerPrepareParameters& params) {
RenderLayer::prepare(params);
renderTiles = params.source->getRenderTiles();
maxzoom = params.source->getMaxZoom();
}

Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/renderer/layers/render_line_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void RenderLineLayer::evaluate(const PropertyEvaluationParameters& parameters) {
&& evaluated.get<style::LineColor>().constantOr(Color::black()).a > 0
&& evaluated.get<style::LineWidth>().constantOr(1.0) > 0)
? RenderPass::Translucent : RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand Down Expand Up @@ -92,7 +93,7 @@ void RenderLineLayer::render(PaintParameters& parameters) {
parameters.renderTileClippingMasks(renderTiles);

for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/mbgl/renderer/layers/render_raster_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void RenderRasterLayer::evaluate(const PropertyEvaluationParameters& parameters)
staticImmutableCast<RasterLayer::Impl>(baseImpl),
unevaluated.evaluate(parameters));
passes = properties->evaluated.get<style::RasterOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/layers/render_symbol_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void RenderSymbolLayer::evaluate(const PropertyEvaluationParameters& parameters)
passes = ((evaluated.get<style::IconOpacity>().constantOr(1) > 0 && hasIconOpacity && iconSize > 0)
|| (evaluated.get<style::TextOpacity>().constantOr(1) > 0 && hasTextOpacity && textSize > 0))
? RenderPass::Translucent : RenderPass::None;

properties->renderPasses = mbgl::underlying_type(passes);
evaluatedProperties = std::move(properties);
}

Expand Down Expand Up @@ -350,7 +350,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters) {
};

for (const RenderTile& tile : *renderTiles) {
const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl);
const LayerRenderData* renderData = getRenderDataForPass(tile, parameters.pass);
if (!renderData) {
continue;
}
Expand Down Expand Up @@ -495,7 +495,7 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper

void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
renderTiles = params.source->getRenderTilesSortedByYPosition();
assert(renderTiles);
addRenderPassesFromTiles();

placementData.clear();
for (const RenderTile& renderTile : *renderTiles) {
Expand Down
18 changes: 17 additions & 1 deletion src/mbgl/renderer/render_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool RenderLayer::supportsZoom(float zoom) const {
void RenderLayer::prepare(const LayerPrepareParameters& params) {
assert(params.source);
renderTiles = params.source->getRenderTiles();
assert(renderTiles);
addRenderPassesFromTiles();
}

optional<Color> RenderLayer::getSolidBackground() const {
Expand Down Expand Up @@ -86,5 +86,21 @@ void RenderLayer::checkRenderability(const PaintParameters& parameters,
}
}

void RenderLayer::addRenderPassesFromTiles() {
assert(renderTiles);
for (const RenderTile& tile : *renderTiles) {
if (const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl)) {
passes |= RenderPass(renderData->layerProperties->renderPasses);
}
}
}

const LayerRenderData* RenderLayer::getRenderDataForPass(const RenderTile& tile, RenderPass pass) const {
if (const LayerRenderData* renderData = tile.getLayerRenderData(*baseImpl)) {
return bool(RenderPass(renderData->layerProperties->renderPasses) & pass) ? renderData : nullptr;
}
return nullptr;
}

} //namespace mbgl

4 changes: 4 additions & 0 deletions src/mbgl/renderer/render_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class RenderLayer {
// in the console to inform the developer.
void checkRenderability(const PaintParameters&, uint32_t activeBindingCount);

void addRenderPassesFromTiles();

const LayerRenderData* getRenderDataForPass(const RenderTile&, RenderPass) const;

protected:
// Stores current set of tiles to be rendered for this layer.
RenderTiles renderTiles;
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/renderer/render_orchestrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,14 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
const Immutable<Layer::Impl>& layerImpl = *it;
RenderLayer* layer = getRenderLayer(layerImpl->id);
const auto* layerInfo = layerImpl->getTypeInfo();
const bool layerNeedsRendering = layer->needsRendering();
const bool layerIsVisible = layer->baseImpl->visibility != style::VisibilityType::None;
const bool zoomFitsLayer = layer->supportsZoom(zoomHistory.lastZoom);
renderTreeParameters->has3D |= (layerInfo->pass3d == LayerTypeInfo::Pass3D::Required);

if (layerInfo->source != LayerTypeInfo::Source::NotRequired) {
if (layerImpl->source == sourceImpl->id) {
sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff || constantsMaskChanged.count(layerImpl->id) || hasLayoutDifference(layerDiff, layerImpl->id));
if (layerNeedsRendering) {
if (layerIsVisible) {
filteredLayersForSource.push_back(layer->evaluatedProperties);
if (zoomFitsLayer) {
sourceNeedsRendering = true;
Expand All @@ -311,7 +311,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
}

// Handle layers without source.
if (layerNeedsRendering && zoomFitsLayer && sourceImpl.get() == sourceImpls->at(0).get()) {
if (layerIsVisible && zoomFitsLayer && sourceImpl.get() == sourceImpls->at(0).get()) {
if (backgroundLayerAsColor && layerImpl.get() == layerImpls->at(0).get()) {
const auto& solidBackground = layer->getSolidBackground();
if (solidBackground) {
Expand Down