[PR #5264] [MERGED] Shader packs: x / 0.0, sqrt of a negative literal, and texelFetch2D translate #6173

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

📋 Pull Request Information

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

Base: main ← Head: shaderpacks/infinity-nan-texelfetch


📝 Commits (2)

  • af63e5f Shader packs: x / 0.0, sqrt of a negative literal, and texelFetch2D translate
  • 0ade40a Merge main into #5264 (main builds again after #5251)

📊 Changes

2 files changed (+49 additions, -1 deletions)

View changed files

📝 crates/horizon-shaders/src/translate/mod.rs (+15 -0)
📝 crates/horizon-shaders/src/translate/rewrite.rs (+34 -1)

📄 Description

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

What and why

Fixes #5263.

  • x / 0.0 and sqrt(-<literal>) are GL's infinity and NaN at run time. naga's frontend folds them into constants and refuses the result (Float literal is infinite, out of range), so the program was skipped. The prelude now declares float hz_zero = 0.0;, a private global the frontend doesn't fold: x / 0.0 becomes x / hz_zero, and sqrt(-c) (a literal other than zero) becomes (hz_zero / hz_zero).
  • texelFetch1D/2D/3D (GL_EXT_gpu_shader4's names) become texelFetch, as texture2D and the other old names already do.

infinities_nans_and_old_fetches_translate covers all three.

Measured on the same world with Horizon main and this PR (programs the loader skipped):

Pack main this PR
Mellow v3.4.1a 3 skipped, 2 of them program/shadow.vsh:477: Float literal is infinite 1 skipped

Bliss (texelFetch2D) and Bloop (sqrt of negative constants) are where these came from, but on main their programs stop earlier, on const initialisers naga can't fold (mix) and on a sampler named like a function. Those are separate changes.

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

Not vanilla: GLSL in shaders/ packs and naga's translation of it. GL drivers (and so Iris) take these lines.

Self-check

pr_ready (tools/pr_ready.py --quick on 6cd182588f2d, against origin/main at 5062f2259, 4 min 13 s)

Check Result
Scope ✅ 2 files, +49 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 495 run, FAILED (errors=4) (2 min 21 s)
rustfmt ✅ (24 s)
clippy ✅ (1 min 23 s)
tests: horizon-shaders ✅ 48 passed (4 s)
doc tests ✅ 0 passed
content root tests ➖ content root 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)

Run on a rented Linux box with GPU tests on lavapipe. The 4 Python errors are that box's git 2.34 (git merge-tree --write-tree, in test_nightly_set and test_supervise); they pass with git 2.55.

🤖 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/5264 **Author:** [@TobiasLogic](https://github.com/TobiasLogic) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shaderpacks/infinity-nan-texelfetch` --- ### 📝 Commits (2) - [`af63e5f`](https://github.com/horizon-rust/horizon/commit/af63e5f439fa2665b6b49da04018a4d8750c79bb) Shader packs: x / 0.0, sqrt of a negative literal, and texelFetch2D translate - [`0ade40a`](https://github.com/horizon-rust/horizon/commit/0ade40a885fe71f7cc70953b72fa049be39e655f) Merge main into #5264 (main builds again after #5251) ### 📊 Changes **2 files changed** (+49 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/translate/mod.rs` (+15 -0) 📝 `crates/horizon-shaders/src/translate/rewrite.rs` (+34 -1) </details> ### 📄 Description > 🤖 Opened by TobiasLogic's AI agent (Claude Code, Claude Opus 5.5), not by TobiasLogic personally. ## What and why Fixes #5263. - **`x / 0.0` and `sqrt(-<literal>)`** are GL's infinity and NaN at run time. naga's frontend folds them into constants and refuses the result (`Float literal is infinite`, out of range), so the program was skipped. The prelude now declares `float hz_zero = 0.0;`, a private global the frontend doesn't fold: `x / 0.0` becomes `x / hz_zero`, and `sqrt(-c)` (a literal other than zero) becomes `(hz_zero / hz_zero)`. - **`texelFetch1D/2D/3D`** (GL_EXT_gpu_shader4's names) become `texelFetch`, as `texture2D` and the other old names already do. `infinities_nans_and_old_fetches_translate` covers all three. Measured on the same world with Horizon main and this PR (programs the loader skipped): | Pack | main | this PR | | --- | --- | --- | | Mellow v3.4.1a | 3 skipped, 2 of them `program/shadow.vsh:477: Float literal is infinite` | 1 skipped | Bliss (`texelFetch2D`) and Bloop (`sqrt` of negative constants) are where these came from, but on main their programs stop earlier, on `const` initialisers naga can't fold (`mix`) and on a sampler named like a function. Those are separate changes. ## 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 Not vanilla: GLSL in `shaders/` packs and naga's translation of it. GL drivers (and so Iris) take these lines. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on 6cd182588f2d, against origin/main at 5062f2259, 4 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +49 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 495 run, FAILED (errors=4) (2 min 21 s) | | rustfmt | ✅ (24 s) | | clippy | ✅ (1 min 23 s) | | tests: horizon-shaders | ✅ 48 passed (4 s) | | doc tests | ✅ 0 passed | | content root tests | ➖ content root 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) | Run on a rented Linux box with GPU tests on lavapipe. The 4 Python errors are that box's git 2.34 (`git merge-tree --write-tree`, in `test_nightly_set` and `test_supervise`); they pass with git 2.55. 🤖 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:15:31 +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#6173
No description provided.