Files
MapLibreParticleLab/include/mbgl/renderer/render_segment.hpp
tei 016fd1fff6
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
feat: add generic render segment model
2026-09-25 13:55:19 +09:00

113 lines
3.3 KiB
C++

#pragma once
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
namespace mbgl {
enum class RenderSegmentStrategy : uint8_t { Retained, Continuous };
inline const char* renderSegmentStrategyText(RenderSegmentStrategy strategy) noexcept {
return strategy == RenderSegmentStrategy::Retained ? "RETAINED" : "CONTINUOUS";
}
struct RenderSegmentDefinition {
RenderSegmentStrategy strategy = RenderSegmentStrategy::Continuous;
std::optional<std::string> startLayerId;
bool operator==(const RenderSegmentDefinition&) const = default;
};
struct RenderSegmentPlan {
uint32_t schemaVersion = 1;
std::vector<RenderSegmentDefinition> segments;
bool operator==(const RenderSegmentPlan&) const = default;
};
struct StyleLayerDiagnostics {
int32_t layerIndex = -1;
std::string layerId;
std::string layerType;
bool visible = false;
std::optional<std::string> sourceId;
std::optional<std::string> sourceLayer;
bool operator==(const StyleLayerDiagnostics&) const = default;
};
struct RenderSegmentCacheDiagnostics {
std::string cacheState{"disabled"};
uint64_t contentRevision = 0;
uint64_t build = 0;
uint64_t reuse = 0;
uint64_t invalidation = 0;
std::string lastInvalidationReason{"none"};
uint64_t textureCreate = 0;
uint64_t compositeCreate = 0;
uint64_t resourceRelease = 0;
};
struct RenderSegmentDiagnosticsEntry {
uint32_t segmentIndex = 0;
RenderSegmentStrategy strategy = RenderSegmentStrategy::Continuous;
std::optional<std::string> configuredStartLayerId;
int32_t beginIndex = -1;
int32_t endExclusive = -1;
std::optional<std::string> resolvedStartLayerId;
std::optional<std::string> resolvedEndLayerId;
std::vector<StyleLayerDiagnostics> layers;
std::optional<RenderSegmentCacheDiagnostics> cache;
};
struct RenderSegmentDiagnostics {
uint32_t schemaVersion = 1;
bool enabled = true;
bool configured = false;
bool valid = false;
std::string configSource{"unconfigured/legacy"};
uint64_t configRevision = 0;
uint64_t topologyRevision = 0;
uint32_t styleLayerCount = 0;
uint32_t segmentCount = 0;
uint32_t retainedSegmentCount = 0;
uint32_t continuousSegmentCount = 0;
bool coverageComplete = false;
bool fallback = false;
std::string lastReason{"not-configured"};
bool fastPathEligible = false;
bool fastPathActive = false;
std::string fastPathFallbackReason{"no-prepared-tree"};
uint64_t fastPathHit = 0;
uint64_t fastPathMiss = 0;
uint64_t fullCpuFrame = 0;
std::vector<StyleLayerDiagnostics> styleLayers;
std::vector<RenderSegmentDiagnosticsEntry> segments;
};
struct ResolvedRenderSegment {
uint32_t segmentIndex = 0;
RenderSegmentStrategy strategy = RenderSegmentStrategy::Continuous;
std::optional<std::string> configuredStartLayerId;
int32_t beginIndex = 0;
int32_t endExclusive = 0;
bool operator==(const ResolvedRenderSegment&) const = default;
};
struct ResolvedRenderSegmentPlan {
bool configured = false;
bool valid = false;
std::string configSource{"unconfigured/legacy"};
uint64_t configRevision = 0;
std::string reason{"not-configured"};
int32_t layerCount = 0;
std::vector<ResolvedRenderSegment> segments;
bool operator==(const ResolvedRenderSegmentPlan&) const = default;
};
} // namespace mbgl