Skip to content

D3D12.X: remap superseded targets bound through descriptor tables - #3179

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
Lakanya:fix/placements-descriptor-remap
Nov 29, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
Lakanya:fix/placements-descriptor-remap

Conversation

@Lakanya

@Lakanya Lakanya commented Nov 28, 2026 •

Copy link
Copy Markdown

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 by placements::note_use on ResourceBarrier or Copy* calls.

Two cases caused live UAV targets to remain unmapped and silently drop all writes (reading back as 0):

  1. A sampled alias placed at the exact same VA with the same texels (e.g. an R9G9B9E5 sampled view over an R32_UINT UAV target whose owned page range differs by a trailing page) produced Overlap::Around instead of Overlap::Same and superseded its own UAV target.
  2. Compute and graphics passes that bind a superseded target through descriptor tables without a per-resource ResourceBarrier (e.g. global UAV barriers) never triggered placements::note_use.

In a retail title, both cases hit the volumetric fog upsample outputs (480x272 R32_UINT/R9G9B9E5 inscatter and adjacent R10G10B10A2 transmittance), causing the fog apply pass to multiply the scene by 0.0 transmittance and black out the 3D frame. With this fix (default XCL_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:
    • Add Desc::same_texels and skip superseding when p.desc.format != 0 && p.va == old.va && p.desc.same_texels(&old.desc).
    • Export any_superseded() (single relaxed atomic load of SUPERSEDED).
    • Add unit tests same_address_same_texels_alias_pair_does_not_supersede and superseded_target_remaps_on_use_again.
  • crates/xcl/src/hle/d3d12x/bind.rs:
    • In bind_abi, when placements::any_superseded() is true, scan descriptor table slots (Param::Table) and call placements::note_use for 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):
    • 1776 passed, 4 failed, 28 ignored (21 GPU/env tests SKIPPED for no wave64 / #1426 / XCL_HEAP_WINDOWS=1 / Developer Mode; all 4 failures are pre-existing gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3; all hle::d3d12x tests including placements, bind, vram, title_textures, and uma_driver passed).
  • cargo test --manifest-path C:\XCL-pr1\Cargo.toml --release -p xcl --test '*' -- --test-threads=1:
    • 19 of 20 integration test binaries passed (73 passed, 0 failed, 4 ignored); e2e.rs had 1 passed / 3 failed because testtitle.exe was not built in target/debug.
  • Verified on retail title (2c508222, default XCL_PLACE_RETIRE=1, 192 s): superseded targets (480x272 transmittance, volumetric 3D textures, shadow maps) automatically remapped on bind and the 3D scene rendered in the presented frame.

Regression run
main (b937fbab):

xcl-smoke v1
commit: b937fbab2964b2c142f5d13662b91b00f99b9848
gpu: NVIDIA GeForce RTX 5070 Laptop GPU
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 217 (PresentX 218)
presents per 2 s (last 3): 9 8 7
device removals: 0
crashes: 0
peak commit: 16246 MB

Base (nvidia-dev, fa204595):

xcl-smoke v1
commit: fa204595a488c60c6c5f905244f0172072c9c2a9
gpu: NVIDIA GeForce RTX 5070 Laptop GPU
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1576)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 12877 MB

PR head (2c2bce36):

xcl-smoke v1
commit: 2c2bce36504a83b36ceece2abb8826855e2f9892
gpu: NVIDIA GeForce RTX 5070 Laptop GPU
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1512 (PresentX 1512)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13110 MB

Not tested

  • macOS / Linux (crate does not build on non-Windows).
  • e2e.rs with debug testtitle.exe.

AI use
Antigravity, Gemini 4 Neon — diagnosed root cause, implemented the placements.rs / bind.rs fix and unit tests, ran tests and smoke regression runs, and opened the PR at the user's request.

@andrewDoing

Copy link
Copy Markdown
Contributor

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.

  • With the older target’s SRV at zero-based slot 256, the scan left it unmapped, as expected from the 256-slot limit.
  • Advancing the table base by one 32-byte slot put the same SRV at slot 255. The scan remapped the older target.
  • After remap, native RTV clears supplied distinct values. A compute shader loaded texel (0, 0) through each descriptor's real shared-heap index. Fenced GPU readback returned 0.25 for the older target and 0.75 for the newer target in both fresh processes. Two passes, zero skips.

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.

@andrewDoing

Copy link
Copy Markdown
Contributor

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_abi passes 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.

@andrewDoing

Copy link
Copy Markdown
Contributor

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:

Declared SRV count Superseded target after the placement scan
1 Still unmapped
256 Still unmapped
257 Remapped

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.

@KDenKC

KDenKC commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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=0 took 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 on nvidia-dev (it contains 5d00b390, and a local port of #3094's alias copies), release. Both runs start from a copy of the same shader cache.

default (XCL_PLACE_RETIRE=1) XCL_PLACE_RETIRE=0
how far loading artwork, then black with the loading spinner; presents stop about 208 s in the 3D scene, presenting to the end
last frame 0 % lit 78 % lit: buildings, a tower, chairs, a table, lit sky
frames per second over the 596 s 0.6 5.3
crashes / device removals 0 / 0 0 / 0

What this does and doesn't say

  • It fits your description: with nothing superseded, the scene is no longer multiplied to black.
  • It is not one clean change. The second run's binary also has our input filter (keyboard and mouse can't reach the title), and it is one run per column. The first run also spent most of its time on first-use compute compiles (65 with no driver blob, 693 s), the second far less (57, 87 s), which we can't explain by the switch yet.

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: 63126a41 and its base nvidia-dev 54225f58.

  • RTX 3090 24 GB, NVIDIA 621.24, i7-10700T x8 (a VM with the GPU passed through), Windows 11 26H2 (26300.9974), Rust 1.99.1 (stable-x86_64-pc-windows-msvc), debug, no 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_window
    • Those three end the lib test binary on 621.24, at the base too.
  • base: 1,900 passed, 7 failed, 48 ignored; head: 1,902 passed, 7 failed, 48 ignored.
  • The 7 failures are the same tests on both, and they come from this VM:
    • 4 title_textures: one 0x8007000E in the full run, which passes alone, and three PoisonError from it;
    • 2 vram 0x8007000E;
    • e2e test_title_runs_and_game_folder_is_untouched.
  • SKIPPED: 30, the same on both.

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).

16 windows: env switch (XCL_PLACE_RETIRE=0), no PR 16 windows: this PR, default XCL_PLACE_RETIRE 4 windows: nvidia-dev 54225f58 + this PR
how far the 3D scene to the end the 3D scene to the end in the world, presenting
last frame 66 % lit 44 % lit 0 % lit, G-buffer targets all 0 %
frames per second 6.8 6.4 (6.8 without one 42 s first-use compile pause) 11.9
crashes / device removals 0 / 0 0 / 0 0 / 0
  • With 16 windows the PR gives the lit scene with the switch at its default, the same yard as the env-only run. Looked at by eye: a bright blocky shape at the right edge that both env-switch runs show is not there with the PR. One frame early in the PR's run looks double-exposed (buildings twice, offset); we have not looked into that.
  • With 4 windows it changes nothing for us: that frame is black because no geometry reaches the G-buffer there, a different cause.
  • Limits: the 16-window tree is the local integration line described above with this commit cherry-picked (it applied clean); the two 16-window runs started from caches one launch apart, so read the frame rate loosely; the lit share is of the last frame, and the camera is not in the same place in each run. @throny's two XCL_PLACE_RETIRE=0 runs 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.

@BBareth

BBareth commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

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-dev 54225f58 + #3094 + KDenKC's exp/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 in bind.rs next to rewrite_root_addresses, resolved by hand).

without with this PR, run 1 with this PR, run 2
end 600 s, no crash device removed at 310 s 600 s, no crash
"a superseded texture is used again" – 64 64
intro cutscene, the same shots near black (mean luma 0–5 of 255) – a lit night street with lamps and windows, a figure and a car behind the credits (mean luma ~10)
  • The 64 remapped targets are mostly format 53 at 1024², 512², 2048², and 256²×6 / 768²×6 arrays.
  • Not every shot is lit: some later crowd shots stay near black in both.
  • Run 1's removal (DRED page fault at VA 0): two lists were in progress in compute pipelines e02500eb2b193f08 (402 of 1,793 operations) and 73dc0d51029621e8 (1,095 of 1,111). Our earlier runs with the D3D12.X: GPU-only buffers placed outside the memory windows live in them #2799 port switched on hit 0x887a0006 in 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.
  • Video memory stayed over the process budget in both setups: 6.4 GB over at the end with the PR, 8.2 GB without.

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.

@fromthemoonx

fromthemoonx commented Nov 28, 2026 •

Copy link
Copy Markdown

Rerun on the new head 2c2bce3 (rebased from nvidia-dev onto main fa20459, with read_committed_into and the hook moved into bind_abi_with_root_resolved): passes on NVIDIA, with the same debug-layer messages as main.

result
cargo test --workspace --no-fail-fast -- --test-threads=4, 2c2bce3 (head = merged) 2610 passed, 0 failed, 49 ignored; 28 SKIPPED lines. main fa20459 here: 2608 passed, 0 failed, 49 ignored
e2e debug-layer messages, both debug-layer tests main's: 3× error id 93, 1× error id 1046, 1× warning id 820, 2× warning id 926, 8× id 0
superseded_target_remaps_on_use_again, same_address_same_texels_alias_pair_does_not_supersede alone 3 of 3 each

Same 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: 63126a4 and its base nvidia-dev 54225f5. RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.

54225f5 63126a4
cargo test -p xcl --test e2e -- --test-threads=1 (debug test title) 4 passed, 0 failed 4 passed, 0 failed
e2e debug-layer messages, both debug-layer tests 3× error id 93, 1× error id 1046, 1× warning id 820, 8× id 0 the same
cargo test --workspace --no-fail-fast -- --test-threads=4 1909 passed, 1 failed, 48 ignored (run for #3116) 1911 passed, 1 failed, 48 ignored; 28 SKIPPED lines
the 1 failure, watch::tests::a_thread_in_the_driver_is_seen_until_it_returns fails in that parallel run on the base too; passes 3 of 3 alone passes 3 of 3 alone
superseded_target_remaps_on_use_again, same_address_same_texels_alias_pair_does_not_supersede alone – 3 of 3 each

Not tested: a title, a release build, AMD / Intel.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 63126a4

Plus what this card can add for the dark picture (RTX 4080 16 GB, 621.40; our world runs on nvidia-dev 54225f58 reach 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 with XCL_PLACE_RETIRE=0. I post the share of lit pixels, the frame rate and the superseded/remap counts of each.

Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Nov 28, 2026
…dev#3179

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@throny

throny commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

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=0 does change it. One run per row, so read it as a first data point.

Tested

run tree presents/s in the world last frame: above 16 above 64 device removed
219 base 2.51 7.1 % 1.8 % no
218 base + this PR 2.54 6.0 % 0.7 % no
220 base, XCL_PLACE_RETIRE=0 2.44 42.1 % 7.5 % no
  • The PR's path ran: run 218 logged a superseded texture is used again 15 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.
  • What the frames show (looked at locally, not posted): 218 and 219 are nearly black with one small lit structure. 220 has clearly more lit geometry (flat light walls left and right, lit blocks), but the middle of the frame is still black and it is not a correct scene either.
  • So here the remap on use through a descriptor table is not what keeps the scene dark, while retiring superseded targets at all is part of it. That fits KDenKC's env-only result on the 5090 and suggests that on this setup targets are superseded that the title still reads through a path this PR does not see (root views? views made before the newer placement?). I did not look for which.

Not tested

  • More than one run per row, and more than one frame per run (the last frame is not the same camera position in each run); the intro cutscene shots BBareth reports; the whole suite on this head (next, for the merge check).

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:

run tree lit share (above 16): median, min–max above 64: median presents/s device removed
221 base 4.8 %, 1.5–12.2 1.2 % 2.44 no
220 base, XCL_PLACE_RETIRE=0 38.4 %, 26.4–42.7 6.3 % 2.44 no
222 base, XCL_PLACE_RETIRE=0 15.8 %, 2.1–20.4 5.5 % 2.36 no

The 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.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 54225f5 (nvidia-dev)
head: 63126a4
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (no --skip) on nvidia-dev 54225f5 + #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).

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up to the 256-slot limit noted in the merge check, on unchanged head 63126a41: a root signature can legally declare DescriptorTable(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_APPEND after 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 calling console_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_again test 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.

A target superseded by a newer overlapping placement (5d00b39) had its tiles unmapped (D3D12_TILE_RANGE_FLAG_NULL) and was only remapped by placements::note_use on ResourceBarrier or Copy* calls. Compute and graphics passes that bind a UAV/SRV texture through descriptor tables without a per-resource barrier (e.g. global UAV barriers) left the target unmapped, silently dropping UAV writes and returning zeros on reads.

Also avoid superseding a live target when a newer placement at the exact same VA has the same texels (e.g. an R9G9B9E5 sampled alias over an R32_UINT UAV target whose owned page range differs by a trailing page).

In bind_abi, scan descriptor table slots and call placements::note_use only when placements::any_superseded() is true (single relaxed atomic load on the fast path).

Assisted-by: Antigravity (Gemini 4 Neon)
@Lakanya
Lakanya force-pushed the fix/placements-descriptor-remap branch from 63126a4 to 2c2bce3 Compare November 29, 2026 01:09
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 2c2bce3

Re-check of the head rebased onto main.

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 29, 2026
@throny

throny commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: fa20459
head: 2c2bce3
merge: 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 fa20459: 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_superseded to 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).

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 29, 2026
@tiagonleal

tiagonleal commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: d2ec83d
head: 2c2bce3
merge: clean (trial merge 9a798f9f, local, not pushed; git diff --check clean). main changed bind.rs since the earlier checks (+52/-2 between d8bd9a38 and d2ec83de); 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_0 to _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.rs and placements.rs).

  1. D3D12.X: a superseded target the title binds, clears or moves is mapped again #3192 (open) also adds any_superseded to placements.rs. Whichever of the two lands second has to drop its copy or the build breaks on a double definition.
  2. note_superseded_in_tables scans 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 call note_use on a superseded target that the draw does not use, and use_again then maps it back for good. That changes behaviour for that target; I see no crash in it.
  3. Of the two tests, same_address_same_texels_alias_pair_does_not_supersede fails without the change by construction. superseded_target_remaps_on_use_again exercises Registry::use_again, which was there before, so it passes without this PR too. The scan at bind time has no test.
  4. The slot filter slot[15] >> 4 < 8 agrees with copy_words (w[3] >> 28 >= 8) but is a bare number, and same_texels leaves 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 REGISTRY mutex for each eligible slot, up to 256 per table. Measured here with scripts/smoke.ps1 -Seconds 60 (retail title, menus, release, XCL_PREPARE=0): merged tree 1697 frames, peak commit 16624 MB; base d2ec83de 1623 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.
  • Tiago

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Nov 29, 2026
@raylitebull
raylitebull merged commit b0b6169 into xcl-dev:main Nov 29, 2026
4 of 5 checks passed
raylitebull pushed a commit that referenced this pull request Nov 29, 2026
A target superseded by a newer overlapping placement (5d00b39) had its tiles unmapped (D3D12_TILE_RANGE_FLAG_NULL) and was only remapped by placements::note_use on ResourceBarrier or Copy* calls. Compute and graphics passes that bind a UAV/SRV texture through descriptor tables without a per-resource barrier (e.g. global UAV barriers) left the target unmapped, silently dropping UAV writes and returning zeros on reads.

Also avoid superseding a live target when a newer placement at the exact same VA has the same texels (e.g. an R9G9B9E5 sampled alias over an R32_UINT UAV target whose owned page range differs by a trailing page).

In bind_abi, scan descriptor table slots and call placements::note_use only when placements::any_superseded() is true (single relaxed atomic load on the fast path).

From #3179 (merge b0b6169). Adapted: bind.rs conflicted (this tree's bind_abi is not split into
bind_abi_with_root_resolved, and XCL_TRACE_SLOT's trace_table_slot sits where
the new function went). note_superseded_in_tables is added beside it and
called in bind_abi right after want_root_views, as upstream calls it there;
a table outside the committed window is read with title_textures::copy_readable
(pub(super) here; upstream's read_committed_into is private in this tree).
placements.rs applied as is.

(cherry picked from commit b0b6169)

Assisted-by: Antigravity (Gemini 4 Neon)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SJTheGreat06 pushed a commit to SJTheGreat06/xcl that referenced this pull request Nov 29, 2026
A target superseded by a newer overlapping placement (5d00b39) had its tiles unmapped (D3D12_TILE_RANGE_FLAG_NULL) and was only remapped by placements::note_use on ResourceBarrier or Copy* calls. Compute and graphics passes that bind a UAV/SRV texture through descriptor tables without a per-resource barrier (e.g. global UAV barriers) left the target unmapped, silently dropping UAV writes and returning zeros on reads.

Also avoid superseding a live target when a newer placement at the exact same VA has the same texels (e.g. an R9G9B9E5 sampled alias over an R32_UINT UAV target whose owned page range differs by a trailing page).

In bind_abi, scan descriptor table slots and call placements::note_use only when placements::any_superseded() is true (single relaxed atomic load on the fast path).

From xcl-dev#3179 (merge b0b6169). Adapted: bind.rs conflicted (this tree's bind_abi is not split into
bind_abi_with_root_resolved, and XCL_TRACE_SLOT's trace_table_slot sits where
the new function went). note_superseded_in_tables is added beside it and
called in bind_abi right after want_root_views, as upstream calls it there;
a table outside the committed window is read with title_textures::copy_readable
(pub(super) here; upstream's read_committed_into is private in this tree).
placements.rs applied as is.

(cherry picked from commit b0b6169)

Assisted-by: Antigravity (Gemini 4 Neon)
lnqigr pushed a commit to lnqigr/xcl that referenced this pull request Nov 29, 2026
A superseded target bound through a descriptor table is remapped when a draw
or dispatch binds the table (xcl-dev#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: the target kept no tiles,
its writes were dropped and its reads returned zeros.

The root signature's SRV and UAV ranges of each descriptor table (RTS0 1.0
and 1.1, appended and unbounded ones included) are now kept in the layout,
and the scan reads those ranges and nothing else. An unbounded range ends
with the view heap the table lies in (console_heap::view_heap_remaining_slots);
outside any view heap it has no known extent and is not read. CBV and sampler
ranges cannot name a placed target and are skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) ready-to-merge Has 2 independent safe merge-checks on current head (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants