feat: admit settled Symbol render results to retained cache
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <mln/renderer/render_orchestrator.hpp>
|
||||
#include <mln/renderer/layers/render_symbol_layer.hpp>
|
||||
#include <mln/renderer/continuous_layer_range.hpp>
|
||||
#include <mln/renderer/particle_fast_path.hpp>
|
||||
|
||||
@@ -1143,11 +1144,76 @@ bool RenderOrchestrator::retainedRangeUsesPlacement(int32_t begin, int32_t endEx
|
||||
}
|
||||
|
||||
bool RenderOrchestrator::retainedRangeHasPlacementCapableLayer(int32_t begin, int32_t endExclusive) const {
|
||||
return renderSegmentHasPlacementCapableLayer(retainedStyleLayers, begin, endExclusive);
|
||||
if (begin < 0 || endExclusive < begin || endExclusive > static_cast<int32_t>(orderedLayers.size())) return true;
|
||||
if (renderSegmentHasPlacementCapableLayer(retainedStyleLayers, begin, endExclusive)) return true;
|
||||
for (int32_t index = begin; index < endExclusive; ++index) {
|
||||
if (orderedLayers[index].get().baseImpl->getTypeInfo()->crossTileIndex ==
|
||||
style::LayerTypeInfo::CrossTileIndex::Required) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RenderOrchestrator::recordRenderError(std::exception_ptr error) {
|
||||
invalidateRetainedRenderResults();
|
||||
observer->onRenderError(error);
|
||||
}
|
||||
|
||||
void RenderOrchestrator::invalidateRetainedRenderResults() {
|
||||
++renderErrorRevision;
|
||||
advanceRetainedUnderlayContentRevision(RetainedUnderlayReason::LayerGroupMutation);
|
||||
}
|
||||
|
||||
SymbolRenderResult RenderOrchestrator::retainedSymbolRenderResult(
|
||||
int32_t begin, int32_t endExclusive, float fadeChange, uint64_t frame) {
|
||||
SymbolRenderResult result;
|
||||
result.append(numLayerGroups()); // global depth range depends on all groups
|
||||
if (begin < 0 || endExclusive > static_cast<int32_t>(orderedLayers.size()) || begin > endExclusive) {
|
||||
result.complete = false;
|
||||
return result;
|
||||
}
|
||||
// Registry membership is checked after processChanges, including old groups
|
||||
// of hidden layers. Preserve global ordinals for depth and cross-segment order.
|
||||
for (int32_t index = begin; index < endExclusive; ++index) {
|
||||
auto& layer = orderedLayers[index].get();
|
||||
const auto* info = layer.baseImpl->getTypeInfo();
|
||||
const bool placementCapable = info->type == std::string_view("symbol") ||
|
||||
info->crossTileIndex == style::LayerTypeInfo::CrossTileIndex::Required;
|
||||
if (!placementCapable) continue;
|
||||
if (info != style::SymbolLayer::Impl::staticTypeInfo()) {
|
||||
result.complete = false;
|
||||
continue;
|
||||
}
|
||||
auto& symbol = static_cast<RenderSymbolLayer&>(layer);
|
||||
const auto registered = layerGroupsByLayerIndex.equal_range(index);
|
||||
std::size_t groups = 0;
|
||||
for (auto it = registered.first; it != registered.second; ++it) {
|
||||
++groups;
|
||||
if (!symbol.isLayerRenderable() || it->second.get() != symbol.retainedResultGroup()) {
|
||||
result.complete = false;
|
||||
}
|
||||
}
|
||||
if (groups > 1 || (symbol.isLayerRenderable() && symbol.retainedResultGroup() && groups != 1)) {
|
||||
result.complete = false;
|
||||
}
|
||||
result.appendResult(symbol.retainedRenderResult(fadeChange, frame));
|
||||
}
|
||||
auto it = layerGroupsByLayerIndex.lower_bound(begin);
|
||||
std::size_t ordinal = static_cast<std::size_t>(std::distance(layerGroupsByLayerIndex.begin(), it));
|
||||
for (; it != layerGroupsByLayerIndex.end() && it->first < endExclusive; ++it, ++ordinal) {
|
||||
if (!it->second) { result.complete = false; continue; }
|
||||
const auto& group = *it->second;
|
||||
result.append(ordinal);
|
||||
result.retain(it->second);
|
||||
result.append(group.getLayerIndex());
|
||||
result.append(group.getDrawableCount());
|
||||
result.append(group.getEnabled());
|
||||
}
|
||||
result.complete = result.complete && pendingChanges.empty();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RenderOrchestrator::retainedPlacementTransitionActive(TimePoint timePoint) const {
|
||||
return placementController.hasTransitions(timePoint);
|
||||
return placementController.hasActiveSymbolFade(timePoint);
|
||||
}
|
||||
|
||||
bool RenderOrchestrator::retainedUnderlayIsStable(TimePoint timePoint, int32_t boundary) const {
|
||||
@@ -1156,7 +1222,7 @@ bool RenderOrchestrator::retainedUnderlayIsStable(TimePoint timePoint, int32_t b
|
||||
|
||||
bool RenderOrchestrator::retainedRangeIsStable(TimePoint timePoint, int32_t begin, int32_t endExclusive) const {
|
||||
if (renderLight.hasTransition()) return false;
|
||||
if (retainedRangeUsesPlacement(begin, endExclusive) && placementController.hasTransitions(timePoint)) return false;
|
||||
if (retainedRangeUsesPlacement(begin, endExclusive) && placementController.hasActiveSymbolFade(timePoint)) return false;
|
||||
|
||||
const auto first = std::clamp<int32_t>(begin, 0, static_cast<int32_t>(orderedLayers.size()));
|
||||
const auto last = std::clamp<int32_t>(endExclusive, first, static_cast<int32_t>(orderedLayers.size()));
|
||||
@@ -1213,7 +1279,7 @@ bool RenderOrchestrator::retainedSegmentIsStable(TimePoint timePoint,
|
||||
int32_t begin,
|
||||
int32_t endExclusive) const {
|
||||
if (renderLight.hasTransition()) return false;
|
||||
if (retainedRangeUsesPlacement(begin, endExclusive) && placementController.hasTransitions(timePoint)) return false;
|
||||
if (retainedRangeUsesPlacement(begin, endExclusive) && placementController.hasActiveSymbolFade(timePoint)) return false;
|
||||
const auto first = std::clamp<int32_t>(begin, 0, static_cast<int32_t>(orderedLayers.size()));
|
||||
const auto last = std::clamp<int32_t>(endExclusive, first, static_cast<int32_t>(orderedLayers.size()));
|
||||
for (int32_t index = first; index < last; ++index) {
|
||||
@@ -1285,7 +1351,7 @@ ParticleFastPathDynamicState RenderOrchestrator::particleFastPathDynamicState(Ti
|
||||
}
|
||||
}
|
||||
}
|
||||
const bool controllerTransition = placementController.hasTransitions(timePoint);
|
||||
const bool controllerTransition = placementController.hasActiveSymbolFade(timePoint);
|
||||
result.placementTransition = controllerTransition &&
|
||||
(retainedStyleLayers.size() != renderLayers.size() ||
|
||||
particleFastPathHasPlacementTransition(retainedStyleLayers, controllerTransition));
|
||||
@@ -1459,7 +1525,7 @@ void RenderOrchestrator::updateLayers(gfx::ShaderRegistry& shaders,
|
||||
try {
|
||||
renderLayer.update(shaders, context, state, updateParameters, paintParameters, renderTree, changes);
|
||||
} catch (...) {
|
||||
observer->onRenderError(std::current_exception());
|
||||
recordRenderError(std::current_exception());
|
||||
}
|
||||
}
|
||||
addChanges(changes);
|
||||
@@ -1487,7 +1553,7 @@ void RenderOrchestrator::updateParticleLayers(gfx::ShaderRegistry& shaders,
|
||||
try {
|
||||
renderLayer.update(shaders, context, state, updateParameters, paintParameters, renderTree, changes);
|
||||
} catch (...) {
|
||||
observer->onRenderError(std::current_exception());
|
||||
recordRenderError(std::current_exception());
|
||||
}
|
||||
}
|
||||
addChanges(changes);
|
||||
@@ -1535,6 +1601,7 @@ void RenderOrchestrator::onGlyphsError(const FontStack& fontStack,
|
||||
const GlyphRange& glyphRange,
|
||||
std::exception_ptr error) {
|
||||
MLN_TRACE_FUNC();
|
||||
advanceRetainedUnderlayContentRevision(RetainedUnderlayReason::GlyphMutation);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Failed to load glyph range ";
|
||||
@@ -1550,11 +1617,13 @@ void RenderOrchestrator::onGlyphsError(const FontStack& fontStack,
|
||||
}
|
||||
|
||||
void RenderOrchestrator::onGlyphsRequested(const FontStack& fontStack, const GlyphRange& range) {
|
||||
advanceRetainedUnderlayContentRevision(RetainedUnderlayReason::GlyphMutation);
|
||||
observer->onGlyphsRequested(fontStack, range);
|
||||
}
|
||||
|
||||
void RenderOrchestrator::onTileError(RenderSource& source, const OverscaledTileID& tileID, std::exception_ptr error) {
|
||||
MLN_TRACE_FUNC();
|
||||
advanceRetainedUnderlayContentRevision(RetainedUnderlayReason::TileMutation, source.baseImpl->id);
|
||||
|
||||
Log::Error(Event::Style,
|
||||
"Failed to load tile " + util::toString(tileID) + " for source " + source.baseImpl->id + ": " +
|
||||
@@ -1585,7 +1654,8 @@ void RenderOrchestrator::onTileAction(RenderSource&,
|
||||
observer->onTileAction(op, id, sourceID);
|
||||
}
|
||||
|
||||
void RenderOrchestrator::onSymbolError(RenderSource&, const std::string& message) {
|
||||
void RenderOrchestrator::onSymbolError(RenderSource& source, const std::string& message) {
|
||||
advanceRetainedUnderlayContentRevision(RetainedUnderlayReason::TileMutation, source.baseImpl->id);
|
||||
observer->onSymbolError(message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user