[PR #7911] Shader packs: size arrays from brace initializers #7894

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

📋 Pull Request Information

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

Base: main ← Head: fix/glsl-audit-gaps-20261102


📝 Commits (2)

  • 05b7a96 fix(shaders): size brace-initialized arrays
  • a091fdc fix(shaders): preserve inferred multidimensional array order

📊 Changes

2 files changed (+172 additions, -12 deletions)

View changed files

📝 crates/horizon-shaders/src/translate/rewrite.rs (+32 -12)
➕ crates/horizon-shaders/tests/array_initializer_lists.rs (+140 -0)

📄 Description

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

What and why

Fixes #7895.

const int values[] = {2, 5, 8}; const int count = values.length(); is valid GLSL, but the standard-pack translator leaves the array dynamically sized and rejects the length expression. The same program with an explicit size or an array constructor already translates.

Extend existing array-size inference to brace initializers. Count only top-level aggregate elements and allow a trailing comma, preserving nested vectors/arrays, independent comma declarators and unsized runtime storage arrays.

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-only standard shader-pack compatibility. GLSL 4.40 §§4.1.9 and 4.1.11 determine an unsized array's size from the initializer and make the resulting length a constant expression.

Other projects' code

Implementation and regression shaders are original, based on MIT Horizon and the public GLSL specification. The compatibility audit cross-referenced Revelation at d591139 (project Apache-2.0), including small declaration/diagnostic context in its credited text helper. No shader-pack algorithm, helper implementation, asset or data was copied or adapted. This is not a claim that no external source was read.

Self-check

Original controls on public main 31f83499: 2 passed, 1 failed. The unsized brace-array program fails with the reported dynamic-array diagnostic; explicit-size brace and unsized-constructor controls each pass Naga validation and SPIR-V emission. glslangValidator 16.6.0 accepts the original brace program.

Candidate focused execution and required broader checks are pending. This draft requests no final review yet. No GPU rendering, named-pack visual parity or complete Revelation repair is claimed.

🤖 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/7911 **Author:** [@gigamans442](https://github.com/gigamans442) **Created:** 11/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/glsl-audit-gaps-20261102` --- ### 📝 Commits (2) - [`05b7a96`](https://github.com/horizon-rust/horizon/commit/05b7a9625b3707b408265de2a15593c4e07aef09) fix(shaders): size brace-initialized arrays - [`a091fdc`](https://github.com/horizon-rust/horizon/commit/a091fdc7cd2716815e30ededd8a4dc0248640f4b) fix(shaders): preserve inferred multidimensional array order ### 📊 Changes **2 files changed** (+172 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-shaders/src/translate/rewrite.rs` (+32 -12) ➕ `crates/horizon-shaders/tests/array_initializer_lists.rs` (+140 -0) </details> ### 📄 Description > 🤖 Opened by gigamans442's AI agent (Codex, GPT-6.1 Sol), not by gigamans442 personally. ## What and why Fixes #7895. `const int values[] = {2, 5, 8}; const int count = values.length();` is valid GLSL, but the standard-pack translator leaves the array dynamically sized and rejects the length expression. The same program with an explicit size or an array constructor already translates. Extend existing array-size inference to brace initializers. Count only top-level aggregate elements and allow a trailing comma, preserving nested vectors/arrays, independent comma declarators and unsized runtime storage arrays. ## 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-only standard shader-pack compatibility. [GLSL 4.40 §§4.1.9 and 4.1.11](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.40.pdf) determine an unsized array's size from the initializer and make the resulting length a constant expression. ## Other projects' code Implementation and regression shaders are original, based on MIT Horizon and the public GLSL specification. The compatibility audit cross-referenced [Revelation at d591139](https://github.com/HaringPro/Revelation/tree/d5911393856d9dd97375b46a1a088e6b8fddd755) (project Apache-2.0), including small declaration/diagnostic context in its credited text helper. No shader-pack algorithm, helper implementation, asset or data was copied or adapted. This is not a claim that no external source was read. ## Self-check Original controls on public main `31f83499`: **2 passed, 1 failed**. The unsized brace-array program fails with the reported dynamic-array diagnostic; explicit-size brace and unsized-constructor controls each pass Naga validation and SPIR-V emission. glslangValidator 16.6.0 accepts the original brace program. Candidate focused execution and required broader checks are pending. This draft requests no final review yet. No GPU rendering, named-pack visual parity or complete Revelation repair is claimed. 🤖 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#7894
No description provided.