[PR #3737] [CLOSED] Shader packs: Iris compute, images, buffers and geometry stages; Photon and Rethinking Voxels run #5182

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3737
Author: @PzmuV1517
Created: 10/29/2026
Status: ❌ Closed

Base: main ← Head: pr/shader-packs


📝 Commits (10+)

  • 5e8c967 Shader packs: macro calls whose arguments span lines
  • 72f3c8c Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps
  • efecaa1 Shader packs: a continued property value stops where its branch does
  • 2ff45ca Shader packs: custom textures, and what Photon needed to render in game
  • 7bc9ed6 Shader packs: compute programs, buffer sizes, options in shaders.properties, the pack's own sky
  • 4820367 Shader packs: matrix elements in custom uniforms are m.column.row
  • e87a47c Shader packs: the view bob is in gbufferModelView, not gbufferProjection
  • ab08b03 Shader packs: IS_IRIS and Iris feature flags, sized array types in global initializers
  • 05c2e05 Shader packs: storage buffers, custom images and atomics
  • 341c408 Shader packs: compute-only programs

📊 Changes

30 files changed (+5179 additions, -286 deletions)

View changed files

📝 Cargo.lock (+5 -4)
📝 Cargo.toml (+5 -0)
📝 crates/horizon-client-render/Cargo.toml (+1 -0)
📝 crates/horizon-client-render/src/gfx.rs (+106 -15)
📝 crates/horizon-client-render/src/gfx/flat.rs (+17 -0)
📝 crates/horizon-client-render/src/gfx/pack_atlas.rs (+17 -0)
📝 crates/horizon-client-render/src/gfx/pack_hand.rs (+4 -5)
➕ crates/horizon-client-render/src/gfx/pack_images.rs (+364 -0)
📝 crates/horizon-client-render/src/gfx/pack_post.rs (+1107 -137)
➕ crates/horizon-client-render/src/gfx/pack_textures.rs (+229 -0)
📝 crates/horizon-client-render/src/gfx/pack_uniforms.rs (+45 -7)
📝 crates/horizon-client/src/game/shader_packs.rs (+10 -2)
📝 crates/horizon-shaders/Cargo.toml (+6 -0)
📝 crates/horizon-shaders/src/config.rs (+4 -0)
📝 crates/horizon-shaders/src/custom.rs (+6 -5)
📝 crates/horizon-shaders/src/lib.rs (+11 -5)
📝 crates/horizon-shaders/src/macros.rs (+45 -0)
📝 crates/horizon-shaders/src/options.rs (+68 -22)
📝 crates/horizon-shaders/src/pack.rs (+2 -2)
📝 crates/horizon-shaders/src/post.rs (+420 -22)

...and 10 more files

📄 Description

What and why

Shader packs that need Iris features now load and render: Photon (88 programs translate, up from 45; about 50 fps where it ran at 8) and Rethinking Voxels (ray traced coloured light through compute passes, custom images, storage buffers and a geometry stage that voxelizes the world in the shadow pass). Everything is generic: nothing in here checks for a pack by name.

This is one large pull request on purpose: the pieces depend on each other and I wanted them reviewed together. The commits are split by topic and each builds on its own, so they read well one at a time.

Translation (horizon-shaders)

  • Macro calls whose arguments span lines; a continued property value stops where its #if branch does; pack options are visible in shaders.properties and in program.*.enabled.
  • Struct varyings, Vulkan type names used as identifiers, outputs narrower than vec4, inverse(), alphaTestRef, gl_VertexID and gl_InstanceID, global initializers that are not constant, sized array types in initializers.
  • IS_IRIS and iris.features.required/optional (IRIS_FEATURE_*); subgroup macros when the GPU has subgroups.
  • Compute programs (.csh, _a to _z, workGroups, workGroupsRender), compute only programs, shadowcomp.
  • Storage buffers (bufferObject.N), custom images (image.*), colorimgN, image and buffer atomics, atomics on a component of a shared vector.
  • Custom textures (texture.<stage>.<name>: PNG, raw 1D/2D/3D, .mcmeta), size.buffer.
  • shadow.culling (true, false, reversed) with voxelDistance, and the default alpha test in the shadow pass.
  • Geometry stages for terrain's shadow, run in the vertex stage over a flat index buffer; their image and buffer writes happen once per triangle.
  • Compute programs see the order their packs were written for: an image a program loads before it stores (no atomics, not coherent or volatile) is loaded from a copy taken before the dispatch, and a barrier follows a statement of main that applies atomics to shared memory. GL leaves both undefined; Rethinking Voxels' light lists changed from frame to frame on Apple GPUs without it.

Renderer (horizon-client-render)

  • New uniforms: cameraPositionInt/Fract and their previous forms, eyePosition, relativeEyePosition, playerLookVector, playerBodyVector, firstPersonCamera.
  • Matrix elements in custom uniforms are m.column.row (the sky turned with the camera), and the view bob is in gbufferModelView, not the projection (the sky and lighting bobbed while walking).
  • The pack's sky clear colour (a square moon), trailing unused targets dropped, wgpu internal errors in a pass caught as notes.
  • Textures used with atomics are made with STORAGE_ATOMIC, which Metal needs or it drops them.

naga
naga 30.0.1's GLSL frontend misses what packs use, so the root Cargo.toml pins a fork through [patch.crates-io] (https://github.com/PzmuV1517/wgpu, branch horizon/naga-30-glsl): std430 for plain structs, vecN(bool) and vector % scalar splats, textureGather and its offset and shadow forms, texture() at level 0 outside fragment shaders, pointers as out arguments, field selection on a matrix column, subgroups and memory barriers, barrier(), constant shifts that wrap, and atomics on buffers, shared memory and images. I plan to send these upstream to wgpu; the pin can go once a release has them.

Related: #3646 contains panics from the driver's shader compiler. This branch catches wgpu's validation and internal error scopes instead; the two fit together.

Everything was written from public documentation and by running packs as black boxes; no Iris, OptiFine or Sodium source was read.

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 45ecf7bef, 4 min 10 s)

Check Result
Scope ⚠️ 30 files, +4775 −284; 5000 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ✅ 416 passed (20 s)
rustfmt ✅ (4 s)
clippy ✅ (1 s)
tests: workspace ✅ 2469 passed (2 min 54 s)
doc tests ✅ 2 passed (6 s)
content root tests ✅ 5 passed (40 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅
launcher clippy ✅ (1 s)
launcher tests ✅ 272 passed (3 s)
Parity ➖ 351 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 339 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Screenshots

I will attach Photon and Rethinking Voxels screenshots (day and night) in a comment.


🔄 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/3737 **Author:** [@PzmuV1517](https://github.com/PzmuV1517) **Created:** 10/29/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/shader-packs` --- ### 📝 Commits (10+) - [`5e8c967`](https://github.com/horizon-rust/horizon/commit/5e8c967ce59bb0c36925e6960db9e0a68fb65ee5) Shader packs: macro calls whose arguments span lines - [`72f3c8c`](https://github.com/horizon-rust/horizon/commit/72f3c8cc02639870e8d0247920038ea1e0b45dd7) Shader packs: struct varyings, Vulkan type names as identifiers, naga's GLSL gaps - [`efecaa1`](https://github.com/horizon-rust/horizon/commit/efecaa19bcc0be8907ba8ccc637bdc5caf6f92cc) Shader packs: a continued property value stops where its branch does - [`2ff45ca`](https://github.com/horizon-rust/horizon/commit/2ff45caf20a2ca5fd49c4d865a55ecce3e2ee35f) Shader packs: custom textures, and what Photon needed to render in game - [`7bc9ed6`](https://github.com/horizon-rust/horizon/commit/7bc9ed6ff6a900d93d82475449ace929618e8b7d) Shader packs: compute programs, buffer sizes, options in shaders.properties, the pack's own sky - [`4820367`](https://github.com/horizon-rust/horizon/commit/482036775d5036aae72a270ba18824df21a3a44a) Shader packs: matrix elements in custom uniforms are m.column.row - [`e87a47c`](https://github.com/horizon-rust/horizon/commit/e87a47c6aacc2075497cbd0b0cb45799910af2d8) Shader packs: the view bob is in gbufferModelView, not gbufferProjection - [`ab08b03`](https://github.com/horizon-rust/horizon/commit/ab08b0365d0ada301c384ea478c8ac0b93185b4e) Shader packs: IS_IRIS and Iris feature flags, sized array types in global initializers - [`05c2e05`](https://github.com/horizon-rust/horizon/commit/05c2e059a45654bbed17873d89feb54b4949806d) Shader packs: storage buffers, custom images and atomics - [`341c408`](https://github.com/horizon-rust/horizon/commit/341c408e86c9a20b3315de2577df0b7b41e616af) Shader packs: compute-only programs ### 📊 Changes **30 files changed** (+5179 additions, -286 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+5 -4) 📝 `Cargo.toml` (+5 -0) 📝 `crates/horizon-client-render/Cargo.toml` (+1 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+106 -15) 📝 `crates/horizon-client-render/src/gfx/flat.rs` (+17 -0) 📝 `crates/horizon-client-render/src/gfx/pack_atlas.rs` (+17 -0) 📝 `crates/horizon-client-render/src/gfx/pack_hand.rs` (+4 -5) ➕ `crates/horizon-client-render/src/gfx/pack_images.rs` (+364 -0) 📝 `crates/horizon-client-render/src/gfx/pack_post.rs` (+1107 -137) ➕ `crates/horizon-client-render/src/gfx/pack_textures.rs` (+229 -0) 📝 `crates/horizon-client-render/src/gfx/pack_uniforms.rs` (+45 -7) 📝 `crates/horizon-client/src/game/shader_packs.rs` (+10 -2) 📝 `crates/horizon-shaders/Cargo.toml` (+6 -0) 📝 `crates/horizon-shaders/src/config.rs` (+4 -0) 📝 `crates/horizon-shaders/src/custom.rs` (+6 -5) 📝 `crates/horizon-shaders/src/lib.rs` (+11 -5) 📝 `crates/horizon-shaders/src/macros.rs` (+45 -0) 📝 `crates/horizon-shaders/src/options.rs` (+68 -22) 📝 `crates/horizon-shaders/src/pack.rs` (+2 -2) 📝 `crates/horizon-shaders/src/post.rs` (+420 -22) _...and 10 more files_ </details> ### 📄 Description ## What and why Shader packs that need Iris features now load and render: Photon (88 programs translate, up from 45; about 50 fps where it ran at 8) and Rethinking Voxels (ray traced coloured light through compute passes, custom images, storage buffers and a geometry stage that voxelizes the world in the shadow pass). Everything is generic: nothing in here checks for a pack by name. This is one large pull request on purpose: the pieces depend on each other and I wanted them reviewed together. The commits are split by topic and each builds on its own, so they read well one at a time. **Translation (horizon-shaders)** - Macro calls whose arguments span lines; a continued property value stops where its `#if` branch does; pack options are visible in `shaders.properties` and in `program.*.enabled`. - Struct varyings, Vulkan type names used as identifiers, outputs narrower than vec4, `inverse()`, `alphaTestRef`, `gl_VertexID` and `gl_InstanceID`, global initializers that are not constant, sized array types in initializers. - `IS_IRIS` and `iris.features.required/optional` (`IRIS_FEATURE_*`); subgroup macros when the GPU has subgroups. - Compute programs (`.csh`, `_a` to `_z`, `workGroups`, `workGroupsRender`), compute only programs, shadowcomp. - Storage buffers (`bufferObject.N`), custom images (`image.*`), `colorimgN`, image and buffer atomics, atomics on a component of a shared vector. - Custom textures (`texture.<stage>.<name>`: PNG, raw 1D/2D/3D, `.mcmeta`), `size.buffer`. - `shadow.culling` (true, false, reversed) with `voxelDistance`, and the default alpha test in the shadow pass. - Geometry stages for terrain's shadow, run in the vertex stage over a flat index buffer; their image and buffer writes happen once per triangle. - Compute programs see the order their packs were written for: an image a program loads before it stores (no atomics, not `coherent` or `volatile`) is loaded from a copy taken before the dispatch, and a barrier follows a statement of `main` that applies atomics to shared memory. GL leaves both undefined; Rethinking Voxels' light lists changed from frame to frame on Apple GPUs without it. **Renderer (horizon-client-render)** - New uniforms: `cameraPositionInt/Fract` and their `previous` forms, `eyePosition`, `relativeEyePosition`, `playerLookVector`, `playerBodyVector`, `firstPersonCamera`. - Matrix elements in custom uniforms are `m.column.row` (the sky turned with the camera), and the view bob is in `gbufferModelView`, not the projection (the sky and lighting bobbed while walking). - The pack's sky clear colour (a square moon), trailing unused targets dropped, wgpu internal errors in a pass caught as notes. - Textures used with atomics are made with `STORAGE_ATOMIC`, which Metal needs or it drops them. **naga** naga 30.0.1's GLSL frontend misses what packs use, so the root `Cargo.toml` pins a fork through `[patch.crates-io]` (https://github.com/PzmuV1517/wgpu, branch `horizon/naga-30-glsl`): std430 for plain structs, `vecN(bool)` and `vector % scalar` splats, `textureGather` and its offset and shadow forms, `texture()` at level 0 outside fragment shaders, pointers as out arguments, field selection on a matrix column, subgroups and memory barriers, `barrier()`, constant shifts that wrap, and atomics on buffers, shared memory and images. I plan to send these upstream to wgpu; the pin can go once a release has them. Related: #3646 contains panics from the driver's shader compiler. This branch catches wgpu's validation and internal error scopes instead; the two fit together. Everything was written from public documentation and by running packs as black boxes; no Iris, OptiFine or Sodium source was read. ## 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 45ecf7bef, 4 min 10 s) | Check | Result | | --- | --- | | Scope | ⚠️ 30 files, +4775 −284; 5000 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ✅ 416 passed (20 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (1 s) | | tests: workspace | ✅ 2469 passed (2 min 54 s) | | doc tests | ✅ 2 passed (6 s) | | content root tests | ✅ 5 passed (40 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ | | launcher clippy | ✅ (1 s) | | launcher tests | ✅ 272 passed (3 s) | | Parity | ➖ 351 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 339 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | ## Screenshots I will attach Photon and Rethinking Voxels screenshots (day and night) in a comment. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:10:47 +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#5182
No description provided.