[PR #4452] [MERGED] Shader packs 11/12: shadow.culling, atomics on colortex, compute programs in the order packs expect #5633

Closed
opened 2026-11-03 05:13:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4452
Author: @PzmuV1517
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: shader-packs/11


📝 Commits (10+)

  • 0bfcf5f Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle
  • fcd2161 Shader packs: atomic functions on a component of a shared integer vector
  • 9d410bc Shader packs: colortex buffers bound as images can take atomics
  • 6e385e7 Shader packs: Iris's camera uniforms
  • 92b62f0 Shader packs: translate geometry stages of terrain's shadow program
  • 60d3a67 Shader packs: draw geometry stages, and what Rethinking Voxels needed
  • 053f5b8 Shader packs: compute programs see the order their packs were written for
  • 62a673e Shader packs: eye uniforms are the player's in third person, compound assignments on atomic vectors
  • ba64c55 Shader packs: geometry stages are tested, take unsized inputs, images keep a layout on the line before
  • 8429a92 Shader packs: a terrain or shadow program that writes only images is drawn

📊 Changes

19 files changed (+2310 additions, -92 deletions)

View changed files

📝 crates/horizon-client-render/src/camera.rs (+8 -0)
📝 crates/horizon-client-render/src/gfx.rs (+72 -12)
📝 crates/horizon-client-render/src/gfx/flat.rs (+17 -0)
📝 crates/horizon-client-render/src/gfx/pack_atlas.rs (+17 -0)
📝 crates/horizon-client-render/src/gfx/pack_images.rs (+179 -21)
📝 crates/horizon-client-render/src/gfx/pack_post.rs (+194 -14)
📝 crates/horizon-client-render/src/gfx/pack_uniforms.rs (+43 -4)
📝 crates/horizon-client/src/game.rs (+12 -0)
📝 crates/horizon-shaders/src/config.rs (+4 -0)
📝 crates/horizon-shaders/src/lib.rs (+4 -4)
📝 crates/horizon-shaders/src/post.rs (+219 -24)
➕ crates/horizon-shaders/src/translate/atomic_vectors.rs (+349 -0)
➕ crates/horizon-shaders/src/translate/geometry.rs (+646 -0)
📝 crates/horizon-shaders/src/translate/mod.rs (+48 -2)
➕ crates/horizon-shaders/src/translate/ordering.rs (+460 -0)
📝 crates/horizon-shaders/src/translate/rewrite.rs (+4 -2)
📝 crates/horizon-shaders/src/translate/scan.rs (+5 -0)
📝 crates/horizon-shaders/tests/real_packs.rs (+15 -2)
📝 third_party/naga/src/front/glsl/builtins.rs (+14 -7)

📄 Description

Part 11 of 12 of the shader pack work from #3737. It builds on part 10 (#4451): this branch is that one plus the commits below, so review only these:

  • 0bfcf5f95 Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle
  • 9d410bc31 Shader packs: colortex buffers bound as images can take atomics
  • 053f5b871 Shader packs: compute programs see the order their packs were written for
  • 23364b2d9 Shader packs: else stays with the pack's if, snapshots skip loops and keep their own texture
  • d8ce624a9 Shader packs: snapshots need loads and stores in one function, firstPersonCamera follows the view, every strip's triangles are drawn

What and why

shadow.culling, voxelDistance and geometry stage writes once per triangle (0bfcf5f95)

  • shadow.culling=false draws every section within the shadow distance and every face of it; reversed does so within voxelDistance (default 160) and culls beyond as before. Horizon drew only the faces turned to the light, and a pack voxelizing the world in its shadow pass lost the others.
  • A geometry stage's image and buffer writes run in one of the invocations that stand for its triangle; in an expression the others read the value instead. The instances drawn follow from the strips EndPrimitive ends.
  • at_midBlock for flat terrain: the offset to the centre of the face's block, in 64ths.
  • firstPersonCamera.
  • naga: imageAtomic* give the texel's value before the operation.

colortex buffers bound as images can take atomics (9d410bc31)

An R32I or R32UI buffer a program binds as colorimgN is made with atomic storage usage, as the pack's own images already are: Metal drops texture atomics on a texture made without it, so imageAtomicMin on colortex9 did nothing.

compute programs see the order their packs were written for (053f5b871)

GL leaves undefined what one invocation reads of what others of the same dispatch write, and packs lean on how desktop drivers happen to run it. Rethinking Voxels' light lists changed from frame to frame on Apple GPUs, so glass, which reads its light volume directly, flickered.

  • An image a compute program both loads and stores, with every load before every store, no atomic function on it and neither coherent nor volatile, is loaded from a copy taken before the dispatch: neighbouring work groups' light lists, reprojection in place and the volume shift read the values they expect.
  • A barrier follows each statement of a compute main that applies an atomic function to shared memory, directly or through a function, unless main returns early: light weights raised with atomicMax were read back before every invocation had raised them.

else stays with the pack's if, snapshots skip loops and keep their own texture (23364b2d9)

A geometry stage's write wrapped as if (hz_primary) took the else of an unbraced if; it is
now a whole if (!hz_primary) {} else write. A barrier after a shared atomic no longer goes
between an if and its else.

An image whose load can run after the same invocation's store (a loop around both, or a
function holding both called in a loop or more than once) is no longer read from the copy
taken before the dispatch. That copy has a texture of its own, so a pass sampling last
frame's copy later in the frame still finds it.

snapshots need loads and stores in one function, firstPersonCamera follows the view, every strip's triangles are drawn (d8ce624a9)

Vanilla reference

Horizon-only: vanilla has no shader packs. Nothing changes unless a pack is selected.

Self-check

pr_ready (tools/pr_ready.py --quick on Mac, against origin/main at 27cb8f96b, 2 min 48 s)

Check Result
Scope ⚠️ 189 files, +126153 −308; 126305 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 495 passed (25 s)
rustfmt ✅ (4 s)
Rust ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (37 s)
tests: workspace ❌ 2562 passed, 7 failed (1 min 15 s)
doc tests ✅ 0 passed (3 s)
content root tests ✅ 7 passed (19 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅
launcher tests ❌ 315 passed, 1 failed (4 s)
Parity ➖ 359 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 347 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Failures that aren't from this stack:

  • The horizon-port-pack resource pack tests and the launcher's modpacks::tests::resource_only_profile_can_play_without_enabling_or_overwriting_packs fail with "/var: not an ordinary directory" on macOS, where /var is a symlink. The resource pack tests fail the same way on main itself, and this stack changes neither horizon-port-pack nor the launcher.

🔄 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/4452 **Author:** [@PzmuV1517](https://github.com/PzmuV1517) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shader-packs/11` --- ### 📝 Commits (10+) - [`0bfcf5f`](https://github.com/horizon-rust/horizon/commit/0bfcf5f954ff1bc45d409e7e44a1362304f62d79) Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle - [`fcd2161`](https://github.com/horizon-rust/horizon/commit/fcd21612876425d80f0b2a4753a971e5653f503e) Shader packs: atomic functions on a component of a shared integer vector - [`9d410bc`](https://github.com/horizon-rust/horizon/commit/9d410bc31fc3b53ee295a3132853415bf02561c7) Shader packs: colortex buffers bound as images can take atomics - [`6e385e7`](https://github.com/horizon-rust/horizon/commit/6e385e741f4e389f611cc9c20c4e435e29e54c50) Shader packs: Iris's camera uniforms - [`92b62f0`](https://github.com/horizon-rust/horizon/commit/92b62f0f0ee9af9902f770b0e6df642ce668675c) Shader packs: translate geometry stages of terrain's shadow program - [`60d3a67`](https://github.com/horizon-rust/horizon/commit/60d3a679bc1d5d0d5905680736de76b7c02185c0) Shader packs: draw geometry stages, and what Rethinking Voxels needed - [`053f5b8`](https://github.com/horizon-rust/horizon/commit/053f5b8714e7cd14b2b19ee8213c36df60bd44c9) Shader packs: compute programs see the order their packs were written for - [`62a673e`](https://github.com/horizon-rust/horizon/commit/62a673ec2ccc8e32919eeb35e1196bc468d7b613) Shader packs: eye uniforms are the player's in third person, compound assignments on atomic vectors - [`ba64c55`](https://github.com/horizon-rust/horizon/commit/ba64c557465f8b6178c2be93cafdca0b0f643c82) Shader packs: geometry stages are tested, take unsized inputs, images keep a layout on the line before - [`8429a92`](https://github.com/horizon-rust/horizon/commit/8429a924edc6f2582b2dea721250ec2de7fd2f69) Shader packs: a terrain or shadow program that writes only images is drawn ### 📊 Changes **19 files changed** (+2310 additions, -92 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/camera.rs` (+8 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+72 -12) 📝 `crates/horizon-client-render/src/gfx/flat.rs` (+17 -0) 📝 `crates/horizon-client-render/src/gfx/pack_atlas.rs` (+17 -0) 📝 `crates/horizon-client-render/src/gfx/pack_images.rs` (+179 -21) 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+194 -14) 📝 `crates/horizon-client-render/src/gfx/pack_uniforms.rs` (+43 -4) 📝 `crates/horizon-client/src/game.rs` (+12 -0) 📝 `crates/horizon-shaders/src/config.rs` (+4 -0) 📝 `crates/horizon-shaders/src/lib.rs` (+4 -4) 📝 `crates/horizon-shaders/src/post.rs` (+219 -24) ➕ `crates/horizon-shaders/src/translate/atomic_vectors.rs` (+349 -0) ➕ `crates/horizon-shaders/src/translate/geometry.rs` (+646 -0) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+48 -2) ➕ `crates/horizon-shaders/src/translate/ordering.rs` (+460 -0) 📝 `crates/horizon-shaders/src/translate/rewrite.rs` (+4 -2) 📝 `crates/horizon-shaders/src/translate/scan.rs` (+5 -0) 📝 `crates/horizon-shaders/tests/real_packs.rs` (+15 -2) 📝 `third_party/naga/src/front/glsl/builtins.rs` (+14 -7) </details> ### 📄 Description Part 11 of 12 of the shader pack work from #3737. It builds on part 10 (#4451): this branch is that one plus the commits below, so review only these: - `0bfcf5f95` Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle - `9d410bc31` Shader packs: colortex buffers bound as images can take atomics - `053f5b871` Shader packs: compute programs see the order their packs were written for - `23364b2d9` Shader packs: else stays with the pack's if, snapshots skip loops and keep their own texture - `d8ce624a9` Shader packs: snapshots need loads and stores in one function, firstPersonCamera follows the view, every strip's triangles are drawn ## What and why **shadow.culling, voxelDistance and geometry stage writes once per triangle** (`0bfcf5f95`) - shadow.culling=false draws every section within the shadow distance and every face of it; reversed does so within voxelDistance (default 160) and culls beyond as before. Horizon drew only the faces turned to the light, and a pack voxelizing the world in its shadow pass lost the others. - A geometry stage's image and buffer writes run in one of the invocations that stand for its triangle; in an expression the others read the value instead. The instances drawn follow from the strips EndPrimitive ends. - at_midBlock for flat terrain: the offset to the centre of the face's block, in 64ths. - firstPersonCamera. - naga: imageAtomic* give the texel's value before the operation. **colortex buffers bound as images can take atomics** (`9d410bc31`) An R32I or R32UI buffer a program binds as colorimgN is made with atomic storage usage, as the pack's own images already are: Metal drops texture atomics on a texture made without it, so imageAtomicMin on colortex9 did nothing. **compute programs see the order their packs were written for** (`053f5b871`) GL leaves undefined what one invocation reads of what others of the same dispatch write, and packs lean on how desktop drivers happen to run it. Rethinking Voxels' light lists changed from frame to frame on Apple GPUs, so glass, which reads its light volume directly, flickered. - An image a compute program both loads and stores, with every load before every store, no atomic function on it and neither coherent nor volatile, is loaded from a copy taken before the dispatch: neighbouring work groups' light lists, reprojection in place and the volume shift read the values they expect. - A barrier follows each statement of a compute main that applies an atomic function to shared memory, directly or through a function, unless main returns early: light weights raised with atomicMax were read back before every invocation had raised them. **else stays with the pack's if, snapshots skip loops and keep their own texture** (`23364b2d9`) A geometry stage's write wrapped as if (hz_primary) took the else of an unbraced if; it is now a whole if (!hz_primary) {} else write. A barrier after a shared atomic no longer goes between an if and its else. An image whose load can run after the same invocation's store (a loop around both, or a function holding both called in a loop or more than once) is no longer read from the copy taken before the dispatch. That copy has a texture of its own, so a pass sampling last frame's copy later in the frame still finds it. **snapshots need loads and stores in one function, firstPersonCamera follows the view, every strip's triangles are drawn** (`d8ce624a9`) ## Vanilla reference Horizon-only: vanilla has no shader packs. Nothing changes unless a pack is selected. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Mac, against origin/main at 27cb8f96b, 2 min 48 s) | Check | Result | | --- | --- | | Scope | ⚠️ 189 files, +126153 −308; 126305 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 495 passed (25 s) | | rustfmt | ✅ (4 s) | | Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (37 s) | | tests: workspace | ❌ 2562 passed, 7 failed (1 min 15 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ✅ 7 passed (19 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ | | launcher tests | ❌ 315 passed, 1 failed (4 s) | | Parity | ➖ 359 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 347 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Failures that aren't from this stack: - The `horizon-port-pack` resource pack tests and the launcher's `modpacks::tests::resource_only_profile_can_play_without_enabling_or_overwriting_packs` fail with "/var: not an ordinary directory" on macOS, where `/var` is a symlink. The resource pack tests fail the same way on main itself, and this stack changes neither `horizon-port-pack` nor the launcher. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:56 +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#5633
No description provided.