M13.24: web app depth (WEB-1) — GPU effects in frame workers, OPFS disk cache, storage manager
- GPU in the browser: each frame worker opens its own WebGPU device (Gpu::request_deferred) and renders the GPU compositor and GPU effects with deferred readbacks (effectcraft-gpu deferred): readbacks keyed by content start with map_async and miss, the pass returns placeholders, the layer cache's gate drops inserts, and FrameServer::resume renders again once the device delivered. Backend Auto times whole frames per comp in the workers. Frames with effects go to GPU workers instead of the page. CPU fallback without WebGPU in workers (?nogpuworkers). - Fix: a WGSL constant (3.40282347e38) that Chrome rejects invalidated every GPU kernel in Chrome (the page's compositor too); a test checks every float literal fits f32. - Disk cache in the Origin Private File System: workers write sealed frame entries with sync access handles (temp file + move), the page keeps the DiskIndex (LRU under the settings' limit, at most half the quota) and reads hits instead of rendering; survives reloads; blue cache bar. - Storage manager: Settings ▸ Disk ▸ Browser Storage (usage/quota, persistent storage, Clear buttons, automation ids) and storage.info / storage.persist / storage.clear (StorageHost). - Docs: web.md (GPU workers, deferred passes, disk cache, storage manager, threading design: one engine instance per worker), architecture, preferences, parity (WEB-1), roadmap. - Tests: deferred passes vs CPU on a real device, placeholder gating, frame server passes and Auto, GPU worker routing + disk cache across a reload, storage commands and widgets, store usage by kind; smoke test: GPU effect frames in workers with pixel parity, disk hits after a reload, storage manager. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
081ce79de3
commit
1b726349ab
@@ -32,6 +32,8 @@ use crate::eval::EvalCtx;
|
||||
pub struct LayerCache {
|
||||
inner: Mutex<Inner>,
|
||||
disk: Mutex<Option<(Arc<crate::disk_cache::DiskCache>, u64)>>,
|
||||
/// While set, inserts are dropped (see [`LayerCache::set_gate`]).
|
||||
gate: Mutex<Option<Arc<std::sync::atomic::AtomicBool>>>,
|
||||
}
|
||||
|
||||
struct Entry {
|
||||
@@ -72,9 +74,24 @@ impl LayerCache {
|
||||
LayerCache {
|
||||
inner: Mutex::new(Inner { map: HashMap::new(), bytes: 0, budget, clock: 0, hits: 0, misses: 0, missed_at: HashMap::new() }),
|
||||
disk: Mutex::new(None),
|
||||
gate: Mutex::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// Drop inserts while `gate` is set. A render whose GPU readbacks are still in flight (the
|
||||
/// browser's deferred readbacks, see [`crate::Accelerator::pass_missed`]) computes some
|
||||
/// buffers from placeholders; the accelerator raises the gate from its first missing
|
||||
/// readback to the end of the pass, so none of them is kept (in memory or on disk).
|
||||
pub fn set_gate(&self, gate: Option<Arc<std::sync::atomic::AtomicBool>>) {
|
||||
if let Ok(mut g) = self.gate.lock() {
|
||||
*g = gate;
|
||||
}
|
||||
}
|
||||
|
||||
fn gated(&self) -> bool {
|
||||
self.gate.lock().ok().and_then(|g| g.as_ref().map(|g| g.load(std::sync::atomic::Ordering::Relaxed))).unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Attach (or detach) the disk cache. `salt` separates projects and footage versions (see
|
||||
/// `footage_salt`); keys on disk are `(salt, key)`.
|
||||
pub fn set_disk(&self, disk: Option<(Arc<crate::disk_cache::DiskCache>, u64)>) {
|
||||
@@ -130,6 +147,9 @@ impl LayerCache {
|
||||
}
|
||||
|
||||
pub fn insert(&self, key: u64, buf: Arc<Buf>) {
|
||||
if self.gated() {
|
||||
return;
|
||||
}
|
||||
let started = self.inner.lock().ok().and_then(|mut g| g.missed_at.remove(&key));
|
||||
if let Some((dc, dk)) = self.disk_key(key) {
|
||||
let slow = started.is_some_and(|t| t.elapsed().as_secs_f64() * 1e3 >= dc.min_layer_ms() as f64);
|
||||
|
||||
Reference in New Issue
Block a user