Console descriptor heaps take the shared heap a page at a time (Minecraft flicker on NVIDIA) #84

Manually merged
github merged 2 commits from gh-pr/84/head into gh-pr/84/base 2026-11-26 04:08:53 +00:00
Owner

@⁠Foniass on GitHub · 2026-11-23 02:02 UTC · original
Foniass:fix/descriptor-heap-pages → main · +153 −52 · 3 files · 2 commits · merged 2026-11-23 09:59 UTC

Minecraft flickers on NVIDIA: about one frame in fourteen at the main menu is a flat dark-gray frame (#212121, the clear colour of its 4× MSAA scene target). Players report it as flicker. This PR fixes it.

Cause

All console view heaps share one shader-visible PC heap (console_heap::Global). Each heap got a contiguous range there of 2 PC descriptors per slot, reserved when the heap was created. That heap's size is the GPU's MaxViewDescriptorHeapSize, capped at 2 097 152: 1 000 000 on NVIDIA.

Minecraft creates eight view heaps of 73 727 slots, 147 454 PC descriptors each, 1 179 632 in all. Six fit. The seventh logs "the shared heap (1000000) has no room for 147454 more – that heap keeps its own", and so does the eighth.

A heap that "keeps its own" is lost: pc_heaps binds only the shared heap for views, so a draw using descriptors from heap 7 or 8 reads another heap's slots. In Minecraft those draws (the panorama and the whole UI) come out transparent, and the resolved frame is just the clear colour. The game rotates its heaps with its frames, so the blank frames always land on the same one of its three back buffers (every gap between them is a multiple of 3). On AMD the cap is 2 097 152, so all eight heaps fit, which is why RDNA never showed it.

The heaps are nearly empty: at the menu each holds 3 images.

Fix

A heap's place in the shared heap is now given a page of 256 slots at a time, when a slot of that page is first used (console_heap::slot). It's no longer reserved whole at creation.

  • Slot indices are per page (page first + 2·(k mod 256)). A T# still carries its own PC index, so copies between heaps behave as before.
  • publish_range copies page by page, since a heap's pages are not adjacent in the shared heap.
  • unregister frees the pages it got.
  • A heap's last page takes only the descriptors the heap has left, so a heap of a few slots still takes 2 per slot, as before. A title with many small heaps doesn't use the shared heap up faster than it did.
  • reserve_global(dev, n) becomes shared_heap(dev) (make the shared heap) plus a private reserve_global(n) per page. register takes shared: bool instead of a range.
  • If the shared heap ever fills up, the remaining slots fall back as before, with a warning.

Related: the first item of #69 (binding the selected private heap for local indices) addresses the same lost heaps from the binding side. Binding a private heap still breaks draws that mix descriptors from several heaps (console descriptor tables may point into any heap). Here every heap stays in the one shared heap.

Measurements (RTX 5070 Ti, driver 32.0.16.2114, Minecraft Preview 1.18.30.64, menu)

Blank frames were counted inside XCL: the middle row of every presented frame was read back after the present copy, and a frame counts as blank when that whole row is a single colour. This was a local diagnostic, not part of this PR.

blank frames at the menu
main 35–55 per 600, every run (6 runs)
this PR 0 in 2 400; 0 in 12 600 over a 3½-minute session

A screen capture of the window at 60–80 captures/s agrees: 5–27 flicker frames per 750 before, 0 per 750 after. Clean builds of main and of this branch, run one after the other, gave 27 and 0; the main run logs the "no room" warning and this branch's doesn't.

Ruled out along the way (no change in the blank count): reporting the flip only after XCL's present copy, uploading whole dirty pages instead of changed 64-byte chunks, a CPU wait for every sparse upload, early command-allocator resets (none happen). With every pixel shader forced to magenta the blank frames disappear, which pointed at what the shaders read rather than at geometry or ordering.

Tests

  • New console_heap::tests::large_heaps_get_shared_pages_as_used: eight heaps of 73 727 slots. Every slot gets a place, pages are contiguous, indices are unique, and two heaps of 4 slots take 8 descriptors each. On a shared heap of 1 000 000 (NVIDIA) the old whole-heap reservation gives the seventh heap no range; on AMD's larger heap the test passes either way.
  • cargo build --workspace --release then cargo test --workspace --release on the RTX 5070 Ti: all pass, including the test title (e2e). 41 GPU tests print SKIPPED (no wave64 on NVIDIA), as on main.

🤖 Generated with Claude Code

**@⁠Foniass** on GitHub · 2026-11-23 02:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/84) `Foniass:fix/descriptor-heap-pages` → `main` · +153 −52 · 3 files · 2 commits · merged 2026-11-23 09:59 UTC Minecraft flickers on NVIDIA: about one frame in fourteen at the main menu is a flat dark-gray frame (#212121, the clear colour of its 4× MSAA scene target). Players report it as flicker. This PR fixes it. ### Cause All console view heaps share one shader-visible PC heap (`console_heap::Global`). Each heap got a contiguous range there of 2 PC descriptors per slot, reserved when the heap was created. That heap's size is the GPU's `MaxViewDescriptorHeapSize`, capped at 2 097 152: **1 000 000 on NVIDIA**. Minecraft creates **eight view heaps of 73 727 slots**, 147 454 PC descriptors each, 1 179 632 in all. Six fit. The seventh logs "the shared heap (1000000) has no room for 147454 more – that heap keeps its own", and so does the eighth. A heap that "keeps its own" is lost: `pc_heaps` binds only the shared heap for views, so a draw using descriptors from heap 7 or 8 reads another heap's slots. In Minecraft those draws (the panorama and the whole UI) come out transparent, and the resolved frame is just the clear colour. The game rotates its heaps with its frames, so the blank frames always land on the same one of its three back buffers (every gap between them is a multiple of 3). On AMD the cap is 2 097 152, so all eight heaps fit, which is why RDNA never showed it. The heaps are nearly empty: at the menu each holds 3 images. ### Fix A heap's place in the shared heap is now given **a page of 256 slots at a time, when a slot of that page is first used** (`console_heap::slot`). It's no longer reserved whole at creation. - `Slot` indices are per page (`page first + 2·(k mod 256)`). A T# still carries its own PC index, so copies between heaps behave as before. - `publish_range` copies page by page, since a heap's pages are not adjacent in the shared heap. - `unregister` frees the pages it got. - A heap's last page takes only the descriptors the heap has left, so a heap of a few slots still takes 2 per slot, as before. A title with many small heaps doesn't use the shared heap up faster than it did. - `reserve_global(dev, n)` becomes `shared_heap(dev)` (make the shared heap) plus a private `reserve_global(n)` per page. `register` takes `shared: bool` instead of a range. - If the shared heap ever fills up, the remaining slots fall back as before, with a warning. Related: the first item of #69 (binding the selected private heap for local indices) addresses the same lost heaps from the binding side. Binding a private heap still breaks draws that mix descriptors from several heaps (console descriptor tables may point into any heap). Here every heap stays in the one shared heap. ### Measurements (RTX 5070 Ti, driver 32.0.16.2114, Minecraft Preview 1.18.30.64, menu) Blank frames were counted inside XCL: the middle row of every presented frame was read back after the present copy, and a frame counts as blank when that whole row is a single colour. This was a local diagnostic, not part of this PR. | | blank frames at the menu | |---|---| | `main` | 35–55 per 600, every run (6 runs) | | this PR | **0 in 2 400**; 0 in 12 600 over a 3½-minute session | A screen capture of the window at 60–80 captures/s agrees: 5–27 flicker frames per 750 before, 0 per 750 after. Clean builds of `main` and of this branch, run one after the other, gave 27 and 0; the `main` run logs the "no room" warning and this branch's doesn't. Ruled out along the way (no change in the blank count): reporting the flip only after XCL's present copy, uploading whole dirty pages instead of changed 64-byte chunks, a CPU wait for every sparse upload, early command-allocator resets (none happen). With every pixel shader forced to magenta the blank frames disappear, which pointed at what the shaders read rather than at geometry or ordering. ### Tests - New `console_heap::tests::large_heaps_get_shared_pages_as_used`: eight heaps of 73 727 slots. Every slot gets a place, pages are contiguous, indices are unique, and two heaps of 4 slots take 8 descriptors each. On a shared heap of 1 000 000 (NVIDIA) the old whole-heap reservation gives the seventh heap no range; on AMD's larger heap the test passes either way. - `cargo build --workspace --release` then `cargo test --workspace --release` on the RTX 5070 Ti: all pass, including the test title (`e2e`). 41 GPU tests print SKIPPED (no wave64 on NVIDIA), as on `main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each console view heap reserved 2 PC descriptors per slot in the shared
shader-visible heap at creation. NVIDIA's shared heap holds 1 000 000;
Minecraft makes eight view heaps of 73 727 slots (147 454 descriptors each),
so the seventh and eighth got no range, and lists, which bind only the shared
heap for views, read other heaps' descriptors for them: about one frame in
fourteen at the menu came out as the bare clear colour.

A heap now gets its place in the shared heap a page of 256 slots at a time,
when a slot of that page is first used (`console_heap::slot`); publish_range
copies page by page and unregister frees the pages. Minecraft's heaps hold a
few hundred views, so all of them fit.

Measured on an RTX 5070 Ti at Minecraft's menu: 35-55 blank frames per 600
before, 0 in 12 600 after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A page reserved 512 descriptors of the shared heap whatever the heap's size,
so a heap of a few slots took 512 where it took 2 per slot before, and a title
with a few thousand small view heaps would have filled the shared heap. The
last page of a heap is now as long as the heap's remaining slots.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:08:51 +00:00
github manually merged commit 385dc5fc3a into gh-pr/84/base 2026-11-26 04:08:53 +00:00
Author
Owner

@⁠Lum7nt on GitHub · 2026-11-23 05:48 UTC · original

Tested this branch locally against main and alongside #43 — all 344 library tests pass (including large_heaps_get_shared_pages_as_used) and it merges cleanly.

Architecturally, this paging design is a clear improvement over capping/recycling monolithic heaps (#69):

  1. Hardware compliance: By demand-paging 32-slot chunks into a shared pool, active PC descriptor counts remain well within NVIDIA's 1M MaxViewDescriptorHeapSize, even when titles allocate multiple large heaps (e.g. Minecraft's 8 × 73k view heaps).
  2. Sound lifecycle: Generation stamping and slot refcounting prevent descriptor aliasing and stale references on page reuse without global serialization.

Solid work — resolves the allocation failures and flickering cleanly.

**@⁠Lum7nt** on GitHub · 2026-11-23 05:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/84#issuecomment-7092750309) Tested this branch locally against `main` and alongside #43 — all 344 library tests pass (including `large_heaps_get_shared_pages_as_used`) and it merges cleanly. Architecturally, this paging design is a clear improvement over capping/recycling monolithic heaps (#69): 1. **Hardware compliance**: By demand-paging 32-slot chunks into a shared pool, active PC descriptor counts remain well within NVIDIA's 1M `MaxViewDescriptorHeapSize`, even when titles allocate multiple large heaps (e.g. Minecraft's 8 × 73k view heaps). 2. **Sound lifecycle**: Generation stamping and slot refcounting prevent descriptor aliasing and stale references on page reuse without global serialization. Solid work — resolves the allocation failures and flickering cleanly.
Author
Owner

@⁠certified-retart on GitHub · 2026-11-23 05:54 UTC · original

Tested head \385dc5fc\ on a dual-GPU Windows 10 setup (NVIDIA RTX 5070 + AMD Radeon 9800X3D iGPU) with D3D12 Agility SDK 1.619.1 (#75) so SM 6.6 / wave64 GPU tests run live:

  • NVIDIA RTX 5070 (\XCL_ADAPTER=0, wave32-only, 1,000,000-descriptor shared view heap):
    • \console_heap::tests::large_heaps_get_shared_pages_as_used: PASS (verified against the 1,000,000-descriptor shared heap — all 8 × 73,727-slot heaps allocate pages cleanly, and the two 4-slot heaps take 8 descriptors each).
    • Full \xcl\ lib suite: 352 passed, 0 failed (41 wave64-only GPU tests \SKIPPED\ as expected on NVIDIA).
  • AMD Radeon(TM) Graphics (9800X3D iGPU, \XCL_ADAPTER=1, wave32..64):
    • Full \xcl\ lib suite: 352 passed, 0 failed, 0 skipped (all wave64 GPU + mesh dispatch tests pass).
    • \gpu_pso_e2e: 6 passed, 0 failed.

(Minor note: \large_heaps_get_shared_pages_as_used\ calls \D3D12CreateDevice(None, ...), so on multi-GPU systems it always tests the default adapter — here the RTX 5070 with the 1M heap cap, which is the exact case that triggers the old overflow.)

**@⁠certified-retart** on GitHub · 2026-11-23 05:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/84#issuecomment-7092842159) Tested head \385dc5fc\ on a dual-GPU Windows 10 setup (NVIDIA RTX 5070 + AMD Radeon 9800X3D iGPU) with D3D12 Agility SDK 1.619.1 (\#75\) so SM 6.6 / wave64 GPU tests run live: - **NVIDIA RTX 5070 (\XCL_ADAPTER=0\, wave32-only, 1,000,000-descriptor shared view heap):** - \console_heap::tests::large_heaps_get_shared_pages_as_used\: **PASS** (verified against the 1,000,000-descriptor shared heap — all 8 × 73,727-slot heaps allocate pages cleanly, and the two 4-slot heaps take 8 descriptors each). - Full \xcl\ lib suite: **352 passed, 0 failed** (41 wave64-only GPU tests \SKIPPED\ as expected on NVIDIA). - **AMD Radeon(TM) Graphics (9800X3D iGPU, \XCL_ADAPTER=1\, wave32..64):** - Full \xcl\ lib suite: **352 passed, 0 failed, 0 skipped** (all wave64 GPU + mesh dispatch tests pass). - \gpu_pso_e2e\: **6 passed, 0 failed**. (Minor note: \large_heaps_get_shared_pages_as_used\ calls \D3D12CreateDevice(None, ...)\, so on multi-GPU systems it always tests the default adapter — here the RTX 5070 with the 1M heap cap, which is the exact case that triggers the old overflow.)
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:59 UTC · original

Merged (55df81b). Checked on an RX 9070 (RDNA4): cargo test --workspace with the retail samples (shader pack, console DLLs, texture archive) – natively, and with XCL_SPLIT_WAVE64=1 (new in ba905cf: forces the split wave64 form on RDNA, which runs both wave sizes, so the NVIDIA path can be checked on AMD). XDefiant (title screen correct, 6 299 translated pipelines, 0 translation errors), Minecraft and Unicorn Overlord run. Minecraft on AMD no longer logs the shared-heap "no room" warning either. Thanks for the careful measurement!

**@⁠ivall** on GitHub · 2026-11-23 09:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/84#issuecomment-7097358583) Merged (55df81b). Checked on an RX 9070 (RDNA4): `cargo test --workspace` with the retail samples (shader pack, console DLLs, texture archive) – natively, and with `XCL_SPLIT_WAVE64=1` (new in ba905cf: forces the split wave64 form on RDNA, which runs both wave sizes, so the NVIDIA path can be checked on AMD). XDefiant (title screen correct, 6 299 translated pipelines, 0 translation errors), Minecraft and Unicorn Overlord run. Minecraft on AMD no longer logs the shared-heap "no room" warning either. Thanks for the careful measurement!
This discussion has been locked. Commenting is limited to contributors.
No description provided.