[PR #1457] [MERGED] High-resolution resource packs no longer crash the game at launch #3535

Closed
opened 2026-11-03 04:10:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1457
Author: @ludovic111
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @ludovic111

Base: main ← Head: fix/resource-pack-crash


📝 Commits (1)

  • 22ad656 High-resolution resource packs no longer crash the game at launch

📊 Changes

3 files changed (+108 additions, -17 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+18 -2)
📝 crates/horizon-client/src/gfx.rs (+7 -0)
📝 crates/horizon-client/src/hud.rs (+83 -15)

📄 Description

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

Fixes the crash in #1442: the game crashed at every launch with Faithful 64x until the pack was removed in the launcher.

What and why

Horizon packs its GUI, item, block, entity, particle and font textures into one "Shared atlas" that was always 4096 texels wide. Faithful 64x needs 4096x32768, and every GPU Horizon runs on allows 16384 a side (Apple silicon, RADV on the reporter's RX 6800 XT, Intel). wgpu then panicked in create_texture during startup. The pack stays selected in options.txt, so the next launch crashed too.

Reproduced on main (Metal, M4 Pro) with Faithful 64x Release 15 from Modrinth (sha512 bc534dfb0e71586c…, the official upload):

panicked at wgpu-30.0.1/src/backend/wgpu_core.rs:1637:26:
wgpu error: Validation Error
  In Device::create_texture, label = 'Shared atlas'
    Dimension Y value 32768 exceeds the limit of 16384

Vanilla 26.3 with the same pack (tools/vanilla_client.py, same Mac) loads without a reload error. It keeps separate atlases (Created: 4096x4096x4 minecraft:textures/atlas/blocks.png-atlas, 4096x4096x0 …gui.png-atlas, 4096x2048x0 …items.png-atlas, …) and loose textures for the screen backgrounds. When a pack does break a reload, vanilla rolls the packs back: Minecraft.rollbackResourcePacks → clearResourcePacksOnError clears resourcePacks, saves options, reloads its own resources and shows "Resource reload failed".

How

  • HudAtlas::layout: the atlas widens (4096, then 8192, then 16384) until it fits in 16384 a side. Its height rounds up to a multiple of 1024 instead of a power of two. That saves memory: the default resources' atlas goes from 4096x8192 to 4096x5120, and Faithful 32x's from 4096x16384 to 4096x12288.
  • Textures that still don't fit are now an error, not a GPU panic. Startup handles it the way vanilla does. load_resources falls back to the default resources when the packs' UI bundle fails, as it already did when the world bundle failed. start_game then clears and saves the selection (clearResourcePacksOnError), so the next launch starts clean. The "Resource reload failed" screen that Cosmic added in 5515cbab3 shows the reason. I left it in place rather than switching to vanilla's toast.
  • Renderer::new checks the atlas against the device's max_texture_dimension_2d and returns an error instead of a validation panic.

The GUI with high-resolution packs (#1442's second half) is the stacked PR on top of this one.

Tests

  • hud::tests::a_high_resolution_pack_widens_the_atlas_to_fit_the_gpu: 100 textures of 1024x512 need 17442 rows at 4096 wide; the layout picks 8192 and every placement stays inside the atlas.
  • hud::tests::textures_that_cannot_fit_are_an_error_not_a_gpu_panic: textures past 16384x16384, or one wider than the atlas, return an error.
  • hud::tests::the_default_textures_keep_a_4096_wide_atlas.
  • End to end on Metal: the crashing case above. With this branch, Faithful 64x loads and reaches the world (115 fps) with no crash report. With a generated pack that cannot fit at all (560 textures of 1024x512, scratch only), the game starts on the default resources and shows "Resource reload failed: the textures (4856 images, 308508420 texels) do not fit a 16384x16384 atlas". options.txt then has resourcePacks:[].

Self-check (on the stack head, which contains this commit)

  • cargo fmt --all: clean
  • cargo clippy --workspace --all-targets -- -D warnings: clean
  • cargo test -p horizon-client: 1055 + 98 + 18 + 2 + 2 + 2 + 1 passed, 0 failed
  • tools/parity.py --changed origin/main: 103 harnesses depend on the changed files; 103 passed, 0 failed (35.5 min)

Benchmarks with Faithful 32x (Metal, offscreen 1280x720, seed 1, interleaved runs; frames are capped near 115 fps here, so compare CPU and GPU times):

CPU ms/frame GPU ms/frame
main, world 0.865 / 0.867 2.48 / 2.63
stack, world 0.862 / 0.862 2.47 / 2.83
main, inventory open 1.33 / 1.36 2.57 / 2.71
stack, inventory open 1.37 / 1.37 2.48 / 2.88
stack, Faithful 64x, world (main crashes) 0.862 2.17

No change beyond run-to-run noise. Nothing per frame changed here; only the atlas size did.

Needs Ludovic

  • Not checked on Linux/Vulkan: you were at the desktop, and the ThinkPad has no display or prepared resources. The limit that failed is the same 16384 on RADV.
  • Atlas memory with Faithful 64x: 8192 wide here. The GUI PR on top raises it to 16384x11264 (704 MiB), because it keeps the 1024x1024 screen backgrounds this one still drops. A better packer than the shelf one, or vanilla-style separate atlases, would bring that down. That's a separate PR if wanted.

🤖 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/1457 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/resource-pack-crash` --- ### 📝 Commits (1) - [`22ad656`](https://github.com/horizon-rust/horizon/commit/22ad65611e85746cc00ad1f5ca25725f40b42d8f) High-resolution resource packs no longer crash the game at launch ### 📊 Changes **3 files changed** (+108 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+18 -2) 📝 `crates/horizon-client/src/gfx.rs` (+7 -0) 📝 `crates/horizon-client/src/hud.rs` (+83 -15) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes the crash in #1442: the game crashed at every launch with Faithful 64x until the pack was removed in the launcher. ## What and why Horizon packs its GUI, item, block, entity, particle and font textures into one "Shared atlas" that was always 4096 texels wide. Faithful 64x needs 4096x32768, and every GPU Horizon runs on allows 16384 a side (Apple silicon, RADV on the reporter's RX 6800 XT, Intel). `wgpu` then panicked in `create_texture` during startup. The pack stays selected in `options.txt`, so the next launch crashed too. Reproduced on main (Metal, M4 Pro) with Faithful 64x Release 15 from Modrinth (sha512 `bc534dfb0e71586c…`, the official upload): ``` panicked at wgpu-30.0.1/src/backend/wgpu_core.rs:1637:26: wgpu error: Validation Error In Device::create_texture, label = 'Shared atlas' Dimension Y value 32768 exceeds the limit of 16384 ``` Vanilla 26.3 with the same pack (`tools/vanilla_client.py`, same Mac) loads without a reload error. It keeps separate atlases (`Created: 4096x4096x4 minecraft:textures/atlas/blocks.png-atlas`, `4096x4096x0 …gui.png-atlas`, `4096x2048x0 …items.png-atlas`, …) and loose textures for the screen backgrounds. When a pack does break a reload, vanilla rolls the packs back: `Minecraft.rollbackResourcePacks` → `clearResourcePacksOnError` clears `resourcePacks`, saves options, reloads its own resources and shows "Resource reload failed". ## How - `HudAtlas::layout`: the atlas widens (4096, then 8192, then 16384) until it fits in 16384 a side. Its height rounds up to a multiple of 1024 instead of a power of two. That saves memory: the default resources' atlas goes from 4096x8192 to 4096x5120, and Faithful 32x's from 4096x16384 to 4096x12288. - Textures that still don't fit are now an error, not a GPU panic. Startup handles it the way vanilla does. `load_resources` falls back to the default resources when the packs' UI bundle fails, as it already did when the world bundle failed. `start_game` then clears and saves the selection (`clearResourcePacksOnError`), so the next launch starts clean. The "Resource reload failed" screen that Cosmic added in 5515cbab3 shows the reason. I left it in place rather than switching to vanilla's toast. - `Renderer::new` checks the atlas against the device's `max_texture_dimension_2d` and returns an error instead of a validation panic. The GUI with high-resolution packs (#1442's second half) is the stacked PR on top of this one. ## Tests - `hud::tests::a_high_resolution_pack_widens_the_atlas_to_fit_the_gpu`: 100 textures of 1024x512 need 17442 rows at 4096 wide; the layout picks 8192 and every placement stays inside the atlas. - `hud::tests::textures_that_cannot_fit_are_an_error_not_a_gpu_panic`: textures past 16384x16384, or one wider than the atlas, return an error. - `hud::tests::the_default_textures_keep_a_4096_wide_atlas`. - End to end on Metal: the crashing case above. With this branch, Faithful 64x loads and reaches the world (115 fps) with no crash report. With a generated pack that cannot fit at all (560 textures of 1024x512, scratch only), the game starts on the default resources and shows "Resource reload failed: the textures (4856 images, 308508420 texels) do not fit a 16384x16384 atlas". `options.txt` then has `resourcePacks:[]`. ## Self-check (on the stack head, which contains this commit) - `cargo fmt --all`: clean - `cargo clippy --workspace --all-targets -- -D warnings`: clean - `cargo test -p horizon-client`: 1055 + 98 + 18 + 2 + 2 + 2 + 1 passed, 0 failed - `tools/parity.py --changed origin/main`: 103 harnesses depend on the changed files; 103 passed, 0 failed (35.5 min) Benchmarks with Faithful 32x (Metal, offscreen 1280x720, seed 1, interleaved runs; frames are capped near 115 fps here, so compare CPU and GPU times): | | CPU ms/frame | GPU ms/frame | | --- | --- | --- | | main, world | 0.865 / 0.867 | 2.48 / 2.63 | | stack, world | 0.862 / 0.862 | 2.47 / 2.83 | | main, inventory open | 1.33 / 1.36 | 2.57 / 2.71 | | stack, inventory open | 1.37 / 1.37 | 2.48 / 2.88 | | stack, Faithful 64x, world (main crashes) | 0.862 | 2.17 | No change beyond run-to-run noise. Nothing per frame changed here; only the atlas size did. ## Needs Ludovic - Not checked on Linux/Vulkan: you were at the desktop, and the ThinkPad has no display or prepared resources. The limit that failed is the same 16384 on RADV. - Atlas memory with Faithful 64x: 8192 wide here. The GUI PR on top raises it to 16384x11264 (704 MiB), because it keeps the 1024x1024 screen backgrounds this one still drops. A better packer than the shelf one, or vanilla-style separate atlases, would bring that down. That's a separate PR if wanted. 🤖 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 04:10:14 +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#3535
No description provided.