[PR #7240] [MERGED] Shader packs: block instances hidden by a local, and a redeclared gl_PerVertex #7435

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/7240
Author: @arslanarm
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: shaderpacks/block-instance-names


📝 Commits (1)

  • 56f749e Shader packs: block instances hidden by a local, and a redeclared gl_PerVertex

📊 Changes

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

View changed files

📝 crates/horizon-shaders/src/translate/interface_blocks.rs (+134 -1)
📝 crates/horizon-shaders/src/translate/mod.rs (+19 -0)

📄 Description

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

What and why

Part of #7171.

Two declarations of RenderPearl v2.7.2 left its interface blocks unflattened or its position unwritten. Both fixes are in translate/interface_blocks.rs, the file #7154 changed; this branch is based on main with #7154 in it.

1. A block instance hidden by a local of the same name.

  • RenderPearl's vertex stages have out VertexData { layout(location = 1, component = 0) vec2 coord; … } v;. Something in those stages uses v other than as v.member (not read; a probe with a parameter named v reproduces the error), so the block counted as used whole.
  • It was then left as written, and naga refused its members' layout ("Expected Void, Struct or a type, found Layout").
  • Fix: a local variable or parameter of that name hides the instance from its declaration to the end of its block or function body (GLSL 4.60, 4.2 Scoping), and x.v is another struct's member. Neither counts as the instance now.

2. A redeclared gl_PerVertex.

  • out gl_PerVertex { vec4 gl_Position; }; (GLSL 4.60, 7.5) is a block without an instance, so it became a plain output named gl_Position. The vertex stage then wrote no position: Vertex shaders must return a `@builtin(position)` output value.
  • Fix: the redeclaration is removed, and its members stay the built-ins.

Measured with real_packs (SHOW_ERRORS=1, 40 packs), main fbb17c980 against this branch. Only RenderPearl's output changes:

  • All 184 Expected Void, Struct or a type, found Layout errors and the 10 gl_PerVertex position errors are gone.
  • Skipped program loads drop from 138 to 68. gbuffers_basic, gbuffers_textured, gbuffers_skybasic, gbuffers_skytextured and gbuffers_clouds now translate wherever they're loaded, and gbuffers_weather in two of its three loads. Terrain and water fall back to gbuffers_textured.
  • The programs still skipped stop on textureQueryLod (#7170), max3, and one texture sample whose offset naga can't take as a constant (not filed yet).

Tests:

  • locals_named_like_the_instance_are_not_it (a parameter, a nested local and another struct's member named like the instance);
  • a_redeclared_gl_per_vertex_goes;
  • a_per_vertex_redeclaration_and_a_parameter_named_like_the_instance (a whole program).

Run against main's flatten, all three fail.

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, 4.2 (Scoping), 4.3.9 (Interface Blocks) and 7.5 (Redeclaring Built-In Blocks).

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:

  • prog/unlit.vsh, lines 1–30; prog/unlit.fsh, 1–40; prog/solid.vsh, 66–69; lib/tbn/fsh.glsl, 2–5 (the lines Horizon's errors name, and the headers above them);
  • prog/none.vsh; gbuffers_skybasic.vsh and gbuffers_skytextured.vsh; gbuffers_basic.vsh and .fsh;
  • prelude/core.glsl;
  • shaders.properties, lines 57, 85, 86, 124 and 126;
  • prelude/compat.glsl, lines 204–211 (where max3 comes from, for the note above);
  • a grep of the whole pack for component = and gl_PerVertex.

What follows RenderPearl: the whole-program test's out gl_PerVertex { vec4 gl_Position; };, and its block VertexData { layout(location = 1, component = 0) vec2 coord; } v;, which have RenderPearl's shapes and names. The function with a parameter v is ours (a guess the probe confirmed, not something read). The unit tests are written for this.

Self-check

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

Check Result
Scope ✅ 2 files, +153 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (32 s)
rustfmt ✅ (7 s)
clippy ✅ (46 s)
tests: horizon-shaders ✅ 145 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/7240 **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/block-instance-names` --- ### 📝 Commits (1) - [`56f749e`](https://github.com/horizon-rust/horizon/commit/56f749e8369b9e2b4d9e577f63cce2f1c79b54f1) Shader packs: block instances hidden by a local, and a redeclared gl_PerVertex ### 📊 Changes **2 files changed** (+153 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/translate/interface_blocks.rs` (+134 -1) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+19 -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. Two declarations of RenderPearl v2.7.2 left its interface blocks unflattened or its position unwritten. Both fixes are in `translate/interface_blocks.rs`, the file #7154 changed; this branch is based on main with #7154 in it. **1. A block instance hidden by a local of the same name.** - RenderPearl's vertex stages have `out VertexData { layout(location = 1, component = 0) vec2 coord; … } v;`. Something in those stages uses `v` other than as `v.member` (not read; a probe with a parameter named `v` reproduces the error), so the block counted as used whole. - It was then left as written, and naga refused its members' `layout` ("Expected Void, Struct or a type, found Layout"). - **Fix:** a local variable or parameter of that name hides the instance from its declaration to the end of its block or function body (GLSL 4.60, 4.2 Scoping), and `x.v` is another struct's member. Neither counts as the instance now. **2. A redeclared `gl_PerVertex`.** - `out gl_PerVertex { vec4 gl_Position; };` (GLSL 4.60, 7.5) is a block without an instance, so it became a plain output named `gl_Position`. The vertex stage then wrote no position: ``Vertex shaders must return a `@builtin(position)` output value``. - **Fix:** the redeclaration is removed, and its members stay the built-ins. **Measured** with `real_packs` (`SHOW_ERRORS=1`, 40 packs), main fbb17c980 against this branch. Only RenderPearl's output changes: - All 184 `Expected Void, Struct or a type, found Layout` errors and the 10 `gl_PerVertex` position errors are gone. - Skipped program loads drop from 138 to 68. `gbuffers_basic`, `gbuffers_textured`, `gbuffers_skybasic`, `gbuffers_skytextured` and `gbuffers_clouds` now translate wherever they're loaded, and `gbuffers_weather` in two of its three loads. Terrain and water fall back to `gbuffers_textured`. - The programs still skipped stop on `textureQueryLod` (#7170), `max3`, and one texture sample whose offset naga can't take as a constant (not filed yet). Tests: - `locals_named_like_the_instance_are_not_it` (a parameter, a nested local and another struct's member named like the instance); - `a_redeclared_gl_per_vertex_goes`; - `a_per_vertex_redeclaration_and_a_parameter_named_like_the_instance` (a whole program). Run against main's `flatten`, all three fail. ## 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, 4.2 (Scoping), 4.3.9 (Interface Blocks) and 7.5 (Redeclaring Built-In Blocks). ## 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: - `prog/unlit.vsh`, lines 1–30; `prog/unlit.fsh`, 1–40; `prog/solid.vsh`, 66–69; `lib/tbn/fsh.glsl`, 2–5 (the lines Horizon's errors name, and the headers above them); - `prog/none.vsh`; `gbuffers_skybasic.vsh` and `gbuffers_skytextured.vsh`; `gbuffers_basic.vsh` and `.fsh`; - `prelude/core.glsl`; - `shaders.properties`, lines 57, 85, 86, 124 and 126; - `prelude/compat.glsl`, lines 204–211 (where `max3` comes from, for the note above); - a grep of the whole pack for `component =` and `gl_PerVertex`. What follows RenderPearl: the whole-program test's `out gl_PerVertex { vec4 gl_Position; };`, and its block `VertexData { layout(location = 1, component = 0) vec2 coord; } v;`, which have RenderPearl's shapes and names. The function with a parameter `v` is ours (a guess the probe confirmed, not something read). The unit tests are written for this. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on plony-pc, against origin/main at fbb17c980, 1 min 27 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +153 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (32 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (46 s) | | tests: horizon-shaders | ✅ 145 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#7435
No description provided.