[PR #4442] [MERGED] Shader packs 2/12: narrow outputs, inverse(), alphaTestRef; read custom textures #5623

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4442
Author: @PzmuV1517
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @ludovic111

Base: main ← Head: shader-packs/02


📝 Commits (6)

  • d085cab Shader packs: outputs narrower than vec4, inverse(), alphaTestRef and the cutout test
  • 6b0f026 Shader packs: read custom textures (texture.*)
  • 1763989 Shader packs: a raw texture's sizes are bounded and checked
  • 6485363 Shader packs: a pack that defines its own inverse() keeps it
  • 0c3831d Merge main into shader-packs/02 (zip 9.1.3 from #3832 beside this part's half and png)
  • 6173f17 Merge remote-tracking branch 'origin/main' into a3-4442

📊 Changes

11 files changed (+607 additions, -13 deletions)

View changed files

📝 Cargo.lock (+2 -0)
📝 crates/horizon-shaders/Cargo.toml (+2 -0)
📝 crates/horizon-shaders/src/lib.rs (+5 -0)
📝 crates/horizon-shaders/src/pack.rs (+2 -2)
📝 crates/horizon-shaders/src/post.rs (+14 -1)
➕ crates/horizon-shaders/src/textures.rs (+427 -0)
📝 crates/horizon-shaders/src/translate/mod.rs (+70 -0)
📝 crates/horizon-shaders/src/translate/rewrite.rs (+21 -0)
📝 crates/horizon-shaders/src/translate/scan.rs (+51 -2)
📝 third_party/naga/src/front/glsl/functions.rs (+4 -5)
📝 third_party/naga/src/front/glsl/variables.rs (+9 -3)

📄 Description

Part 2 of 12 of the shader pack work from #3737. It builds on part 1 (#4441): this branch is that one plus the commits below, so review only these:

  • d085cabe4 Shader packs: outputs narrower than vec4, inverse(), alphaTestRef and the cutout test
  • 6b0f0261e Shader packs: read custom textures (texture.*)
  • 17639892e Shader packs: a raw texture's sizes are bounded and checked
  • 6485363dc Shader packs: a pack that defines its own inverse() keeps it

What and why

outputs narrower than vec4, inverse(), alphaTestRef and the cutout test (d085cabe4)

  • A fragment output declared float, vec2 or vec3 (int and uint too) is written as the vec4 of its kind, alpha 1: wgpu's targets take four components.
  • inverse() of a mat2, mat3 or mat4 is a function of ours (the adjugate over the determinant): naga writes it neither for Metal nor for WGSL.
  • alphaTestRef is a constant of the program: its alpha test's reference.
  • Solid and cutout terrain draw together, so terrain gets the cutout test (alpha > 0.1) unless alphaTest.* says otherwise.
  • The naga pin moves to the fixes for pointers into vectors passed as out arguments and field selection on a matrix column.

read custom textures (texture.*) (6b0f0261e)

texture.. and texture.noise name the files a pack binds to its samplers: PNG images, and raw 1D, 2D and 3D data with their size, format and type, each with its .mcmeta (blur, clamp). Post carries them, with a note for each that can't be read; nothing draws them yet.

a raw texture's sizes are bounded and checked (17639892e)

Each dimension of a TEXTURE_* entry is at most 16384, and the bytes it needs are counted
without overflowing, so a pack asking for a huge volume gets a note instead of a wrapped
length check.

a pack that defines its own inverse() keeps it (6485363dc)

Vanilla reference

Horizon-only: vanilla has no shader packs. Nothing changes unless a pack is selected.

Self-check

pr_ready (tools/pr_ready.py --quick on Mac, against origin/main at 27cb8f96b, 2 min 31 s)

Check Result
Scope ⚠️ 171 files, +120915 −25; 120838 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅ (1 s)
Python tests ✅ 495 passed (24 s)
rustfmt ✅ (4 s)
Rust ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with rustup update
clippy ✅ (38 s)
tests: workspace ❌ 2184 passed, 1 failed (57 s)
doc tests ✅ 0 passed (4 s)
content root tests ✅ 7 passed (18 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅
launcher tests ❌ 315 passed, 1 failed (4 s)
Parity ➖ 359 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 347 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Failures that aren't from this stack:

  • The horizon-port-pack resource pack tests and the launcher's modpacks::tests::resource_only_profile_can_play_without_enabling_or_overwriting_packs fail with "/var: not an ordinary directory" on macOS, where /var is a symlink. The resource pack tests fail the same way on main itself, and this stack changes neither horizon-port-pack nor the launcher.
  • gfx::frame_gen::optical_flow::tests::finds_a_shift_and_a_scene_change is main's and fails now and then in a full run on this machine, on main too (1 of 5 runs); nothing here touches it. When it fails first, cargo stops before the horizon-port-pack tests.

🔄 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/4442 **Author:** [@PzmuV1517](https://github.com/PzmuV1517) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `shader-packs/02` --- ### 📝 Commits (6) - [`d085cab`](https://github.com/horizon-rust/horizon/commit/d085cabe41a8bcd8146c93c31eb1ea95e2b6b5e1) Shader packs: outputs narrower than vec4, inverse(), alphaTestRef and the cutout test - [`6b0f026`](https://github.com/horizon-rust/horizon/commit/6b0f0261e9b31a16528275fdcccc8170534b2fb6) Shader packs: read custom textures (texture.*) - [`1763989`](https://github.com/horizon-rust/horizon/commit/17639892ece3aa3aa3313a73e752b96fc50b368a) Shader packs: a raw texture's sizes are bounded and checked - [`6485363`](https://github.com/horizon-rust/horizon/commit/6485363dc2516cf9ea5c6e3ed0296646577aaa74) Shader packs: a pack that defines its own inverse() keeps it - [`0c3831d`](https://github.com/horizon-rust/horizon/commit/0c3831d711c26decc128b794447e335c397c1021) Merge main into shader-packs/02 (zip 9.1.3 from #3832 beside this part's half and png) - [`6173f17`](https://github.com/horizon-rust/horizon/commit/6173f174b1d48a73c79f315b19545ca945ab84e5) Merge remote-tracking branch 'origin/main' into a3-4442 ### 📊 Changes **11 files changed** (+607 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+2 -0) 📝 `crates/horizon-shaders/Cargo.toml` (+2 -0) 📝 `crates/horizon-shaders/src/lib.rs` (+5 -0) 📝 `crates/horizon-shaders/src/pack.rs` (+2 -2) 📝 `crates/horizon-shaders/src/post.rs` (+14 -1) ➕ `crates/horizon-shaders/src/textures.rs` (+427 -0) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+70 -0) 📝 `crates/horizon-shaders/src/translate/rewrite.rs` (+21 -0) 📝 `crates/horizon-shaders/src/translate/scan.rs` (+51 -2) 📝 `third_party/naga/src/front/glsl/functions.rs` (+4 -5) 📝 `third_party/naga/src/front/glsl/variables.rs` (+9 -3) </details> ### 📄 Description Part 2 of 12 of the shader pack work from #3737. It builds on part 1 (#4441): this branch is that one plus the commits below, so review only these: - `d085cabe4` Shader packs: outputs narrower than vec4, inverse(), alphaTestRef and the cutout test - `6b0f0261e` Shader packs: read custom textures (texture.*) - `17639892e` Shader packs: a raw texture's sizes are bounded and checked - `6485363dc` Shader packs: a pack that defines its own inverse() keeps it ## What and why **outputs narrower than vec4, inverse(), alphaTestRef and the cutout test** (`d085cabe4`) - A fragment output declared float, vec2 or vec3 (int and uint too) is written as the vec4 of its kind, alpha 1: wgpu's targets take four components. - inverse() of a mat2, mat3 or mat4 is a function of ours (the adjugate over the determinant): naga writes it neither for Metal nor for WGSL. - alphaTestRef is a constant of the program: its alpha test's reference. - Solid and cutout terrain draw together, so terrain gets the cutout test (alpha > 0.1) unless alphaTest.* says otherwise. - The naga pin moves to the fixes for pointers into vectors passed as out arguments and field selection on a matrix column. **read custom textures (texture.*)** (`6b0f0261e`) texture.<stage>.<name> and texture.noise name the files a pack binds to its samplers: PNG images, and raw 1D, 2D and 3D data with their size, format and type, each with its .mcmeta (blur, clamp). Post carries them, with a note for each that can't be read; nothing draws them yet. **a raw texture's sizes are bounded and checked** (`17639892e`) Each dimension of a TEXTURE_* entry is at most 16384, and the bytes it needs are counted without overflowing, so a pack asking for a huge volume gets a note instead of a wrapped length check. **a pack that defines its own inverse() keeps it** (`6485363dc`) ## Vanilla reference Horizon-only: vanilla has no shader packs. Nothing changes unless a pack is selected. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Mac, against origin/main at 27cb8f96b, 2 min 31 s) | Check | Result | | --- | --- | | Scope | ⚠️ 171 files, +120915 −25; 120838 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ (1 s) | | Python tests | ✅ 495 passed (24 s) | | rustfmt | ✅ (4 s) | | Rust | ⚠️ 1.98.1 is older than CI's stable (1.99): clippy may flag lints CI doesn't, update with `rustup update` | | clippy | ✅ (38 s) | | tests: workspace | ❌ 2184 passed, 1 failed (57 s) | | doc tests | ✅ 0 passed (4 s) | | content root tests | ✅ 7 passed (18 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ | | launcher tests | ❌ 315 passed, 1 failed (4 s) | | Parity | ➖ 359 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 347 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Failures that aren't from this stack: - The `horizon-port-pack` resource pack tests and the launcher's `modpacks::tests::resource_only_profile_can_play_without_enabling_or_overwriting_packs` fail with "/var: not an ordinary directory" on macOS, where `/var` is a symlink. The resource pack tests fail the same way on main itself, and this stack changes neither `horizon-port-pack` nor the launcher. - `gfx::frame_gen::optical_flow::tests::finds_a_shift_and_a_scene_change` is main's and fails now and then in a full run on this machine, on main too (1 of 5 runs); nothing here touches it. When it fails first, cargo stops before the `horizon-port-pack` tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:13:51 +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#5623
No description provided.