[PR #1820] [MERGED] Horizon shader packs: the check every pack passes before it runs #3791

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

📋 Pull Request Information

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

Base: main ← Head: feat/native-shaders-check


📝 Commits (1)

  • 923fdee Horizon shader packs: the check every pack passes before it runs

📊 Changes

8 files changed (+682 additions, -4 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-shader-api/Cargo.toml (+3 -3)
➕ crates/horizon-shader-api/src/check.rs (+495 -0)
📝 crates/horizon-shader-api/src/lib.rs (+2 -0)
📝 crates/horizon-shader-api/src/package.rs (+15 -0)
📝 crates/horizon-shader-api/src/reference.rs (+10 -1)
➕ crates/horizon-shader-api/tests/check.rs (+146 -0)
📝 docs/api/shaders-reference.md (+10 -0)

📄 Description

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

Stacked on #1818 (stages) and #1817 (format); the diff below is only this step.

What

horizon_shader_api::check(&Pack): the validation at the core of the shader SDK. The same function will run in the game when it loads a pack (refusing it with the message, the last good pack keeps drawing), in the launcher before it installs one, in the registry's CI (the shader kind), and in the horizon-shader check command (next PR). For each stage:

  1. Build it as the renderer does (prelude + shared files + the stage file + entry points) and parse it with naga.
  2. The stage function has its signature (fn post(input: PostInput) -> vec4<f32>, ...); a missing or mistyped one is named as such.
  3. API rules: the pack's files declare no bindings, no entry points, no horizon_ names.
  4. Options: each override is an option of the right type (bool/f32/i32/u32) or has a default; every option is used by some stage.
  5. naga validation (all flags).
  6. Budgets: 20 000 expressions and 64 texture reads per stage.
  7. Every entry point translated to SPIR-V, Metal (MSL 2.2) and HLSL, with the options at their defaults, minimums and maximums, as wgpu does when it builds the pipelines.

All problems are returned, each with the pack's file, line and column (post/grade.wgsl:4:24: expected expression...). Pack::sha256() hashes the reproducible package. The checked naga modules are returned for the renderer (wgpu's naga-ir source, no second parse). The reference gains the limits and the check's rules.

How tested

cargo test -p horizon-shader-api: 17 passed
  check.rs (7): the sample pack passes with its labels, costs and a stable SHA-256; a syntax error at its file:line;
    wrong and missing stage signatures; an extra binding, an entry point, a horizon_ name; override type vs option,
    an override with no default, an unused option (reported on horizon-shaders.toml); a validation-only error
    (a compute barrier in a fragment stage); the texture read budget
  reference.rs (4), schema.rs (5), inputs (1)
cargo clippy -p horizon-shader-api --all-targets -- -D warnings: clean; cargo fmt --check: clean

Needs Ludovic

Nothing. skip-release.

🤖 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/1820 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/native-shaders-check` --- ### 📝 Commits (1) - [`923fdee`](https://github.com/horizon-rust/horizon/commit/923fdee42e1cfa9596dff25e449050bc20ae34d4) Horizon shader packs: the check every pack passes before it runs ### 📊 Changes **8 files changed** (+682 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-shader-api/Cargo.toml` (+3 -3) ➕ `crates/horizon-shader-api/src/check.rs` (+495 -0) 📝 `crates/horizon-shader-api/src/lib.rs` (+2 -0) 📝 `crates/horizon-shader-api/src/package.rs` (+15 -0) 📝 `crates/horizon-shader-api/src/reference.rs` (+10 -1) ➕ `crates/horizon-shader-api/tests/check.rs` (+146 -0) 📝 `docs/api/shaders-reference.md` (+10 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1818 (stages) and #1817 (format); the diff below is only this step. ## What `horizon_shader_api::check(&Pack)`: the validation at the core of the shader SDK. The same function will run in the game when it loads a pack (refusing it with the message, the last good pack keeps drawing), in the launcher before it installs one, in the registry's CI (the `shader` kind), and in the `horizon-shader check` command (next PR). For each stage: 1. Build it as the renderer does (prelude + shared files + the stage file + entry points) and parse it with naga. 2. The stage function has its signature (`fn post(input: PostInput) -> vec4<f32>`, ...); a missing or mistyped one is named as such. 3. API rules: the pack's files declare no bindings, no entry points, no `horizon_` names. 4. Options: each `override` is an option of the right type (`bool`/`f32`/`i32`/`u32`) or has a default; every option is used by some stage. 5. naga validation (all flags). 6. Budgets: 20 000 expressions and 64 texture reads per stage. 7. Every entry point translated to SPIR-V, Metal (MSL 2.2) and HLSL, with the options at their defaults, minimums and maximums, as wgpu does when it builds the pipelines. All problems are returned, each with the pack's file, line and column (`post/grade.wgsl:4:24: expected expression...`). `Pack::sha256()` hashes the reproducible package. The checked naga modules are returned for the renderer (wgpu's `naga-ir` source, no second parse). The reference gains the limits and the check's rules. ## How tested ``` cargo test -p horizon-shader-api: 17 passed check.rs (7): the sample pack passes with its labels, costs and a stable SHA-256; a syntax error at its file:line; wrong and missing stage signatures; an extra binding, an entry point, a horizon_ name; override type vs option, an override with no default, an unused option (reported on horizon-shaders.toml); a validation-only error (a compute barrier in a fragment stage); the texture read budget reference.rs (4), schema.rs (5), inputs (1) cargo clippy -p horizon-shader-api --all-targets -- -D warnings: clean; cargo fmt --check: clean ``` ## Needs Ludovic Nothing. `skip-release`. 🤖 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:12:21 +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#3791
No description provided.