[PR #2592] [CLOSED] Renderer: a headless constructor and frame readback #4455

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2592
Author: @Kydaix
Created: 10/27/2026
Status: ❌ Closed

Base: main ← Head: headless-capture


📝 Commits (10+)

  • cfd2dc8 HDR: present HDR10 (PQ) where the surface offers it, scRGB otherwise
  • cf6b91a Items: draw the enchantment glint from enchanted_glint_item
  • a1761dc Lightning: move the bolt offset to vertex attribute 7
  • 1c6c6c0 Items: sample the glint from its own repeating texture
  • 43e4075 Items: animate the armour glint from enchanted_glint_armor
  • 66607c9 Items: glint enchanted armour on armour stands
  • e38e25c Renderer: a headless constructor and frame readback
  • 1a05204 Merge commit 'refs/cg20/pr2296' into HEAD
  • 34dd3de Thread #2296's glint textures through the headless renderer
  • c7de637 Merge #2292 (HDR output)

📊 Changes

49 files changed (+1039 additions, -149 deletions)

View changed files

📝 crates/horizon-client/src/block_entity_render.rs (+7 -0)
📝 crates/horizon-client/src/breaking.rs (+2 -0)
📝 crates/horizon-client/src/clouds.rs (+2 -0)
📝 crates/horizon-client/src/entity.wgsl (+49 -13)
📝 crates/horizon-client/src/entity_culling.rs (+2 -0)
📝 crates/horizon-client/src/fire_render.rs (+2 -0)
📝 crates/horizon-client/src/game.rs (+21 -0)
📝 crates/horizon-client/src/game/armor_stands.rs (+17 -2)
📝 crates/horizon-client/src/game/creatures.rs (+4 -0)
📝 crates/horizon-client/src/game/dragon.rs (+6 -0)
📝 crates/horizon-client/src/game/end.rs (+4 -0)
📝 crates/horizon-client/src/game/fishing.rs (+2 -0)
📝 crates/horizon-client/src/game/frames.rs (+2 -0)
📝 crates/horizon-client/src/game/item_draw.rs (+26 -0)
📝 crates/horizon-client/src/game/leads.rs (+2 -0)
📝 crates/horizon-client/src/game/maps.rs (+6 -0)
📝 crates/horizon-client/src/game/minecarts.rs (+1 -0)
📝 crates/horizon-client/src/game/mob_blocks.rs (+2 -0)
📝 crates/horizon-client/src/game/names.rs (+1 -0)
📝 crates/horizon-client/src/game/paintings.rs (+2 -0)

...and 29 more files

📄 Description

What and why

Adds Renderer::new_headless, a renderer with no window that draws into the offscreen target --offscreen already uses, and an opt-in readback: with capture_frames set, each rendered frame is copied to a reusable mappable buffer, and read_capture returns the oldest one as tightly packed rows, waiting only for that frame's submission (two frames stay in flight). pending_captures and capture_format complete the API. window becomes an Option; the windowed constructor and new_headless share one open, and recreate_surface reports an error instead of creating a surface when there is no window.

Nothing changes for the game: no copy is made unless capture_frames is set, and screenshots go through the same copy helper as before (copy_frame_into).

This lets programs draw with Horizon's renderer without a display server: reference-image tests, map or skin renderers, video tools. Horizon Studio uses it to render Minecraft scenes to video, and today carries this as a patch on v0.2.64.

gfx/headless_tests.rs draws two 64×64 frames from synthetic inputs (no game files) and checks that both come back in order, at the right size, in the clear colour, and that the queue is then empty. Like the other GPU tests, it is #[ignore] without an adapter.

Tested on Windows (Vulkan, NVIDIA RTX 5070) and on Linux without a display or a GPU (GitHub's ubuntu-24.04, Mesa's software Vulkan): Studio renders 540×960 frames there at 0.069 s each.

Vanilla reference

Horizon-only: vanilla has no windowless renderer.

Self-check

pr_ready (tools/pr_ready.py --quick on Windows 11, against origin/main at a727f617f)

Check Result
Scope ✅ 2 files, +328 −26
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 320 run, failures=16, errors=6 (see below)
rustfmt ✅
clippy ✅
tests: horizon-client ❌ 1177 passed, 2 failed (see below)
doc tests ✅
Parity ➖ not run (--quick)
Label skip-release: players see no change

The failures are this machine's, not the change's: the Python tests that run the git hooks call python3, which on this Windows box is only the Microsoft Store alias, and save::tests::session_lock_is_exclusive and crash::tests::stacks_start_at_the_panicking_frame fail the same way on an untouched origin/main here. gfx::headless_tests passes with --ignored on the RTX 5070. The branch was then rebased on 4be5c8eb, which does not touch gfx.rs or gfx/; fmt, clippy and the gfx:: tests (96 passed, run one at a time, plus headless_tests with --ignored) were rerun after the rebase.

🤖 Generated with Claude Code

https://claude.ai/code/session_013MP8b7giHfBB8Hcs4w81Qe


🔄 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/2592 **Author:** [@Kydaix](https://github.com/Kydaix) **Created:** 10/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `headless-capture` --- ### 📝 Commits (10+) - [`cfd2dc8`](https://github.com/horizon-rust/horizon/commit/cfd2dc83922ce606c518b085443d634f3931b23e) HDR: present HDR10 (PQ) where the surface offers it, scRGB otherwise - [`cf6b91a`](https://github.com/horizon-rust/horizon/commit/cf6b91a710eb52fa1b856d11da197514694eb243) Items: draw the enchantment glint from enchanted_glint_item - [`a1761dc`](https://github.com/horizon-rust/horizon/commit/a1761dcb658b8ac5401251320e3d18237067e42d) Lightning: move the bolt offset to vertex attribute 7 - [`1c6c6c0`](https://github.com/horizon-rust/horizon/commit/1c6c6c0b97ae6144bf476d76962d744c6d29a815) Items: sample the glint from its own repeating texture - [`43e4075`](https://github.com/horizon-rust/horizon/commit/43e407562fdfe02f05986b7721b638a033ad092a) Items: animate the armour glint from enchanted_glint_armor - [`66607c9`](https://github.com/horizon-rust/horizon/commit/66607c9eab9a313542e2a149446519b15d55a68f) Items: glint enchanted armour on armour stands - [`e38e25c`](https://github.com/horizon-rust/horizon/commit/e38e25c1a824105793e1e1ed33fc2896b48ea52e) Renderer: a headless constructor and frame readback - [`1a05204`](https://github.com/horizon-rust/horizon/commit/1a052041dc4765a36216cf452471f65ec48c3481) Merge commit 'refs/cg20/pr2296' into HEAD - [`34dd3de`](https://github.com/horizon-rust/horizon/commit/34dd3de8f47e7fbeff3a62977ebfbb1416c76301) Thread #2296's glint textures through the headless renderer - [`c7de637`](https://github.com/horizon-rust/horizon/commit/c7de637f0f751947c755219176e8581c2ac15c9e) Merge #2292 (HDR output) ### 📊 Changes **49 files changed** (+1039 additions, -149 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_render.rs` (+7 -0) 📝 `crates/horizon-client/src/breaking.rs` (+2 -0) 📝 `crates/horizon-client/src/clouds.rs` (+2 -0) 📝 `crates/horizon-client/src/entity.wgsl` (+49 -13) 📝 `crates/horizon-client/src/entity_culling.rs` (+2 -0) 📝 `crates/horizon-client/src/fire_render.rs` (+2 -0) 📝 `crates/horizon-client/src/game.rs` (+21 -0) 📝 `crates/horizon-client/src/game/armor_stands.rs` (+17 -2) 📝 `crates/horizon-client/src/game/creatures.rs` (+4 -0) 📝 `crates/horizon-client/src/game/dragon.rs` (+6 -0) 📝 `crates/horizon-client/src/game/end.rs` (+4 -0) 📝 `crates/horizon-client/src/game/fishing.rs` (+2 -0) 📝 `crates/horizon-client/src/game/frames.rs` (+2 -0) 📝 `crates/horizon-client/src/game/item_draw.rs` (+26 -0) 📝 `crates/horizon-client/src/game/leads.rs` (+2 -0) 📝 `crates/horizon-client/src/game/maps.rs` (+6 -0) 📝 `crates/horizon-client/src/game/minecarts.rs` (+1 -0) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+2 -0) 📝 `crates/horizon-client/src/game/names.rs` (+1 -0) 📝 `crates/horizon-client/src/game/paintings.rs` (+2 -0) _...and 29 more files_ </details> ### 📄 Description ## What and why Adds `Renderer::new_headless`, a renderer with no window that draws into the offscreen target `--offscreen` already uses, and an opt-in readback: with `capture_frames` set, each rendered frame is copied to a reusable mappable buffer, and `read_capture` returns the oldest one as tightly packed rows, waiting only for that frame's submission (two frames stay in flight). `pending_captures` and `capture_format` complete the API. `window` becomes an `Option`; the windowed constructor and `new_headless` share one `open`, and `recreate_surface` reports an error instead of creating a surface when there is no window. Nothing changes for the game: no copy is made unless `capture_frames` is set, and screenshots go through the same copy helper as before (`copy_frame_into`). This lets programs draw with Horizon's renderer without a display server: reference-image tests, map or skin renderers, video tools. [Horizon Studio](https://github.com/Kydaix/Horizon-Clips) uses it to render Minecraft scenes to video, and today carries this as a patch on v0.2.64. `gfx/headless_tests.rs` draws two 64×64 frames from synthetic inputs (no game files) and checks that both come back in order, at the right size, in the clear colour, and that the queue is then empty. Like the other GPU tests, it is `#[ignore]` without an adapter. Tested on Windows (Vulkan, NVIDIA RTX 5070) and on Linux without a display or a GPU (GitHub's ubuntu-24.04, Mesa's software Vulkan): Studio renders 540×960 frames there at 0.069 s each. ## Vanilla reference Horizon-only: vanilla has no windowless renderer. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on Windows 11, against origin/main at a727f617f) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +328 −26 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 320 run, failures=16, errors=6 (see below) | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client | ❌ 1177 passed, 2 failed (see below) | | doc tests | ✅ | | Parity | ➖ not run (--quick) | | Label | `skip-release`: players see no change | The failures are this machine's, not the change's: the Python tests that run the git hooks call `python3`, which on this Windows box is only the Microsoft Store alias, and `save::tests::session_lock_is_exclusive` and `crash::tests::stacks_start_at_the_panicking_frame` fail the same way on an untouched `origin/main` here. `gfx::headless_tests` passes with `--ignored` on the RTX 5070. The branch was then rebased on 4be5c8eb, which does not touch `gfx.rs` or `gfx/`; fmt, clippy and the `gfx::` tests (96 passed, run one at a time, plus `headless_tests` with `--ignored`) were rerun after the rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013MP8b7giHfBB8Hcs4w81Qe --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:17:17 +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#4455
No description provided.