[PR #1742] [MERGED] Terrain vertex arena readable as storage where flat draws run #3734

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

📋 Pull Request Information

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

Base: main ← Head: feat/shader-packs-arena-storage


📝 Commits (10+)

  • 6c8880f Shader packs, clean room 15: globals initialized at run time, switch options
  • 505e8e9 Shader packs, clean room 16: custom uniforms
  • a2ec3fc Shader packs, clean room 17: real packs' buffers and samplers
  • 3e2c30a Shader packs, clean room 18: translucent terrain drawn by the pack
  • b6345fc Shader packs, clean room 19: GPU time of each pass (developers' aid)
  • 5e348aa Shader packs, clean room 20: buffer mipmaps
  • b9b47f1 Shader packs, clean room 21: per-draw uniforms (renderStage)
  • 7d6583d Shader packs, clean room 22: the sky (gbuffers_skybasic)
  • 230730d Shader packs, clean room 23: the sun and moon (gbuffers_skytextured)
  • b940754 Terrain vertex arena readable as storage where flat draws run

📊 Changes

25 files changed (+2623 additions, -203 deletions)

View changed files

📝 crates/horizon-client/src/game/shader_packs.rs (+2 -2)
📝 crates/horizon-client/src/gfx.rs (+83 -20)
📝 crates/horizon-client/src/gfx/arena.rs (+11 -4)
📝 crates/horizon-client/src/gfx/pack_atlas.rs (+1 -0)
➕ crates/horizon-client/src/gfx/pack_draw.rs (+67 -0)
📝 crates/horizon-client/src/gfx/pack_post.rs (+737 -124)
📝 crates/horizon-client/src/gfx/pack_post.wgsl (+8 -0)
➕ crates/horizon-client/src/gfx/pack_sky.rs (+319 -0)
➕ crates/horizon-client/src/gfx/pack_timing.rs (+147 -0)
📝 crates/horizon-client/src/gfx/pack_uniforms.rs (+57 -0)
➕ crates/horizon-shaders/src/custom.rs (+570 -0)
📝 crates/horizon-shaders/src/lib.rs (+11 -4)
📝 crates/horizon-shaders/src/macros.rs (+8 -0)
➕ crates/horizon-shaders/src/options.rs (+80 -0)
📝 crates/horizon-shaders/src/pack.rs (+33 -0)
📝 crates/horizon-shaders/src/post.rs (+257 -15)
📝 crates/horizon-shaders/src/translate/mod.rs (+64 -4)
📝 crates/horizon-shaders/src/translate/scan.rs (+95 -21)
📝 crates/horizon-shaders/tests/packs/terrain-test/README.md (+4 -1)
➕ crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_skybasic.fsh (+15 -0)

...and 5 more files

📄 Description

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

Terrain vertex arena readable as storage where flat draws run. Stacked on #1723. It's a small base-renderer change that the coordinator approved for the shader-pack clean room; perf-next-1 has been told it touches gfx/arena.rs.

What

  • On devices that run flat draws (vertex storage and compute), the terrain vertex arena's pages also get STORAGE usage. A shader pack's terrain program can then read the other corners of a vertex's quad, which gives packs a face normal and tangent (clean room 25, two PRs up this stack).
  • Arena::new takes a storage flag, as Arena::indices already does.
  • Horizon's own pipelines and draws are unchanged.

About 20 lines.

No regression without a pack (A/B)

  • Setup: Mac mini (M4 Pro, Metal), --benchmark forest, 1280×720, no pack. A is the parent commit, B this one. The two builds ran alternately on the same scene; the machine was shared with other sessions, so single runs swing.
  • RD 16, 7 alternated pairs:
    • GPU p50 per pair (A / B, ms): 0.736/0.470, 0.641/0.299, 0.225/0.267, 0.292/0.396, 0.290/0.272, 0.640/0.638, 0.412/0.412.
    • Median B − A: −0.002 ms. FPS medians: A 1816, B 1867.
  • RD 32, 3 pairs:
    • GPU p50 (A / B, ms): 2.687/2.674, 1.924/2.676, 2.672/2.670.
    • FPS (A / B): 341/343, 526/344, 343/343. A's second run is the only outlier.
  • Screenshots without a pack, time and weather frozen: A against B differs no more than A against a second run of A.
    • First view: A2 vs B 15 205 pixels differ (173 by more than 16 levels); A vs A2 159 718 (145 872).
    • Second view: about 53 000 pixels in each comparison, 130 to 333 of them by more than 16 levels.
    • The differences are chunk-loading and cloud timing.

How tested

The arena tests (gfx/arena.rs) pass with the new flag, and pr_ready below covers the workspace.

Self-check (whole stack, on its top branch feat/shader-packs-normals)

Overhead with BSL (720p, Mac mini, HORIZON_SHADER_PACK_TIMING, top of the stack): Horizon's own world copy is 0.067 ms, under the 0.1 ms target. The pack's terrain pass is 0.52 ms (0.50–0.51 before normals). Its water pass is 0.22–0.28 ms (0.14–0.17 before), now that BSL recognises its water and runs its water shading. GPU p50 is 2.12 ms.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 07e46daa5, 20 min 27 s)

Check Result
Scope ⚠️ 51 files, +8678 −39; 8317 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (20 s)
clippy ✅ (1 min 24 s)
tests: workspace ✅ 1976 passed (17 min 30 s)
doc tests ✅ 1 passed (1 min 13 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: 326 harnesses selected (the root Cargo.toml and gfx.rs earlier in the stack); CI runs them. The shader-pack parts act only with HORIZON_SHADER_PACK; the arena flag acts always and has its A/B above. The Label row is the tool's generic hint: these PRs are skip-release.

Needs Ludovic

Nothing. Label skip-release: players see no change.

🤖 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/1742 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-packs-arena-storage` --- ### 📝 Commits (10+) - [`6c8880f`](https://github.com/horizon-rust/horizon/commit/6c8880fbd887a69af1f12acc5f2f9c3b64cbec85) Shader packs, clean room 15: globals initialized at run time, switch options - [`505e8e9`](https://github.com/horizon-rust/horizon/commit/505e8e960f9956a51bde92a52b737d4f7f413c69) Shader packs, clean room 16: custom uniforms - [`a2ec3fc`](https://github.com/horizon-rust/horizon/commit/a2ec3fc791e773c69b852922ca53af1be298cd47) Shader packs, clean room 17: real packs' buffers and samplers - [`3e2c30a`](https://github.com/horizon-rust/horizon/commit/3e2c30a852452a3ee0a4cf778d85aee55b98c205) Shader packs, clean room 18: translucent terrain drawn by the pack - [`b6345fc`](https://github.com/horizon-rust/horizon/commit/b6345fc61d640de07afc9a2f3695039e02ac3201) Shader packs, clean room 19: GPU time of each pass (developers' aid) - [`5e348aa`](https://github.com/horizon-rust/horizon/commit/5e348aa479aafa0ab2f03320fb637a5596f00900) Shader packs, clean room 20: buffer mipmaps - [`b9b47f1`](https://github.com/horizon-rust/horizon/commit/b9b47f12dabd79ba8c48998d9aa98974e26a3eb4) Shader packs, clean room 21: per-draw uniforms (renderStage) - [`7d6583d`](https://github.com/horizon-rust/horizon/commit/7d6583dc4d088d794398391aad4c0ced94009883) Shader packs, clean room 22: the sky (gbuffers_skybasic) - [`230730d`](https://github.com/horizon-rust/horizon/commit/230730d1f5324ed3fc7a658e384767f6d706e713) Shader packs, clean room 23: the sun and moon (gbuffers_skytextured) - [`b940754`](https://github.com/horizon-rust/horizon/commit/b940754555666ba25fa8541e537b7b9a83aa0449) Terrain vertex arena readable as storage where flat draws run ### 📊 Changes **25 files changed** (+2623 additions, -203 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/shader_packs.rs` (+2 -2) 📝 `crates/horizon-client/src/gfx.rs` (+83 -20) 📝 `crates/horizon-client/src/gfx/arena.rs` (+11 -4) 📝 `crates/horizon-client/src/gfx/pack_atlas.rs` (+1 -0) ➕ `crates/horizon-client/src/gfx/pack_draw.rs` (+67 -0) 📝 `crates/horizon-client/src/gfx/pack_post.rs` (+737 -124) 📝 `crates/horizon-client/src/gfx/pack_post.wgsl` (+8 -0) ➕ `crates/horizon-client/src/gfx/pack_sky.rs` (+319 -0) ➕ `crates/horizon-client/src/gfx/pack_timing.rs` (+147 -0) 📝 `crates/horizon-client/src/gfx/pack_uniforms.rs` (+57 -0) ➕ `crates/horizon-shaders/src/custom.rs` (+570 -0) 📝 `crates/horizon-shaders/src/lib.rs` (+11 -4) 📝 `crates/horizon-shaders/src/macros.rs` (+8 -0) ➕ `crates/horizon-shaders/src/options.rs` (+80 -0) 📝 `crates/horizon-shaders/src/pack.rs` (+33 -0) 📝 `crates/horizon-shaders/src/post.rs` (+257 -15) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+64 -4) 📝 `crates/horizon-shaders/src/translate/scan.rs` (+95 -21) 📝 `crates/horizon-shaders/tests/packs/terrain-test/README.md` (+4 -1) ➕ `crates/horizon-shaders/tests/packs/terrain-test/shaders/gbuffers_skybasic.fsh` (+15 -0) _...and 5 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Terrain vertex arena readable as storage where flat draws run.** Stacked on #1723. It's a small base-renderer change that the coordinator approved for the shader-pack clean room; perf-next-1 has been told it touches `gfx/arena.rs`. ## What - On devices that run flat draws (vertex storage and compute), the terrain vertex arena's pages also get `STORAGE` usage. A shader pack's terrain program can then read the other corners of a vertex's quad, which gives packs a face normal and tangent (clean room 25, two PRs up this stack). - `Arena::new` takes a `storage` flag, as `Arena::indices` already does. - Horizon's own pipelines and draws are unchanged. About 20 lines. ## No regression without a pack (A/B) - **Setup:** Mac mini (M4 Pro, Metal), `--benchmark forest`, 1280×720, no pack. A is the parent commit, B this one. The two builds ran alternately on the same scene; the machine was shared with other sessions, so single runs swing. - **RD 16, 7 alternated pairs:** - GPU p50 per pair (A / B, ms): 0.736/0.470, 0.641/0.299, 0.225/0.267, 0.292/0.396, 0.290/0.272, 0.640/0.638, 0.412/0.412. - Median B − A: −0.002 ms. FPS medians: A 1816, B 1867. - **RD 32, 3 pairs:** - GPU p50 (A / B, ms): 2.687/2.674, 1.924/2.676, 2.672/2.670. - FPS (A / B): 341/343, 526/344, 343/343. A's second run is the only outlier. - **Screenshots without a pack, time and weather frozen:** A against B differs no more than A against a second run of A. - First view: A2 vs B 15 205 pixels differ (173 by more than 16 levels); A vs A2 159 718 (145 872). - Second view: about 53 000 pixels in each comparison, 130 to 333 of them by more than 16 levels. - The differences are chunk-loading and cloud timing. ## How tested The arena tests (`gfx/arena.rs`) pass with the new flag, and `pr_ready` below covers the workspace. ## Self-check (whole stack, on its top branch `feat/shader-packs-normals`) **Overhead with BSL** (720p, Mac mini, `HORIZON_SHADER_PACK_TIMING`, top of the stack): Horizon's own world copy is 0.067 ms, under the 0.1 ms target. The pack's terrain pass is 0.52 ms (0.50–0.51 before normals). Its water pass is 0.22–0.28 ms (0.14–0.17 before), now that BSL recognises its water and runs its water shading. GPU p50 is 2.12 ms. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 07e46daa5, 20 min 27 s) | Check | Result | | --- | --- | | Scope | ⚠️ 51 files, +8678 −39; 8317 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (20 s) | | clippy | ✅ (1 min 24 s) | | tests: workspace | ✅ 1976 passed (17 min 30 s) | | doc tests | ✅ 1 passed (1 min 13 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: 326 harnesses selected (the root `Cargo.toml` and `gfx.rs` earlier in the stack); CI runs them. The shader-pack parts act only with `HORIZON_SHADER_PACK`; the arena flag acts always and has its A/B above. The Label row is the tool's generic hint: these PRs are `skip-release`. ## Needs Ludovic Nothing. Label `skip-release`: players see no change. 🤖 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:11:51 +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#3734
No description provided.