[PR #676] [MERGED] Release unused terrain GPU buffers #2724

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

📋 Pull Request Information

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

Base: main ← Head: fix/reclaim-terrain-gpu-memory


📝 Commits (1)

  • b47f565 Reclaim unused terrain GPU arena pages

📊 Changes

2 files changed (+128 additions, -21 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+2 -0)
📝 crates/horizon-client/src/gfx/arena.rs (+126 -21)

📄 Description

Terrain vertex and translucent-index arenas kept their GPU buffers after all ranges were released, including when closing a world. Reclaim fully empty pages between upload batches, preserve live page IDs and reuse vacant slots, and allocate buffers on demand after clearing an arena.

Refs #600.

Measured in an isolated test-terrain world on a GTX 1660 SUPER (6 GB), at 32 chunks:

  • Loaded terrain uses about 480 MiB of vertex arena capacity both before and after.
  • Reducing to two chunks retains 480 MiB before; this change retains 256 MiB, releasing an empty page.
  • Returning to the title screen retains 480 MiB before; this change retains zero terrain vertex arena bytes. Backend-reported allocated GPU memory falls from about 644 MiB before to 156 MiB after. Backend-reserved memory is a separate allocator pool and remains larger.
  • The fixed client reopens the world and renders terrain again.

Validation: four allocator tests pass on the NVIDIA adapter, including live-page GPU readback after reclaiming/reusing another page, and clear/reallocate checks for vertex and index arenas. Fast client build, client all-target Clippy with warnings denied, workspace formatting, whitespace and public-tree checks pass.

Limits: partially occupied pages retain their capacity; this adds no compaction, total VRAM budget or OOM recovery. Initial loading at 32/64 chunks can still exceed available memory. Repeated travel, resource packs and dimension changes need manual testing. This fixes confirmed buffer retention without claiming to resolve every cause of #600.


🔄 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/676 **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:** `fix/reclaim-terrain-gpu-memory` --- ### 📝 Commits (1) - [`b47f565`](https://github.com/horizon-rust/horizon/commit/b47f5658496cf787db06cdb46681c36d96bffbf6) Reclaim unused terrain GPU arena pages ### 📊 Changes **2 files changed** (+128 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+2 -0) 📝 `crates/horizon-client/src/gfx/arena.rs` (+126 -21) </details> ### 📄 Description Terrain vertex and translucent-index arenas kept their GPU buffers after all ranges were released, including when closing a world. Reclaim fully empty pages between upload batches, preserve live page IDs and reuse vacant slots, and allocate buffers on demand after clearing an arena. Refs #600. Measured in an isolated test-terrain world on a GTX 1660 SUPER (6 GB), at 32 chunks: - Loaded terrain uses about 480 MiB of vertex arena capacity both before and after. - Reducing to two chunks retains 480 MiB before; this change retains 256 MiB, releasing an empty page. - Returning to the title screen retains 480 MiB before; this change retains zero terrain vertex arena bytes. Backend-reported allocated GPU memory falls from about 644 MiB before to 156 MiB after. Backend-reserved memory is a separate allocator pool and remains larger. - The fixed client reopens the world and renders terrain again. Validation: four allocator tests pass on the NVIDIA adapter, including live-page GPU readback after reclaiming/reusing another page, and clear/reallocate checks for vertex and index arenas. Fast client build, client all-target Clippy with warnings denied, workspace formatting, whitespace and public-tree checks pass. Limits: partially occupied pages retain their capacity; this adds no compaction, total VRAM budget or OOM recovery. Initial loading at 32/64 chunks can still exceed available memory. Repeated travel, resource packs and dimension changes need manual testing. This fixes confirmed buffer retention without claiming to resolve every cause of #600. --- <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:34 +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#2724
No description provided.