Repository navigation
Console descriptor heaps take the shared heap a page at a time (Minecraft flicker on NVIDIA) - #84
Conversation
…(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]>
|
Tested this branch locally against Architecturally, this paging design is a clear improvement over capping/recycling monolithic heaps (#69):
Solid work — resolves the allocation failures and flickering cleanly. |
|
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:
(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.) |
…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.
|
Merged (55df81b). Checked on an RX 9070 (RDNA4): |
…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)
…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)
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]>
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'sMaxViewDescriptorHeapSize, 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_heapsbinds 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.Slotindices 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_rangecopies page by page, since a heap's pages are not adjacent in the shared heap.unregisterfrees the pages it got.reserve_global(dev, n)becomesshared_heap(dev)(make the shared heap) plus a privatereserve_global(n)per page.registertakesshared: boolinstead of a range.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.
mainA 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
mainand of this branch, run one after the other, gave 27 and 0; themainrun 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
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 --releasethencargo test --workspace --releaseon the RTX 5070 Ti: all pass, including the test title (e2e). 41 GPU tests print SKIPPED (no wave64 on NVIDIA), as onmain.🤖 Generated with Claude Code