d3d12: follow descriptor records a title copies into an indexed heap #391
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/391"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by MathiewMay on 2026-11-28T09:20:20Z.
Summary
On console a descriptor heap's memory holds its descriptors, so a title can copy a 32-byte record into the shader-visible heap with ordinary stores, from a CPU heap or from another index. ProjectScarlett fills slots of its 38 MiB heap this way. Root tables already resolve such records each time they are bound (
lookup.rs). The resource index map, which direct-indexed programs read, fills an index's slot only when the API writes that index. So such a program kept reading through the view the API last wrote there.Arena::refresh_index_map,descriptor_paging/index_map.rs): before a batch whose programs read an arena's index map, the map re-reads the record of every index that has a slot and follows the ones that changed. A record naming another descriptor puts that view in the slot, and an empty one a null view. A record naming a descriptor the title has written again since, and bytes that are not a record, leave the slot as it was. An index the API writes again holds that view once more.recording.rs), as draws do, so that submission checks and refreshes it for them too. They were not registered before, socheck_index_capacitydid not run for them either.null_viewmoves fromlookup.rstoArenaso that both use it.The refresh reads one record per mapped index for each batch that indexes the arena. In ProjectScarlett, with traces I kept out of this branch, it resolved 9,045 copied records and cleared 1,424 in 84 s of one run. A scan took up to 17 ms in another.
The same run left 16,661 records stale. All came from one CPU heap of 3,128 slots: the title writes a descriptor there, copies its 32 bytes into the shader-visible heap, then writes the next descriptor into the same slot before the copy is used. The record then names a view that no longer exists. A follow-up PR keeps replaced views for such records; it builds on this one.
In game I tested this on an older
maintogether with other fixes of mine, not on this branch alone; with all my fixes a 30-minute run had no fault.Tested
New Lanes scenario
bindless-raw-copy(gateslanes-bindless-raw-copy-wideand-constrained, in thelanes-bindless-computesuite). A heap slot holds a view of one window of a buffer, written through the API. The title then copies, withmemcpy, a view of another window from a CPU heap over it, and the direct-indexed program must store through the copy. Onmainboth gates fail:A unit test,
index_map_follows_records_the_title_copies_with_ordinary_stores(runtime/d3d12/src/tests/device/descriptor_paging.rs), covers each case of the refresh: a copy, a copy followed once, a stale copy, an empty record, bytes that are not a record, and the API writing the index again.GPU, driver and backend: AMD Radeon RX 9070 (1002:7550, RADV GFX1201), Mesa 26.2.7, Linux 7.3, GE-Proton11-14 (
--backend proton).Commands run and their results:
The D3D12 controls ran with the tool's own case table, staging and
validate, but outside its Bubblewrap/xvfb-runsandbox, which stalls on this machine (it has no Xvfb).Checks
No evidence JSON changes.