euv-core 0.48.3

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::*;

/// Explicit outcome of a frame submission attempt separating idle skip, successful submit, and retryable failure.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum FrameSubmitOutcome {
    /// No scene or surface damage required presentation on this tick.
    #[default]
    SkippedNoDamage,
    /// Complete frame was successfully submitted to the active surface generation.
    Submitted,
    /// Presentation submission failed; the complete pending frame is retained for automatic retry on the same surface generation.
    SubmitFailed,
}

/// Reason a runtime fallback switched execution to the full CPU reference backend.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum FallbackCpuReason {
    /// Physical GPU device or pipeline initialization failed.
    #[default]
    GpuInitFailed,
    /// GPU device or context was lost beyond bounded recovery attempts.
    DeviceLost,
    /// Critical GPU resource allocation failed after cache trimming.
    CriticalAllocationFailed,
    /// A cross-layer visual effect lacks an equivalent GPU path and cannot be safely isolated to one layer.
    UnisolatableEffectPath,
}

/// Runtime event evaluated by `FallbackPolicyEngine` to pick a strictly non-degrading response.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum FallbackTrigger {
    /// Host or allocator memory pressure notification.
    MemoryPressure(MemoryPressure),
    /// Single-frame budget overrun or cache pressure spike.
    TransientFrameOverrun,
    /// Sustained frame budget overrun across consecutive active frames.
    SustainedFrameOverrun,
    /// Active GPU backend lacks an equivalent shader path for an effect layer.
    MissingGpuEffectPath {
        /// Whether the effect can be isolated to a single layer with exact backdrop/blend semantics.
        isolatable: bool,
    },
    /// GPU backend initialization failed.
    GpuInitFailed,
    /// GPU device was lost at runtime.
    DeviceLost,
    /// Required frame resource allocation failed.
    AllocationFailed,
}

/// Strictly non-degrading 4-step fallback ladder state tracked by `FallbackPolicyEngine`.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum FallbackLadderStep {
    /// Normal full-cadence GPU direct-draw execution with full prefetch and cache retention.
    #[default]
    Normal,
    /// Tier 1: Speculative route prefetch cancelled and cold/offscreen caches trimmed.
    Tier1CacheAndPrefetchTrim,
    /// Tier 2: Presentation cadence stepped down along display-compatible tiers with hysteresis.
    Tier2CadenceStepDown,
    /// Tier 3: Isolated missing GPU effect layer rasterized through CPU reference with exact fidelity.
    Tier3IsolatedCpuEffect,
    /// Tier 4: Full-frame CPU software reference backend active after GPU init/device-loss or unisolatable effect.
    Tier4FullCpuReference,
}

/// Strictly non-degrading action produced by `FallbackPolicyEngine` (never modifies shadows, blur, AA, clipping, or resolution).
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub enum FallbackAction {
    /// Continue normal execution with no policy change.
    #[default]
    None,
    /// Cancel speculative route prefetch and shrink cold/invisible cache retention while keeping all visible content identical.
    TrimPrefetchAndColdCache {
        /// Retained fraction of default cold cache budgets in `(0.0..=1.0]`.
        retain_ratio: f32,
    },
    /// Adjust presentation cadence along display-compatible tiers with hysteresis and minimum dwell time.
    AdjustPresentCadence {
        /// Target presentation cadence in Hertz.
        target_hz: f32,
    },
    /// Render one isolated effect layer through the full CPU reference rasterizer and composite into the GPU frame.
    RouteLayerToCpuReference,
    /// Switch the entire frame to the full CPU reference backend while preserving route, scroll, focus, and gesture state.
    SwitchToCpuReference {
        /// Structured cause for moving to CPU reference rendering.
        reason: FallbackCpuReason,
    },
}

/// Unified backend-agnostic resource classification shared by CPU reference and GPU direct-draw backends.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum RenderResourceKind {
    /// Color or alpha texture image resource.
    #[default]
    Texture,
    /// Vertex, index, or instanced quad GPU buffer.
    Buffer,
    /// Persistent cached scroll tile texture layer.
    TileLayer,
    /// Packed glyph coverage texture atlas.
    GlyphAtlas,
    /// Reusable per-frame upload staging buffer slot.
    StagingSlot,
}