Phase 3a-1: lazy fault-in of raster keyframe pixels
Raster keyframes are no longer eagerly decoded at load — `raw_pixels` stays empty and is paged in on demand from the project container, so a big paint project opens instantly and only touched frames hit RAM. - core: `read_packed_media_readonly` (fresh read-only connection, can't conflict with an in-place save) + `RasterStore` (holds the container path; `load_pixels` reads+decodes a keyframe's PNG by id). `load_beam_sqlite` stops eager-decoding and instead marks every raster keyframe `needs_fault_in` (recursively, incl. nested); a freshly-created keyframe stays false (blank-resident, nothing to page). Added `Document::all_layers_mut`. - editor: the canvas records a fault-in request when it needs a paged-out keyframe (empty pixels && needs_fault_in); the App drains the sink at the top of update(), pages the pixels in via the store, clears the flag, and repaints. Store path is set on load and after save. Export faults in synchronously per frame. Cold-scrub still shows a 1-frame gap and the page-in is synchronous; the image proxy (3a-2) and async load (3a-3) remove those next.
This commit is contained in:
@@ -246,6 +246,12 @@ pub struct SharedPaneState<'a> {
|
||||
/// raw samples (pool_index -> `B`, floor frames-per-texel). Drives the GPU
|
||||
/// min/max upload path and the floor's effective rate `sr/B` in the renderer.
|
||||
pub waveform_minmax_pools: &'a std::collections::HashMap<usize, u32>,
|
||||
/// Miss-sink for on-demand raster keyframe pixel faulting (Phase 3 paging).
|
||||
/// The canvas inserts the id of any raster keyframe it wants to upload whose
|
||||
/// `raw_pixels` aren't resident; the App drains this at the top of the next
|
||||
/// `update()` and faults the pixels in from the project container.
|
||||
pub raster_fault_requests:
|
||||
&'a std::sync::Arc<std::sync::Mutex<std::collections::HashSet<uuid::Uuid>>>,
|
||||
/// Effect ID to load into shader editor (set by asset library, consumed by shader editor)
|
||||
pub effect_to_load: &'a mut Option<Uuid>,
|
||||
/// Queue for effect thumbnail requests (effect IDs to generate thumbnails for)
|
||||
|
||||
@@ -523,6 +523,12 @@ struct VelloRenderContext {
|
||||
/// When `Some`, readback this B-canvas into `RASTER_READBACK_RESULTS` after
|
||||
/// dispatching GPU tool work. Set on mouseup by the unified raster tool commit path.
|
||||
pending_tool_readback_b: Option<uuid::Uuid>,
|
||||
/// Miss-sink for on-demand raster keyframe pixel faulting (Phase 3 paging).
|
||||
/// When the compositor wants to upload an idle raster keyframe whose `raw_pixels`
|
||||
/// aren't resident, it inserts the keyframe id here; the App drains this at the
|
||||
/// top of the next `update()` and faults the pixels in from the project container.
|
||||
raster_fault_requests:
|
||||
std::sync::Arc<std::sync::Mutex<std::collections::HashSet<uuid::Uuid>>>,
|
||||
}
|
||||
|
||||
/// Callback for Vello rendering within egui
|
||||
@@ -1206,6 +1212,15 @@ impl egui_wgpu::CallbackTrait for VelloCallback {
|
||||
);
|
||||
Some(kf_id)
|
||||
} else {
|
||||
// Empty pixels: if the frame is paged out (lives in the
|
||||
// container), record a fault-in request so the App pages it
|
||||
// in at the top of the next frame. A new blank keyframe
|
||||
// (needs_fault_in == false) has nothing to load — skip it.
|
||||
if kf.needs_fault_in {
|
||||
if let Ok(mut reqs) = self.ctx.raster_fault_requests.lock() {
|
||||
reqs.insert(kf_id);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
} else {
|
||||
@@ -11902,6 +11917,7 @@ impl PaneRenderer for StagePane {
|
||||
.and_then(|(tool, _)| tool.take_pending_gpu_work()),
|
||||
pending_layer_cache_removals: std::mem::take(&mut self.pending_layer_cache_removals),
|
||||
pending_tool_readback_b: self.pending_tool_readback_b.take(),
|
||||
raster_fault_requests: std::sync::Arc::clone(shared.raster_fault_requests),
|
||||
}};
|
||||
|
||||
let cb = egui_wgpu::Callback::new_paint_callback(
|
||||
|
||||
Reference in New Issue
Block a user