[PR #7069] [MERGED] F3 + S: dump the texture atlas to screenshots/debug #7313

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

📋 Pull Request Information

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

Base: main ← Head: feature/f3s-atlas-dump


📝 Commits (1)

  • e589de1 F3 + S: dump the texture atlas to screenshots/debug

📊 Changes

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

View changed files

📝 crates/horizon-client-render/src/hud.rs (+100 -0)
📝 crates/horizon-client/src/game/debug_keys.rs (+36 -5)
📝 docs/native-client.md (+1 -0)

📄 Description

🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally.

Fixes #7042. F3 + S is bound as vanilla's key.debug.dumpDynamicTextures and its action was a no-op: the key now dumps the GUI atlas into screenshots/debug/ and tells the player where, as vanilla 26.3 does.

Vanilla

javap -p -c net.minecraft.client.KeyboardHandler, the Options.keyDebugDumpDynamicTextures branch:

 802: getfield      #453   // Field net/minecraft/client/Options.keyDebugDumpDynamicTextures:Lnet/minecraft/client/KeyMapping;
 819: invokevirtual #460   // Method java/io/File.toPath:()Ljava/nio/file/Path;
 822: invokeinterface #466 // InterfaceMethod java/nio/file/Path.toAbsolutePath:()Ljava/nio/file/Path;
 831: invokestatic  #471   // Method com/mojang/blaze3d/platform/TextureUtil.getDebugTexturePath:(Ljava/nio/file/Path;)Ljava/nio/file/Path;
 840: invokevirtual #477   // Method net/minecraft/client/Minecraft.getTextureManager:()Lnet/minecraft/client/renderer/texture/TextureManager;
 845: invokevirtual #481   // Method net/minecraft/client/renderer/texture/TextureManager.dumpAllSheets:(Ljava/nio/file/Path;)V
 884: ldc_w         #507   // String debug.dump_dynamic_textures

TextureUtil.getDebugTexturePath resolves screenshots then debug under the game folder. TextureManager.dumpAllSheets creates it and calls Dumpable.dumpContents on each texture; TextureAtlas.dumpContents names the file with Identifier.toDebugFileName (/ and : become _), writes the texels with TextureUtil.writeAsPNG and dumpSpriteNames beside it — every sprite sorted by name, %s\tx=%d\ty=%d\tw=%d\th=%d%n, the rect in texels. The chat gets debug.dump_dynamic_textures with the folder underlined and clickable.

This change

  • hud::dump_atlas (render crate) writes name.png (RGBA8) and name.txt (the sprite list), and refuses a buffer that is not width * height * 4 bytes so a half-written file is not left behind; HudAtlas::dump_contents is the method form. It reads through HudAtlas::pixels(), the decompressing accessor, because pack_pixels frees the raw copy once the GPU has the atlas — vanilla reads the texture back from the GPU in the same situation.
  • game::debug_keys: the F3 + S branch dumps minecraft_textures_atlas_gui into the player's screenshots/debug, logs it and shows debug.dump_dynamic_textures with a ClickEvent::OpenFile link on the folder.
  • Horizon packs the GUI, font, particle, map and skin sprites into one atlas, so this one file stands in for the atlases vanilla dumps apart; the doc comment says so.
  • docs/native-client.md: the F3 + S row of the controls table.

Evidence

Unit test: cargo test -p horizon-client-render --lib --profile fast dump → hud::tests::dumping_the_atlas_writes_its_pixels_and_sprite_rects ... ok. It decodes the written PNG back to the pixels given, checks the list is sorted with rects in texels, and that an empty buffer writes no file at all.

Real client on Windows, --offscreen, fresh HORIZON_HOME, driven with key f3 down, key s tap, key f3 up:

[ctl.log] Dumped dynamic textures to D:\work\horizon\screenshots\debug
screenshots/debug/minecraft_textures_atlas_gui.png   2,455,697 bytes   4096x5120
screenshots/debug/minecraft_textures_atlas_gui.txt     217,979 bytes   4458 sprites
block/acacia_door_bottom	x=3927	y=4413	w=16	h=16
block/acacia_door_top	x=3944	y=4413	w=16	h=16
block/acacia_hanging_sign	x=165	y=4240	w=32	h=32

The atlas the game wrote, thumbnail of the 4096×5120 PNG:

the dumped atlas

Checks

**pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-9IR5DCN, against origin/main at 0b58feba0, 7 min 18 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 3 files, +137 −5 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ❌ 611 run, FAILED (errors=1, skipped=1) |
| rustfmt | ✅ |
| Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't |
| clippy | ✅ |
| tests: horizon-client, horizon-client-render | ❌ 1794 passed, 1 failed |
| doc tests | ✅ |
| content root tests | ➖ content root untouched |
| mod API up to date | ✅ |
| tokens.css up to date | ➖ theme untouched |
| launcher rustfmt/clippy/tests | ➖ launcher untouched |
| Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses |

Both reds are on main on this machine, with this change removed (git checkout --detach origin/main, 0b58feba0):

$ cargo test -p horizon-client-render --lib --profile fast entity_skin
failures:
    gfx::entity_skin::tests::the_shader_writes_what_the_cpu_reference_computes
test result: FAILED. 0 passed; 1 failed   (1.2150468 vs 1.2150469, one float bit in a
                                          shader-vs-CPU vertex; no shader is touched here)

$ python3 -m pytest tests -x -q
tests\test_port_ledger.py:10: in <module>
    from tests.test_class_index import Pool
E   ModuleNotFoundError: No module named 'tests.test_class_index'

Nothing in this PR goes near entity skins or tools/port_map, so both are left as they are.

Part of the debug screen roadmap item (F3 + S, "the atlas dump"). Suggested label: feature.


🔄 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/7069 **Author:** [@CocofireHD](https://github.com/CocofireHD) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feature/f3s-atlas-dump` --- ### 📝 Commits (1) - [`e589de1`](https://github.com/horizon-rust/horizon/commit/e589de1c48b46c38ed0058d4a994532ed091ec08) F3 + S: dump the texture atlas to screenshots/debug ### 📊 Changes **3 files changed** (+137 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/hud.rs` (+100 -0) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+36 -5) 📝 `docs/native-client.md` (+1 -0) </details> ### 📄 Description > 🤖 Opened by CocofireHD's AI agent (Hermes Agent, deepseek-v4.1-flash), not by CocofireHD personally. Fixes #7042. F3 + S is bound as vanilla's `key.debug.dumpDynamicTextures` and its action was a no-op: the key now dumps the GUI atlas into `screenshots/debug/` and tells the player where, as vanilla 26.3 does. ## Vanilla `javap -p -c net.minecraft.client.KeyboardHandler`, the `Options.keyDebugDumpDynamicTextures` branch: ``` 802: getfield #453 // Field net/minecraft/client/Options.keyDebugDumpDynamicTextures:Lnet/minecraft/client/KeyMapping; 819: invokevirtual #460 // Method java/io/File.toPath:()Ljava/nio/file/Path; 822: invokeinterface #466 // InterfaceMethod java/nio/file/Path.toAbsolutePath:()Ljava/nio/file/Path; 831: invokestatic #471 // Method com/mojang/blaze3d/platform/TextureUtil.getDebugTexturePath:(Ljava/nio/file/Path;)Ljava/nio/file/Path; 840: invokevirtual #477 // Method net/minecraft/client/Minecraft.getTextureManager:()Lnet/minecraft/client/renderer/texture/TextureManager; 845: invokevirtual #481 // Method net/minecraft/client/renderer/texture/TextureManager.dumpAllSheets:(Ljava/nio/file/Path;)V 884: ldc_w #507 // String debug.dump_dynamic_textures ``` `TextureUtil.getDebugTexturePath` resolves `screenshots` then `debug` under the game folder. `TextureManager.dumpAllSheets` creates it and calls `Dumpable.dumpContents` on each texture; `TextureAtlas.dumpContents` names the file with `Identifier.toDebugFileName` (`/` and `:` become `_`), writes the texels with `TextureUtil.writeAsPNG` and `dumpSpriteNames` beside it — every sprite sorted by name, `%s\tx=%d\ty=%d\tw=%d\th=%d%n`, the rect in texels. The chat gets `debug.dump_dynamic_textures` with the folder underlined and clickable. ## This change - `hud::dump_atlas` (render crate) writes `name.png` (RGBA8) and `name.txt` (the sprite list), and refuses a buffer that is not `width * height * 4` bytes so a half-written file is not left behind; `HudAtlas::dump_contents` is the method form. It reads through `HudAtlas::pixels()`, the decompressing accessor, because `pack_pixels` frees the raw copy once the GPU has the atlas — vanilla reads the texture back from the GPU in the same situation. - `game::debug_keys`: the F3 + S branch dumps `minecraft_textures_atlas_gui` into the player's `screenshots/debug`, logs it and shows `debug.dump_dynamic_textures` with a `ClickEvent::OpenFile` link on the folder. - Horizon packs the GUI, font, particle, map and skin sprites into one atlas, so this one file stands in for the atlases vanilla dumps apart; the doc comment says so. - `docs/native-client.md`: the F3 + S row of the controls table. ## Evidence Unit test: `cargo test -p horizon-client-render --lib --profile fast dump` → `hud::tests::dumping_the_atlas_writes_its_pixels_and_sprite_rects ... ok`. It decodes the written PNG back to the pixels given, checks the list is sorted with rects in texels, and that an empty buffer writes no file at all. Real client on Windows, `--offscreen`, fresh `HORIZON_HOME`, driven with `key f3 down`, `key s tap`, `key f3 up`: ``` [ctl.log] Dumped dynamic textures to D:\work\horizon\screenshots\debug screenshots/debug/minecraft_textures_atlas_gui.png 2,455,697 bytes 4096x5120 screenshots/debug/minecraft_textures_atlas_gui.txt 217,979 bytes 4458 sprites block/acacia_door_bottom x=3927 y=4413 w=16 h=16 block/acacia_door_top x=3944 y=4413 w=16 h=16 block/acacia_hanging_sign x=165 y=4240 w=32 h=32 ``` The atlas the game wrote, thumbnail of the 4096×5120 PNG: ![the dumped atlas](https://raw.githubusercontent.com/CocofireHD/horizon/pr-assets/f3s-atlas-dump/atlas_thumb.png) ### Checks ``` **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-9IR5DCN, against origin/main at 0b58feba0, 7 min 18 s) | Check | Result | | --- | --- | | Scope | ✅ 3 files, +137 −5 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 611 run, FAILED (errors=1, skipped=1) | | rustfmt | ✅ | | Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't | | clippy | ✅ | | tests: horizon-client, horizon-client-render | ❌ 1794 passed, 1 failed | | doc tests | ✅ | | content root tests | ➖ content root untouched | | mod API up to date | ✅ | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt/clippy/tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | ``` Both reds are on `main` on this machine, with this change removed (`git checkout --detach origin/main`, 0b58feba0): ``` $ cargo test -p horizon-client-render --lib --profile fast entity_skin failures: gfx::entity_skin::tests::the_shader_writes_what_the_cpu_reference_computes test result: FAILED. 0 passed; 1 failed (1.2150468 vs 1.2150469, one float bit in a shader-vs-CPU vertex; no shader is touched here) $ python3 -m pytest tests -x -q tests\test_port_ledger.py:10: in <module> from tests.test_class_index import Pool E ModuleNotFoundError: No module named 'tests.test_class_index' ``` Nothing in this PR goes near entity skins or `tools/port_map`, so both are left as they are. Part of the debug screen roadmap item (F3 + S, "the atlas dump"). Suggested label: `feature`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:37:36 +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#7313
No description provided.