Skip to content

Commit

Permalink
Fixed render target.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcristici committed Oct 29, 2024
1 parent fc0832b commit 112a462
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions include/mbgl/renderer/render_target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class RenderTarget {
}
}
}

/// Execute the given function for each contained layer group in reversed order
template <typename Func /* void(LayerGroupBase&) */>
void visitLayerGroupsReversed(Func f) {
for (auto rit = layerGroupsByLayerIndex.rbegin(); rit != layerGroupsByLayerIndex.rend(); ++rit) {
if (rit->second) {
f(*rit->second);
}
}
}

/// Upload the layer groups
void upload(gfx::UploadPass& uploadPass);
Expand Down
16 changes: 9 additions & 7 deletions src/mbgl/renderer/render_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,29 @@ void RenderTarget::render(RenderOrchestrator& orchestrator, const RenderTree& re
"render target", {*offscreenTexture, Color{0.0f, 0.0f, 0.0f, 1.0f}, {}, {}});

// Run layer tweakers to update any dynamic elements
visitLayerGroups([&](LayerGroupBase& layerGroup) { layerGroup.runTweakers(renderTree, parameters); });
parameters.currentLayer = 0;
visitLayerGroups([&](LayerGroupBase& layerGroup) {
layerGroup.runTweakers(renderTree, parameters);
parameters.currentLayer++;
});

// draw layer groups, opaque pass
parameters.pass = RenderPass::Opaque;
parameters.currentLayer = static_cast<uint32_t>(numLayerGroups()) - 1;
parameters.depthRangeSize = 1 -
(numLayerGroups() + 2) * PaintParameters::numSublayers * PaintParameters::depthEpsilon;

visitLayerGroups([&](LayerGroupBase& layerGroup) {
parameters.currentLayer = 0;
visitLayerGroupsReversed([&](LayerGroupBase& layerGroup) {
layerGroup.render(orchestrator, parameters);
if (parameters.currentLayer > 0) {
parameters.currentLayer--;
}
parameters.currentLayer++;
});

// draw layer groups, translucent pass
parameters.pass = RenderPass::Translucent;
parameters.currentLayer = static_cast<uint32_t>(numLayerGroups()) - 1;
parameters.depthRangeSize = 1 -
(numLayerGroups() + 2) * PaintParameters::numSublayers * PaintParameters::depthEpsilon;

parameters.currentLayer = static_cast<uint32_t>(numLayerGroups()) - 1;
visitLayerGroups([&](LayerGroupBase& layerGroup) {
layerGroup.render(orchestrator, parameters);
if (parameters.currentLayer > 0) {
Expand Down

0 comments on commit 112a462

Please sign in to comment.