Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/render/src/frame_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
19 changes: 11 additions & 8 deletions crates/render/src/layer_meshes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>, phone: bool) -> usize {
const FLOOR: usize = 128 << 20;
const CEILING: usize = 640 << 20;
if phone {
return FLOOR;
return MIN_BYTES;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour note, not a defect: on a phone (and in the scaled floor) max_bytes_for used to return 128 MB on every target, and now returns MIN_BYTES, which is 32 MB when built for wasm. Nothing reaches it there today, because max_bytes returns MIN_BYTES before calling it on wasm, so the desktop values are unchanged. But the function's contract changed for the wasm build, and the budget table test (the_meshes_kept_scale_with_the_memory) only checks the desktop values. A short note in the doc comment, or a wasm-gated expectation, would make the intent explicit if this path is ever used there.

Confidence: low (no observable change in the current code).

Category: quality

}
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
Expand Down Expand Up @@ -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];
Expand Down
Loading