d3d12: do not follow a record into a slot being written #448
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/448"
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 NickStallman on 2026-11-29T05:17:51Z.
Summary
A title copies a descriptor's record and then writes the next descriptor into the same CPU slot. A thread that resolved the record between the host's write and the moment the new view is authored was given the slot. It could then copy the new view, or a half-written one, and the table slot or index-map entry kept that view because its record hadn't changed.
preservenow takes the version off the slot, after saving the replaced view and before the host writes, so the record resolves to the kept view from then on. A copy that began before that resolves its record again when done, and copies again if the view has moved.How it was found
By reading, and confirmed only in unit tests that interleave the threads deterministically. It hasn't been seen in ProjectScarlett. It needs a record lagging the slots by about one wrap, so I expect it to be rare; where it does happen, the wrong view stays until the record changes. I don't claim it causes any reported fault.
It covers the same pattern
0ae06f52describes (a title reusing a CPU heap whose records it copied).CopyDescriptorshas the same shape and isn't changed here; neither are hosts with no history heap.Cost
Two extra mutex operations per materialised record. Not measured in a game.
Tested
Unit tests: two new ones; both fail (
resolved to 0x30000000) when the two behaviour lines are disabled. They needHistorywithout a device, hence a small struct split. The project's checks only typecheck the D3D12 crate, so run them by name; 285 device-free D3D12 tests pass in Wine with Vulkan off.Lanes: none. The race is a window of microseconds between two CPU threads, which a guest can't make deterministic.
GPU, driver and backend:
Run on a machine loading a game's shaders at the same time. Not run in the game, or on Windows.
🤖 Generated with Claude Code