[PR #4453] [MERGED] Shader packs 12/12: devices without compute or storage writes fall back; Vulkan and DirectX 12 fixes #5634

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

📋 Pull Request Information

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

Base: main ← Head: shader-packs/12


📝 Commits (10+)

  • 0bfcf5f Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle
  • 63bd8e0 Shader packs: a device without compute, storage writes or clear_texture skips what needs them
  • fcd2161 Shader packs: atomic functions on a component of a shared integer vector
  • 9d410bc Shader packs: colortex buffers bound as images can take atomics
  • 8538201 Shader packs: struct fields and array elements passed as out arguments no longer crash Vulkan
  • 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
  • 49500aa Shader packs: gl_WorkGroupSize is the program's local size

📊 Changes

21 files changed (+2790 additions, -106 deletions)

View changed files

📝 crates/horizon-client-render/src/camera.rs (+8 -0)
📝 crates/horizon-client-render/src/gfx.rs (+73 -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 (+249 -27)
📝 crates/horizon-client-render/src/gfx/pack_post.rs (+338 -22)
📝 crates/horizon-client-render/src/gfx/pack_uniforms.rs (+43 -4)
📝 crates/horizon-client/src/game.rs (+12 -0)
📝 crates/horizon-shaders/Cargo.toml (+4 -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 (+150 -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 (+170 -2)
📝 third_party/naga/src/front/glsl/builtins.rs (+14 -7)

...and 1 more files

📄 Description

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

  • 63bd8e047 Shader packs: a device without compute, storage writes or clear_texture skips what needs them
  • 85382019c Shader packs: struct fields and array elements passed as out arguments no longer crash Vulkan
  • 49500aacd Shader packs: gl_WorkGroupSize is the program's local size
  • 0920c36d1 Shader packs: a local size gl_WorkGroupSize can't take fails the program, image clears copy in slices
  • fe3083e11 Shader packs: the out-argument fix is tested in CI, BACKENDS=1 fails on a backend error

What and why

a device without compute, storage writes or clear_texture skips what needs them (63bd8e047)

The pack's renderer asks the adapter what it can do instead of assuming Metal or desktop Vulkan. Without compute shaders compute programs are skipped; without storage writes from fragment or vertex shaders the programs that write images or buffers there, and geometry stages, are skipped; an image whose format can't be a storage texture is left out with the programs using it; without clear_texture images are cleared by copying zeros. Each leaves a note, and the bind group layouts made outside the error scope (storage buffers, geometry indices) only name stages the device supports, so none of it can stop the game.

HORIZON_SHADER_PACK_WITHOUT=compute,fragment-storage,vertex-storage,clear tries the fallbacks on a device that has it all.

struct fields and array elements passed as out arguments no longer crash Vulkan (85382019c)

naga's SPIR-V writer panicked on Photon's deferred4 ("Expression is not cached"): the GLSL frontend passed a pointer into the middle of a variable for f(s.field), which only Metal's writer takes. The naga pin moves to a fix that spills such arguments through a local and writes them back after the call, as GLSL's copy-out says.

real_packs with BACKENDS=1 hands every translated module to the SPIR-V, HLSL, GLSL and MSL writers with wgpu's settings, so this is caught on any machine.

gl_WorkGroupSize is the program's local size (49500aacd)

naga's HLSL writer has no WorkGroupSize built-in, so on DirectX 12 the two Rethinking Voxels compute programs that read it were refused. It becomes the constant the program's layout(local_size_*) declares, as GLSL defines it.

a local size gl_WorkGroupSize can't take fails the program, image clears copy in slices (0920c36d1)

local_size_x = 8 * 2 gave gl_WorkGroupSize 8, and a size that is not a number 1, silently;
such a program now fails with a message. Without clear_texture, images clear from a zero
buffer of at most 4 MiB, copied a slice of rows at a time, instead of one as large as the
largest image.

the out-argument fix is tested in CI, BACKENDS=1 fails on a backend error (fe3083e11)

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 55 s)

Check Result
Scope ⚠️ 189 files, +126619 −308; 126616 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 ✅ (41 s)
tests: workspace ❌ 2562 passed, 7 failed (1 min 12 s)
doc tests ✅ 0 passed (3 s)
content root tests ✅ 7 passed (25 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.

Screenshots

Photon and Rethinking Voxels rendering, no pack and the packs that worked before unchanged, and the fallbacks: https://github.com/horizon-rust/horizon/pull/3737#issuecomment-6503561132.


🔄 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/4453 **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/12` --- ### 📝 Commits (10+) - [`0bfcf5f`](https://github.com/horizon-rust/horizon/commit/0bfcf5f954ff1bc45d409e7e44a1362304f62d79) Shader packs: shadow.culling, voxelDistance and geometry stage writes once per triangle - [`63bd8e0`](https://github.com/horizon-rust/horizon/commit/63bd8e04747c7647778bed3fb78f1e5685ffa361) Shader packs: a device without compute, storage writes or clear_texture skips what needs them - [`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 - [`8538201`](https://github.com/horizon-rust/horizon/commit/85382019cfb09c25ecc4835dd12ce0ca07c25f30) Shader packs: struct fields and array elements passed as out arguments no longer crash Vulkan - [`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 - [`49500aa`](https://github.com/horizon-rust/horizon/commit/49500aacd2e4e0593f453b04d6b4d639c409f50e) Shader packs: gl_WorkGroupSize is the program's local size ### 📊 Changes **21 files changed** (+2790 additions, -106 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/camera.rs` (+8 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+73 -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` (+249 -27) 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+338 -22) 📝 `crates/horizon-client-render/src/gfx/pack_uniforms.rs` (+43 -4) 📝 `crates/horizon-client/src/game.rs` (+12 -0) 📝 `crates/horizon-shaders/Cargo.toml` (+4 -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` (+150 -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` (+170 -2) 📝 `third_party/naga/src/front/glsl/builtins.rs` (+14 -7) _...and 1 more files_ </details> ### 📄 Description Part 12 of 12 of the shader pack work from #3737. It builds on part 11 (#4452): this branch is that one plus the commits below, so review only these: - `63bd8e047` Shader packs: a device without compute, storage writes or clear_texture skips what needs them - `85382019c` Shader packs: struct fields and array elements passed as out arguments no longer crash Vulkan - `49500aacd` Shader packs: gl_WorkGroupSize is the program's local size - `0920c36d1` Shader packs: a local size gl_WorkGroupSize can't take fails the program, image clears copy in slices - `fe3083e11` Shader packs: the out-argument fix is tested in CI, BACKENDS=1 fails on a backend error ## What and why **a device without compute, storage writes or clear_texture skips what needs them** (`63bd8e047`) The pack's renderer asks the adapter what it can do instead of assuming Metal or desktop Vulkan. Without compute shaders compute programs are skipped; without storage writes from fragment or vertex shaders the programs that write images or buffers there, and geometry stages, are skipped; an image whose format can't be a storage texture is left out with the programs using it; without clear_texture images are cleared by copying zeros. Each leaves a note, and the bind group layouts made outside the error scope (storage buffers, geometry indices) only name stages the device supports, so none of it can stop the game. HORIZON_SHADER_PACK_WITHOUT=compute,fragment-storage,vertex-storage,clear tries the fallbacks on a device that has it all. **struct fields and array elements passed as out arguments no longer crash Vulkan** (`85382019c`) naga's SPIR-V writer panicked on Photon's deferred4 ("Expression is not cached"): the GLSL frontend passed a pointer into the middle of a variable for f(s.field), which only Metal's writer takes. The naga pin moves to a fix that spills such arguments through a local and writes them back after the call, as GLSL's copy-out says. real_packs with BACKENDS=1 hands every translated module to the SPIR-V, HLSL, GLSL and MSL writers with wgpu's settings, so this is caught on any machine. **gl_WorkGroupSize is the program's local size** (`49500aacd`) naga's HLSL writer has no WorkGroupSize built-in, so on DirectX 12 the two Rethinking Voxels compute programs that read it were refused. It becomes the constant the program's layout(local_size_*) declares, as GLSL defines it. **a local size gl_WorkGroupSize can't take fails the program, image clears copy in slices** (`0920c36d1`) local_size_x = 8 * 2 gave gl_WorkGroupSize 8, and a size that is not a number 1, silently; such a program now fails with a message. Without clear_texture, images clear from a zero buffer of at most 4 MiB, copied a slice of rows at a time, instead of one as large as the largest image. **the out-argument fix is tested in CI, BACKENDS=1 fails on a backend error** (`fe3083e11`) ## 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 55 s) | Check | Result | | --- | --- | | Scope | ⚠️ 189 files, +126619 −308; 126616 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 | ✅ (41 s) | | tests: workspace | ❌ 2562 passed, 7 failed (1 min 12 s) | | doc tests | ✅ 0 passed (3 s) | | content root tests | ✅ 7 passed (25 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. ## Screenshots Photon and Rethinking Voxels rendering, no pack and the packs that worked before unchanged, and the fallbacks: https://github.com/horizon-rust/horizon/pull/3737#issuecomment-6503561132. --- <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:57 +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#5634
No description provided.