Skip to main content

euv_core/render/fallback/
enum.rs

1use super::*;
2
3/// Explicit outcome of a frame submission attempt separating idle skip, successful submit, and retryable failure.
4#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum FrameSubmitOutcome {
6    /// No scene or surface damage required presentation on this tick.
7    #[default]
8    SkippedNoDamage,
9    /// Complete frame was successfully submitted to the active surface generation.
10    Submitted,
11    /// Presentation submission failed; the complete pending frame is retained for automatic retry on the same surface generation.
12    SubmitFailed,
13}
14
15/// Reason a runtime fallback switched execution to the full CPU reference backend.
16#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub enum FallbackCpuReason {
18    /// Physical GPU device or pipeline initialization failed.
19    #[default]
20    GpuInitFailed,
21    /// GPU device or context was lost beyond bounded recovery attempts.
22    DeviceLost,
23    /// Critical GPU resource allocation failed after cache trimming.
24    CriticalAllocationFailed,
25    /// A cross-layer visual effect lacks an equivalent GPU path and cannot be safely isolated to one layer.
26    UnisolatableEffectPath,
27}
28
29/// Runtime event evaluated by `FallbackPolicyEngine` to pick a strictly non-degrading response.
30#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
31pub enum FallbackTrigger {
32    /// Host or allocator memory pressure notification.
33    MemoryPressure(MemoryPressure),
34    /// Single-frame budget overrun or cache pressure spike.
35    TransientFrameOverrun,
36    /// Sustained frame budget overrun across consecutive active frames.
37    SustainedFrameOverrun,
38    /// Active GPU backend lacks an equivalent shader path for an effect layer.
39    MissingGpuEffectPath {
40        /// Whether the effect can be isolated to a single layer with exact backdrop/blend semantics.
41        isolatable: bool,
42    },
43    /// GPU backend initialization failed.
44    GpuInitFailed,
45    /// GPU device was lost at runtime.
46    DeviceLost,
47    /// Required frame resource allocation failed.
48    AllocationFailed,
49}
50
51/// Strictly non-degrading action produced by `FallbackPolicyEngine` (never modifies shadows, blur, AA, clipping, or resolution).
52#[derive(Clone, Copy, Debug, Default, PartialEq)]
53pub enum FallbackAction {
54    /// Continue normal execution with no policy change.
55    #[default]
56    None,
57    /// Cancel speculative route prefetch and shrink cold/invisible cache retention while keeping all visible content identical.
58    TrimPrefetchAndColdCache {
59        /// Retained fraction of default cold cache budgets in `(0.0..=1.0]`.
60        retain_ratio: f32,
61    },
62    /// Adjust presentation cadence along display-compatible tiers with hysteresis and minimum dwell time.
63    AdjustPresentCadence {
64        /// Target presentation cadence in Hertz.
65        target_hz: f32,
66    },
67    /// Render one isolated effect layer through the full CPU reference rasterizer and composite into the GPU frame.
68    RouteLayerToCpuReference,
69    /// Switch the entire frame to the full CPU reference backend while preserving route, scroll, focus, and gesture state.
70    SwitchToCpuReference {
71        /// Structured cause for moving to CPU reference rendering.
72        reason: FallbackCpuReason,
73    },
74}
75
76/// Unified backend-agnostic resource classification shared by CPU reference and GPU direct-draw backends.
77#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub enum RenderResourceKind {
79    /// Color or alpha texture image resource.
80    #[default]
81    Texture,
82    /// Vertex, index, or instanced quad GPU buffer.
83    Buffer,
84    /// Persistent cached scroll tile texture layer.
85    TileLayer,
86    /// Packed glyph coverage texture atlas.
87    GlyphAtlas,
88    /// Reusable per-frame upload staging buffer slot.
89    StagingSlot,
90}