Skip to main content

euv_core/render/hybrid/
struct.rs

1use super::*;
2
3/// Result of partitioning a `DisplayList` into GPU-native primitives and sparse CPU-only effect regions.
4#[derive(Clone, Data, Debug, Default, PartialEq)]
5pub struct HybridCommandPartition {
6    /// Number of commands compiled directly into GPU-native instanced batches.
7    #[get(type(copy))]
8    pub(crate) gpu_native_count: usize,
9    /// Tight physical pixel bounds for sparse CPU-only effect regions requiring tile rasterization.
10    pub(crate) cpu_effect_regions: Vec<Rect>,
11    /// Total GPU-native primitive area covered in physical pixels.
12    #[get(type(copy))]
13    pub(crate) gpu_covered_pixels: usize,
14}
15
16/// Net-gain evaluation proving whether `Hybrid` beats both pure `GpuDirect` and pure `Software`.
17#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
18pub struct HybridNetGainEstimate {
19    /// Fraction of viewport pixels covered by sparse CPU-only effect regions in `[0.0, 1.0]`.
20    #[get(type(copy))]
21    pub(crate) cpu_effect_coverage_ratio: f64,
22    /// Estimated total frame duration for the hybrid path (`cpu_tile_ms + gpu_composite_ms`).
23    #[get(type(copy))]
24    pub(crate) hybrid_total_ms: f64,
25    /// Estimated net gain in milliseconds over `min(gpu_full_ms, cpu_full_ms)` (`<= 0.0` disqualifies `Hybrid`).
26    #[get(type(copy))]
27    pub(crate) net_gain_ms: f64,
28    /// True ONLY when `cpu_effect_regions` is sparse and `Hybrid` delivers strictly positive net gain over pure GPU and pure CPU.
29    #[get(type(copy))]
30    pub(crate) should_use_hybrid: bool,
31    /// Recommended rendering backend (`Hybrid`, `GpuDirect`, or `Software`).
32    #[get(type(copy))]
33    pub(crate) recommended_candidate: RenderBackendCandidate,
34}
35
36/// Sparse-effect hybrid renderer compiling GPU-native primitives directly and rasterizing ONLY tight CPU-only effect tiles.
37#[derive(Clone, Data, Debug, Default)]
38pub struct HybridRenderer {
39    /// On-demand CPU tile rasterizer invoked ONLY for sparse `cpu_effect_regions` (never unconditional full-frame rasterization).
40    pub(crate) software: SoftwareRenderer,
41    /// GPU compositor driver executing GPU-native batches plus tight sparse-effect tile quads.
42    pub(crate) compositor: RecordingGpuDriver,
43    /// Sparse CPU-only effect regions isolated during the most recent frame.
44    pub(crate) last_cpu_effect_regions: Vec<Rect>,
45    /// Number of GPU-native draw commands compiled directly without CPU rasterization on the most recent frame.
46    #[get(type(copy))]
47    pub(crate) last_gpu_native_commands: usize,
48    /// Number of tight CPU effect tiles rasterized and uploaded on the most recent frame (`0` when no CPU-only effects exist).
49    #[get(type(copy))]
50    pub(crate) last_cpu_tile_count: usize,
51    /// Exact tight-tile RGBA8 bytes uploaded on the most recent frame (`0` when no CPU-only effects exist).
52    #[get(type(copy))]
53    pub(crate) last_cpu_upload_bytes: usize,
54    /// Total CPU pixels rasterized on the most recent frame (`0` when no CPU-only effects exist).
55    #[get(type(copy))]
56    pub(crate) last_cpu_rasterized_pixels: usize,
57}