[PR #7861] Block sprites: keep the CPU copy compressed once uploaded #7868

Open
opened 2026-11-03 07:25:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7861
Author: @ludovic111
Created: 11/2/2026
Status: 🔄 Open

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


📝 Commits (1)

  • 2c9dac6 Block sprites: keep the CPU copy compressed once uploaded

📊 Changes

3 files changed (+103 additions, -5 deletions)

View changed files

📝 crates/horizon-client-render/src/assets.rs (+99 -2)
📝 crates/horizon-client/examples/sprite_cache_parity.rs (+1 -1)
📝 crates/horizon-client/src/game.rs (+3 -2)

📄 Description

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

What

The block texture array's pixels (RenderAssets::pixels, 20 MB with the default resources) stayed on the heap for the whole session. Once uploaded they are only read again to build another renderer: after the GPU device is lost, or for a split-screen window. Once a renderer exists, they are now lz4-compressed on a thread of their own, as the GUI atlas is since #6843. A renderer built later decompresses them (SpritePixels::get). The test sprite_pixels_come_back_the_same_once_packed checks that the pixels come back byte for byte.

A/B (playhorizon, offscreen on llvmpipe, server thread, seed 1234, alloc-census build, 3 pairs, medians)

A = this branch with main's three files, B = this branch.

A B
core.block_models_sprites (live MB) 49.5 29.3
Sprite packing (the compressed copy, MB) 0 1.2
live heap in the world, RD 8 (MB) 330.1 311.2
RSS at the title (MB) 710 (694–728) 684 (662–710)
RSS in the world, RD 8 (MB) 1134 (1129–1158) 1132 (1118–1135)
  • The live heap is down 19 MB at the title and in the world.
  • RSS in the world does not move beyond run-to-run noise (a 30 MB spread): other allocations reuse the freed pages.

Image check. One A run and one B run at the same spot: spectator at (−519.5, 76, 64.5), facing 45°/65°, noon, clear weather, ticks frozen, RD 8. On land, every pixel of A differs from B by the same sign: only a uniform brightness shift of 0.5–1.2 levels on average, at most 6. Two screenshots taken 5 s apart in one run are identical there. The shift is not this PR's:

  • A run against another A run with a longer settle shows the same kind of shift, +0.8 to +1.6 levels.
  • B is brighter than A at a 40 s settle and darker at 70 s.

So scene brightness depends on when the shot is taken, in both builds. No texture differs.

Checks

  • sprite_pixels_come_back_the_same_once_packed (horizon-client-render): the pixels come back byte for byte once compressed.
  • Render harnesses on playhorizon at 2c9dac6bb: all 8 pass (block_entity_render, blockstate_model, breaking_model, environment_render, item_model, mipmap, model_baking, sprite_animation).
  • Server play, same head:
    • lan_e2e: light passes. Chest failed once: the guest's lid stayed at 0 while its container screen was open. Rerun 4 times from the A/B builds (twice this branch, twice main's sprite code), it passes every time.
    • A dedicated server with 2 walking bots (server_bench) holds 20 TPS, with MSPT averaging 6.48.

pr_ready (tools/pr_ready.py --quick on playhorizon, against origin/main at a11300210, 34 min 2 s)

Check Result
Scope ✅ 3 files, +103 −5
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 614 run, FAILED (failures=2, skipped=1) (1 min 0 s)
rustfmt ✅ (13 s)
clippy ✅ (5 min 15 s)
tests: horizon-client, horizon-client-lib, horizon-client-render ✅ 3339 passed (22 min 28 s)
doc tests ✅ 0 passed (7 s)
content root tests ✅ 24 passed (4 min 42 s)
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 140 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles and 128 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)
  • Python tests: test_lab's test_macos_and_windows_start_no_virtual_screen fails because the playhorizon runner's own VSCREEN leaks into it. It fails the same way on main.

Label: none (players get less memory used).

🤖 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/7861 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/sprite-cpu-copy` --- ### 📝 Commits (1) - [`2c9dac6`](https://github.com/horizon-rust/horizon/commit/2c9dac6bbc8395c84c381c464e8b9313a7015bda) Block sprites: keep the CPU copy compressed once uploaded ### 📊 Changes **3 files changed** (+103 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/assets.rs` (+99 -2) 📝 `crates/horizon-client/examples/sprite_cache_parity.rs` (+1 -1) 📝 `crates/horizon-client/src/game.rs` (+3 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What The block texture array's pixels (`RenderAssets::pixels`, 20 MB with the default resources) stayed on the heap for the whole session. Once uploaded they are only read again to build another renderer: after the GPU device is lost, or for a split-screen window. Once a renderer exists, they are now lz4-compressed on a thread of their own, as the GUI atlas is since #6843. A renderer built later decompresses them (`SpritePixels::get`). The test `sprite_pixels_come_back_the_same_once_packed` checks that the pixels come back byte for byte. ## A/B (playhorizon, offscreen on llvmpipe, server thread, seed 1234, `alloc-census` build, 3 pairs, medians) A = this branch with main's three files, B = this branch. | | A | B | |---|---|---| | `core.block_models_sprites` (live MB) | 49.5 | 29.3 | | `Sprite packing` (the compressed copy, MB) | 0 | 1.2 | | live heap in the world, RD 8 (MB) | 330.1 | 311.2 | | RSS at the title (MB) | 710 (694–728) | 684 (662–710) | | RSS in the world, RD 8 (MB) | 1134 (1129–1158) | 1132 (1118–1135) | - The live heap is down 19 MB at the title and in the world. - RSS in the world does not move beyond run-to-run noise (a 30 MB spread): other allocations reuse the freed pages. **Image check.** One A run and one B run at the same spot: spectator at (−519.5, 76, 64.5), facing 45°/65°, noon, clear weather, ticks frozen, RD 8. On land, every pixel of A differs from B by the same sign: only a uniform brightness shift of 0.5–1.2 levels on average, at most 6. Two screenshots taken 5 s apart in one run are identical there. The shift is not this PR's: - A run against another A run with a longer settle shows the same kind of shift, +0.8 to +1.6 levels. - B is brighter than A at a 40 s settle and darker at 70 s. So scene brightness depends on when the shot is taken, in both builds. No texture differs. ## Checks - `sprite_pixels_come_back_the_same_once_packed` (horizon-client-render): the pixels come back byte for byte once compressed. - Render harnesses on playhorizon at 2c9dac6bb: all 8 pass (block_entity_render, blockstate_model, breaking_model, environment_render, item_model, mipmap, model_baking, sprite_animation). - Server play, same head: - `lan_e2e`: light passes. Chest failed once: the guest's lid stayed at 0 while its container screen was open. Rerun 4 times from the A/B builds (twice this branch, twice main's sprite code), it passes every time. - A dedicated server with 2 walking bots (`server_bench`) holds 20 TPS, with MSPT averaging 6.48. **pr_ready** (`tools/pr_ready.py --quick` on playhorizon, against origin/main at a11300210, 34 min 2 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +103 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 614 run, FAILED (failures=2, skipped=1) (1 min 0 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (5 min 15 s) | | tests: horizon-client, horizon-client-lib, horizon-client-render | ✅ 3339 passed (22 min 28 s) | | doc tests | ✅ 0 passed (7 s) | | content root tests | ✅ 24 passed (4 min 42 s) | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 140 affected, to run in CI (--quick): ambient_sound, anvil_turtle_egg, armor_stand_frost, armor_stand_turtle_egg, arrow, arrow_wind_charge, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles and 128 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | - Python tests: `test_lab`'s `test_macos_and_windows_start_no_virtual_screen` fails because the playhorizon runner's own `VSCREEN` leaks into it. It fails the same way on main. Label: none (players get less memory used). 🤖 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>
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#7868
No description provided.