[PR #6843] [MERGED] The GUI atlas keeps its pixels compressed once the GPU has them #7135

Closed
opened 2026-11-03 06:34:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6843
Author: @ludovic111
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: perf/atlas-cpu-copy


📝 Commits (1)

  • e959cd1 The GUI atlas keeps its pixels compressed once the GPU has them

📊 Changes

5 files changed (+105 additions, -10 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client-render/Cargo.toml (+2 -0)
📝 crates/horizon-client-render/src/hud.rs (+94 -0)
📝 crates/horizon-client/src/game.rs (+7 -1)
📝 crates/horizon-client/src/game/stations.rs (+1 -9)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

The window's GUI atlas (the 4096x5120 "Shared atlas": GUI sprites, fonts, entity textures) kept its pixels in memory as they were built, 80 MB of RGBA for the whole session. Once the renderer has uploaded them, only a renderer built again reads them: a graphics API switch, a lost device, or a pack reload that rebuilds the renderer. The GPU's copy is what draws.

  • Once a renderer exists, the pixels are compressed with lz4 on a thread of their own and the raw copy is freed. HudAtlas::pixels() decompresses them for a renderer built later.
  • The enchanting table's Standard Galactic text measured each glyph's width from those pixels every frame. The widths are now measured once, when the atlas is built, with the same scan.

The same bytes are uploaded and the glyph widths are the same, so the images are identical. Screenshots of the Options screen from both binaries are compared below.

A/B

playhorizon (Linux, llvmpipe Vulkan, 1280x720 offscreen, load 14-29), title screen 60 s after start. Three rounds, main and this branch side by side; medians.

main this PR Δ rounds
RSS at the title 697 MB 650 MB −47 MB 3/3 down (−65, −50, −26)
peak RSS by then 761 MB 818 MB +57 MB the compression's buffer, once
GPU allocated 131 MB 131 MB 0
screenshot (first-run accessibility screen: logo, buttons, icons, text) da44a3d8… da44a3d8… byte-identical 3/3
  • The peak rises once, at the first frame, while the compressed copy is written next to the raw one. It stays far under a world's peak (1 GB at RD 32 in #6827's runs), so the session's peak doesn't change.
  • The compressed copy's size wasn't logged. The RSS drop and the peak put it at roughly 30 MB, against 80 MB raw. lz4 was chosen because it decompresses at GB/s, so a renderer rebuild waits only milliseconds for it.
  • New dependency: lz4_flex 0.14 (MIT), with the safe encoder and decoder only.

Next, on the GPU side: the 4096x5120 layout rounds its height up to a multiple of 1024 (up to 16 MB of empty rows). That is a separate change, and its image check moves texel coordinates.

Checks

pr_ready --quick on playhorizon. Cargo.lock changed, so it ran the whole workspace.

Check Result
Scope ✅ 5 files, +105 −10
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅ (1 s)
Python tests ❌ 598 run, FAILED (failures=2, skipped=1) (1 min 6 s)
rustfmt ✅ (20 s)
clippy ✅ (3 min 53 s)
tests: workspace ❌ 2117 passed (37 min 48 s)
doc tests ✅ 0 passed (12 s)
content root tests ✅ 22 passed (9 min 14 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (2 s)
launcher clippy ✅ (3 min 51 s)
launcher tests ❌ 400 passed, 1 failed (7 min 50 s)
Parity ➖ 377 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 365 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • tests: workspace: the horizon-client-render lib tests crashed with SIGSEGV while running in parallel on llvmpipe, a known crash on that host. Rerun alone with --test-threads 1: 985 passed, 0 failed.
  • launcher tests: backend::tests::a_replaced_binary_is_replaced_again_at_its_path failed (a binary's size, 509 vs 493). This PR doesn't touch the launcher.
  • Python tests: test_lab.GameEnvScreenTests fails twice because the host's runner environment sets VSCREEN. This PR touches no Python.
  • New unit test packed_pixels_come_back_the_same.
  • Parity: left to CI's parity job.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/6843 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/atlas-cpu-copy` --- ### 📝 Commits (1) - [`e959cd1`](https://github.com/horizon-rust/horizon/commit/e959cd1516d2f0c866d428dd88a688b353e75bf0) The GUI atlas keeps its pixels compressed once the GPU has them ### 📊 Changes **5 files changed** (+105 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client-render/Cargo.toml` (+2 -0) 📝 `crates/horizon-client-render/src/hud.rs` (+94 -0) 📝 `crates/horizon-client/src/game.rs` (+7 -1) 📝 `crates/horizon-client/src/game/stations.rs` (+1 -9) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The window's GUI atlas (the 4096x5120 "Shared atlas": GUI sprites, fonts, entity textures) kept its pixels in memory as they were built, 80 MB of RGBA for the whole session. Once the renderer has uploaded them, only a renderer built again reads them: a graphics API switch, a lost device, or a pack reload that rebuilds the renderer. The GPU's copy is what draws. - Once a renderer exists, the pixels are compressed with lz4 on a thread of their own and the raw copy is freed. `HudAtlas::pixels()` decompresses them for a renderer built later. - The enchanting table's Standard Galactic text measured each glyph's width from those pixels every frame. The widths are now measured once, when the atlas is built, with the same scan. The same bytes are uploaded and the glyph widths are the same, so the images are identical. Screenshots of the Options screen from both binaries are compared below. ## A/B playhorizon (Linux, llvmpipe Vulkan, 1280x720 offscreen, load 14-29), title screen 60 s after start. Three rounds, main and this branch side by side; medians. | | main | this PR | Δ | rounds | |---|---|---|---|---| | RSS at the title | 697 MB | 650 MB | **−47 MB** | 3/3 down (−65, −50, −26) | | peak RSS by then | 761 MB | 818 MB | +57 MB | the compression's buffer, once | | GPU allocated | 131 MB | 131 MB | 0 | | | screenshot (first-run accessibility screen: logo, buttons, icons, text) | `da44a3d8…` | `da44a3d8…` | byte-identical | 3/3 | - The peak rises once, at the first frame, while the compressed copy is written next to the raw one. It stays far under a world's peak (1 GB at RD 32 in #6827's runs), so the session's peak doesn't change. - The compressed copy's size wasn't logged. The RSS drop and the peak put it at roughly 30 MB, against 80 MB raw. lz4 was chosen because it decompresses at GB/s, so a renderer rebuild waits only milliseconds for it. - New dependency: `lz4_flex` 0.14 (MIT), with the safe encoder and decoder only. Next, on the GPU side: the 4096x5120 layout rounds its height up to a multiple of 1024 (up to 16 MB of empty rows). That is a separate change, and its image check moves texel coordinates. ## Checks `pr_ready --quick` on playhorizon. `Cargo.lock` changed, so it ran the whole workspace. | Check | Result | | --- | --- | | Scope | ✅ 5 files, +105 −10 | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ (1 s) | | Python tests | ❌ 598 run, FAILED (failures=2, skipped=1) (1 min 6 s) | | rustfmt | ✅ (20 s) | | clippy | ✅ (3 min 53 s) | | tests: workspace | ❌ 2117 passed (37 min 48 s) | | doc tests | ✅ 0 passed (12 s) | | content root tests | ✅ 22 passed (9 min 14 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (2 s) | | launcher clippy | ✅ (3 min 51 s) | | launcher tests | ❌ 400 passed, 1 failed (7 min 50 s) | | Parity | ➖ 377 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, armor_stand_frost, arrow, arrow_wind_charge, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes and 365 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - **tests: workspace**: the `horizon-client-render` lib tests crashed with SIGSEGV while running in parallel on llvmpipe, a known crash on that host. Rerun alone with `--test-threads 1`: 985 passed, 0 failed. - **launcher tests**: `backend::tests::a_replaced_binary_is_replaced_again_at_its_path` failed (a binary's size, 509 vs 493). This PR doesn't touch the launcher. - **Python tests**: `test_lab.GameEnvScreenTests` fails twice because the host's runner environment sets `VSCREEN`. This PR touches no Python. - New unit test `packed_pixels_come_back_the_same`. - **Parity**: left to CI's parity job. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:34:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7135
No description provided.