euv_core/render/pipeline/struct.rs
1use super::*;
2
3/// Shared font provider, glyph coverage atlas, and text shaping service reused across active and fallback backends.
4#[derive(Clone, Data, Debug, Default)]
5pub struct FontAtlasService {
6 /// Active native OS or deterministic font provider.
7 pub(crate) font_provider: NativeSystemFont,
8 /// Shared glyph coverage atlas transferred to fallback or switched backends without 3x duplication.
9 pub(crate) glyph_atlas: GlyphAtlas,
10 /// Shared DPI-independent text shaping and line-break cache.
11 pub(crate) text_shaping_cache: TextShapingCache,
12}
13
14/// Fluent per-frame parameter bundle for `Renderer::render_with`.
15#[derive(Clone, Copy, Data, Debug, PartialEq)]
16pub struct FrameRenderParams {
17 /// Logical viewport size.
18 #[get(type(copy))]
19 pub(crate) viewport: Size,
20 /// Active physical DPI scale factor.
21 #[get(type(copy))]
22 pub(crate) scale_factor: f32,
23 /// Surface background clear color.
24 #[get(type(copy))]
25 pub(crate) clear_color: Color,
26 /// Layout pass telemetry from the current frame.
27 #[get(type(copy))]
28 pub(crate) layout_stats: LayoutStats,
29 /// Damaged screen region requiring rasterization.
30 #[get(type(copy))]
31 pub(crate) damage: DamageRegion,
32 /// Optional authoritative physical surface width in pixels (`0` derives from `viewport.width * scale_factor`).
33 #[get(type(copy))]
34 pub(crate) physical_width: u32,
35 /// Optional authoritative physical surface height in pixels (`0` derives from `viewport.height * scale_factor`).
36 #[get(type(copy))]
37 pub(crate) physical_height: u32,
38}
39
40/// Unified single-backend rendering facade orchestrating lazy Software, Hardware, and Hybrid execution.
41#[derive(Data, Debug)]
42pub struct Renderer {
43 /// Active render configuration.
44 #[get(type(copy))]
45 pub(crate) config: RenderConfig,
46 /// Resolved active render mode (never `Auto`).
47 #[get(type(copy))]
48 pub(crate) active_mode: RenderMode,
49 /// Resolved active graphics backend.
50 #[get(type(copy))]
51 pub(crate) active_backend: GraphicsBackend,
52 /// Target execution platform identity used for explicit GPU scene-pass capability gating.
53 #[get(type(copy))]
54 #[get_mut(skip)]
55 #[set(skip)]
56 pub(crate) active_platform: PlatformKind,
57 /// Strictly single active rendering backend instantiated for the resolved mode.
58 #[get(skip)]
59 #[get_mut(skip)]
60 #[set(skip)]
61 pub(crate) active_backend_impl: ActiveRenderBackend,
62 /// Lazily allocated CPU reference software fallback instantiated only on fallback or reference readback.
63 #[get(skip)]
64 #[get_mut(skip)]
65 #[set(skip)]
66 pub(crate) fallback_software: Option<Box<SoftwareRenderer>>,
67 /// Single shared font provider, glyph atlas, and text shaping service across all render paths.
68 pub(crate) font_service: FontAtlasService,
69 /// Tracked physical surface width in pixels for lazy backend instantiation.
70 #[get(type(copy))]
71 #[get_mut(skip)]
72 #[set(pub(crate))]
73 pub(crate) surface_width: u32,
74 /// Tracked physical surface height in pixels for lazy backend instantiation.
75 #[get(type(copy))]
76 #[get_mut(skip)]
77 #[set(pub(crate))]
78 pub(crate) surface_height: u32,
79 /// Reusable scene-to-display-list compiler handle.
80 #[get(skip)]
81 #[get_mut(skip)]
82 #[set(skip)]
83 pub(crate) paint_pass: PaintPass,
84 /// Cross-frame retained `DisplayList` and subtree `DrawCommand` fragment cache.
85 #[get(pub(crate))]
86 #[get_mut(skip)]
87 #[set(skip)]
88 pub(crate) paint_fragment_cache: PaintFragmentCache,
89 /// Reusable frame display list.
90 pub(crate) display_list: DisplayList,
91 /// Monotonic frame counter.
92 #[get(type(copy))]
93 pub(crate) frame_index: u64,
94 /// Whether to compute full-framebuffer FNV-1a pixel hashes on each frame (enabled for headless parity tests).
95 #[get(type(copy))]
96 pub(crate) compute_pixel_hash: bool,
97 /// Whether per-frame timing instrumentation (`Instant::now`) is active inside software band scheduling.
98 #[get(type(copy))]
99 pub(crate) telemetry_enabled: bool,
100 /// Active render mode of the most recent hashed frame (`None` before first render or after mode switch).
101 #[get(skip)]
102 #[get_mut(skip)]
103 #[set(skip)]
104 pub(crate) last_hashed_mode: Option<RenderMode>,
105 /// Physical framebuffer dimensions `(phys_w, phys_h)` of the most recent hashed frame.
106 #[get(skip)]
107 #[get_mut(skip)]
108 #[set(skip)]
109 pub(crate) last_hashed_dims: (u32, u32),
110 /// Telemetry from the most recent frame.
111 #[get(type(copy))]
112 pub(crate) last_stats: FrameStats,
113 /// Non-degrading runtime fallback policy engine (never downgrades shadows, blur, AA, clipping, or resolution).
114 pub(crate) fallback_policy: FallbackPolicyEngine,
115 /// Cumulative frames executed via the composite-only fast path without relayout or full repaint.
116 #[get(type(copy))]
117 #[get_mut(skip)]
118 #[set(skip)]
119 pub(crate) composite_fast_path_frames: u64,
120 /// Cumulative frames routed to full CPU reference rasterization by `FallbackPolicyEngine`.
121 #[get(type(copy))]
122 #[get_mut(skip)]
123 #[set(skip)]
124 pub(crate) cpu_fallback_frames: u64,
125 /// Unified 5-stage adaptive render router governing startup cache, probing, selection, handoff, and faults.
126 pub(crate) adaptive_router: AdaptiveRenderRouter,
127 /// Truthful per-frame observability snapshot from the most recent rendered or skipped frame.
128 #[get(type(copy))]
129 pub(crate) last_adaptive_metrics: AdaptiveFrameMetrics,
130 /// Closed-loop EWMA execution lane router (`CpuSerial` / `CpuParallel` / `GpuCompute` / `MixedCoExec`).
131 pub(crate) execution_router: AdaptiveExecutionRouter,
132 /// Unified render-graph scheduler coordinating Pass 0..4, dirty-span uploads, and incremental atlas sync.
133 pub(crate) render_graph: RenderGraph,
134 /// Last active DPI scale bits used to detect exact scale changes for `GlyphAtlas::invalidate_for_render_params`.
135 #[get(type(copy))]
136 #[get_mut(skip)]
137 #[set(skip)]
138 pub(crate) last_scale_bits: u32,
139 /// Persistent boxed direct-GPU frame submission scratch container reused across frames with zero atlas or batch cloning and minimal stack footprint.
140 #[get(skip)]
141 #[get_mut(skip)]
142 #[set(skip)]
143 pub(crate) direct_submission_scratch: Box<GpuFrameSubmission>,
144 /// Persistent pool stashing inactive tail `GpuBatch` slots during zero-copy swapchain submission.
145 #[get(skip)]
146 #[get_mut(skip)]
147 #[set(skip)]
148 pub(crate) direct_batch_tail_pool: Vec<GpuBatch>,
149}