euv_core/layout/partition/struct.rs
1use super::*;
2
3/// Containment boundary marking a candidate subtree root for CPU/GPU mixed co-execution partitioning.
4#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
5pub struct LayoutBoundary {
6 /// Root `NodeId` of the contained layout subtree.
7 #[get(type(copy))]
8 pub(crate) root_node: NodeId,
9 /// Placement hint influencing CPU vs GPU subtree assignment.
10 #[get(type(copy))]
11 pub(crate) hint: LayoutBoundaryHint,
12 /// Whether the boundary has an explicit outer width constraint independent of descendant content.
13 #[get(type(copy))]
14 pub(crate) fixed_width_constraint: bool,
15 /// Whether the boundary has an explicit outer height constraint independent of descendant content.
16 #[get(type(copy))]
17 pub(crate) fixed_height_constraint: bool,
18}
19
20/// Configurable thresholds and device state governing `SubtreePartitionPlanner`.
21#[derive(Clone, Copy, Data, Debug, PartialEq)]
22pub struct SubtreePartitionConfig {
23 /// Minimum node count required for GPU compute promotion (`512` default).
24 #[get(type(copy))]
25 pub(crate) min_gpu_nodes: usize,
26 /// Maximum allowed ratio of wrapping text nodes in `[0.0, 1.0]` (`0.15` default).
27 #[get(type(copy))]
28 pub(crate) max_text_wrap_ratio: f32,
29 /// Maximum tree depth allowed for level-synchronous GPU compute passes (`32` default).
30 #[get(type(copy))]
31 pub(crate) max_gpu_depth: usize,
32 /// True when the active backend supports real hardware GPU compute shaders.
33 #[get(type(copy))]
34 pub(crate) hardware_compute_ready: bool,
35 /// True when thermal telemetry requests avoiding sustained GPU compute bursts.
36 #[get(type(copy))]
37 pub(crate) thermal_throttled: bool,
38}
39
40/// Measured structural and text-complexity metrics for a candidate layout subtree.
41#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
42pub struct SubtreePartitionMetrics {
43 /// Total live nodes inside the subtree (including its root).
44 #[get(type(copy))]
45 pub(crate) total_nodes: usize,
46 /// Number of nodes inside the subtree currently marked layout-dirty.
47 #[get(type(copy))]
48 pub(crate) dirty_nodes: usize,
49 /// Number of wrapping `NodeKind::Text` nodes inside the subtree.
50 #[get(type(copy))]
51 pub(crate) wrapping_text_nodes: usize,
52 /// Number of nodes using layout modes or node kinds ineligible for GPU compute.
53 #[get(type(copy))]
54 pub(crate) unsupported_mode_nodes: usize,
55 /// Maximum tree depth measured from the subtree root (`0` for leaf).
56 #[get(type(copy))]
57 pub(crate) max_depth: usize,
58 /// Fraction of wrapping text nodes (`wrapping_text_nodes / total_nodes`).
59 #[get(type(copy))]
60 pub(crate) wrapping_text_ratio: f32,
61}
62
63/// Partition assignment decision for one subtree root.
64#[derive(Clone, Copy, Data, Debug, PartialEq)]
65pub struct SubtreePartitionEntry {
66 /// Root `NodeId` of the evaluated subtree.
67 #[get(type(copy))]
68 pub(crate) root_node: NodeId,
69 /// Chosen execution lane (`CpuSubtree` or `GpuSubtree`).
70 #[get(type(copy))]
71 pub(crate) lane: SubtreeLane,
72 /// Measured metrics backing the assignment decision.
73 #[get(type(copy))]
74 pub(crate) metrics: SubtreePartitionMetrics,
75 /// Optional rejection reason when `lane == SubtreeLane::CpuSubtree`.
76 #[get(skip)]
77 #[get_mut(skip)]
78 #[set(skip)]
79 pub(crate) reject_reason: Option<GpuSubtreeRejectReason>,
80}
81
82/// Complete mixed CPU+GPU subtree partition plan produced for one `SceneTree` frame.
83#[derive(Clone, Data, Debug, Default, PartialEq)]
84pub struct SubtreePartitionPlan {
85 /// Ordered subtree partition decisions (top-down containment roots).
86 pub(crate) entries: Vec<SubtreePartitionEntry>,
87 /// Total nodes assigned to CPU execution lanes.
88 #[get(type(copy))]
89 pub(crate) cpu_node_count: usize,
90 /// Total nodes assigned to GPU compute layout lanes.
91 #[get(type(copy))]
92 pub(crate) gpu_node_count: usize,
93 /// Number of subtrees assigned to CPU.
94 #[get(type(copy))]
95 pub(crate) cpu_subtree_count: usize,
96 /// Number of subtrees assigned to GPU compute.
97 #[get(type(copy))]
98 pub(crate) gpu_subtree_count: usize,
99 /// True when the plan contains both CPU chrome/text subtrees and at least one GPU compute subtree.
100 #[get(type(copy))]
101 pub(crate) requires_mixed_coexec: bool,
102}
103
104/// Subtree partitioner splitting a `SceneTree` into CPU chrome/prose subtrees and GPU compute subtrees.
105#[derive(Clone, Data, Debug)]
106pub struct SubtreePartitionPlanner {
107 /// Active eligibility thresholds and device capability flags.
108 #[get(type(copy))]
109 pub(crate) config: SubtreePartitionConfig,
110 /// Explicit containment boundaries registered by node identifier.
111 pub(crate) boundaries: HashMap<NodeId, LayoutBoundary>,
112}