Skip to content

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

Merged
ivall merged 2 commits into
xcl-dev:mainfrom
Foniass:fix/descriptor-heap-pages
Nov 23, 2026
Merged

ivall merged 2 commits into
xcl-dev:mainfrom
Foniass:fix/descriptor-heap-pages

Conversation

@Foniass

@Foniass Foniass commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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 and others added 2 commits November 23, 2026 02:44
…(NVIDIA flicker)

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]>
…rs it has

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]>
@Lum7nt

Lum7nt commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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.

@certified-retart

Copy link
Copy Markdown
Contributor

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.)

@ivall
ivall merged commit ef4d7d6 into xcl-dev:main Nov 23, 2026
ivall added a commit that referenced this pull request Nov 23, 2026
…ible

Follow-up to #69: with #84 every view heap goes to the shared heap and is created CPU-only;
one that found no room there (or no UMA for its slots) is such a CPU-only heap, and binding
it would be invalid – the shared heap stays bound then, as before #69. A heap that kept a
shader-visible PC heap of its own (no shared heap) is bound for its local indices.
ivall added a commit that referenced this pull request Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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!

Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…cl-dev#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
Michael-Glaser added a commit to Michael-Glaser/xcl that referenced this pull request Nov 24, 2026
…vall#104)

On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method.

Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned.

Assisted-by: Antigravity (Gemini 4 Neon)
CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
The layout entry matches the Windows SDK's d3d12.h (IID, parent List9,
SetProgram xcl-dev#84 / DispatchGraph xcl-dev#85 after List9's 84 methods, List11 after
it); a console list object passes List10 QueryInterface on to the PC list
(itself out when supported, E_NOINTERFACE unchanged when not) and forwards
xcl-dev#84 / xcl-dev#85; an adopted PC list gets the List10+ layout while a title's xcl-dev#84 /
xcl-dev#85 stay the console methods (CopyResource with flags, SetPredication with
a buffer). The GPU test skips when the runtime has no List10.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants