diff --git a/crates/render/src/frame_cache.rs b/crates/render/src/frame_cache.rs index f12dcef4c7..eb91a2db54 100644 --- a/crates/render/src/frame_cache.rs +++ b/crates/render/src/frame_cache.rs @@ -71,9 +71,9 @@ const KEPT: usize = 2; /// The most bytes of meshes the kept GPU checkpoints hold together ([`GpuPart`]), as /// [`crate::layer_meshes`] counts them: they share them with the scenes on screen and the meshes -/// that module keeps, so what they hold beside those is at most this: 128 MB (32 MB in the -/// browser), that module's least budget ([`crate::layer_meshes::max_bytes`]). -const MAX_MESH_BYTES: usize = if cfg!(target_arch = "wasm32") { 32 << 20 } else { 128 << 20 }; +/// that module keeps, so what they hold beside those is at most this: that module's least budget +/// ([`crate::layer_meshes::MIN_BYTES`]). +const MAX_MESH_BYTES: usize = crate::layer_meshes::MIN_BYTES; /// What a frame is drawn from besides its layers. #[derive(Clone, Debug)] diff --git a/crates/render/src/layer_meshes.rs b/crates/render/src/layer_meshes.rs index f6a5f9dddb..f70536489f 100644 --- a/crates/render/src/layer_meshes.rs +++ b/crates/render/src/layer_meshes.rs @@ -47,19 +47,21 @@ use crate::mesh_tiles::MadeTile; /// (`memory::physical`). pub(crate) fn max_bytes() -> usize { if cfg!(target_arch = "wasm32") { - return 32 << 20; + return MIN_BYTES; } max_bytes_for(rustgis_data::memory::physical(), rustgis_data::memory::on_phone()) } +/// The least [`max_bytes`] gives: 128 MB, 32 MB in the browser (its whole budget there). +pub(crate) const MIN_BYTES: usize = if cfg!(target_arch = "wasm32") { 32 << 20 } else { 128 << 20 }; + /// [`max_bytes`] on a computer with `memory` bytes (`None`: not known), or on a phone. fn max_bytes_for(memory: Option, phone: bool) -> usize { - const FLOOR: usize = 128 << 20; const CEILING: usize = 640 << 20; if phone { - return FLOOR; + return MIN_BYTES; } - rustgis_data::memory::scaled(memory.map(|m| m / 4), FLOOR, CEILING, 1) + rustgis_data::memory::scaled(memory.map(|m| m / 4), MIN_BYTES, CEILING, 1) } /// What a kept mesh is counted as holding beside its data and rows: its layer's look (the @@ -517,10 +519,11 @@ mod tests { } } - /// Whether `scene` draws all `afresh` draws, mesh by mesh in the same place: a tilted view's - /// band tile taken again may hold features past its ground too, which its depth clipping - /// leaves out, so each of `afresh`'s meshes' triangles (by their vertices' values) need only - /// be among `scene`'s there. + /// Whether `scene` draws all `afresh` draws: the same meshes in the same places (a pan takes + /// the tiles of the new ground, none more), each of `afresh`'s meshes' triangles (by their + /// vertices' values) among `scene`'s there. A tilted view's band tile taken again may hold + /// features past its ground too, which its depth clipping leaves out, so a mesh of `scene` + /// may have more triangles than `afresh`'s. fn draws_all_of(scene: &GpuScene, afresh: &GpuScene) -> bool { type Key = ([u64; 2], Option<[u32; 4]>); type Triangle = [[u32; 4]; 3];