[PR #6822] [MERGED] Shader packs: a function prototype declared again translates #7116

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6822
Author: @arslanarm
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: shaderpacks/repeated-prototypes


📝 Commits (2)

  • 8c924cd Shader packs: a function prototype declared again translates
  • e7226b7 Merge main into #6822

📊 Changes

1 file changed (+76 additions, -4 deletions)

View changed files

📝 crates/horizon-shaders/src/translate/mod.rs (+76 -4)

📄 Description

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

What and why

Fixes #6810.

GLSL lets a function be declared any number of times, before or after its one definition (GLSL 4.60, 6.1); packs get there by including the same helper's prototype from two files. naga's GLSL frontend refuses a second prototype with the same parameter types ("Prototype already defined", Frontend::add_prototype), so the program was skipped.

compile already rewrites a few refusals where naga points and parses again (scalar swizzles, uint literals); repeated_prototype joins them: the refused prototype, from its type to its ;, turns to spaces with its newlines kept, so later errors still name their own lines. A prototype with qualifiers before its type (naga's span starts at the type) is left alone rather than guessed at.

Measured with real_packs over Modrinth's 40 most-downloaded shader packs (SHOW_ERRORS=1), against main at 3a264943c: composite-style programs 1500 ok / 54 failing → 1503 / 51, and 11 programs of Bloop 1.8.0-Alpha-3 are no longer skipped (deferred10 in all three dimensions; gbuffers_entities, gbuffers_entities_translucent, gbuffers_water). No program that translated before fails now.

Tests: functions_declared_again_translate (prototypes repeated before and after the definition, one over two lines) and errors_after_a_prototype_declared_again_keep_their_line; both fail on main.

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 (shader packs; vanilla has no such feature). The rule followed is the GLSL 4.60 specification, 6.1; glslangValidator 1.4.363 accepts the issue's example.

Other projects' code

naga 30.0.1 (MIT OR Apache-2.0), https://docs.rs/crate/naga/30.0.1/source/: read src/front/glsl/functions.rs (add_prototype) and src/front/glsl/parser/declarations.rs (the span a prototype's error carries). Nothing copied. No Iris, OptiFine or pack code read; Bloop was only run as a black box.

Self-check

pr_ready (tools/pr_ready.py --quick on plony-pc, against origin/main at 3a264943c, 2 min 23 s)

Check Result
Scope ✅ 1 files, +76 −4
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 602 passed (32 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 41 s)
tests: horizon-shaders ✅ 125 passed (3 s)
doc tests ✅ 0 passed
content root tests ➖ content root untouched
mod API up to date ➖ native hooks 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)

🤖 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/6822 **Author:** [@arslanarm](https://github.com/arslanarm) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shaderpacks/repeated-prototypes` --- ### 📝 Commits (2) - [`8c924cd`](https://github.com/horizon-rust/horizon/commit/8c924cd4f2e27c381cc69a7c342d7bc5a45e39ab) Shader packs: a function prototype declared again translates - [`e7226b7`](https://github.com/horizon-rust/horizon/commit/e7226b798f8d2dfdc73faf1d7053689063929ad1) Merge main into #6822 ### 📊 Changes **1 file changed** (+76 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/translate/mod.rs` (+76 -4) </details> ### 📄 Description > 🤖 Opened by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally. ## What and why Fixes #6810. GLSL lets a function be declared any number of times, before or after its one definition (GLSL 4.60, 6.1); packs get there by including the same helper's prototype from two files. naga's GLSL frontend refuses a second prototype with the same parameter types ("Prototype already defined", `Frontend::add_prototype`), so the program was skipped. `compile` already rewrites a few refusals where naga points and parses again (scalar swizzles, `uint` literals); `repeated_prototype` joins them: the refused prototype, from its type to its `;`, turns to spaces with its newlines kept, so later errors still name their own lines. A prototype with qualifiers before its type (naga's span starts at the type) is left alone rather than guessed at. Measured with `real_packs` over Modrinth's 40 most-downloaded shader packs (`SHOW_ERRORS=1`), against main at 3a264943c: composite-style programs 1500 ok / 54 failing → 1503 / 51, and 11 programs of Bloop 1.8.0-Alpha-3 are no longer skipped (`deferred10` in all three dimensions; `gbuffers_entities`, `gbuffers_entities_translucent`, `gbuffers_water`). No program that translated before fails now. Tests: `functions_declared_again_translate` (prototypes repeated before and after the definition, one over two lines) and `errors_after_a_prototype_declared_again_keep_their_line`; both fail on main. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] 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 (shader packs; vanilla has no such feature). The rule followed is the GLSL 4.60 specification, 6.1; `glslangValidator` 1.4.363 accepts the issue's example. ## Other projects' code naga 30.0.1 (MIT OR Apache-2.0), https://docs.rs/crate/naga/30.0.1/source/: read `src/front/glsl/functions.rs` (`add_prototype`) and `src/front/glsl/parser/declarations.rs` (the span a prototype's error carries). Nothing copied. No Iris, OptiFine or pack code read; Bloop was only run as a black box. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on plony-pc, against origin/main at 3a264943c, 2 min 23 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +76 −4 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 602 passed (32 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 41 s) | | tests: horizon-shaders | ✅ 125 passed (3 s) | | doc tests | ✅ 0 passed | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks 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) | 🤖 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:34:08 +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#7116
No description provided.