D3D12.X: look for superseded targets in every declared table range #3443
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3443"
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 Lakanya on 2026-11-29T17:57:15Z.
A superseded target bound through a descriptor table is remapped when a draw or dispatch binds the table (#3179), but only the first 256 slots of each table were read. A view further in – a bindless SRV range, or a range at an explicit offset past slot 256 – was never seen, so that target kept no tiles: its writes were dropped and its reads returned zeros. This reads the SRV and UAV ranges each table's root signature declares instead, wherever they lie in the table, and only those. Follow-up to #3179.
What is in it (one commit)
crates/xcl/src/hle/d3d12x/console_list.rs:Layout::table_ranges, the SRV / UAV ranges of each descriptor-table parameter (RTS0 1.0 and 1.1 range layouts,OFFSET_APPENDand unbounded ranges). CBV and sampler ranges cannot name a placed target and are left out.crates/xcl/src/hle/d3d12x/bind.rs:note_superseded_in_tablesscans those ranges in chunks of 256 slots. An unbounded range ends with the view heap the table lies in; outside any view heap it has no known extent and is not read. The scan isscan_superseded_in_tables_with, with the memory and heap lookups passed in so it can be tested without a device.crates/xcl/src/hle/d3d12x/console_heap.rs:view_heap_remaining_slots, the slots from an address to the end of its view heap (no shared-heap page is allocated by asking).descriptor_tables_keep_their_srv_and_uav_ranges(both RTS0 versions: appended, unbounded and explicit-offset ranges, CBV / sampler ranges skipped) andsuperseded_targets_are_found_in_every_declared_table_range(a target at slot 300 is found – the old 256-slot scan never read it –, slots between declared ranges are not read, unbounded ranges stop at the view heap's end, and are not read outside one).Tested
cargo test --release --workspace --no-fail-fast -- --test-threads=4on7afecf84: the integration harnesses 139 passed, 0 failed, 20 ignored (4 e2e tests first failed only becausexcl_testtitle.exewas not built; aftercargo build --release --workspace,cargo test --release -p xcl --test e2e: 5 passed, 0 failed).main0fe06eb0alike: two tests end the process (0x80004005):gpu::recomp::dxc::private_heap_tests::failed_private_heap_compiler_falls_back_to_dxc_create_instance, and one whose title reachesend_title("sparse upload preparation still failed after bounded retries"). Counts before they do:--test-threads=1: 962 passed, 0 failed, 24 ignored, on this PR and onmain;--test-threads=4 --skip failed_private_heap_compiler_falls_back_to_dxc_create_instance: 1078 passed, 0 failed on this PR, 1070 passed, 0 failed onmain.cargo test --release -p xcl --lib -- hle::d3d12x::console_list:: hle::d3d12x::console_heap:: hle::d3d12x::placements:: hle::d3d12x::bind::: 166 passed, 0 failed, 0 ignored, the two new tests among them.SKIPPEDon this adapter: 25 lines, the same on both: 22 "no wave64", 3 per-lane f16 / f32 forms refused (#1426 semantics). None is a test of this PR.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 600, each tree's own script and release build, the same environment for both (the title's Series S profile,XCL_DIRECT_DXIL=1,XCL_SPARSE_LAZY=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE=1with a warm cache, scripted A presses). A run of this PR's head came first to fill the translation cache (cold); not pasted.main:
this PR's head:
Not tested
mainrun stopped presenting at world loading (frame ~2,000, video memory over budget) until its time ran out; this PR's run stayed in the intro video and menus at 30 fps for its 600 s. Both ended without a crash or device removal. They check that nothing breaks, not the change itself.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T18:18:04Z.
I tested the descriptor scan on
7afecf845184279013bac99796d4d5b0417d6e4ewith an RTX 5070 12 GB (616.92), Ryzen 7 5700X3D, Windows 11 26300.10075 and Rust 1.100.0, debug. The synthetic fixture registered a real sparse-backed 73,727-slot view heap, created console SRVs through the production writer, and overlapped two R32_FLOAT render targets by one 64 KiB page.0fe06eb0left it unmapped. On the PR, a declared one-slot range at offset 73,726 and an unbounded range from slot zero each remapped it in fresh processes. A 256-slot range on the PR left it unmapped. After remapping, native compute readback returned 0.25 and 0.75 through the two real descriptors after distinct clears.I repeated the CPU comparison in three fresh processes with the XCL crate compiled at
opt-level=2(cargo --config profile.test.package.xcl.opt-level=2 test …). Main and the PR's 256-slot range took 8.2–8.4 µs median. The PR's unbounded miss took 382–387 µs median and 440–532 µs p95. All three processes reproduced the same native readback.I ran
cargo test --offline --locked -p xcl --lib -- hle::d3d12x::bind::probe3443::native_wide_table hle::d3d12x::bind::tests::superseded_targets_are_found_in_every_declared_table_range hle::d3d12x::console_list::tests::descriptor_tables_keep_their_srv_and_uav_ranges --exact --test-threads=1 --nocapturewithXCL_ADAPTER=5070 XCL_COHERENT_CAP_MB=512. Each process passed all three selected tests with zero skips. The full release profile, frequency of wide misses in a title, preservation of pre-eviction contents, and gameplay impact remain unmeasured. A release capture of scan count and scanned slots while the gate is open would tell whether to optimize this before shipping. Codex with GPT-6.2 Sol adapted the test-only fixture and ran the controls.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:22:55Z.
merge-check
base:
7d86c5d2b7head:
7afecf8451merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2898 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: read the whole diff (+192/-23). Findings: (1) Per-bind cost has no bound. An unbounded range (the usual bindless SRV table) is now read to the end of its view heap (
bind.rs~1346-1350,heap_rem - start), on every draw and dispatch bind while any target is superseded (XCL_PLACE_RETIREis on by default). Main reads 256 slots (8 KB) per table. A heap of 1M descriptors is 32 MB read per bind, and every T# found takesnote_use's registry lock. Nothing measures this. Capping it, or keeping a per-heap index of the slots that name superseded targets, would bound it. (2) More stale views get remapped. Every T# in the range counts as a use, including views the title left in the heap for an aliased transient target it no longer samples. Those targets are mapped again (note_use->map_again), which brings back the tile sharing that supersession removes. The 256-slot scan had the same weakness on a smaller window. Reasoned only. (3) Nothing shows a case that needs it: no issue is linked, the description says it is unknown whether the title binds a superseded target past slot 256, and its smoke runs don't reach the draws it changes. (4) Minor:view_heap_remaining_slotshas no test of its own (the bind.rs test passes a closure), and overlapping declared ranges are read twice. Fine: RTS0 1.0 / 1.1 range layouts (20 / 24 bytes, offset at +16 / +20) andOFFSET_APPENDare parsed correctly, CBV and sampler ranges are skipped, clipping at the heap end is right, the 8 KB stack buffer is reused (no allocation per bind), and the ranges are parsed once per root signature.performance: 60 s smoke of a retail title, main
7d86c5d2vs this merge (7cd8991a): 1663 -> 1668 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17153 -> 17480 MB, 0 device removals, 0 crashes. This run's log has no supersession at all in 60 s, so it doesn't reach the changed scan; it's a boot regression check only.verdict: not yet: an unbounded range is now read to the end of its view heap on every bind while any target is superseded (finding 1), with nothing measuring that cost or showing a title that needs it; bound the scan, or show the cost on a run that reaches superseded targets
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:55:51Z.
Triage (#1607) – head
7afecf8No open or merged PR makes the same change. #3395 shares most of these lines because it is stacked on this PR (its description says only its top commit
bdf38bf4belongs to it), so it is not a duplicate.One thing to measure:
scan_superseded_in_tables_withnow reads an unbounded SRV/UAV range up to the end of its view heap on every draw/dispatch whileplacements::any_superseded()is true, andconsole_heap::view_heap_remaining_slotstakes theHEAPSlock per table. With a bindless table over a large heap that is far more than the old fixed 8 KiB per table; a frame-time number with superseded targets live would settle it.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T06:43:38Z.
Review: COMMENTED
Review of
7afecf84: 4 finding(s). 4 are inline.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T06:43:39Z.
Code review location:
crates/xcl/src/hle/d3d12x/bind.rs; line 1346An unbounded SRV/UAV range is now scanned to the end of its view heap on every draw and dispatch, where the old scan stopped at 256 slots. With the usual bindless table, SRV(t0, unbounded) at offset 0 of a ~1M-descriptor heap, and any target superseded (
any_superseded()true), each bind copies ~32 MB of descriptors. It then callsnamed_by_indexandplacements::note_usefor every live T#, taking the REGISTRY mutex up to 1M times per draw. A few thousand draws per frame drop the frame rate to near zero while anything is superseded. Aliased ranges (Texture2D[]/Texture3D[]/TextureCube[] all unbounded at offset 0 in different spaces) are kept separately (console_list.rs ~196), so the scan runs once per alias. Looking superseded resources up through console_heap's reverse map (NAMES.by) and testing their indexes against each table's slot interval would cost O(superseded) per bind instead.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T06:43:39Z.
Code review location:
crates/xcl/src/hle/d3d12x/bind.rs; line 1347When the table is outside any registered view heap, a bounded range is scanned for its full declared count with no cap (the
(None, Some(c))arm). A root signature with a bounded bindless range (NumDescriptors = 1_000_000 or 0xFFFF_FFFE) whose table address isn't inside a registered heap sends every 256-slot chunk throughread_committed_into, which does ReadProcessMemory plus a VirtualQuery walk per chunk. That's thousands to millions of syscalls per draw, which effectively hangs the render thread. The old code read 256 slots.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T06:43:39Z.
Code review location:
crates/xcl/src/hle/d3d12x/console_list.rs; line 199Tables with no parsed SRV/UAV ranges are now never scanned, where the old code scanned the first 256 slots of every Param::Table. That covers a truncated range array or a bad offset (
r(pay)/r(base..)returns None and the loop breaks with no ranges), a parameter type >= 5 (still Param::Table, but only ty == 0 gets ranges), and an RTS0 version or range layout the parser doesn't expect. A superseded target bound through such a table keeps no tiles again: writes are dropped and reads return zeros, the bug #3179 fixed. Falling back to the old 256-slot scan when no ranges were parsed would keep that coverage.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T06:43:39Z.
Code review location:
crates/xcl/src/hle/d3d12x/console_list.rs; line 191Not certain about this one: after an unbounded range
next_offsetbecomes u32::MAX, so a later OFFSET_APPEND range starts at u32::MAX instead of being rejected, and large starts saturate the same way. An unbounded SRV range followed by an appended UAV range of N parses asTableRange { start: u32::MAX, count: Some(N) }. Outside a heap that reads N slots ~128 GiB past table_base, where any 32 bytes with type nibble >= 8 and a non-zero word 0 are taken as a T#, sonote_useremaps an unrelated resource.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T14:13:37Z.
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
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.