[PR #1600] [MERGED] Shader packs, clean room 5: the GLSL preprocessor and #include #3622

Closed
opened 2026-11-03 04:10:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1600
Author: @ludovic111
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @ludovic111

Base: main ← Head: feat/shader-packs-preprocessor


📝 Commits (5)

  • 07e46da Shader packs, clean room 1: read packs and their lang files
  • eb0a6f7 Shader packs, clean room 2: macros and #if conditions
  • 397d529 Shader packs, clean room 3: .properties files with conditional directives
  • 4c65ed2 Shader packs, clean room 4: function-like macros and the standard macros
  • f239955 Shader packs, clean room 5: the GLSL preprocessor and #include

📊 Changes

13 files changed (+1850 additions, -1 deletions)

View changed files

📝 AGENTS.md (+1 -0)
📝 Cargo.lock (+8 -0)
📝 Cargo.toml (+1 -1)
➕ crates/horizon-shaders/Cargo.toml (+14 -0)
➕ crates/horizon-shaders/src/condition.rs (+369 -0)
➕ crates/horizon-shaders/src/discover.rs (+82 -0)
➕ crates/horizon-shaders/src/lang.rs (+74 -0)
➕ crates/horizon-shaders/src/lib.rs (+26 -0)
➕ crates/horizon-shaders/src/macros.rs (+317 -0)
➕ crates/horizon-shaders/src/pack.rs (+262 -0)
➕ crates/horizon-shaders/src/preprocess.rs (+374 -0)
➕ crates/horizon-shaders/src/properties.rs (+229 -0)
➕ crates/horizon-shaders/tests/real_packs.rs (+93 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Shader packs, clean room 5 (slice 2b): the GLSL preprocessor and #include. Stacked on #1599.

What

preprocess(pack, path, macros): a stage file goes through comment removal, #include, conditionals and macro expansion, and every output line remembers the pack file and line it came from, so later errors point at the pack's own code.

  • #include "x" from the including file's folder, "/x" from the shaders folder, expanded in live code only (an include inside a false #if is not read, OQ-14), ten levels at most, paths that leave the pack refused; a file is read once per run however often it is included.
  • #define, #undef, line continuations, __LINE__, __VERSION__; #version and #extension kept apart for the translation's own header; the block comments of live code kept for the directives packs write in them (DRAWBUFFERS, buffer formats); #error and unknown directives diagnosed.

Nothing uses it yet: players see no change (skip-release).

Clean room

Clean-room: implemented from cleanroom/shader-packs-spec.md revision 1, §1.4, §1.5, §1.6 and OQ-14; no other loader's code read.

How tested

  • Unit tests: include paths and the line map, missing and runaway includes diagnosed where they stand, macro expansion as the GLSL preprocessor does it, comments, extensions and errors.
  • Black box on the public test packs (never committed), tests/real_packs.rs: every stage file of the base and dimension folders (126 to 219 per pack, four packs) preprocesses with 0 diagnostics, about 4 ms per stage file for the largest pack on the Mac mini.

Self-check (whole stack, on its top branch feat/shader-packs-translate)

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 16d49fe66, 32 min 35 s)

Check Result
Scope ⚠️ 16 files, +3028 −1; 2864 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (35 s)
clippy ✅ (3 min 10 s)
tests: workspace ✅ 1955 passed (27 min 39 s)
doc tests ✅ 1 passed (rerun alone: the first run compiled the next slice's uncommitted files in the same worktree)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more
Label skip-release: players see nothing yet

Parity: the root Cargo.toml change selects 326 harnesses, but nothing in the game depends on the new crate, so they can't change. CI runs them.

Needs Ludovic

Nothing for this PR. Label skip-release because players see nothing yet (the first visible slice is the Shader Packs page, slice 9).

🤖 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/1600 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/shader-packs-preprocessor` --- ### 📝 Commits (5) - [`07e46da`](https://github.com/horizon-rust/horizon/commit/07e46daa59e2c6238a443c7992beb10af1307266) Shader packs, clean room 1: read packs and their lang files - [`eb0a6f7`](https://github.com/horizon-rust/horizon/commit/eb0a6f74e6d5911cc63e637b6dcd14076c28ac0e) Shader packs, clean room 2: macros and #if conditions - [`397d529`](https://github.com/horizon-rust/horizon/commit/397d529db72a17a1def83e1d7c50e9f866beb69e) Shader packs, clean room 3: .properties files with conditional directives - [`4c65ed2`](https://github.com/horizon-rust/horizon/commit/4c65ed2f5c6c4e089cf4f0bec4b32ab97004e4bc) Shader packs, clean room 4: function-like macros and the standard macros - [`f239955`](https://github.com/horizon-rust/horizon/commit/f2399559979c1fd1a0e62c578a83ae4e5a29cd75) Shader packs, clean room 5: the GLSL preprocessor and #include ### 📊 Changes **13 files changed** (+1850 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -0) 📝 `Cargo.lock` (+8 -0) 📝 `Cargo.toml` (+1 -1) ➕ `crates/horizon-shaders/Cargo.toml` (+14 -0) ➕ `crates/horizon-shaders/src/condition.rs` (+369 -0) ➕ `crates/horizon-shaders/src/discover.rs` (+82 -0) ➕ `crates/horizon-shaders/src/lang.rs` (+74 -0) ➕ `crates/horizon-shaders/src/lib.rs` (+26 -0) ➕ `crates/horizon-shaders/src/macros.rs` (+317 -0) ➕ `crates/horizon-shaders/src/pack.rs` (+262 -0) ➕ `crates/horizon-shaders/src/preprocess.rs` (+374 -0) ➕ `crates/horizon-shaders/src/properties.rs` (+229 -0) ➕ `crates/horizon-shaders/tests/real_packs.rs` (+93 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Shader packs, clean room 5 (slice 2b):** the GLSL preprocessor and `#include`. Stacked on #1599. ## What `preprocess(pack, path, macros)`: a stage file goes through comment removal, `#include`, conditionals and macro expansion, and every output line remembers the pack file and line it came from, so later errors point at the pack's own code. - `#include "x"` from the including file's folder, `"/x"` from the `shaders` folder, expanded in live code only (an include inside a false `#if` is not read, OQ-14), ten levels at most, paths that leave the pack refused; a file is read once per run however often it is included. - `#define`, `#undef`, line continuations, `__LINE__`, `__VERSION__`; `#version` and `#extension` kept apart for the translation's own header; the block comments of live code kept for the directives packs write in them (`DRAWBUFFERS`, buffer formats); `#error` and unknown directives diagnosed. Nothing uses it yet: players see no change (`skip-release`). ## Clean room Clean-room: implemented from `cleanroom/shader-packs-spec.md` revision 1, §1.4, §1.5, §1.6 and OQ-14; no other loader's code read. ## How tested - Unit tests: include paths and the line map, missing and runaway includes diagnosed where they stand, macro expansion as the GLSL preprocessor does it, comments, extensions and errors. - Black box on the public test packs (never committed), `tests/real_packs.rs`: every stage file of the base and dimension folders (126 to 219 per pack, four packs) preprocesses with **0 diagnostics**, about 4 ms per stage file for the largest pack on the Mac mini. ## Self-check (whole stack, on its top branch `feat/shader-packs-translate`) **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 16d49fe66, 32 min 35 s) | Check | Result | | --- | --- | | Scope | ⚠️ 16 files, +3028 −1; 2864 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (35 s) | | clippy | ✅ (3 min 10 s) | | tests: workspace | ✅ 1955 passed (27 min 39 s) | | doc tests | ✅ 1 passed (rerun alone: the first run compiled the next slice's uncommitted files in the same worktree) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 326 affected, to run in CI (--quick): active_effect_tick, active_effects, ambient_sound, anchor, arrow, attribute_health, attribute_map_queries, attribute, attribute_updates, audio_attributes, auto_jump, bamboo and 314 more | | Label | `skip-release`: players see nothing yet | Parity: the root `Cargo.toml` change selects 326 harnesses, but nothing in the game depends on the new crate, so they can't change. CI runs them. ## Needs Ludovic Nothing for this PR. Label `skip-release` because players see nothing yet (the first visible slice is the Shader Packs page, slice 9). 🤖 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 04:10:52 +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#3622
No description provided.