[PR #728] [MERGED] Cache closed chest geometry in large block-entity fields #2763

Closed
opened 2026-11-02 15:58:51 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/728
Author: @Online5277
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @ludovic111

Base: main ← Head: perf/block-entity-fields


📝 Commits (1)

  • d35f892 Cache closed chest geometry for block-entity fields (#717)

📊 Changes

2 files changed (+131 additions, -7 deletions)

View changed files

📝 crates/horizon-client/src/block_entity_render.rs (+128 -7)
📝 crates/horizon-client/src/game.rs (+3 -0)

📄 Description

Closed chests rebuilt their part transforms, face normals, diffuse colors and UVs every frame. Cache 24 local meshes (three chest parts × four facings × two lighting modes), then apply current position, packed light and atlas UVs. Open lids keep the existing model renderer; double-chest openness/light combining runs before cache selection. Breaking and minecart transforms retain their existing paths.

Skip block states without a dynamic renderer before name/frustum work; barrels remain terrain meshes. The shared section list used by tickers and other effects is preserved. Addresses #717.

Validation: extended the existing prepared-model regression to compare cached/original vertices across chest parts, facings, dimension lighting, non-unit atlas UVs, current light and open-lid fallback; existing breaking checks pass. Fast native client build, all-target client Clippy with warnings denied, formatting and whitespace checks pass. Native flat chest/barrel field captures inspected. In the final 64×64 chest field (two steady three-second samples/build), CPU frame time averages 4.49 → 3.05 ms (32% lower), with preparation 2.36 → 1.00 ms. Barrel/stone controls remain about 0.43/0.39 ms. These offscreen, uncapped Vulkan results are local measurements, not M4 FPS predictions.

CPU-only geometry benchmark on this Linux machine: 4,096 closed chests, seven alternating sample pairs, 30 frames/sample: original 1.937 ms → cached 0.509 ms (74% less geometry CPU time). The original direct path omits world distance checks, making this a conservative comparison. This measures geometry generation, not total frame time; some native runs had renderer stalls also present in the unchanged baseline.

Draft for the reported M4 Pro/Metal scene: compare F3 CPU/frame times over the same field, and check single/double chest opening, lighting changes, resource reload and breaking cracks. M4 performance and broader vanilla parity are unverified.


🔄 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/728 **Author:** [@Online5277](https://github.com/Online5277) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/block-entity-fields` --- ### 📝 Commits (1) - [`d35f892`](https://github.com/horizon-rust/horizon/commit/d35f892b7f092ff2b5a71a5d9fcd89360bb70ebd) Cache closed chest geometry for block-entity fields (#717) ### 📊 Changes **2 files changed** (+131 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/block_entity_render.rs` (+128 -7) 📝 `crates/horizon-client/src/game.rs` (+3 -0) </details> ### 📄 Description Closed chests rebuilt their part transforms, face normals, diffuse colors and UVs every frame. Cache 24 local meshes (three chest parts × four facings × two lighting modes), then apply current position, packed light and atlas UVs. Open lids keep the existing model renderer; double-chest openness/light combining runs before cache selection. Breaking and minecart transforms retain their existing paths. Skip block states without a dynamic renderer before name/frustum work; barrels remain terrain meshes. The shared section list used by tickers and other effects is preserved. Addresses #717. Validation: extended the existing prepared-model regression to compare cached/original vertices across chest parts, facings, dimension lighting, non-unit atlas UVs, current light and open-lid fallback; existing breaking checks pass. Fast native client build, all-target client Clippy with warnings denied, formatting and whitespace checks pass. Native flat chest/barrel field captures inspected. In the final 64×64 chest field (two steady three-second samples/build), CPU frame time averages 4.49 → 3.05 ms (32% lower), with preparation 2.36 → 1.00 ms. Barrel/stone controls remain about 0.43/0.39 ms. These offscreen, uncapped Vulkan results are local measurements, not M4 FPS predictions. CPU-only geometry benchmark on this Linux machine: 4,096 closed chests, seven alternating sample pairs, 30 frames/sample: original 1.937 ms → cached 0.509 ms (74% less geometry CPU time). The original direct path omits world distance checks, making this a conservative comparison. This measures geometry generation, not total frame time; some native runs had renderer stalls also present in the unchanged baseline. Draft for the reported M4 Pro/Metal scene: compare F3 CPU/frame times over the same field, and check single/double chest opening, lighting changes, resource reload and breaking cracks. M4 performance and broader vanilla parity are unverified. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:58:51 +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#2763
No description provided.