[PR #2939] [CLOSED] Shader API: the check of a mod's own post pass (params, no bindings of its own, size and compile budget) #4695

Closed
opened 2026-11-03 05:07:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2939
Author: @ludovic111
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: feat/mod-shader-check


📝 Commits (2)

  • d534c9a Mods: storage holds 16 MiB and 256 files, set per server in server.toml
  • 47f424c Shader API: the check of a mod's own post pass

📊 Changes

16 files changed (+556 additions, -46 deletions)

View changed files

📝 crates/horizon-client/src/game/mods.rs (+3 -1)
📝 crates/horizon-mods/src/runtime.rs (+98 -15)
📝 crates/horizon-mods/tests/sandbox.rs (+23 -8)
📝 crates/horizon-server/src/config.rs (+40 -0)
📝 crates/horizon-server/src/engine.rs (+9 -1)
📝 crates/horizon-server/src/settings.rs (+2 -0)
📝 crates/horizon-server/src/supervisor.rs (+1 -1)
📝 crates/horizon-shader-api/src/check.rs (+36 -13)
📝 crates/horizon-shader-api/src/lib.rs (+1 -0)
➕ crates/horizon-shader-api/src/mods.rs (+241 -0)
📝 crates/horizon-shader-api/src/stages.rs (+41 -5)
📝 docs/api/mods.md (+1 -1)
📝 docs/api/server-reference.md (+9 -0)
📝 docs/api/shaders.md (+10 -0)
📝 docs/hosting.md (+4 -0)
📝 docs/mods.md (+37 -1)

📄 Description

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

Second of four stacked PRs for brief mod-shaders-1. Stacked on #2935; its own diff is the last commit.

What

This PR adds the check a mod's WGSL goes through before the game builds it. It reuses horizon-shader-api's pack check instead of adding a second shader system.

  • horizon_shader_api::mods::check(kind, file, text, params):
    • For now it takes a Post stage only.
    • It returns the same CheckedStage as a pack's post pass, so the renderer builds both the same way.
  • What a mod's shader sees:
    • the post prelude (frame, scene_color, scene_depth, previous, both samplers, PostInput);
    • plus struct Params { <its names>: f32, … } and @group(3) @binding(6) var<uniform> params: Params;.
    • The mod names its parameters when it registers the shader: at most 16, each [a-z][a-z0-9_]{0,31}, not horizon_*, not a WGSL keyword, no repeats.
  • What it refuses, with file:line:col errors:
    • WGSL that doesn't parse or validate (naga);
    • bindings of its own: storage buffers, read-write storage, textures, or any other group or binding;
    • its own entry points;
    • sources over 64 KiB;
    • more than 4,000 naga expressions;
    • a compile that runs over 250 ms.
  • To support this, check_stage now goes through a Source (prelude, shared files, file) that both packs and mods use. Packs behave exactly as before; their tests are unchanged.
  • docs/api/shaders.md gains a "Shaders from a mod" section and a changelog line.

Tests (cargo test -p horizon-shader-api)

  • a_post_pass_reads_its_params: a valid pass compiles. Its params uniform is at group 3, binding 6.
  • bad_wgsl_is_refused_where_it_is_wrong: a misspelled field is refused at its line and column. A file with no fn post is refused by name.
  • bindings_of_its_own_are_refused: a var<storage, read_write> buffer, a texture binding and an @fragment entry point are all refused.
  • limits_hold: covers the size, the parameter count, bad names, the expression cap (1,500 chained statements), a Sky kind and a zero compile budget.

pr_ready (tools/pr_ready.py --base feat/mod-storage-quota on ludovics-mac-mini, against feat/mod-storage-quota at d534c9ab1, 24 min 15 s)

Check Result
Scope ✅ 5 files, +329 −18
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 369 passed (1 min 19 s)
rustfmt ✅ (13 s)
clippy ✅ (37 s)
tests: horizon-shader-api ✅ 24 passed (12 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 ✅ 36 affected, 35 passed (21 min 20 s)
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/2939 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/mod-shader-check` --- ### 📝 Commits (2) - [`d534c9a`](https://github.com/horizon-rust/horizon/commit/d534c9ab1dd6a0f9bc63d6feb36dfdd14c368be5) Mods: storage holds 16 MiB and 256 files, set per server in server.toml - [`47f424c`](https://github.com/horizon-rust/horizon/commit/47f424cdcfbebaaacd5c445db58d5d436a36bfa5) Shader API: the check of a mod's own post pass ### 📊 Changes **16 files changed** (+556 additions, -46 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/mods.rs` (+3 -1) 📝 `crates/horizon-mods/src/runtime.rs` (+98 -15) 📝 `crates/horizon-mods/tests/sandbox.rs` (+23 -8) 📝 `crates/horizon-server/src/config.rs` (+40 -0) 📝 `crates/horizon-server/src/engine.rs` (+9 -1) 📝 `crates/horizon-server/src/settings.rs` (+2 -0) 📝 `crates/horizon-server/src/supervisor.rs` (+1 -1) 📝 `crates/horizon-shader-api/src/check.rs` (+36 -13) 📝 `crates/horizon-shader-api/src/lib.rs` (+1 -0) ➕ `crates/horizon-shader-api/src/mods.rs` (+241 -0) 📝 `crates/horizon-shader-api/src/stages.rs` (+41 -5) 📝 `docs/api/mods.md` (+1 -1) 📝 `docs/api/server-reference.md` (+9 -0) 📝 `docs/api/shaders.md` (+10 -0) 📝 `docs/hosting.md` (+4 -0) 📝 `docs/mods.md` (+37 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Second of four stacked PRs for brief mod-shaders-1. Stacked on #2935; its own diff is the last commit. ## What This PR adds the check a mod's WGSL goes through before the game builds it. It reuses horizon-shader-api's pack check instead of adding a second shader system. - **`horizon_shader_api::mods::check(kind, file, text, params)`:** - For now it takes a `Post` stage only. - It returns the same `CheckedStage` as a pack's post pass, so the renderer builds both the same way. - **What a mod's shader sees:** - the post prelude (`frame`, `scene_color`, `scene_depth`, `previous`, both samplers, `PostInput`); - plus `struct Params { <its names>: f32, … }` and `@group(3) @binding(6) var<uniform> params: Params;`. - The mod names its parameters when it registers the shader: at most 16, each `[a-z][a-z0-9_]{0,31}`, not `horizon_*`, not a WGSL keyword, no repeats. - **What it refuses, with `file:line:col` errors:** - WGSL that doesn't parse or validate (naga); - bindings of its own: storage buffers, read-write storage, textures, or any other group or binding; - its own entry points; - sources over 64 KiB; - more than 4,000 naga expressions; - a compile that runs over 250 ms. - To support this, `check_stage` now goes through a `Source` (prelude, shared files, file) that both packs and mods use. Packs behave exactly as before; their tests are unchanged. - docs/api/shaders.md gains a "Shaders from a mod" section and a changelog line. ## Tests (`cargo test -p horizon-shader-api`) - `a_post_pass_reads_its_params`: a valid pass compiles. Its `params` uniform is at group 3, binding 6. - `bad_wgsl_is_refused_where_it_is_wrong`: a misspelled field is refused at its line and column. A file with no `fn post` is refused by name. - `bindings_of_its_own_are_refused`: a `var<storage, read_write>` buffer, a texture binding and an `@fragment` entry point are all refused. - `limits_hold`: covers the size, the parameter count, bad names, the expression cap (1,500 chained statements), a `Sky` kind and a zero compile budget. **pr_ready** (`tools/pr_ready.py --base feat/mod-storage-quota` on ludovics-mac-mini, against feat/mod-storage-quota at d534c9ab1, 24 min 15 s) | Check | Result | | --- | --- | | Scope | ✅ 5 files, +329 −18 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 369 passed (1 min 19 s) | | rustfmt | ✅ (13 s) | | clippy | ✅ (37 s) | | tests: horizon-shader-api | ✅ 24 passed (12 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 | ✅ 36 affected, 35 passed (21 min 20 s) | | 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 05:07:16 +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#4695
No description provided.