[PR #4441] [MERGED] Shader packs 1/12: translation fixes: multi-line macro calls, struct varyings, continued property values #5624

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

📋 Pull Request Information

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

Base: main ← Head: shader-packs/01


📝 Commits (5)

  • c29967b Shader packs: macro calls whose arguments span lines
  • 914e5d0 Vendor naga 30.0.1 unchanged
  • a59d378 Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps
  • 6edd81d Shader packs: a continued property value stops where its branch does
  • 3e1641b Shader packs: a directive ends a continued property value

📊 Changes

166 files changed (+120316 additions, -20 deletions)

View changed files

📝 Cargo.lock (+0 -2)
📝 Cargo.toml (+3 -1)
📝 THIRD_PARTY_NOTICES.md (+6 -0)
📝 crates/horizon-shaders/src/macros.rs (+13 -0)
📝 crates/horizon-shaders/src/preprocess.rs (+33 -0)
📝 crates/horizon-shaders/src/properties.rs (+27 -5)
📝 crates/horizon-shaders/src/translate/mod.rs (+241 -5)
📝 crates/horizon-shaders/src/translate/rewrite.rs (+4 -2)
📝 crates/horizon-shaders/src/translate/scan.rs (+108 -4)
📝 crates/horizon-shaders/tests/real_packs.rs (+6 -1)
➕ third_party/naga/Cargo.toml (+246 -0)
➕ third_party/naga/LICENSE.APACHE (+176 -0)
➕ third_party/naga/LICENSE.MIT (+21 -0)
➕ third_party/naga/README.md (+89 -0)
➕ third_party/naga/build.rs (+12 -0)
➕ third_party/naga/src/arena/handle.rs (+121 -0)
➕ third_party/naga/src/arena/handle_set.rs (+132 -0)
➕ third_party/naga/src/arena/handlevec.rs (+106 -0)
➕ third_party/naga/src/arena/mod.rs (+342 -0)
➕ third_party/naga/src/arena/range.rs (+139 -0)

...and 80 more files

📄 Description

Part 1 of 12 of the shader pack work from #3737, split into a stack as asked there. Each part builds and passes its tests on its own, and each later part adds its own commits on top of this one.

  • c29967b1a Shader packs: macro calls whose arguments span lines
  • 914e5d010 Vendor naga 30.0.1 unchanged
  • a59d378bf Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps
  • 6edd81d36 Shader packs: a continued property value stops where its branch does
  • 3e1641b75 Shader packs: a directive ends a continued property value

What and why

macro calls whose arguments span lines (c29967b1a)

A function-like macro called across lines (Photon's clamp01(\n ... \n)) was left unexpanded. Its lines now join the line the call starts on; the lines after it stay, empty, so line numbers still map back.

Vendor naga 30.0.1 unchanged (914e5d010)

Shader packs need fixes to naga's GLSL frontend that no release has yet. They go on top of this
copy in the commits that need them, as wgpu-hal's fix did, instead of a git dependency.

struct varyings, Vulkan type names as identifiers, naga's GLSL gaps (a59d378bf)

Photon translated 45 of its 88 composite-style programs and none of its overworld terrain, sky set-up or final pass; now all 88 translate and every dimension loads its full set.

  • A struct passed between stages (flat out CloudsParameters p) keeps the pack's declaration as a private global and travels as its members packed into vectors, copied by our main.
  • sampler, texture2D and Vulkan GLSL's other texture and sampler type names are free names in desktop GLSL (sampler2D sampler); they are renamed unless called.
  • naga's GLSL frontend lacked textureGather, sampled implicit levels in vertex shaders, broke struct constructors with array members, vecN(bool) and vector % scalar: naga is patched with the fixes until a release has them.
  • real_packs prints every loader note with SHOW_ERRORS.

a continued property value stops where its branch does (6edd81d36)

shaders.properties is preprocessed before its lines join: a value continued with \ just before #else (Photon's moon_phase_brightness) swallowed the directive and the other branch, so the uniform was never defined. Directives now apply while lines join, and lines of branches they turn off are dropped.

a directive ends a continued property value (3e1641b75)

Clean room

None of this was written from Iris's or OptiFine's source, or with it open. It comes from public documentation of the format (shaders.properties and the stage files) and from running packs (Photon, Rethinking Voxels, Complementary, BSL) as black boxes and reading their own shader files. naga 30.0.1 is vendored under third_party/naga as published, and the GLSL frontend fixes shader packs need are applied to it in the commits that need them, until a naga release has them.

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, 3 min 32 s)

Check Result
Scope ⚠️ 166 files, +120316 −20; 120234 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 ✅ (43 s)
tests: workspace ❌ 2559 passed, 7 failed (1 min 23 s)
doc tests ✅ 0 passed (4 s)
content root tests ✅ 7 passed (25 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (8 s)
launcher tests ❌ 315 passed, 1 failed (19 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/4441 **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/01` --- ### 📝 Commits (5) - [`c29967b`](https://github.com/horizon-rust/horizon/commit/c29967b1aa69a50d4ef3d3223523431e2fb4b8f6) Shader packs: macro calls whose arguments span lines - [`914e5d0`](https://github.com/horizon-rust/horizon/commit/914e5d01039326ccbd9b581ac108342549435d0b) Vendor naga 30.0.1 unchanged - [`a59d378`](https://github.com/horizon-rust/horizon/commit/a59d378bf4603f8ff54dd5d730b6b517b35752e7) Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps - [`6edd81d`](https://github.com/horizon-rust/horizon/commit/6edd81d368eb98e6551e35d5bc8f2ac3287daeac) Shader packs: a continued property value stops where its branch does - [`3e1641b`](https://github.com/horizon-rust/horizon/commit/3e1641b754d0179734d1cc6c0c55b82a091571f8) Shader packs: a directive ends a continued property value ### 📊 Changes **166 files changed** (+120316 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+0 -2) 📝 `Cargo.toml` (+3 -1) 📝 `THIRD_PARTY_NOTICES.md` (+6 -0) 📝 `crates/horizon-shaders/src/macros.rs` (+13 -0) 📝 `crates/horizon-shaders/src/preprocess.rs` (+33 -0) 📝 `crates/horizon-shaders/src/properties.rs` (+27 -5) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+241 -5) 📝 `crates/horizon-shaders/src/translate/rewrite.rs` (+4 -2) 📝 `crates/horizon-shaders/src/translate/scan.rs` (+108 -4) 📝 `crates/horizon-shaders/tests/real_packs.rs` (+6 -1) ➕ `third_party/naga/Cargo.toml` (+246 -0) ➕ `third_party/naga/LICENSE.APACHE` (+176 -0) ➕ `third_party/naga/LICENSE.MIT` (+21 -0) ➕ `third_party/naga/README.md` (+89 -0) ➕ `third_party/naga/build.rs` (+12 -0) ➕ `third_party/naga/src/arena/handle.rs` (+121 -0) ➕ `third_party/naga/src/arena/handle_set.rs` (+132 -0) ➕ `third_party/naga/src/arena/handlevec.rs` (+106 -0) ➕ `third_party/naga/src/arena/mod.rs` (+342 -0) ➕ `third_party/naga/src/arena/range.rs` (+139 -0) _...and 80 more files_ </details> ### 📄 Description Part 1 of 12 of the shader pack work from #3737, split into a stack as asked there. Each part builds and passes its tests on its own, and each later part adds its own commits on top of this one. - `c29967b1a` Shader packs: macro calls whose arguments span lines - `914e5d010` Vendor naga 30.0.1 unchanged - `a59d378bf` Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps - `6edd81d36` Shader packs: a continued property value stops where its branch does - `3e1641b75` Shader packs: a directive ends a continued property value ## What and why **macro calls whose arguments span lines** (`c29967b1a`) A function-like macro called across lines (Photon's clamp01(\n ... \n)) was left unexpanded. Its lines now join the line the call starts on; the lines after it stay, empty, so line numbers still map back. **Vendor naga 30.0.1 unchanged** (`914e5d010`) Shader packs need fixes to naga's GLSL frontend that no release has yet. They go on top of this copy in the commits that need them, as wgpu-hal's fix did, instead of a git dependency. **struct varyings, Vulkan type names as identifiers, naga's GLSL gaps** (`a59d378bf`) Photon translated 45 of its 88 composite-style programs and none of its overworld terrain, sky set-up or final pass; now all 88 translate and every dimension loads its full set. - A struct passed between stages (flat out CloudsParameters p) keeps the pack's declaration as a private global and travels as its members packed into vectors, copied by our main. - sampler, texture2D and Vulkan GLSL's other texture and sampler type names are free names in desktop GLSL (sampler2D sampler); they are renamed unless called. - naga's GLSL frontend lacked textureGather, sampled implicit levels in vertex shaders, broke struct constructors with array members, vecN(bool) and vector % scalar: naga is patched with the fixes until a release has them. - real_packs prints every loader note with SHOW_ERRORS. **a continued property value stops where its branch does** (`6edd81d36`) shaders.properties is preprocessed before its lines join: a value continued with \ just before #else (Photon's moon_phase_brightness) swallowed the directive and the other branch, so the uniform was never defined. Directives now apply while lines join, and lines of branches they turn off are dropped. **a directive ends a continued property value** (`3e1641b75`) ## Clean room None of this was written from Iris's or OptiFine's source, or with it open. It comes from public documentation of the format (shaders.properties and the stage files) and from running packs (Photon, Rethinking Voxels, Complementary, BSL) as black boxes and reading their own shader files. naga 30.0.1 is vendored under `third_party/naga` as published, and the GLSL frontend fixes shader packs need are applied to it in the commits that need them, until a naga release has them. ## 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, 3 min 32 s) | Check | Result | | --- | --- | | Scope | ⚠️ 166 files, +120316 −20; 120234 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 | ✅ (43 s) | | tests: workspace | ❌ 2559 passed, 7 failed (1 min 23 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ✅ 7 passed (25 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (8 s) | | launcher tests | ❌ 315 passed, 1 failed (19 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:52 +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#5624
No description provided.