euv-core 0.52.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Result of partitioning a `DisplayList` into GPU-native primitives and sparse CPU-only effect regions.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct HybridCommandPartition {
    /// Number of commands compiled directly into GPU-native instanced batches.
    #[get(type(copy))]
    pub(crate) gpu_native_count: usize,
    /// Tight physical pixel bounds for sparse CPU-only effect regions requiring tile rasterization.
    pub(crate) cpu_effect_regions: Vec<Rect>,
    /// Total GPU-native primitive area covered in physical pixels.
    #[get(type(copy))]
    pub(crate) gpu_covered_pixels: usize,
}

/// Net-gain evaluation proving whether `Hybrid` beats both pure `GpuDirect` and pure `Software`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct HybridNetGainEstimate {
    /// Fraction of viewport pixels covered by sparse CPU-only effect regions in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) cpu_effect_coverage_ratio: f64,
    /// Estimated total frame duration for the hybrid path (`cpu_tile_ms + gpu_composite_ms`).
    #[get(type(copy))]
    pub(crate) hybrid_total_ms: f64,
    /// Estimated net gain in milliseconds over `min(gpu_full_ms, cpu_full_ms)` (`<= 0.0` disqualifies `Hybrid`).
    #[get(type(copy))]
    pub(crate) net_gain_ms: f64,
    /// True ONLY when `cpu_effect_regions` is sparse and `Hybrid` delivers strictly positive net gain over pure GPU and pure CPU.
    #[get(type(copy))]
    pub(crate) should_use_hybrid: bool,
    /// Recommended rendering backend (`Hybrid`, `GpuDirect`, or `Software`).
    #[get(type(copy))]
    pub(crate) recommended_candidate: RenderBackendCandidate,
}

/// Sparse-effect hybrid renderer compiling GPU-native primitives directly and rasterizing ONLY tight CPU-only effect tiles onto real `NativeGpuDriver`.
#[derive(Data, Debug, Default)]
pub struct HybridRenderer {
    /// On-demand CPU tile rasterizer invoked ONLY for sparse `cpu_effect_regions` (never unconditional full-frame rasterization).
    pub(crate) software: SoftwareRenderer,
    /// Real physical OS GPU driver executing GPU-native 64-byte primitive batches plus tight sparse-effect tile quads.
    pub(crate) driver: NativeGpuDriver,
    /// Persistent incremental R8 glyph atlas synchronized via dirty sub-rect uploads to GPU texture slot 0.
    pub(crate) gpu_glyph_atlas: IncrementalGpuGlyphAtlas,
    /// Sparse CPU-only effect regions isolated during the most recent frame.
    pub(crate) last_cpu_effect_regions: Vec<Rect>,
    /// Number of GPU-native draw commands compiled directly without CPU rasterization on the most recent frame.
    #[get(type(copy))]
    pub(crate) last_gpu_native_commands: usize,
    /// Number of tight CPU effect tiles rasterized and uploaded on the most recent frame (`0` when no CPU-only effects exist).
    #[get(type(copy))]
    pub(crate) last_cpu_tile_count: usize,
    /// Exact tight-tile RGBA8 bytes uploaded on the most recent frame (`0` when no CPU-only effects exist).
    #[get(type(copy))]
    pub(crate) last_cpu_upload_bytes: usize,
    /// Total CPU pixels rasterized on the most recent frame (`0` when no CPU-only effects exist).
    #[get(type(copy))]
    pub(crate) last_cpu_rasterized_pixels: usize,
    /// Compiled 64-byte `GpuBatch` list submitted to `driver` on the most recent frame.
    pub(crate) last_batches: Vec<GpuBatch>,
}