D3D12.X: remap superseded targets bound through descriptor tables #3179
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3179"
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-28T16:20:39Z.
A target superseded by a newer overlapping placement (
5d00b390,XCL_PLACE_RETIRE=1) had its tiles unmapped (D3D12_TILE_RANGE_FLAG_NULL) and was only remapped byplacements::note_useonResourceBarrierorCopy*calls.Two cases caused live UAV targets to remain unmapped and silently drop all writes (reading back as
0):R9G9B9E5sampled view over anR32_UINTUAV target whose owned page range differs by a trailing page) producedOverlap::Aroundinstead ofOverlap::Sameand superseded its own UAV target.ResourceBarrier(e.g. global UAV barriers) never triggeredplacements::note_use.In a retail title, both cases hit the volumetric fog upsample outputs (
480x272R32_UINT/R9G9B9E5inscatter and adjacentR10G10B10A2transmittance), causing the fog apply pass to multiply the scene by0.0transmittance and black out the 3D frame. With this fix (defaultXCL_PLACE_RETIRE=1, no workarounds), the superseded targets remap on bind and the 3D scene renders normally.What is in it
crates/xcl/src/hle/d3d12x/placements.rs:Desc::same_texelsand skip superseding whenp.desc.format != 0 && p.va == old.va && p.desc.same_texels(&old.desc).any_superseded()(single relaxed atomic load ofSUPERSEDED).same_address_same_texels_alias_pair_does_not_supersedeandsuperseded_target_remaps_on_use_again.crates/xcl/src/hle/d3d12x/bind.rs:bind_abi, whenplacements::any_superseded()is true, scan descriptor table slots (Param::Table) and callplacements::note_usefor named image descriptors.Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5070 Laptop GPU (8 GB, driver 617.71), Rust stable MSVC release.
cargo test --manifest-path C:\XCL-pr1\Cargo.toml --release --workspace -- --test-threads=1(xcl --lib):SKIPPEDforno wave64/#1426/XCL_HEAP_WINDOWS=1/ Developer Mode; all 4 failures are pre-existinggpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3; allhle::d3d12xtests includingplacements,bind,vram,title_textures, anduma_driverpassed).cargo test --manifest-path C:\XCL-pr1\Cargo.toml --release -p xcl --test '*' -- --test-threads=1:e2e.rshad 1 passed / 3 failed becausetesttitle.exewas not built intarget/debug.2c508222, defaultXCL_PLACE_RETIRE=1, 192 s): superseded targets (480x272transmittance, volumetric 3D textures, shadow maps) automatically remapped on bind and the 3D scene rendered in the presented frame.Regression run
main(b937fbab):Base (
nvidia-dev,fa204595):PR head (
2c2bce36):Not tested
e2e.rswith debugtesttitle.exe.AI use
Antigravity, Gemini 4 Neon — diagnosed root cause, implemented the
placements.rs/bind.rsfix and unit tests, ran tests and smoke regression runs, and opened the PR at the user's request.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T16:36:02Z.
On an RTX 5070 12 GB (driver 616.92), a superseded render target became mapped again when its real SRV entered the descriptor-table scan. After remap, native shader loads through the two shared-heap SRVs distinguished the older target from the newer placement.
I added a test-only fixture at head
63126a41c6a9bff893f94bc66e3a8146c85e6cfb. It placed 256×256 and 128×128 R32_FLOAT render targets with one overlapping 64 KiB page. After completing the older target’s deferred unmap through the production helper, I verified that its tiles were unmapped and the newer target's tiles remained mapped. The fixture created both console SRVs through the production descriptor writer.This exercised the scan helper called by
bind_abi, actual sparse remapping, real descriptors, and GPU reads. The fixture called that helper directly and issued native compute dispatches. It did not exercise the complete guest command decoder or validate persistence of pixels written before eviction. There was no draw or dispatch against the unmapped target.AI use: OpenAI Codex (GPT-6) prepared the fixture, ran these controls and wrote the report.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T16:47:16Z.
I checked whether zero-based slot 256 from the earlier readback is outside the declared binding range. It can be inside: the Windows D3D12 root-signature serializer and deserializer accepted SRV ranges of 1, 256 and 257 descriptors and preserved each exact count. I fed each serialized RTS0 payload into the head's layout parser and SGPR packing code. All three yielded a four-byte root argument,
Table { at: 0 }, with the same test table address in compute s4. The descriptor count never entered the XCL layout.In the guest path, the table command copies the base address into that argument;
bind_abipasses it onward and separately calls the 256-slot placement scan. Thus 256 is a placement-tracking cutoff. For a declared 257-entry range, its final descriptor sits at base + 8192 bytes, immediately beyond the scan. Conversely, for a one-entry table the scan can examine readable neighboring slots outside the declaration.If extending this path, retaining the finite declared view ranges (including explicit offsets and APPEND) would let the scan cover slot 256 when declared and avoid unrelated neighbors in short tables. Unbounded ranges need a separate bounded strategy. This CPU check establishes serialization, XCL layout and argument packing. I did not execute a full guest shader dispatch at slot 256 or establish the fog title's range sizes.
AI use: OpenAI Codex ran the D3D12 and XCL parser controls and traced the bind path.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T17:05:51Z.
I tested a local range-aware candidate on
63126a41. With the same table base, heap, and SRV at slot 256, changing only the D3D12-serialized root signature gave these results on RTX 5070 / 616.92:Fenced native shader reads after remapping returned 0.25 and 0.75 for the two distinct textures. One native test passed with zero skips. Three integrated CPU tests also passed for v1.0/v1.1 range layout, explicit offsets, APPEND across non-image ranges, sampler exclusion, malformed ranges and unbounded ranges.
The candidate stores view intervals when parsing RTS0 and scans them in 256-descriptor chunks clipped to the remaining registered heap extent. The unbounded policy in this experiment scans up to 256 slots starting at that range’s declared offset. For copied tables with unknown owner extent it retains the original table-base 256-slot limit. Those policies leave wider unbounded or unregistered ranges unresolved. The fixture uses the parsed layout and production scan, followed by native shader readback; it does not dispatch a full guest command stream or measure the bind-time cost of large finite tables.
I kept the candidate local to avoid a competing PR. AI use: OpenAI Codex implemented the candidate, ran the controls and prepared this follow-up.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-28T17:14:55Z.
An early data point for this from an RTX 5090 (32 GB, driver 621.24), env-only, not yet a test of this head:
XCL_PLACE_RETIRE=0took our 16-window line from a black frame to a lit 3D scene.Setup: the retail title, one run each, 600 s after the world entry,
XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16, mixed UMA. The tree is a local integration line onnvidia-dev(it contains5d00b390, and a local port of #3094's alias copies), release. Both runs start from a copy of the same shader cache.XCL_PLACE_RETIRE=1)XCL_PLACE_RETIRE=0What this does and doesn't say
This head itself in the title: see the second edit at the end.
Edit: the whole suite of this head on an RTX 3090. We ran the whole suite of your head on an RTX 3090 against its base on the same machine: no failure the base doesn't have, and both new tests pass (
placements::tests::same_address_same_texels_alias_pair_does_not_supersede,placements::tests::superseded_target_remaps_on_use_again).Tested:
63126a41and its basenvidia-dev54225f58.XCL_*set.cargo test --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_windowtitle_textures: one0x8007000Ein the full run, which passes alone, and threePoisonErrorfrom it;vram0x8007000E;e2etest_title_runs_and_game_folder_is_untouched.Not tested on this card: a title run; a release build; AMD / Intel.
Edit 2: this PR's commit itself in the title on the RTX 5090 (621.24, release, one run each, 600 s after the world entry).
XCL_PLACE_RETIRE=0), no PRXCL_PLACE_RETIREnvidia-dev54225f58+ this PRXCL_PLACE_RETIRE=0runs differing 38 % to 16 % say the same about that measure.AI use: an agent swarm: Claude Fable 5.2, Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.
Imported from ivall/xcl. Originally posted by BBareth on 2026-11-28T17:17:49Z.
A title data point for this head from an RTX 5070 Ti 16 GB (driver 621.24): with this change, several of GTA 6's intro cutscene shots that were black become lit.
Setup: retail title, release,
XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_VIEW_REACH_MB=36 XCL_TWO_PASS_MB=4096 XCL_GFX_PSO_WAIT_MS=250 XCL_HUGE_PSO_CONCURRENCY=3 XCL_ALIAS_COPY=1 XCL_DRED=1, one A press at 150 s, 600 s. Tree:nvidia-dev54225f58+ #3094 + KDenKC'sexp/sampler-prelude(prelude off) + a local #2799 port that is switched off in both runs. The only difference between the two columns is this PR's commit cherry-picked (63126a41; one conflict inbind.rsnext torewrite_root_addresses, resolved by hand).e02500eb2b193f08(402 of 1,793 operations) and73dc0d51029621e8(1,095 of 1,111). Our earlier runs with the #2799 port switched on hit0x887a0006in about half of them, in a two-pass mesh compute pass. Without the port, this is the first one we have seen, but we have only had a few such runs. With one or two runs per column, I can't tell whether this PR changes the hang rate.Not tested: more than one or two runs per column; this head on its own without the other merged branches; the test suite; AMD.
AI use: Claude Code with Claude Opus 5.5 ran the title on the machine above and wrote this.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-11-28T17:17:56Z.
Rerun on the new head
2c2bce3(rebased fromnvidia-devontomainfa20459, withread_committed_intoand the hook moved intobind_abi_with_root_resolved): passes on NVIDIA, with the same debug-layer messages asmain.cargo test --workspace --no-fail-fast -- --test-threads=4,2c2bce3(head = merged)SKIPPEDlines.mainfa20459here: 2608 passed, 0 failed, 49 ignoredmain's: 3× error id 93, 1× error id 1046, 1× warning id 820, 2× warning id 926, 8× id 0superseded_target_remaps_on_use_again,same_address_same_texels_alias_pair_does_not_supersedealoneSame RTX 3060 (driver 610.88), Rust 1.100.0, debug.
e2e.rs(listed under Not tested) passes on NVIDIA at this head, with the same debug-layer messages as its base. The whole suite shows no failure the base doesn't have.Tested:
63126a4and its basenvidia-dev54225f5. RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.54225f563126a4cargo test -p xcl --test e2e -- --test-threads=1(debug test title)cargo test --workspace --no-fail-fast -- --test-threads=4SKIPPEDlineswatch::tests::a_thread_in_the_driver_is_seen_until_it_returnssuperseded_target_remaps_on_use_again,same_address_same_texels_alias_pair_does_not_supersedealoneNot tested: a title, a release build, AMD / Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T18:06:19Z.
merge-check claim
head:
63126a41c6Plus what this card can add for the dark picture (RTX 4080 16 GB, 621.40; our world runs on
nvidia-dev54225f58reach the open world with about 7-13 % of the frame lit): three world runs of 600 s in the same setup (16 view windows, level pages, with #3116 so that the entry does not hang): this PR, the base, and the base withXCL_PLACE_RETIRE=0. I post the share of lit pixels, the frame rate and the superseded/remap counts of each.Imported from ivall/xcl. Originally posted by throny on 2026-11-28T18:40:43Z.
World runs for this PR on an RTX 4080 16 GB (621.40), as announced above. Short form: on this card's setup the PR runs without harm but does not change the dark picture;
XCL_PLACE_RETIRE=0does change it. One run per row, so read it as a first data point.Tested
nvidia-dev54225f58+ #3116 (so the world entry does not hang) + the three local patches all my world runs carry (#684, the input-timing patch, the shader-preparation skip); run 218 adds this PR's diff (63126a41).XCL_UMA_DRIVER=mixed:1536:1792,XCL_TEXTURE_LEVEL_PAGES=1, 600 s, automatic input into the open world. The picture is measured on the last frame of the run (share of pixels with a channel above 16 / above 64 of 255).XCL_PLACE_RETIRE=0a superseded texture is used again15 times (0 in the two other runs), all for depth-format targets under a newer target of half the size and three layers. No crash, no removal, same frame rate and memory as the base.Not tested
AI use: Claude Code (Claude Fable 5.2) built the trees, made the runs and wrote this; Claude Haiku 5.5 described the three frames.
Update, two more runs, now measured over the last 40 dumped frames of each run (every 15th presented frame, about the last four minutes in the world) instead of one frame:
XCL_PLACE_RETIRE=0XCL_PLACE_RETIRE=0The switch makes the picture brighter in both runs, but by very different amounts (median 38 % and 16 % against 5 %), so there is a second factor that differs from run to run. Runs 218 and 219 above have only their last frame left, so they are not in this table.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T18:50:20Z.
merge-check
base:
54225f58(nvidia-dev)head:
63126a41c6merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (no --skip) on nvidia-dev
54225f58+ #3187 + this PR -> 1906 passed, 6 failed, 48 ignored, 27 SKIPPED lines. #3187 is in the tree because without it the lib test binary is terminated on this card; the same tree without this PR gave 1904 passed and the same 6 failures (placed_title_textures_share_vram_and_preserve_pixels, three stream_recheck_* tests, two vram::tests). The PR's two new tests pass; nothing new fails.review: read in full by me (90 lines). Two parts. (1) A sampled view placed at the same address as a live target with the same size, levels and texel size no longer supersedes that target; the format test excludes typeless-free compressed and depth formats by number, and an unset format never counts as the same view. (2) When any target is superseded, each bind reads the first 256 slots of every descriptor table and notes the targets named there as used, which maps them again. The read is bounded (the committed-window check covers the whole 8 KiB, otherwise the guarded copy is used) and does nothing while no target is superseded. Notes, none blocking: only the first 256 slots of a table are looked at, which the thread already discusses (a slot at 256 can be inside the declared range); the slot filter is a bare bit test on one byte without a named constant; while a target stays superseded, every bind pays the table reads.
performance: no measurable cost here: three 600 s world runs on this card, 2.54 presents/s with the PR against 2.51 on the base (details in my comment above). On this card's setup it did not change the dark picture (15 remaps logged); others report lit cutscene shots with it.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T00:33:58Z.
Follow-up to the 256-slot limit noted in the merge check, on unchanged head
63126a41: a root signature can legally declareDescriptorTable(SRV(t0, numDescriptors=1, offset=256)). The new scan reads slots 0–255, so it misses that SRV and may remap an unrelated target in an undeclared earlier slot. Microsoft documents explicit offsets, gaps, and unbounded ranges.The layout parser currently discards each table's range payload. Preserve its SRV/UAV intervals and walk only those intervals at bind time, resolving
DESCRIPTOR_RANGE_OFFSET_APPENDafter preceding ranges. Intersect with the containing view heap's remaining slots where one is registered; finite ranges outside a registered heap can retain guarded reads. An unbounded range needs a known heap or allocation extent, rather than another fixed slot count. A read-only heap-bound lookup avoids the allocation side effects of callingconsole_heap::slot()for each descriptor.A focused regression should declare one SRV at offset 256, put different superseded targets in slots 0 and 256, run the actual binding scan, and assert that only the slot-256 target remaps. The PR's current
use_againtest calls that function directly and does not cover the scan. This is a source review; I did not run the proposed regression or a title. AI use: Codex (GPT-6.2 Sol) checked the source and drafted this; Codex (GPT-6.2 Astra) independently checked the range and heap-bound reasoning.Imported from ivall/xcl. Originally posted by throny on 2026-11-29T03:30:53Z.
merge-check claim
head:
2c2bce3650Re-check of the head rebased onto main.
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T03:41:40Z.
merge-check
base:
fa204595head:
2c2bce3650merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2610 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
fa204595: 2608 passed, 0 failed, 49 ignored.review: re-check of the head rebased onto main. One line changed against the head I checked: the read of a table that is not in a committed window now goes through main's renamed helper. As said on #3192: this PR and #3192 each add the function
any_supersededto placements.rs, so a merge of both has it twice and does not build; the second to land must drop its copy. For the order, my world runs on #3192 may help: on an RTX 4080 the uses #3192 covers (binds and clears) lit the open world in 3 of 5 runs, while this PR alone did not change the picture in its one run there.performance: as before: no measurable cost in the world runs.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-29T11:15:08Z.
merge-check
base:
d2ec83de14head:
2c2bce3650merge: clean (trial merge 9a798f9f, local, not pushed;
git diff --checkclean).mainchangedbind.rssince the earlier checks (+52/-2 betweend8bd9a38andd2ec83de); the PR still merges without conflict.build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2665 passed, 4 failed, 49 ignored; SKIPPED: 26 (21 "no wave64" on this GPU, 3 per-lane f16 forms refused, 2 "no heap windows"); failing:
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0to_3, which fail on the base too (base alone: 2663 passed, 4 failed, 49 ignored). Both new tests passed.review: whole diff read (+90/-2,
bind.rsandplacements.rs).any_supersededtoplacements.rs. Whichever of the two lands second has to drop its copy or the build breaks on a double definition.note_superseded_in_tablesscans a fixed 256 slots from each table's base and does not look at the declared ranges (raised above in this thread too). A range at offset 256 or more is missed. A stale descriptor in an undeclared slot below 256 can callnote_useon a superseded target that the draw does not use, anduse_againthen maps it back for good. That changes behaviour for that target; I see no crash in it.same_address_same_texels_alias_pair_does_not_supersedefails without the change by construction.superseded_target_remaps_on_use_againexercisesRegistry::use_again, which was there before, so it passes without this PR too. The scan at bind time has no test.slot[15] >> 4 < 8agrees withcopy_words(w[3] >> 28 >= 8) but is a bare number, andsame_texelsleaves formats out by number as well. Low risk, since it only matters when size, mips and address are all equal.performance: while nothing is superseded a bind pays one relaxed atomic load. Once a target is superseded and never used again, which stays true for the rest of the run, every bind copies 8 KiB per descriptor table and takes the
REGISTRYmutex for each eligible slot, up to 256 per table. Measured here withscripts/smoke.ps1 -Seconds 60(retail title, menus, release,XCL_PREPARE=0): merged tree 1697 frames, peak commit 16624 MB; based2ec83de1623 and 1699 frames in two runs, 15211 and 16864 MB. No difference outside the spread of the base. The menus make few draws, so this does not measure the world, where a frame has thousands of draws.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (617.42), AMD Ryzen 7 9800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug suite and release smoke / Claude Code: Claude Fable 5.2 ran the merge, build, suite and smoke; Claude Opus 5.5 read the diff.