Uploads: main's path again when no upload budget is set

The soft 4 ms yield per frame (also with Unlimited budgets) made a saved
RD32 world reach full render distance about 1 s later on the Mac mini
(streaming time after launch, 4 alternating pairs: main 1.9 s mean, yield
2.8 s; t100 from a first batch of 3 pairs: 6.1 s vs 7.1 s) without better
loading frame times (max 133-210 ms vs 31-150 ms). Without a budget every
finished mesh uploads at once again, as on main. The budgeted path keeps
this branch's fixes: only loaded chunks' sections wait, and sizes count the
24-byte terrain vertex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-19 01:45:38 +02:00
parent a3f38b76aa
commit c74948d24c
2 changed files with 21 additions and 13 deletions
+20 -12
View File
@@ -9740,12 +9740,18 @@ impl Game<'_> {
}
if let Some(renderer) = self.renderer.as_mut() {
let g = &self.settings.horizon;
// Even unlimited count/byte settings must yield during a join's
// upload burst; draining it all blocked input/rendering for seconds.
horizon_client::spans::time("upload", || {
let budgeted = g.chunk_updates > 0 || g.upload_budget_kib > 0;
if !budgeted && self.pending_uploads.is_empty() {
horizon_client::spans::time("upload", || {
for (key, mesh) in uploads {
renderer.upload(key, &mesh);
}
});
} else {
// Horizon's chunk-update and upload budgets: the nearest
// sections go first, the rest wait for later frames; a newer
// mesh of a waiting section replaces it.
// mesh of a waiting section replaces it, and sections of
// chunks no longer loaded are dropped.
let pending = &mut self.pending_uploads;
let fresh: horizon_client::fast_hash::FxHashSet<(i32, i32, i32)> =
uploads.iter().map(|(k, _)| *k).collect();
@@ -9759,18 +9765,20 @@ impl Game<'_> {
let centre = self.streaming.center;
let far = |k: &(i32, i32, i32)| (k.0 - centre.0).pow(2) + (k.2 - centre.1).pow(2);
pending.sort_unstable_by_key(|(k, _)| std::cmp::Reverse(far(k)));
let (limit, budget) = (
g.chunk_updates as usize,
u64::from(g.upload_budget_kib) * 1024,
);
let (limit, budget) = if budgeted {
(
g.chunk_updates as usize,
u64::from(g.upload_budget_kib) * 1024,
)
} else {
(0, 0)
};
let (mut count, mut bytes) = (0, 0u64);
let upload_started = Instant::now();
while let Some((_, mesh)) = pending.last() {
let size = ((mesh.solid.len() + mesh.translucent.len())
* std::mem::size_of::<horizon_client::mesher::TerrainVertex>())
as u64;
if (count > 0 && upload_started.elapsed() >= Duration::from_millis(4))
|| (limit > 0 && count >= limit)
if (limit > 0 && count >= limit)
|| (budget > 0 && bytes > 0 && bytes + size > budget)
{
break;
@@ -9780,7 +9788,7 @@ impl Game<'_> {
count += 1;
bytes += size;
}
});
}
for c in unloaded {
for sy in 0..(HEIGHT / 16) {
renderer.remove((c.x, sy, c.z));
+1 -1
View File
@@ -25,7 +25,7 @@ Every row has a one-line description and its cost in frame time (none, low, medi
| Performance | battery mode, worker threads, upload budget per frame | `horizon-graphics.txt` |
| Overlay | performance overlay: FPS, frame/CPU/GPU times, frame-time graph | `horizon-graphics.txt` |
`options.txt` keeps exactly vanilla's keys and values, so the options harness still compares it with vanilla; Horizon's settings live in `horizon-graphics.txt` beside it. Their defaults render as vanilla does: cave culling on, no explicit upload count/byte limits, sky, fog and weather on, 100% resolution, no FXAA, the present mode following VSync. VSync on always waits for the display (Fifo), in a window and in fullscreen, as in vanilla; the present mode setting chooses how frames are shown only while VSync is off. Chunk mesh uploads yield after roughly 4 ms per frame, even with count and byte limits set to Unlimited; a single upload can exceed that soft limit. Frame pacing defaults to Efficient: the limiter sleeps through the last half millisecond where vanilla spins, which changes timing, not pixels.
`options.txt` keeps exactly vanilla's keys and values, so the options harness still compares it with vanilla; Horizon's settings live in `horizon-graphics.txt` beside it. Their defaults render as vanilla does: cave culling on, no upload budgets, sky, fog and weather on, 100% resolution, no FXAA, the present mode following VSync. VSync on always waits for the display (Fifo), in a window and in fullscreen, as in vanilla; the present mode setting chooses how frames are shown only while VSync is off. Frame pacing defaults to Efficient: the limiter sleeps through the last half millisecond where vanilla spins, which changes timing, not pixels.
**Battery mode** (Performance, off by default) is for laptops and handhelds: at most 60 frames per second in a world, 30 in menus without a world or while another window has focus, and half the automatic worker threads (chunks load slower). It changes only when frames are drawn: what they show and the game's 20 ticks per second stay as they are.