[PR #7215] [MERGED] Draw mobs' held items on the GPU skin path #7419

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

📋 Pull Request Information

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

Base: main ← Head: perf/held-items-gpu


📝 Commits (1)

  • 9598faa Draw mobs' held items on the GPU skin path

📊 Changes

7 files changed (+84 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+8 -2)
📝 crates/horizon-client/src/game/item_draw.rs (+26 -0)
📝 crates/horizon-client/src/game/mob_blocks.rs (+10 -1)
📝 crates/horizon-client/src/game/perspective.rs (+2 -2)
📝 crates/horizon-client/src/item_render.rs (+18 -5)
📝 tests/test_perf_bench.py (+1 -0)
📝 tools/stress_scenes.py (+19 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Before this PR, a mob's main- and off-hand items were posed and lit vertex by vertex on the CPU every frame. That happened even when the mob's body already went through the GPU skin path (#7056). In a crowd where every zombie, skeleton, vindicator or piglin holds something, the items were the frame's main CPU cost.

Now an item whose baked model fits the skin path joins the mob's skinned draw. It fits when it is opaque or cutout, with no glint, emission or translucent quads.

  • Draw. The item becomes one skin job with its hand pose.
  • Bounds. Its corners widen the mob's cull bounds, so body and items are culled together, and truncated together when the mob is culled.

These stay on the CPU, as before:

  • outlined or glowing mobs (outlines need the CPU vertices);
  • first-person hands;
  • items that don't fit the path.

Exactness

items_posed_on_the_gpu_draw_what_the_cpu_draws is the #7056 test, extended to every item state in the ground, both third-person hands, fixed and head contexts. On the real 26.3 assets:

  • 15514 states take the GPU path, and its vertices equal the CPU's byte for byte;
  • 1066 states stay on the CPU.

A/B: new stress_held scene

The scene has 1000 husks, wither skeletons, vindicators and piglins (NoAI). Each holds a different item in each hand: swords, an axe, a pickaxe, a torch, an apple, a bow, a carrot and stone.

Setup: Mac mini M4 Pro, RD 16, 1280×720 offscreen, 10 s; 3 alternating pairs, base b410fb5d73.

Metric base this PR change
avg fps 137.1 / 131.7 / 139.4 217.8 / 227.8 / 211.8 +61 % (136 → 219)
1 % low fps 108.7 / 113.2 / 118.5 135.3 / 185.8 / 179.5 +47 % (113 → 167)
0.1 % low fps 91.3 / 107.3 / 107.8 102.9 / 173.2 / 169.5 +45 % (102 → 149)
frame CPU p50 7.22 ms 4.44 ms −39 %
steady RSS 1413 MB 1113 MB −300 MB

Checks (playhorizon, head 623fec233c; the head only rewords the commit, same tree)

cargo fmt --all -- --check                                              ok
cargo clippy --profile fast -p horizon-client -p horizon-client-lib --lib --bins --tests -- -D warnings   ok, 0 diagnostics
cargo test -p horizon-client-lib --lib items_posed_on_the_gpu           1 passed (15514 GPU / 1066 CPU states)
cargo test -p horizon-client --bin horizon-client mob_blocks            2 passed
cargo test -p horizon-client --bin horizon-client creatures             7 passed
python3 -m unittest tests.test_perf_bench                               24 passed

Next: item frames and armour-stand hand items take the same path. The test already covers their contexts.

🤖 Generated with Claude Code


🔄 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/7215 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/held-items-gpu` --- ### 📝 Commits (1) - [`9598faa`](https://github.com/horizon-rust/horizon/commit/9598faaba1420a97cc4b2444ded078e9fd7959c8) Draw mobs' held items on the GPU skin path ### 📊 Changes **7 files changed** (+84 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+8 -2) 📝 `crates/horizon-client/src/game/item_draw.rs` (+26 -0) 📝 `crates/horizon-client/src/game/mob_blocks.rs` (+10 -1) 📝 `crates/horizon-client/src/game/perspective.rs` (+2 -2) 📝 `crates/horizon-client/src/item_render.rs` (+18 -5) 📝 `tests/test_perf_bench.py` (+1 -0) 📝 `tools/stress_scenes.py` (+19 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Before this PR, a mob's main- and off-hand items were posed and lit vertex by vertex on the CPU every frame. That happened even when the mob's body already went through the GPU skin path (#7056). In a crowd where every zombie, skeleton, vindicator or piglin holds something, the items were the frame's main CPU cost. Now an item whose baked model fits the skin path joins the mob's skinned draw. It fits when it is opaque or cutout, with no glint, emission or translucent quads. - **Draw.** The item becomes one skin job with its hand pose. - **Bounds.** Its corners widen the mob's cull bounds, so body and items are culled together, and truncated together when the mob is culled. These stay on the CPU, as before: - outlined or glowing mobs (outlines need the CPU vertices); - first-person hands; - items that don't fit the path. ### Exactness `items_posed_on_the_gpu_draw_what_the_cpu_draws` is the #7056 test, extended to every item state in the ground, both third-person hands, fixed and head contexts. On the real 26.3 assets: - **15514 states** take the GPU path, and its vertices equal the CPU's byte for byte; - **1066 states** stay on the CPU. ### A/B: new `stress_held` scene The scene has 1000 husks, wither skeletons, vindicators and piglins (NoAI). Each holds a different item in each hand: swords, an axe, a pickaxe, a torch, an apple, a bow, a carrot and stone. Setup: Mac mini M4 Pro, RD 16, 1280×720 offscreen, 10 s; 3 alternating pairs, base `b410fb5d73`. | Metric | base | this PR | change | |---|---|---|---| | avg fps | 137.1 / 131.7 / 139.4 | 217.8 / 227.8 / 211.8 | **+61 %** (136 → 219) | | 1 % low fps | 108.7 / 113.2 / 118.5 | 135.3 / 185.8 / 179.5 | **+47 %** (113 → 167) | | 0.1 % low fps | 91.3 / 107.3 / 107.8 | 102.9 / 173.2 / 169.5 | +45 % (102 → 149) | | frame CPU p50 | 7.22 ms | 4.44 ms | **−39 %** | | steady RSS | 1413 MB | 1113 MB | −300 MB | ### Checks (playhorizon, head 623fec233c; the head only rewords the commit, same tree) ``` cargo fmt --all -- --check ok cargo clippy --profile fast -p horizon-client -p horizon-client-lib --lib --bins --tests -- -D warnings ok, 0 diagnostics cargo test -p horizon-client-lib --lib items_posed_on_the_gpu 1 passed (15514 GPU / 1066 CPU states) cargo test -p horizon-client --bin horizon-client mob_blocks 2 passed cargo test -p horizon-client --bin horizon-client creatures 7 passed python3 -m unittest tests.test_perf_bench 24 passed ``` Next: item frames and armour-stand hand items take the same path. The test already covers their contexts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:15 +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#7419
No description provided.