[PR #7239] [MERGED] Shader packs: struct types without a name #7432

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

Base: main ← Head: shaderpacks/anonymous-structs


📝 Commits (1)

  • 5e2c8f5 Shader packs: struct types without a name

📊 Changes

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

View changed files

➕ crates/horizon-shaders/src/translate/anonymous_structs.rs (+44 -0)
📝 crates/horizon-shaders/src/translate/mod.rs (+27 -2)

📄 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: GLSL lets a declaration define its struct type in place without naming it (GLSL 4.60, 4.1.8), for example shared struct { uint sum; uint tile[8][8]; } lds;. naga's frontend wants a name there and fails with Expected identifier, found LeftBrace. RenderPearl v2.7.2's compute programs deferred, deferred1, composite and composite3 keep their work group's data this way.

The fix: a new pass, translate/anonymous_structs.rs, gives each such type a name, hz_struct<n>, before the stages are read. It runs on the stages of every program and on compute programs. Nothing else changes.

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

  • On its own: no output changes. RenderPearl's compute programs first stop on #version coming from an included header, which the #version PR for #7171 fixes.
  • With that branch underneath: composite translates. deferred1 and composite3 stop on max3/min3, and deferred on the next gap; all are outside #7171 (not filed yet). No other pack changes.

Tests: struct_types_without_a_name_get_one (the pass) and a_shared_struct_without_a_type_name_compiles (a compute program). Run against main's code, the second fails: Expected identifier, found LeftBrace.

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.1.8 Structures.

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:

  • deferred1.csh, lines 46–49; composite.csh, 45–48; composite3.csh, 13–16 (the shared struct declarations Horizon's errors name);
  • deferred.csh, lines 20–32;
  • prelude/compat.glsl, lines 204–211 (where max3/min3 come from, for the note above);
  • a grep of the whole pack for shared.

What follows RenderPearl: the compute test declares shared struct { … } lds; with a member array sized by gl_WorkGroupSize.x and gl_WorkGroupSize.y, the shape of RenderPearl's declarations (its own member types and names are not used). The pass's unit test is written for this.

Self-check

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

Check Result
Scope ✅ 2 files, +71 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (56 s)
rustfmt ✅ (14 s)
clippy ✅ (3 min 10 s)
tests: horizon-shaders ✅ 144 passed (16 s)
doc tests ✅ 0 passed (1 s)
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/7239 **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/anonymous-structs` --- ### 📝 Commits (1) - [`5e2c8f5`](https://github.com/horizon-rust/horizon/commit/5e2c8f5641f51e8298c174bc328e40e891242c41) Shader packs: struct types without a name ### 📊 Changes **2 files changed** (+71 additions, -2 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-shaders/src/translate/anonymous_structs.rs` (+44 -0) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+27 -2) </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:** GLSL lets a declaration define its struct type in place without naming it (GLSL 4.60, 4.1.8), for example `shared struct { uint sum; uint tile[8][8]; } lds;`. naga's frontend wants a name there and fails with `Expected identifier, found LeftBrace`. RenderPearl v2.7.2's compute programs `deferred`, `deferred1`, `composite` and `composite3` keep their work group's data this way. **The fix:** a new pass, `translate/anonymous_structs.rs`, gives each such type a name, `hz_struct<n>`, before the stages are read. It runs on the stages of every program and on compute programs. Nothing else changes. **Measured** with `real_packs` (`SHOW_ERRORS=1`, 40 packs), main fbb17c980 against this branch: - **On its own:** no output changes. RenderPearl's compute programs first stop on `#version` coming from an included header, which the `#version` PR for #7171 fixes. - **With that branch underneath:** `composite` translates. `deferred1` and `composite3` stop on `max3`/`min3`, and `deferred` on the next gap; all are outside #7171 (not filed yet). No other pack changes. Tests: `struct_types_without_a_name_get_one` (the pass) and `a_shared_struct_without_a_type_name_compiles` (a compute program). Run against main's code, the second fails: `Expected identifier, found LeftBrace`. ## 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.1.8 Structures. ## 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: - `deferred1.csh`, lines 46–49; `composite.csh`, 45–48; `composite3.csh`, 13–16 (the `shared struct` declarations Horizon's errors name); - `deferred.csh`, lines 20–32; - `prelude/compat.glsl`, lines 204–211 (where `max3`/`min3` come from, for the note above); - a grep of the whole pack for `shared`. What follows RenderPearl: the compute test declares `shared struct { … } lds;` with a member array sized by `gl_WorkGroupSize.x` and `gl_WorkGroupSize.y`, the shape of RenderPearl's declarations (its own member types and names are not used). The pass's unit test is written for this. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on plony-pc, against origin/main at fbb17c980, 4 min 37 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +71 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (56 s) | | rustfmt | ✅ (14 s) | | clippy | ✅ (3 min 10 s) | | tests: horizon-shaders | ✅ 144 passed (16 s) | | doc tests | ✅ 0 passed (1 s) | | 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#7432
No description provided.