D3D12.X: find superseded placements under a shared lock #3577
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3577"
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 ivall/xcl. Originally posted by raylitebull on 2026-12-01T14:44:35Z.
While any target is superseded,
placements::note_useruns for every barrier, every copy and every texture in a draw's descriptor tables, and it took theREGISTRYmutex each time to learn whether that texture was superseded. It almost never is. Now the superseded placements are mirrored in a set that a shared read lock can check, andREGISTRYis taken only for the ones that are superseded.What is in it
placements.rs:SUPERSEDED_IDS.Registryrecords each change where it counts superseded placements (superseded_delta), andsync_supersededapplies those changes whereSUPERSEDEDwas stored before.note_usereturns early for a texture not in the set, andnote_useschecks a batch under one read lock.bind.rs:note_superseded_in_tablescollects a draw's textures, sorts and deduplicates them, and callsnote_uses.sync_supersededchecks that the set holds as many entries asRegistry::unmappedcounts.the_superseded_set_follows_the_registry.Tested
cargo check --workspace --all-targets --target x86_64-pc-windows-gnu: no errors, no new warnings.x86_64-pc-windows-gnuand run under Wine 9.0 (no GPU) with--test-threads=4, next to the same filters onmainb2b1f109:hle::d3d12x::placements: 14 passed, 0 failed (main: 13 / 0)hle::d3d12x::bind: 113 passed, 3 failed (main: 113 / 3)The failures are the same tests on both, ones that need a D3D12 device or Windows' working-set queries, which Wine lacks.
Regression run
Not run yet: there was no Windows machine or title here.
scripts/smoke.ps1still has to run on a title, built frommainand from this head, soPR checksfails until those two blocks are added.Not tested
cargo test --workspace -- --test-threads=4) on Windows, with or without a GPU; CI's no-GPU job is the first Windows run.main, and any performance onmain: the numbers above are fromamd-dev.amd-devit is part of4d6d4a77, whose numbers cover all of its lock changes together.AI use
amd-devcommit4d6d4a77tomain, split it into this PR and five others, and wrote the test, the commit message and this description. Theamd-devmeasurements are raylitebull's own runs.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T14:49:50Z.
Review (head
b0fa4d61, diff read, not a merge-check; draft):note_usenow returns early when a texture isn't in the set, so a superseded texture missing from it would never be mapped back when the title uses it again, and its reads would hit unmapped tiles without an error. All four current changes tomapped/releasedpush asuperseded_delta(placements.rs~262, ~284, ~315, ~346). Adebug_assert_eq!(set.len(), r.unmapped)insync_superseded(~509) would keep future changes honest.bind.rs~1333 dedups the textures a draw's tables name withnamed.contains, a linear scan, so a draw with many tables naming up to 256 textures each pays O(n²). It runs while anything is superseded, which happens by default (XCL_PLACE_RETIREis on). A small set or sorting would bound it.amd-dev4d6d4a77with six lock changes together.Fine: lookups only read the set, and the new lock is only ever taken last, under
REGISTRY, so there's no lock-order cycle. No read lock is taken twice on one thread: the guards at ~584 and ~601 drop beforenote_use/REGISTRY. A stale read only looks like the use happened before or after the placement, which main already allows between threads, and theREGISTRYpath rechecks throughuse_again. It conflicts with #3443 (note_superseded_in_tables).AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T14:59:05Z.
Follow-up (head
ea033df7; the diff fromb0fa4d61read). Both points are addressed:sync_supersedednow asserts that the set's size matchesr.unmappedafter the drain, so a missed registry change fails in debug builds; and the per-draw dedup is asort_unstable+dedupafter collecting instead of a linearcontainsper texture, so it's O(n log n). The set is checked under the write guard it's built with, so the assertion can't see a half-drained set. The gain on main is still unmeasured.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-01T15:06:18Z.
@Foniass thanks, both are in (
ea033df7), as you confirmed. A measurement onmainwill come with the smoke runs. On #3443: whichever lands second will need a rebase ofnote_superseded_in_tables. I'll do it here if this one is second.AI use: written by Capy (Claude Opus 5.5) and posted on raylitebull's behalf, with their go-ahead.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T15:20:39Z.
Test report (not a merge-check: draft,
PR descriptionred)base:
b2b1f109d2head:
ea033df715merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2903 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3577#issuecomment-7315147590, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run. A lock change whose cost a 60 s run capped at 60 presents per second can't show.
assessment: merges, builds and passes the whole suite on current main, including the new superseded-set check in the debug-build tests; still open: a measurement of the gain on main
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.