[PR #5984] [MERGED] Translucent batching (1/3): translucent terrain in an arena of its own, off by default #6594

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

📋 Pull Request Information

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

Base: main ← Head: perf/translucent-arena


📝 Commits (2)

  • 27a5ccd Renderer: translucent terrain in an arena of its own (off by default)
  • f0b0890 Renderer: a Horizon pack's [shadow] keeps translucent quads in place

📊 Changes

11 files changed (+729 additions, -86 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx.rs (+301 -57)
📝 crates/horizon-client-render/src/gfx/arena.rs (+306 -18)
📝 crates/horizon-client-render/src/gfx/lod.rs (+1 -1)
📝 crates/horizon-client-render/src/gfx/pack_post.rs (+7 -2)
📝 crates/horizon-client-render/src/graphics.rs (+25 -1)
📝 crates/horizon-client/src/game.rs (+21 -0)
📝 crates/horizon-client/src/game/packs.rs (+2 -0)
📝 crates/horizon-client/src/game/shader_packs.rs (+53 -7)
📝 crates/horizon-client/src/game/split.rs (+8 -0)
📝 crates/horizon-client/src/game/split/players.rs (+3 -0)
📝 docs/graphics.md (+2 -0)

📄 Description

🤖 Opened by NerfPhaselock's AI agent (Claude Code, Claude Opus 5.5), not by NerfPhaselock personally.

What and why

Part of #5983 (1 of 3).

Translucent quads (water, stained glass, ice) are drawn after the solid ones, back to front. They sit right after
their section's solid quads in the 256 MiB arena pages, so in back-to-front order the next section is in another page
every few sections and only short runs merge: over the ocean at render distance 64, 3,832 draw calls a frame. With
translucentBatching on, translucent quads get a vertex arena of their own whose pages may grow to about 2 GiB
(LARGE_PAGE_BYTES: DirectX 12 and OpenGL cap a buffer at i32::MAX), and the sorted indices the same cap, so the
back-to-front list stays in one vertex page and one index page and goes out as a few multi-draws. Vertex data, sorted
indices and draw order are unchanged; only where the translucent vertices live changes.

Off by default and only in horizon-graphics.txt for now, so players see no change: the third PR of the stack adds
the switch and the default, and the second shrinks the large pages once the view has settled.

Fitted to current main:

  • Shader packs draw terrain and shadow passes flat where the device can (6d7323af8), reading translucent quads from
    the section arena, so the split holds only while no running pack can (translucent_split): a shaders/ pack's
    terrain or shadow programs, or the [shadow] pass of one of Horizon's own packs. A new renderer starts in the
    picked pack's layout (picked_pack_draws_flat); a pack that changes it drops the sections and far tiles, which the
    game meshes again (take_dropped_sections, the path splitscreen uses for a fresh renderer). flat.add registers
    the solid range only.
  • compact_arena (#3466) moves what a section holds in the section arena: its solid range when split, skipping
    sections without solid quads, and keeps translucent_at with the move when not split (move_off_page). The
    translucent arena and the sorted indices keep their pages: one large page has no others to empty into.
  • LOD tiles and their fade stand-ins draw and release from the translucent arena too (drawn_mut, meshes_mut).
  • The shadow camera's translucent lists go through draw_sections, which binds the translucent arena for draws with
    sorted indices.
  • Offered with indirect multi-draws, not OpenGL's (its multi-draw loops on the CPU), and not where vanilla frames draw
    flat (Metal, Intel Gen11/Gen12 Vulkan) (translucent_batchable).
  • Every build_renderer caller passes the setting, splitscreen and resource reloads included.

Measured (RTX 4090 / 7800X3D, 1920x1080, offscreen, on main at b6ac0602d before the rebase; off -> on, two runs
each, alternating):

Render distance Scene FPS Draw calls CPU ms/frame 1 % low Arena memory
32 village 921 -> 993 (+7.8 %) 395 -> 93 1.07 -> 0.99 446 -> 467 +9 %
32 forest 1,129 -> 1,260 (+11.5 %) 337 -> 57 0.87 -> 0.78 501 -> 568 +1 %
32 ocean 1,039 -> 1,206 (+16.1 %) 946 -> 81 0.94 -> 0.81 523 -> 566 +15 %
32 mountain 687 -> 717 (+4.4 %) 234 -> 88 1.44 -> 1.37 324 -> 339 +2 %
64 forest 345 -> 414 (+20.1 %) 2,070 -> 450 2.88 -> 2.39 161 -> 173 +5 %
64 ocean 284 -> 406 (+42.8 %) 3,832 -> 354 3.50 -> 2.45 147 -> 195 +5 %
64 mountain 255 -> 261 (+2.4 %) 667 -> 340 3.90 -> 3.81 106 -> 110 +10 %

GPU time is unchanged (within 0.03 ms). The memory cost is solid and translucent quads no longer sharing free space,
and the large page keeping its size while water stays loaded; the next PR shrinks it. Rebased on 374b50d48, at render
distance 16, the same sections go out in 14 calls instead of 66 (village), 9 instead of 38 (forest), 5 instead of 72
(ocean) and 16 instead of 79 (mountain).

Pixels. Frozen frames on this branch (render distance 16, 1080p; time, weather, clouds, mobs and animated textures
frozen or off), off against on: the forest is identical; the ocean and the mountain differ in at most 241 and 22
pixels by one level, less than two shots of the same run do; the village in 3,012 and 4,373 pixels of lit walls and
slopes, none of them water, where two runs with it off differ in 340,595 to 666,800. No validation errors.

Tests. arena.rs: pages stay within their caps and the device limits (default and adapter limits), the arenas
follow the layout, large pages grow by bounded steps, clearing releases both large arenas, and compaction moves what
sections hold in the section arena (split and not, a section without solid quads, data read back). gfx.rs: the
offer and the pack-flat rule as truth tables. shader_packs.rs: which packs draw flat. graphics.rs: round trip,
default off. GPU tests run on Vulkan (RTX 4090) and skip without an adapter; CI has no GPU.

Not covered by a run yet: loading or dropping a pack that draws flat (a shaders/ pack, or one of Horizon's own with
[shadow]) while batching is on, which is the re-mesh path; DirectX 12; splitscreen.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only: vanilla draws translucent sections one by one. What is drawn, and in which order, stays vanilla's.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick --base upstream/main on DESKTOP-4R7C0FC, against upstream/main at 374b50d48, 1 min 44 s)

Check Result
Scope ⚠️ 11 files, +729 −86; 813 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (49 s)
rustfmt ✅ (8 s)
clippy ✅ (11 s)
tests: horizon-client, horizon-client-render ❌ 1638 passed, 1 failed (31 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The failing test is game::native_hooks::tests::loot_table_load_stays_hookable, which this PR doesn't touch: it looks
for "\n}\n" in horizon-world/src/loot.rs, and this Windows checkout has CRLF line endings there.

On size: of the 813 changed lines, 290 are tests (inline, as the crates keep them). The arena, the split sections and
the pack-flat rule only work together, so this is the smallest part that ships alone; shrinking the large pages and
the switch are the next two PRs. Two commits: the change, then the same rule for Horizon's own packs' [shadow]
(d36550e82), which reached main after the change was written.

🤖 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/5984 **Author:** [@NerfPhaselock](https://github.com/NerfPhaselock) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/translucent-arena` --- ### 📝 Commits (2) - [`27a5ccd`](https://github.com/horizon-rust/horizon/commit/27a5ccdbcabe890978abec2a9d3ebfcfb5a59bc9) Renderer: translucent terrain in an arena of its own (off by default) - [`f0b0890`](https://github.com/horizon-rust/horizon/commit/f0b0890d6a40c5f687bcd1084af2ff9aa74c2213) Renderer: a Horizon pack's [shadow] keeps translucent quads in place ### 📊 Changes **11 files changed** (+729 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx.rs` (+301 -57) 📝 `crates/horizon-client-render/src/gfx/arena.rs` (+306 -18) 📝 `crates/horizon-client-render/src/gfx/lod.rs` (+1 -1) 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+7 -2) 📝 `crates/horizon-client-render/src/graphics.rs` (+25 -1) 📝 `crates/horizon-client/src/game.rs` (+21 -0) 📝 `crates/horizon-client/src/game/packs.rs` (+2 -0) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+53 -7) 📝 `crates/horizon-client/src/game/split.rs` (+8 -0) 📝 `crates/horizon-client/src/game/split/players.rs` (+3 -0) 📝 `docs/graphics.md` (+2 -0) </details> ### 📄 Description > 🤖 Opened by NerfPhaselock's AI agent (Claude Code, Claude Opus 5.5), not by NerfPhaselock personally. ## What and why Part of #5983 (1 of 3). Translucent quads (water, stained glass, ice) are drawn after the solid ones, back to front. They sit right after their section's solid quads in the 256 MiB arena pages, so in back-to-front order the next section is in another page every few sections and only short runs merge: over the ocean at render distance 64, 3,832 draw calls a frame. With `translucentBatching` on, translucent quads get a vertex arena of their own whose pages may grow to about 2 GiB (`LARGE_PAGE_BYTES`: DirectX 12 and OpenGL cap a buffer at `i32::MAX`), and the sorted indices the same cap, so the back-to-front list stays in one vertex page and one index page and goes out as a few multi-draws. Vertex data, sorted indices and draw order are unchanged; only where the translucent vertices live changes. Off by default and only in `horizon-graphics.txt` for now, so players see no change: the third PR of the stack adds the switch and the default, and the second shrinks the large pages once the view has settled. **Fitted to current main:** - Shader packs draw terrain and shadow passes flat where the device can (6d7323af8), reading translucent quads from the section arena, so the split holds only while no running pack can (`translucent_split`): a `shaders/` pack's terrain or shadow programs, or the `[shadow]` pass of one of Horizon's own packs. A new renderer starts in the picked pack's layout (`picked_pack_draws_flat`); a pack that changes it drops the sections and far tiles, which the game meshes again (`take_dropped_sections`, the path splitscreen uses for a fresh renderer). `flat.add` registers the solid range only. - `compact_arena` (#3466) moves what a section holds in the section arena: its solid range when split, skipping sections without solid quads, and keeps `translucent_at` with the move when not split (`move_off_page`). The translucent arena and the sorted indices keep their pages: one large page has no others to empty into. - LOD tiles and their fade stand-ins draw and release from the translucent arena too (`drawn_mut`, `meshes_mut`). - The shadow camera's translucent lists go through `draw_sections`, which binds the translucent arena for draws with sorted indices. - Offered with indirect multi-draws, not OpenGL's (its multi-draw loops on the CPU), and not where vanilla frames draw flat (Metal, Intel Gen11/Gen12 Vulkan) (`translucent_batchable`). - Every `build_renderer` caller passes the setting, splitscreen and resource reloads included. **Measured** (RTX 4090 / 7800X3D, 1920x1080, offscreen, on main at b6ac0602d before the rebase; off -> on, two runs each, alternating): | Render distance | Scene | FPS | Draw calls | CPU ms/frame | 1 % low | Arena memory | |---|---|---|---|---|---|---| | 32 | village | 921 -> 993 (+7.8 %) | 395 -> 93 | 1.07 -> 0.99 | 446 -> 467 | +9 % | | 32 | forest | 1,129 -> 1,260 (+11.5 %) | 337 -> 57 | 0.87 -> 0.78 | 501 -> 568 | +1 % | | 32 | ocean | 1,039 -> 1,206 (+16.1 %) | 946 -> 81 | 0.94 -> 0.81 | 523 -> 566 | +15 % | | 32 | mountain | 687 -> 717 (+4.4 %) | 234 -> 88 | 1.44 -> 1.37 | 324 -> 339 | +2 % | | 64 | forest | 345 -> 414 (+20.1 %) | 2,070 -> 450 | 2.88 -> 2.39 | 161 -> 173 | +5 % | | 64 | ocean | 284 -> 406 (+42.8 %) | 3,832 -> 354 | 3.50 -> 2.45 | 147 -> 195 | +5 % | | 64 | mountain | 255 -> 261 (+2.4 %) | 667 -> 340 | 3.90 -> 3.81 | 106 -> 110 | +10 % | GPU time is unchanged (within 0.03 ms). The memory cost is solid and translucent quads no longer sharing free space, and the large page keeping its size while water stays loaded; the next PR shrinks it. Rebased on 374b50d48, at render distance 16, the same sections go out in 14 calls instead of 66 (village), 9 instead of 38 (forest), 5 instead of 72 (ocean) and 16 instead of 79 (mountain). **Pixels.** Frozen frames on this branch (render distance 16, 1080p; time, weather, clouds, mobs and animated textures frozen or off), off against on: the forest is identical; the ocean and the mountain differ in at most 241 and 22 pixels by one level, less than two shots of the same run do; the village in 3,012 and 4,373 pixels of lit walls and slopes, none of them water, where two runs with it off differ in 340,595 to 666,800. No validation errors. **Tests.** `arena.rs`: pages stay within their caps and the device limits (default and adapter limits), the arenas follow the layout, large pages grow by bounded steps, clearing releases both large arenas, and compaction moves what sections hold in the section arena (split and not, a section without solid quads, data read back). `gfx.rs`: the offer and the pack-flat rule as truth tables. `shader_packs.rs`: which packs draw flat. `graphics.rs`: round trip, default off. GPU tests run on Vulkan (RTX 4090) and skip without an adapter; CI has no GPU. Not covered by a run yet: loading or dropping a pack that draws flat (a `shaders/` pack, or one of Horizon's own with `[shadow]`) while batching is on, which is the re-mesh path; DirectX 12; splitscreen. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [x] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only: vanilla draws translucent sections one by one. What is drawn, and in which order, stays vanilla's. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick --base upstream/main` on DESKTOP-4R7C0FC, against upstream/main at 374b50d48, 1 min 44 s) | Check | Result | | --- | --- | | Scope | ⚠️ 11 files, +729 −86; 813 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (49 s) | | rustfmt | ✅ (8 s) | | clippy | ✅ (11 s) | | tests: horizon-client, horizon-client-render | ❌ 1638 passed, 1 failed (31 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The failing test is `game::native_hooks::tests::loot_table_load_stays_hookable`, which this PR doesn't touch: it looks for `"\n}\n"` in `horizon-world/src/loot.rs`, and this Windows checkout has CRLF line endings there. On size: of the 813 changed lines, 290 are tests (inline, as the crates keep them). The arena, the split sections and the pack-flat rule only work together, so this is the smallest part that ships alone; shrinking the large pages and the switch are the next two PRs. Two commits: the change, then the same rule for Horizon's own packs' `[shadow]` (d36550e82), which reached main after the change was written. 🤖 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:23:33 +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#6594
No description provided.