[PR #6033] [MERGED] Add asynchronous mode to entity occlusion culling #6616

Closed
opened 2026-11-03 06:23:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6033
Author: @elythepreciouscat
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: feat/async-entity-culling


📝 Commits (3)

  • f68f5de Entity culling: add asynchronous occlusion mode
  • 4a9fc00 Merge branch 'main' into feat/async-entity-culling
  • 5472e11 Fix graphics culling merge errors

📊 Changes

10 files changed (+706 additions, -43 deletions)

View changed files

📝 crates/horizon-client-render/src/graphics.rs (+62 -6)
📝 crates/horizon-client-render/src/graphics_ui.rs (+19 -13)
📝 crates/horizon-client/src/entity_culling.rs (+20 -4)
📝 crates/horizon-client/src/game.rs (+12 -2)
📝 crates/horizon-client/src/game/entity_culling.rs (+557 -17)
📝 docs/graphics.md (+3 -1)
➕ docs/media/entity-culling-async.png (+0 -0)
➕ docs/media/entity-culling-benchmark.md (+33 -0)
➕ docs/media/entity-culling-off.png (+0 -0)
➕ docs/media/entity-culling-sync.png (+0 -0)

📄 Description

🤖 Opened by elythepreciouscat's AI agent (Codex, GPT-6), not by elythepreciouscat personally.

What and why

Add an asynchronous option to the existing Entity Culling control under Advanced Graphics. Off remains the default, and the existing synchronous same-frame mode remains available.

The asynchronous mode batches and deduplicates completed entity-mesh bounds, then checks them on a dedicated worker using a bounded one-job queue. It reuses a result only when the camera and mesh bounds match exactly and the world/chunk snapshot and the blocks and rendered sections that proved occlusion still validate. If evidence is stale, incomplete, outside the snapshot or exceeds the query budget, the entity stays visible. Entity ticking and interaction are unchanged, and the existing eligibility restrictions still apply.

The worker uses compact sorted vectors and reusable query scratch instead of a hash set for per-frame query collection. The render thread submits available results without waiting for the occlusion work.

Fixes #5939

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
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only rendering option; Java 26.3 has no equivalent entity-occlusion mode to follow. Off remains the default, and synchronous culling remains available. This renderer-only feature does not change gameplay or entity simulation.

Other projects' code

No external project source code was read or copied.

Self-check

python3 tools/pr_ready.py --quick on omarchy, against origin/main at 71b1ed56f (15 min 33 s):

Check Result
Scope ⚠️ 10 files, +708 −44; 713 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 523 passed (57 s)
rustfmt ✅ (15 s)
clippy ✅ (1 min 34 s)
tests: horizon-client, horizon-client-render ✅ 2564 passed (12 min 15 s)
doc tests ✅ 0 passed (24 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 358 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 346 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The scope is over the guideline because the async worker, its conservative snapshot validation, UI mode and behavior tests need to land together; they do not form useful independent changes. The 358 parity harnesses are left for CI as directed by --quick.

Live benchmark

Built with cargo build --profile fast -p horizon-client, then ran through horizon-ctl on a 1366×768 fullscreen display at render distance 2, Immediate presentation, VSync off and a 260 FPS cap. Each mode has six 10-second samples across two mode orders (Off → Sync → Async, then Async → Sync → Off); the same seed-1234 scene was created for each pass and reused across its three modes.

The scene has 300 static armor stands behind a 33×31 stone wall 3.5 blocks from the camera, with a 1×4 opening. The camera stayed at the initial spawn X/Z, feet at Y=100, yaw 0 and pitch 0. The table reports the median across all six samples per mode.

Hardware: Intel Core i7-3770S (8 threads), Intel HD Graphics 4000 (IVB GT2), Intel Mesa 26.2.4-arch1.1, Vulkan, Linux/Hyprland Wayland, 1366×768 at 60 Hz.

Mode Median FPS Change vs Off 1% low FPS CPU avg (ms) P99 frame time
Off 83.59 baseline 60.48 8.66 14.99 ms
Sync 96.90 +15.9% 62.83 6.82 12.99 ms
Async 99.67 +19.2% 64.55 5.99 13.02 ms

This is a synthetic, static occlusion scene on one integrated GPU, so treat the result as workload-specific evidence, not a general FPS guarantee. GPU timestamp queries returned zero on this driver and are unavailable. The benchmark report contains all 18 individual samples and conditions.

Screenshots

Same camera and occlusion scene in each mode. The FPS overlay is the instantaneous value at capture time, not the median above.

Off Sync Async
Entity culling Off Entity culling Sync Entity culling Async

🤖 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/6033 **Author:** [@elythepreciouscat](https://github.com/elythepreciouscat) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/async-entity-culling` --- ### 📝 Commits (3) - [`f68f5de`](https://github.com/horizon-rust/horizon/commit/f68f5def32e36f985916ee56e4a67a8dbf18a4b1) Entity culling: add asynchronous occlusion mode - [`4a9fc00`](https://github.com/horizon-rust/horizon/commit/4a9fc00315a6e0834ccf92bca15d5a42c0fde4e2) Merge branch 'main' into feat/async-entity-culling - [`5472e11`](https://github.com/horizon-rust/horizon/commit/5472e113b23bf706afc89752632a83c0cc894d01) Fix graphics culling merge errors ### 📊 Changes **10 files changed** (+706 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/graphics.rs` (+62 -6) 📝 `crates/horizon-client-render/src/graphics_ui.rs` (+19 -13) 📝 `crates/horizon-client/src/entity_culling.rs` (+20 -4) 📝 `crates/horizon-client/src/game.rs` (+12 -2) 📝 `crates/horizon-client/src/game/entity_culling.rs` (+557 -17) 📝 `docs/graphics.md` (+3 -1) ➕ `docs/media/entity-culling-async.png` (+0 -0) ➕ `docs/media/entity-culling-benchmark.md` (+33 -0) ➕ `docs/media/entity-culling-off.png` (+0 -0) ➕ `docs/media/entity-culling-sync.png` (+0 -0) </details> ### 📄 Description > 🤖 Opened by elythepreciouscat's AI agent (Codex, GPT-6), not by elythepreciouscat personally. ## What and why Add an asynchronous option to the existing Entity Culling control under Advanced Graphics. Off remains the default, and the existing synchronous same-frame mode remains available. The asynchronous mode batches and deduplicates completed entity-mesh bounds, then checks them on a dedicated worker using a bounded one-job queue. It reuses a result only when the camera and mesh bounds match exactly and the world/chunk snapshot and the blocks and rendered sections that proved occlusion still validate. If evidence is stale, incomplete, outside the snapshot or exceeds the query budget, the entity stays visible. Entity ticking and interaction are unchanged, and the existing eligibility restrictions still apply. The worker uses compact sorted vectors and reusable query scratch instead of a hash set for per-frame query collection. The render thread submits available results without waiting for the occlusion work. Fixes #5939 ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only rendering option; Java 26.3 has no equivalent entity-occlusion mode to follow. Off remains the default, and synchronous culling remains available. This renderer-only feature does not change gameplay or entity simulation. ## Other projects' code No external project source code was read or copied. ## Self-check `python3 tools/pr_ready.py --quick` on omarchy, against `origin/main` at `71b1ed56f` (15 min 33 s): | Check | Result | | --- | --- | | Scope | ⚠️ 10 files, +708 −44; 713 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 523 passed (57 s) | | rustfmt | ✅ (15 s) | | clippy | ✅ (1 min 34 s) | | tests: horizon-client, horizon-client-render | ✅ 2564 passed (12 min 15 s) | | doc tests | ✅ 0 passed (24 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 358 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 346 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The scope is over the guideline because the async worker, its conservative snapshot validation, UI mode and behavior tests need to land together; they do not form useful independent changes. The 358 parity harnesses are left for CI as directed by `--quick`. ## Live benchmark Built with `cargo build --profile fast -p horizon-client`, then ran through `horizon-ctl` on a 1366×768 fullscreen display at render distance 2, Immediate presentation, VSync off and a 260 FPS cap. Each mode has six 10-second samples across two mode orders (Off → Sync → Async, then Async → Sync → Off); the same seed-1234 scene was created for each pass and reused across its three modes. The scene has 300 static armor stands behind a 33×31 stone wall 3.5 blocks from the camera, with a 1×4 opening. The camera stayed at the initial spawn X/Z, feet at Y=100, yaw 0 and pitch 0. The table reports the median across all six samples per mode. Hardware: Intel Core i7-3770S (8 threads), Intel HD Graphics 4000 (IVB GT2), Intel Mesa 26.2.4-arch1.1, Vulkan, Linux/Hyprland Wayland, 1366×768 at 60 Hz. | Mode | Median FPS | Change vs Off | 1% low FPS | CPU avg (ms) | P99 frame time | | --- | ---: | ---: | ---: | ---: | ---: | | Off | 83.59 | baseline | 60.48 | 8.66 | 14.99 ms | | Sync | 96.90 | +15.9% | 62.83 | 6.82 | 12.99 ms | | Async | 99.67 | +19.2% | 64.55 | 5.99 | 13.02 ms | This is a synthetic, static occlusion scene on one integrated GPU, so treat the result as workload-specific evidence, not a general FPS guarantee. GPU timestamp queries returned zero on this driver and are unavailable. [The benchmark report](https://github.com/elythepreciouscat/horizon/blob/feat/async-entity-culling/docs/media/entity-culling-benchmark.md) contains all 18 individual samples and conditions. ## Screenshots Same camera and occlusion scene in each mode. The FPS overlay is the instantaneous value at capture time, not the median above. | Off | Sync | Async | | --- | --- | --- | | ![Entity culling Off](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/async-entity-culling/docs/media/entity-culling-off.png) | ![Entity culling Sync](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/async-entity-culling/docs/media/entity-culling-sync.png) | ![Entity culling Async](https://raw.githubusercontent.com/elythepreciouscat/horizon/feat/async-entity-culling/docs/media/entity-culling-async.png) | 🤖 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>
bsakaguchi 2026-11-03 06:23:50 +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#6616
No description provided.