[PR #7237] [MERGED] Shader packs: a stage's #version may come from a header it includes #7434

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

📋 Pull Request Information

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

Base: main ← Head: shaderpacks/version-in-include


📝 Commits (1)

  • ceb77a5 Shader packs: a stage's #version may come from a header it includes

📊 Changes

2 files changed (+25 additions, -2 deletions)

View changed files

📝 crates/horizon-shaders/src/preprocess.rs (+4 -2)
📝 crates/horizon-shaders/src/translate/mod.rs (+21 -0)

📄 Description

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

What and why

Part of #7171.

The problem: RenderPearl v2.7.2 starts every stage with #include "/prelude/core.glsl", and that header's first line is #version 460 core. Horizon took #version from the stage file only, so these stages counted as GLSL 1.10. Words that became keywords later were then renamed as names, shared becoming hz_kw_shared. RenderPearl's compute programs deferred1, composite and composite3 failed with Expected end of file, found Identifier("hz_kw_shared").

The fix: the first #version read is now the stage's, even when it comes from an included file.

Measured with real_packs (SHOW_ERRORS=1, 40 packs), main fbb17c980 against this branch:

  • Only RenderPearl's output changes. Its three compute programs get past shared and stop on the next construct, a shared struct with no type name (Expected identifier, found LeftBrace), which the anonymous-struct PR for #7171 fixes.
  • With the other #7171 branches applied together, composite translates. deferred, deferred1 and composite3 then stop on gaps outside #7171 (not filed yet).

Test: the_version_may_come_from_an_included_header (a compute stage whose #version is in an included header and which uses shared). Run against main's code it fails: the stage has no version there (left: None, right: Some((460, Some("core")))).

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). Source: GLSL 4.60 specification, 3.3 (#version).

Other projects' code

RenderPearl v2.7.2, MIT: github.com/Luracasmus/renderpearl@86de79c4fa/LICENSE (tag v2.7.2). The files were read from the Modrinth v2.7.2 zip, whose LICENSE is identical to that one.

What was read:

  • prelude/core.glsl, lines 1–12;
  • deferred1.csh, lines 1–12 and 46–49; composite.csh, 45–48; composite3.csh, 13–16 (the lines Horizon's errors name);
  • a grep of the whole pack for #version and for shared.

What follows RenderPearl: the test's stage includes a header at the same path, /prelude/core.glsl, whose only line is #version 460 core, as RenderPearl's begins. The rest of the test is written for this.

Self-check

pr_ready (tools/pr_ready.py --quick on plony-pc, against origin/main at fbb17c980, 1 min 18 s)

Check Result
Scope ✅ 2 files, +25 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (31 s)
rustfmt ✅ (7 s)
clippy ✅ (38 s)
tests: horizon-shaders ✅ 143 passed (1 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/7237 **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/version-in-include` --- ### 📝 Commits (1) - [`ceb77a5`](https://github.com/horizon-rust/horizon/commit/ceb77a5167e00b89b4661d72177efe3f238179b6) Shader packs: a stage's #version may come from a header it includes ### 📊 Changes **2 files changed** (+25 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/preprocess.rs` (+4 -2) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+21 -0) </details> ### 📄 Description > 🤖 Opened by arslanarm's AI agent (Claude Code, Claude Opus 5.5), not by arslanarm personally. ## What and why Part of #7171. **The problem:** RenderPearl v2.7.2 starts every stage with `#include "/prelude/core.glsl"`, and that header's first line is `#version 460 core`. Horizon took `#version` from the stage file only, so these stages counted as GLSL 1.10. Words that became keywords later were then renamed as names, `shared` becoming `hz_kw_shared`. RenderPearl's compute programs `deferred1`, `composite` and `composite3` failed with `Expected end of file, found Identifier("hz_kw_shared")`. **The fix:** the first `#version` read is now the stage's, even when it comes from an included file. **Measured** with `real_packs` (`SHOW_ERRORS=1`, 40 packs), main fbb17c980 against this branch: - Only RenderPearl's output changes. Its three compute programs get past `shared` and stop on the next construct, a `shared struct` with no type name (`Expected identifier, found LeftBrace`), which the anonymous-struct PR for #7171 fixes. - With the other #7171 branches applied together, `composite` translates. `deferred`, `deferred1` and `composite3` then stop on gaps outside #7171 (not filed yet). Test: `the_version_may_come_from_an_included_header` (a compute stage whose `#version` is in an included header and which uses `shared`). Run against main's code it fails: the stage has no version there (`left: None, right: Some((460, Some("core")))`). ## 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). Source: GLSL 4.60 specification, 3.3 (`#version`). ## Other projects' code RenderPearl v2.7.2, MIT: https://github.com/Luracasmus/renderpearl/blob/86de79c4fa7d07fb47628dd9620efb10fb4be9d9/LICENSE (tag v2.7.2). The files were read from the Modrinth v2.7.2 zip, whose `LICENSE` is identical to that one. What was read: - `prelude/core.glsl`, lines 1–12; - `deferred1.csh`, lines 1–12 and 46–49; `composite.csh`, 45–48; `composite3.csh`, 13–16 (the lines Horizon's errors name); - a grep of the whole pack for `#version` and for `shared`. What follows RenderPearl: the test's stage includes a header at the same path, `/prelude/core.glsl`, whose only line is `#version 460 core`, as RenderPearl's begins. The rest of the test is written for this. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on plony-pc, against origin/main at fbb17c980, 1 min 18 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +25 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (31 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (38 s) | | tests: horizon-shaders | ✅ 143 passed (1 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:39:28 +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#7434
No description provided.