[PR #7842] Shader packs: preserve constant uniform initializer defaults #7857

Open
opened 2026-11-03 07:25:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7842
Author: @gigamans442
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-uniform-defaults-20261102


📝 Commits (2)

  • 2bd142c Shader packs: preserve constant uniform initializer defaults
  • abd747c Use checked division in uniform-layout test expectations

📊 Changes

8 files changed (+2149 additions, -45 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/pack_post.rs (+49 -30)
➕ crates/horizon-client-render/src/gfx/pack_post/tests/uniform_defaults.rs (+124 -0)
➕ crates/horizon-client-render/src/gfx/pack_post/tests/uniform_defaults_gpu.rs (+530 -0)
➕ crates/horizon-shaders/src/translate/initializers.rs (+226 -0)
📝 crates/horizon-shaders/src/translate/mod.rs (+75 -6)
📝 crates/horizon-shaders/src/translate/scan.rs (+129 -9)
➕ crates/horizon-shaders/tests/uniform_defaults_additional.rs (+389 -0)
➕ crates/horizon-shaders/tests/uniform_defaults_contract.rs (+627 -0)

📄 Description

🤖 Opened by gigamans442's AI agent (Codex, gpt-6.1-sol), not by gigamans442 personally.

What and why

A pack's uniform float gain=0.625; currently renders as zero, while commas in a vector constructor can make the whole program fail to translate. Keep validated constant defaults through reflection and seed each draw/compute block before the existing engine/custom writes. Uniforms remain writable through their normal suppliers; absent initializers remain zero.

Naga validates/folds internal initializer mirrors at the authored source location. Typed serialization uses the actual member layout, including array and matrix padding. Linked declarations compare values independently of their runtime supplier, so conflicting values are rejected and floating signed zeros compare equal without losing seed bits. Generated array declarations match the existing constructor dimension order.

Fixes #7811.

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 standard shader-pack compatibility, following Khronos GLSL 4.60 sections 4.1.9/4.1.11 (arrays/initializers), 4.3.5 (linked uniform initial values) and 5.4 (constructors). No vanilla Java behavior is changed.

Other projects' code

No new external implementation was copied. Read Horizon's existing vendored Naga 30.0.1 at f1d6576b, under its MIT license, to use its constant IR and reflected layout. The serializer and synthetic pack fixtures are original. The frame test literal adapts Horizon's own MIT test setup. For this change, no external converter, restricted mod or third-party shader-pack implementation was read or reused. Earlier separate private shader-pack research exists; this patch uses only the public sources and original fixtures described above.

Self-check

Full local python3 tools/pr_ready.py --base origin/main was safely deferred before acquiring the build lease; no local self-check pass/block is claimed. Equivalent broad checks passed on exact head abd747cc90ea29f07b66a3a1c9b7b5f56c48f881 in CI run 41538903402:

  • Public-tree and Python tooling tests.
  • Workspace formatting and Clippy for all targets, plus the client's no-default-features server build, with warnings denied.
  • Workspace library/binary/integration tests, the ignored content-root invocation, and workspace doc tests. This includes all 19 new shader tests and both renderer CPU tests.

The launcher's scope check passed; its build/lint/tests were skipped because the launcher was unaffected. Parity jobs were skipped and no vanilla harness execution is claimed. The earlier head failed a test-only manual_checked_ops lint; the correction uses checked_div for the independent expected-offset helper and passed the exact-head checks above.

Separate strict local validation passed all 6 real Vulkan GPU tests with no skips, using production and renderer regression source whose captured hashes are unchanged by the test-only lint correction. Nine readbacks cover 2,304 pixels. Source, test lists, executables and dependency hashes were captured while holding the shared build lease. This is fixture evidence, not a gameplay or all-pack claim.

Rendered diagnostics

Original asset-free fixtures use the real pack loader, renderer and RGBA8 readback. The public baseline on Arc A770/Mesa 26.2.4 Vulkan rendered the scalar default as [0,0,64,255] instead of [159,0,64,255] at all 256 pixels; the vector constructor was rejected. Its supplied-camera control passed. Raw and website-transformed original inputs had identical results.

Final original fixtures on Intel Arc A770 / Mesa 26.2.4 Vulkan pass all six GPU tests. Nine 16×16 readbacks (2,304 pixels) match independent expected values within one RGBA8 step: scalar [159,0,64,255], constructor vector/compute [32,96,159,255], camera override [64,128,191,255], independent replacement [223,0,64,255], retained original default and two typed/provider frames. The strict adapter/count guards were enabled; none skipped.

The controls cover typed scalar/vector/matrix/array bytes, high unsigned bits, linked-stage consistency, malformed/default diagnostics, same-path source replacement, supplied values across frames, and independent draw/compute programs. Existing bool-composite/matCx2 and unsupported constant-folding limits remain frontend diagnostics. These fixtures do not establish gameplay or all-pack visual parity.

🤖 Generated with Codex


🔄 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/7842 **Author:** [@gigamans442](https://github.com/gigamans442) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-uniform-defaults-20261102` --- ### 📝 Commits (2) - [`2bd142c`](https://github.com/horizon-rust/horizon/commit/2bd142c7fde906dcecf8e32972f8d46b3aade913) Shader packs: preserve constant uniform initializer defaults - [`abd747c`](https://github.com/horizon-rust/horizon/commit/abd747cc90ea29f07b66a3a1c9b7b5f56c48f881) Use checked division in uniform-layout test expectations ### 📊 Changes **8 files changed** (+2149 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+49 -30) ➕ `crates/horizon-client-render/src/gfx/pack_post/tests/uniform_defaults.rs` (+124 -0) ➕ `crates/horizon-client-render/src/gfx/pack_post/tests/uniform_defaults_gpu.rs` (+530 -0) ➕ `crates/horizon-shaders/src/translate/initializers.rs` (+226 -0) 📝 `crates/horizon-shaders/src/translate/mod.rs` (+75 -6) 📝 `crates/horizon-shaders/src/translate/scan.rs` (+129 -9) ➕ `crates/horizon-shaders/tests/uniform_defaults_additional.rs` (+389 -0) ➕ `crates/horizon-shaders/tests/uniform_defaults_contract.rs` (+627 -0) </details> ### 📄 Description > 🤖 Opened by gigamans442's AI agent (Codex, gpt-6.1-sol), not by gigamans442 personally. ## What and why A pack's `uniform float gain=0.625;` currently renders as zero, while commas in a vector constructor can make the whole program fail to translate. Keep validated constant defaults through reflection and seed each draw/compute block before the existing engine/custom writes. Uniforms remain writable through their normal suppliers; absent initializers remain zero. Naga validates/folds internal initializer mirrors at the authored source location. Typed serialization uses the actual member layout, including array and matrix padding. Linked declarations compare values independently of their runtime supplier, so conflicting values are rejected and floating signed zeros compare equal without losing seed bits. Generated array declarations match the existing constructor dimension order. Fixes #7811. ## 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 standard shader-pack compatibility, following [Khronos GLSL 4.60](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf) sections 4.1.9/4.1.11 (arrays/initializers), 4.3.5 (linked uniform initial values) and 5.4 (constructors). No vanilla Java behavior is changed. ## Other projects' code No new external implementation was copied. Read Horizon's existing vendored [Naga 30.0.1 at f1d6576b](https://github.com/horizon-rust/horizon/tree/f1d6576b338e050908aa630016311129c7161d2d/third_party/naga), under its [MIT license](https://github.com/horizon-rust/horizon/blob/f1d6576b338e050908aa630016311129c7161d2d/third_party/naga/LICENSE.MIT), to use its constant IR and reflected layout. The serializer and synthetic pack fixtures are original. The frame test literal adapts Horizon's own MIT test setup. For this change, no external converter, restricted mod or third-party shader-pack implementation was read or reused. Earlier separate private shader-pack research exists; this patch uses only the public sources and original fixtures described above. ## Self-check Full local `python3 tools/pr_ready.py --base origin/main` was safely deferred before acquiring the build lease; no local self-check pass/block is claimed. Equivalent broad checks passed on exact head `abd747cc90ea29f07b66a3a1c9b7b5f56c48f881` in [CI run 41538903402](https://github.com/horizon-rust/horizon/actions/runs/41538903402): - Public-tree and Python tooling tests. - Workspace formatting and Clippy for all targets, plus the client's no-default-features server build, with warnings denied. - Workspace library/binary/integration tests, the ignored content-root invocation, and workspace doc tests. This includes all 19 new shader tests and both renderer CPU tests. The launcher's scope check passed; its build/lint/tests were skipped because the launcher was unaffected. Parity jobs were skipped and no vanilla harness execution is claimed. The earlier head failed a test-only `manual_checked_ops` lint; the correction uses `checked_div` for the independent expected-offset helper and passed the exact-head checks above. Separate strict local validation passed all 6 real Vulkan GPU tests with no skips, using production and renderer regression source whose captured hashes are unchanged by the test-only lint correction. Nine readbacks cover 2,304 pixels. Source, test lists, executables and dependency hashes were captured while holding the shared build lease. This is fixture evidence, not a gameplay or all-pack claim. ## Rendered diagnostics Original asset-free fixtures use the real pack loader, renderer and RGBA8 readback. The public baseline on Arc A770/Mesa 26.2.4 Vulkan rendered the scalar default as `[0,0,64,255]` instead of `[159,0,64,255]` at all 256 pixels; the vector constructor was rejected. Its supplied-camera control passed. Raw and website-transformed original inputs had identical results. Final original fixtures on Intel Arc A770 / Mesa 26.2.4 Vulkan pass all six GPU tests. Nine 16×16 readbacks (2,304 pixels) match independent expected values within one RGBA8 step: scalar `[159,0,64,255]`, constructor vector/compute `[32,96,159,255]`, camera override `[64,128,191,255]`, independent replacement `[223,0,64,255]`, retained original default and two typed/provider frames. The strict adapter/count guards were enabled; none skipped. The controls cover typed scalar/vector/matrix/array bytes, high unsigned bits, linked-stage consistency, malformed/default diagnostics, same-path source replacement, supplied values across frames, and independent draw/compute programs. Existing bool-composite/matCx2 and unsupported constant-folding limits remain frontend diagnostics. These fixtures do not establish gameplay or all-pack visual parity. 🤖 Generated with [Codex](https://openai.com/codex/) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7857
No description provided.