Skip to content

D3D12.X: a sampled texture in the memory of a written one of another format is copied from it (XCL_ALIAS_COPY=1) - #3094

Open
imnicho wants to merge 2 commits into
xcl-dev:mainfrom
imnicho:alias-copy
Open

imnicho wants to merge 2 commits into
xcl-dev:mainfrom
imnicho:alias-copy

Conversation

@imnicho

@imnicho imnicho commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

With XCL_ALIAS_COPY=1, a sampled texture the title places in the memory of a written one of another format is copied from it on the GPU. A retail title reads its sky, its light probes and its bounced light through 59 such pairs; they were stale, and with the copies its room, sky and yard are lit. The default is unchanged (off).

Rebased onto main and reworked for it, with what the reviews asked for. Two commits on main 493dbd3dd: the rework, and what the reviews of that rework (as ee7196a76) asked for; the head is 8a28d3176. The old head 6396870e2 (on nvidia-dev) is what the reports below from before 1 December tested.

Plan comment: #1989 (comment)

What is in it

The title packs light as R9G9B9E5 into R32_UINT textures with unordered access (a compute program cannot store R9G9B9E5) and samples the same memory through R9G9B9E5 textures it places at the same addresses. On the console the two are one memory. Here the written one is GPU-owned (vram) and the sampled one is a texture of its own, kept in step with the title's memory (title_textures), which nothing writes.

New module hle/d3d12x/alias_copy.rs:

  1. The pairs. create_placed_resource_x tells it of every placed texture (three places: GPU-owned, kept in step, a resource of its own). A pair is a written texture (render target or UAV) and a sampled one at the same address with the same size, levels, layers and texel width and another format. Buffers, depth buffers, multisampled and block-compressed textures are not kept.
  2. When. Where the written texture leaves RENDER_TARGET / UNORDERED_ACCESS, as the PC list gets the transition in resource_barrier_x. On main that one place sees both a legacy ResourceBarrier and the title's enhanced barriers of list Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146, which barrier_groups (D3D12.X: translate list #146 enhanced barrier groups into legacy texture transitions #3287) makes transitions of and sends the same way. So the first version's own reading of the Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 groups is gone, and the copies are planned from the barriers as the PC gets them, after the console's state bits are dropped (@thehollowedone's first point). With XCL_BARRIER_GROUPS=0 the enhanced barriers move no texture and ask for no copy.
  3. The copy. Through a buffer made at the pair's first copy: each level and layer into the buffer by the written format's footprint and out of it by the sampled one's (list_x::texture_through_buffer, on the PC list past XCL's hooks). The two textures go to the copy states and back from the states the title's transitions left them in. The states are kept by subresource, so a texture the title moves level by level is copied like any other, each level moved from its own state (on ee7196a76 such a texture was left out: 4.7 % of the copies of @KDenKC's run below). On DIRECT and COMPUTE lists; on a COMPUTE list a copy is left out, and counted, when one of the two is in a state such a list cannot name (@KDenKC). No copy is recorded while a texture of the pair is between the two halves of a split transition, where D3D12 lets nothing touch it; such a copy is left out and counted (@thehollowedone).
  4. The buffer. It is made with the table's lock released, so plan of another pair does not wait for the PC's D3D12 (@andrewDoing). It goes with the pair: at the title's last release of one of its textures, late_release::hold_own (new) lets it go once every queue is past the work submitted before (@KDenKC). It also holds a reference to the sampled texture: the title's list names the written texture only, the copy XCL adds to it names the sampled one and the buffer too, and the title may release the sampled texture before it submits that list. Both go when the written texture goes (@thehollowedone).
  5. No read-back of the destination. main reads a texture the GPU wrote back into the title's memory. What a copy puts into the sampled texture gets no GPU writer in title_textures, so it is still not uploaded over and is not read back: XG lays R9G9B9E5 out in more bytes than the R32_UINT texture has under it (0x3c0000 against 0x384000 at 1280x720), and the read-back went over what the title keeps behind the pair. Found and fixed by @claudetools-gh in the comments; this is that fix with the question asked of the texture's own entry instead of the table of buffers.
  6. Off by default. With the switch off nothing is kept and each hook is one atomic load.

The pairs by address and shape and the copy through a buffer are @raylitebull's, from #1989.

Size: 7 files, 508 lines of code and 321 of tests. That is more than a PR should be; about 90 lines of it came with the reviews.

Not in it

  • States are kept in the order the title records its transitions, as barrier_groups keeps the states it starts from. A list recorded and never submitted, and two lists submitted in another order than recorded, are not told apart (@thehollowedone's second point, with the WARP regression that shows it). I have not changed that here: the title's own enhanced barriers name their layouts, and what XCL adds for the copy starts from the last state recorded, as barrier_groups does for a barrier from the undefined layout. @KDenKC has taken the submit-time state model on as PRs of its own, with @thehollowedone's cases as its tests, and will bring the alias copy's part back here as a suggestion.
  • A copy left out between the halves of a split transition is not made up for at the split's end.
  • Views by address (Create{ShaderResource,UnorderedAccess}ViewAtX at a written texture's address), CopyResource between format families, a copy back from the sampled texture, a skip of a copy whose written texture has not changed.
  • D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281 / D3D12.X: XCL_PAIR_PAGES=1 puts a GPU-owned texture on pages at an address its layout allows #3282 (shared pages, XCL_PAIR_PAGES=1) and the castable-format route @KDenKC describes are other ways to the same pairs; with pages shared the copy goes onto memory the view already has.

Tested

On this head (debug, RTX 5080 16 GB, driver 610.47, Windows 10 22H2):

  • cargo test -p xcl --lib -- --test-threads=1 alias_copy late_release: 13 passed, 0 failed, no SKIPPED line (the crate's outputs cleaned first: see the note under "Not tested").
  • cargo test -p xcl --lib -- --test-threads=4 gives no count on this PC: plain main (d0832e614) ends the test process partway here. After 1,376 tests alloc_pool::tests::a_reset_that_puts_the_allocator_aside_keeps_what_the_gpu_still_reads fails and the process stops with sparse upload preparation still failed after bounded retries – the title is stopped before its GPU submission (exit 0x80004005); one test at a time (--test-threads=1 hle::d3d12x) it stops the same way in sparse::tests::a_buffer_over_a_remapped_tile_reads_the_new_page after 739 tests. I did not run this head past that; CI has the whole suite.

The tests:

  • gpu_a_written_textures_texels_reach_its_sampled_pair_at_the_titles_barrier (WARP): an R32_UINT array texture with unordered access, 70 layers and two levels (140 parts) holds a different value in every texel. The title's own call is made on an adopted list: uav_barrier_x with one D3D12_BARRIER_GROUP whose texture barrier takes it from unordered access to shader resource. After it the R9G9B9E5 pair, read back, holds the same bits in every level of every layer. Then the written texture is released as a title does: no entry is left for the pair, and once the queues are past it the buffer's reference count falls to the test's own and the sampled texture loses the buffer's reference.
  • a_written_textures_transition_out_of_a_written_state_asks_for_the_copy: what asks and what does not (a transition into a written state, the first half of a split one, the sampled one's, UAV and aliasing barriers), the states followed level by level, and the copy's moves for a texture in one state and for one whose levels differ.
  • no_copy_is_recorded_between_the_halves_of_a_split_transition: @thehollowedone's schedule (the sampled texture's split begins, the written one leaves unordered access, the split ends): the copy asked for in between is left out, and after the end one may be recorded again.
  • a_copy_starts_from_states_the_list_can_name: what a copy can start from on a DIRECT and on a COMPUTE list.
  • a_sampled_texture_in_the_memory_of_a_written_one_of_another_format_is_its_pair: the pairs.

In the title, on this head: not run by me (see "Not tested"). What there is:

Regression run

scripts/smoke.ps1, 60 s, XCL_PREPARE=0, each built in release from a clean worktree. The switch is off in these runs, as it is by default.

main (d0832e614):

xcl-smoke v1
commit: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1560 (PresentX 1560)
presents per 2 s (last 3): 62 62 62
device removals: 0
crashes: 0
peak commit: 12450 MB

This PR (8a28d3176), its second run (the first run of a new binary fills its caches and is not kept, as for main):

xcl-smoke v1
commit: 8a28d31764071ad8cbfc7021d6d1d987e3745b11
gpu: NVIDIA GeForce RTX 5080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1505 (PresentX 1505)
presents per 2 s (last 3): 63 61 60
device removals: 0
crashes: 0
peak commit: 12738 MB

Not tested

  • The title's world on this head. This PC's caches are of the nvidia-dev tree, and main builds every pipeline anew; the 60 s runs above do not reach the world. A run of mine on main with this head will follow as a comment.
  • The module with D3D12.X: translate list #146 enhanced barrier groups into legacy texture transitions #3287's real transitions in a title: on nvidia-dev the textures stayed in the states they were made in. The unit and WARP tests cover the states; a title's lists on DIRECT and COMPUTE queues in the order it submits them are not covered (see "Not in it").
  • A COMPUTE list's copy on a GPU, volumes and cubes on a GPU in this PR's test (it copies a 2D array; @andrewDoing's reports have a volume on an RTX 5070 on the first version).
  • AMD and Intel GPUs, Linux / Wine. The D3D12 debug layer is not available on this PC.
  • The integration test binaries of crates/xcl/tests (each d3d12_* one takes about 9 minutes here).
  • A note on my own numbers: I build several worktrees into one target folder, and today cargo twice called a test binary of another worktree up to date. Every count on this page is from a build whose log names this worktree as compiled, with the crate's outputs cleaned first.
  • The copies' cost in frame time.

AI use

Claude Code with Claude Fable 5.2 wrote the code and the tests, ran the suite and the regression runs, and wrote this description.

🤖 Generated with Claude Code

@imnicho

imnicho commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

CI: the "Build and test" job's one failure is not in this PR's code. The run shows 1781 passed, 1 failed, 28 ignored. The one is hle::kernelx::tests::a_page_whose_move_fails_stays_mapped_where_it_was (kernelx.rs:4161), a test of page moves this PR does not touch; it passed in my local run of the library suite on the same head (1778 passed, 0 failed) and #2773 is open about the address it uses. This PR's 4 tests pass in the CI run, the WARP one included.

AI use: Claude Code with Claude Fable 5.2 read the CI log and wrote this.

@andrewDoing

Copy link
Copy Markdown
Contributor

I tested larger synthetic shapes on RTX 5070 / NVIDIA 616.92 at head 839b33a1, using a test-only extension of the enhanced-barrier alias-copy fixture. Each run paired an R32_UINT written texture with an R9G9B9E5 sampled texture, used distinct words across the data, and fenced the GPU readback.

Shape Planned jobs Recorded / refused Readback
40×23, 64-layer 2D array, 1 mip (64 subresources) 1 1 / 0 58,880 / 58,880 words matched
Same array, 2 mips (128 subresources) 1 0 / 1 72,960 / 72,960 words mismatched
40×23×64 3D volume, 2 mips (2 subresources) 1 1 / 0 65,920 / 65,920 words matched

The two-mip array hits make_through's parts > 64 limit. As a diagnostic only, changing that limit to 128 let the same array case record and all 72,960 words match. That isolates the observed refusal, but it does not establish that 128 is the right production budget or that the title uses a 64-layer, two-mip pair. The title report lists 64-layer/slice pairs and multi-mip pairs without establishing that they are the same pair.

All focused GPU runs completed without skips and the device remained healthy. No retail title, GPU memory budget, or timing was measured.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

@KDenKC

KDenKC commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

@imnicho, thanks for this. We ported raylitebull's amd-dev format_alias.rs onto nvidia-dev locally for the same R32_UINT -> R9G9B9E5 problem, so here's what that taught us, read against 839b33a1. On an RTX 5090 that port took the HDR lighting target, the luminance chain and the final target from black to lit (sky, sun and fog; our G-buffer is still empty for the separate view-window reason in #505). So we expect yours to do the same here, and we'd rather add to this PR than open a second one.

One thing that looks like a defect:

  • Table::gone (alias_copy.rs:96) only grows. forget pushes every departed pair's Through into it (:190-191), and nothing ever drains it, so each pair the title tears down keeps its copy buffer for the life of the process. Keeping them while a list in flight may name them is right. Releasing them once the fence of the last list that recorded a copy with them has passed (or on the next list reset after forget) would bound it.

Coverage differences, as possible follow-ups on top of yours, not changes this PR needs:

  • Pairs are only found through create_placed_resource_x (the three note_created calls). The amd-dev version also catches readers made with Create{ShaderResource,UnorderedAccess}ViewAtX at the written texture's address. We haven't measured how many of this title's reads take that path.
  • It skips a copy when the written texture hasn't changed since the last one (a per-pair activity stamp).
  • On COMPUTE lists it checks that the state it transitions from is valid on that list type before recording. If a pair is copied on a compute list here, the transition from 0xC0 may need the same guard; we haven't seen it hit.

Checked and fine: the split-barrier test is bitwise (b[1] & BEGIN_ONLY, :229), so the console hint bits that #3090 now keeps don't break it. That was the one place our own rebase onto 54225f58 needed a fix.

We're glad to send any of the follow-ups as small PRs stacked on this one if you'd like them.

AI use: an agent swarm: Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.

@DarkPanda69

DarkPanda69 commented Nov 28, 2026 •

Copy link
Copy Markdown

Update for head 6396870 (the limit of 64 parts removed): same command, same merge-base, 54 passed, 0 failed, 0 ignored, no SKIPPED with XCL_ADAPTER=Radeon and with =3060, and no result changes from 839b33a. The 70-layer test still runs on WARP, so the same caveat applies.

Run on an RX 9070 XT and an RTX 3060 in the same PC: the four new tests pass, and nothing in list_x changes. But the GPU test runs on WARP, so this isn't AMD hardware coverage of the copy.

Tested: at the PR head 839b33a against its merge-base with nvidia-dev, 01b94f5 (the diff doesn't apply as a patch on today's nvidia-dev 54225f5). Debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X. RX 9070 XT driver 32.0.32029.2010; RTX 3060 driver 32.0.16.1088.

  • cargo test -p xcl --lib -- hle::d3d12x::alias_copy hle::d3d12x::list_x::tests:: --test-threads=1 --nocapture, once with XCL_ADAPTER=Radeon and once with =3060: merge-base 50 passed, 0 failed (list_x only, since alias_copy is new); PR 54 passed, 0 failed, 0 ignored, no SKIPPED, both times.
  • The only changes are the four new alias_copy tests, all ok.
  • gpu_a_written_textures_texels_reach_its_sampled_pair_at_the_enhanced_barrier builds its device on EnumWarpAdapter, so it ran on WARP both times, not on either card. If you want a hardware data point for the copy, I can run that test on the RX 9070 XT and the RTX 3060 with the device swapped to the XCL_ADAPTER card.

Not tested: XCL_ALIAS_COPY=1 in a title, the whole suite, Intel.

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

@imnicho

imnicho commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@andrewDoing thank you, that was a real hole: the limit of 64 parts was an arbitrary one of mine, and a pair past it was silently left stale (counted under "pairs that cannot be copied", nothing more). The head is now 6396870e2: the limit is gone, and the PR's own WARP test is an array of 70 layers with two levels (140 parts) instead of two levels of one layer. In the title's runs that counter stayed at 0, so none of its 59 pairs was past 64. The description has the new head's smoke block; the library suite's counts are from the commit before (839b33a1f), with the module's 4 tests run again on the head.

AI use: Claude Code with Claude Fable 5.2 made the change and wrote this.

@andrewDoing

Copy link
Copy Markdown
Contributor

I reran the three native RTX 5070 / NVIDIA 616.92 alias-copy controls from my earlier report on updated head 6396870e2184c80b7fa0404edf419d2f8ee262e1, using the same test overlay and production enhanced-barrier planner/recorder.

  • 64-layer 2D array, two mips: 1 recorded / 0 refused, all 72,960 / 72,960 words matched. The earlier head recorded none, refused one, and all words mismatched.
  • 64-layer array, one mip: 58,880 / 58,880 matched.
  • 64-deep 3D volume, two mips: 65,920 / 65,920 matched.

All three fenced readbacks passed without skips. This validates the synthetic subresource boundary and controls; the title's use of the exact two-mip array shape, performance, and memory budget remain unmeasured.

AI use: OpenAI Codex with GPT-6.2 Astra ran the tests; Codex reviewed and prepared this report.

@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 54225f5 (nvidia-dev)
head: 6396870 (6396870)
merge: clean, five files, +675/-2

Independent Windows check: cargo build --offline --locked -j 4 --workspace passed on the merged tree. With XCL_ALIAS_COPY=1, cargo test --offline --locked -j 4 -p xcl --lib alias_copy::tests -- --nocapture --test-threads=1 passed 4/4, no skips. The full cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 ran on both trees: head merged onto base 1,911 passed / 3 failed / 48 ignored, base 1,907 passed / 3 failed / 48 ignored. Both printed 26 explicit SKIPPED notices, which are included in Cargo's passing counts. The same three library tests failed on both: console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, a_held_submit_goes_on_when_the_hold_ends_and_at_once_inside_a_timed_call, and a_thread_in_the_driver_is_seen_until_it_returns. These failures do not distinguish this PR from the base.

verdict: not yet

Review verdict: not yet. I traced two state mismatches in the opt-in path. These are source-level findings; I have not run a GPU regression for either boundary.

  1. Legacy planning sees raw console barriers before texture states are normalized. For a texture transition 0x8 -> 0xC1, the native list receives 0x8 -> 0xC0 after the buffer-only 0x1 is removed, but alias-copy state tracking retains 0xC1. Its injected copy then requests a transition from the state the native barrier never established. Plan from the normalized out barriers instead, before other features mutate that vector. A WARP debug-layer test should call the actual resource_barrier_x path and execute the following copy with this state combination.
  2. The planner updates Tex.now globally while recording. Recording a transition on list A and then resetting A without submission still changes the state used to build the injected transitions on list B. For example, an unsubmitted COPY_DEST -> COPY_SOURCE leaves the GPU in COPY_DEST, while the planner would use COPY_SOURCE as B's before-state. Keep pending states with the recording list, discard them on reset, and commit them in queue submission order. A two-list reset/cancel test under the debug layer would guard this lifecycle.

The PR's WARP fixture verifies its copy path; this check did not measure title visuals, title performance, or paired smoke. Hardware: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), rustc 1.99.1. AI use: Codex (GPT-6.2 Sol) ran the builds and tests and checked the source paths; Codex (GPT-6.2 Astra) independently reviewed the state invariants.

@upipibi

upipibi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Test report for #3094 on NVIDIA: the whole workspace suite on this PR merged onto today's nvidia-dev and on nvidia-dev alone, and the PR's own tests 3 times by name.

Tested

  • Base: nvidia-dev 54225f5884a94cd23b7aab3f703a7c975070aa77. Head: 6396870e2184c80b7fa0404edf419d2f8ee262e1. git merge --no-ff of the head onto the base: clean, no conflicts (list_x.rs auto-merged); the merge (d6fa58fc, local) differs from the base by 5 files, +675/-2.

  • RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11 Pro 10.0.26100, Rust 1.100.0 MSVC, debug. Each tree in its own worktree and target dir; XCL_ALIAS_COPY not set.

  • cargo build --workspace and cargo build --workspace --tests: both exit 0 on both trees, 9 and 10 warnings, the same count as the base.

  • cargo test --workspace --no-fail-fast -- --test-threads=4, once on each tree. On both trees the xcl library binary stopped partway through, before printing its result. It exited with code 130088963 (0x7C10003) after D3D12.X: coherent window could not be restored at ... (268435456 bytes, got 0x0, Windows error 487) after CreateCommandQueue: ... (0x8007000E); stopping before guest memory is used, which a uma_driver mixed-window test prints. The other 39 result lines:

    • merge: 132 passed, 0 failed, 20 ignored, 26 SKIPPED lines;
    • base: 132 passed, 0 failed, 20 ignored, 26 SKIPPED lines; the same per-binary results as the merge.
    • Before the stop, the library binary printed 4 FAILED lines on the merge and 5 on the base: the 4 title_textures tests below on both, plus hle::d3d12x::list_x::tests::mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares on the base only. That test passed in the base's 3 library re-runs and 3 of 3 times alone, and it passed in the merge's run.
  • Because of that stop, the library binary was run again on each tree with the two mixed-window tests skipped: cargo test -p xcl --lib -- --test-threads=4 --skip hle::d3d12x::uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip hle::d3d12x::uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment:

    • merge: 1774 passed, 6 failed, 28 ignored (2 filtered out), 26 SKIPPED lines;
    • base: 1770 passed, 6 failed, 28 ignored (2 filtered out), 26 SKIPPED lines, the same in 3 runs.
    • The 6 failures have the same names on both trees: hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, …stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, …stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, …stream_recheck_schedule_catches_late_writes_and_resets_milestones, hle::d3d12x::vram::tests::d32s8_targets_take_their_own_size_of_video_memory and …gpu_retire_queue_holds_heap_until_blocked_queue_passes_mark. Three panic on 0x8007000E (E_OUTOFMEMORY) from a D3D12 call, and the other three stream_recheck_* ones on a PoisonError after those panics. All 6 pass alone, one at a time, 3 of 3 times on the base.
    • The two skipped mixed-window tests pass alone on both trees: 2 passed, 0 failed, 3 of 3 times each (--exact --test-threads=1).
    • Together with the other 39 result lines of the workspace run: merge 1906 passed, 6 failed, 48 ignored, base 1902 passed, 6 failed, 48 ignored. The difference of 4 is the PR's new tests: the merge lists 1810 library tests, the base 1806.
  • The 26 SKIPPED lines are the same on both trees: 21 "no wave64", 3 f16/f32 per-lane forms refused after gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426, 1 "no heap windows", 1 "cannot disable the driver cache".

  • None of the 9 tests in main e429936 on NVIDIA: 3 e2e title tests and 6 split-wave64 GPU tests fail since #2959 #3093 fail here. The 5 split-wave64 tests present on nvidia-dev and the 3 e2e title tests pass on both trees; gpu_heap_flat_reads_match_guarded_and_root_output is not in nvidia-dev's test list.

  • The PR's own tests, by exact name, 3 runs: cargo test -p xcl --lib -- <the 4 names> --exact --test-threads=1 --nocapture. 4 passed, 0 failed, 0 ignored in each of the 3 runs, 0 SKIPPED lines:

    • hle::d3d12x::alias_copy::tests::a_sampled_texture_in_the_memory_of_a_written_one_of_another_format_is_its_pair
    • hle::d3d12x::alias_copy::tests::a_written_textures_transition_out_of_a_written_state_asks_for_the_copy
    • hle::d3d12x::alias_copy::tests::an_enhanced_barrier_of_a_written_texture_asks_for_the_copy
    • hle::d3d12x::alias_copy::tests::gpu_a_written_textures_texels_reach_its_sampled_pair_at_the_enhanced_barrier

    The GPU test's fixture makes its device on WARP (EnumWarpAdapter), so these runs do not test the copy on the RTX 3070 itself.

Not tested

  • No xcl-smoke block: no title was run.
  • XCL_ALIAS_COPY=1: every run here had the switch unset.
  • The PR's GPU test on the RTX 3070 rather than WARP.
  • A release build, AMD or Intel GPUs, Linux / Wine.

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

@minimalhipster990

Copy link
Copy Markdown

RTX 4090, Series X profile, clean head 6396870e2184c80b7fa0404edf419d2f8ee262e1. The courtyard reaches the G-buffer and the swapchain on the unmodified PR executable. With alias copies enabled, the log reaches at least 16,384 enhanced-barrier copies and zero legacy copies at that checkpoint.

Copies off/on at the same 50 ms graphics wait. I matched the first three heavy frames using features in the base-color dump, then compared the format-10 FP16 target on pixels where the aligned base colors agreed within 8/255 in every channel. In the first pair (BMP 1908 off / 1899 on), 157 features agreed with 0.05-pixel median residual at 640×360. Both HDR targets ran 168 draws, with 487/486 stand-ins off/on. Across 60,341 matching scene pixels the median brightness in XCL’s tone-mapped 8-bit HDR preview was 0 off / 182 on. Both final images were still nearly black. The next two matched HDR pairs gave 0 / 177 and 0 / 191. By the third pair (1910 off / 1901 on), the median of the whole presented image was 21 / 197. The off image shows a dark yard with a few lights. With copies on, people and tables are visible in bright haze. This supports the courtyard lighting change on Ada. Exposure and geometry are still visibly broken. The cell interior and the copies' frame-time cost remain unmeasured here.

Getting past the loading artwork. I used the same checkpoint, A presses at 25/30/35/40/62/64 s and a fresh verified copy of the same populated XCL cache (4,946 files) for each 360 s run. With copies on and the default graphics pipeline wait, the last interval with a present ended at 116.07 s. One thread spent 241.62 of the remaining 243.93 s inside 59 logged graphics pipeline waits. With just XCL_GFX_PSO_WAIT_MS=50 changed, the recorder completed a world frame at 152.91 s. Earlier cold-cache (395 s) and populated-cache (600 s) off/on pairs with the default wait had also ended with loading artwork as their last sampled image.

Where the world first appears. In capture_1900/frame.jsonl, stream entry 1104 is the first recorded indirect mesh dispatch, writing 2560×1440 depth. Entry 22539 is the first recorded mesh dispatch with six 2560×1440 color targets (formats 29/28/28/28/34/28). Both ran on lists submitted to the queue of PresentX 1900. Three earlier list references have missing or partial recordings. In the corresponding BMP sample 1899, courtyard tables and figures are already visible in the base color and HDR target while the final image is black. Sample 1901 presents the courtyard with strongly overexposed lighting. The capture also contains 291 stand-ins, 347 deferred and 450 skipped operations out of 19,406 recorded draws/dispatches.

Reproduction settings. Windows 11 build 26300, RTX 4090 24 GB, NVIDIA 621.40, Ryzen 7 5800X3D, 32 GB RAM. XCL_DEVICE_TYPE=anaconda XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_DIRECT_DXIL=1 XCL_COHERENT_MB=3990 XCL_COHERENT_HEAPS=sparse XCL_TEXTURE_LEVEL_PAGES=1 XCL_PAGE_BUDGET_MB=1024 XCL_VIEW_POOL_MB=1024 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072. Capture used XCL_CAPTURE_FRAME=500,80 XCL_DUMP_TARGETS=500,3,8 XCL_DUMP_AFTER_S=80 XCL_FRAME_DUMP=12. Network and preparation were disabled. The NVIDIA driver cache remained driver-managed. The 50 ms pair completed 360 s with 2,417 frames shown off and 2,361 on, both exit 0 with no logged device removal. This report covers the retail title.

OpenAI Codex (GPT-6) assisted with building the head, running the title, verifying the traces and images, and writing this report.

@vasanex

vasanex commented Nov 28, 2026

Copy link
Copy Markdown

Test report for 6396870e2 on an RTX 3080: the copy lights the world here, and gives a better picture than sharing the memory, which we had tried.

Tested

neither XCL_ALIAS_COPY=1 (this PR) shared memory (local)
world reached at 513 s 510 s 537 s
logged – 32 or more pairs, 8192 or more copies at enhanced barriers, 0 at legacy transitions, 0 left out (the lines are logged at powers of two) 32 sampled textures on the tiles of their written ones, 5 volumes by the first description's size
the world's picture dark: only what the sun hits directly, black sky (mean of the settled frames 6 of 255) lit: room, yard, blue sky (mean 35) lit: room darker, yard and sky brighter and hazier (mean 50)
presents in the last 60 s 72 74 74
local video memory at the end 7490 MB 7777 MB 7527 MB
device removals / crashes 0 / 0 0 / 0 0 / 0

The copy does what the description says on this card: the same scene goes from black with sunlit edges to a lit room and sky, at the same frame rate (about 1.1 presents a second in the world in all three runs; the frame is bound elsewhere). A first run with the copy on reached the world at 449 s, fell back to the title's loading screen after about a minute and crashed at 689 s when the title read a page XCL had moved to its other mapping 207 ms before (the limit of #1031); the copy was at work in it too (1024 or more copies), and I have no sign that it had a part in that.

For comparison: one memory for both. Before finding this PR we had the same pairs dark on this card and tried the console's own arrangement locally: the sampled texture is given the video-memory tiles of the written texture at its address (a written texture at an address off the 64 KiB pages is still put on the title's shared pages, and a sampled texture of the same shape placed there later is mapped to the same tiles), so nothing is copied. That is the table's third column. It lights the scene too, but the picture is worse than with this PR's copy: through the window the copy gives a clear sky gradient, a sharp fence and tower and a plant on the sill, where the shared memory gives a washed-out, hazy view, dot patterns on the window frame and no plant. With both on (the sharing takes the 2D pairs, the copy is left with 5 to 7 pairs, the 40x23x64 volumes among them) the picture is the hazy one again. So on this card the copy is the better of the two, and sharing tiles between the two formats is not the same thing as it looks on paper; I have not found out why (the tile shapes of the two formats, or the moment a pair's content is taken).

Not tested

  • AMD and Intel GPUs; other titles; main.
  • The cost of the copies per frame beyond the presents counted above.

AI use

  • Claude Code (Claude Fable 5.2) wrote the local sharing change used for the comparison, ran the tests and the title runs and drafted this report.

@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to my merge check, item 2, on unchanged head 6396870e: list-local state alone would not finish the fix. If list A records a sampled-texture transition and list B records an alias copy before A is submitted, B's copy barriers are already encoded from the state A wrote into the global Tex.now. Submitting A later, or resetting A without submitting it, cannot rewrite B's barriers. plan updates that global value while recording; record reads it when it emits the native barriers. The later visual reports do not exercise this ordering.

A focused regression can use two adopted DIRECT lists and independent allocators on WARP with the D3D12 debug layer: record a sampled-texture transition on A, then record the enhanced-barrier copy on B, reset A without submission, and submit only B. The native before-state encoded for B should match the state the device actually has; inspect ID3D12InfoQueue and a fenced readback. Also run the control with A submitted before B is recorded. The eventual state owner needs to account for recording, successful reset, and actual submission order (including kickoff segments); otherwise a cached global or list-local state can still describe work the GPU never executed. This is a source-level follow-up; I have not run this two-list GPU regression.

Measured WARP follow-up on the same head. Windows 11 build 26300, WARP software adapter with Graphics Tools debug layer (host RTX 3080 Ti / NVIDIA 621.35), rustc 1.99.1. The temporary regression records the sampled texture's shader-read → COPY_SOURCE transition through resource_barrier_x on adopted list A, closes and resets A without submitting it, then uses the PR's enhanced-barrier planner and native copy recorder on list B. Only B is submitted and fenced. With XCL_ALIAS_COPY=1, cargo test --offline --locked -j 4 -p xcl --lib gpu_reset_list_does_not_change_another_lists_alias_copy_before_state -- --nocapture --test-threads=1 failed 0/1/0 on unchanged head. ID3D12InfoQueue reported B's barrier before-state 0x800 (COPY_SOURCE) while the texture remained in 0xC0 (shader read). With the test-only XCL_ALIAS_SUBMIT_A_CONTROL=1, A was submitted and fenced before B was recorded; the same test passed 1/0/0, with no error or skip. The PR's stock gpu_a_written_textures_texels_reach_its_sampled_pair_at_the_enhanced_barrier WARP fixture also passed 1/0/0 with the switch on. The diff below is a temporary regression only, not a production fix. I did not run the full workspace suite or paired title smoke on this test overlay.

Temporary two-list WARP regression diff
diff --git a/crates/xcl/src/hle/d3d12x/alias_copy.rs b/crates/xcl/src/hle/d3d12x/alias_copy.rs
index 50e68b76..ab193813 100644
--- a/crates/xcl/src/hle/d3d12x/alias_copy.rs
+++ b/crates/xcl/src/hle/d3d12x/alias_copy.rs
@@ -508,6 +508,89 @@ mod tests {
         forget(r);
     }
 
+    #[test]
+    fn gpu_reset_list_does_not_change_another_lists_alias_copy_before_state() {
+        use super::super::real::{adopt, Kind};
+        use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0;
+        use windows::Win32::Graphics::Dxgi::{CreateDXGIFactory1, IDXGIAdapter, IDXGIFactory4};
+        unsafe {
+            let skip = || crate::gpu::recomp::runner::skip_test("no WARP device or D3D12 debug layer");
+            let Ok(debug) = crate::gpu::agility::configuration_interface::<ID3D12Debug>(&CLSID_D3D12Debug) else { return skip() };
+            debug.EnableDebugLayer();
+            let Ok(factory) = CreateDXGIFactory1::<IDXGIFactory4>() else { return skip() };
+            let Ok(warp) = factory.EnumWarpAdapter::<IDXGIAdapter>() else { return skip() };
+            let mut device: Option<ID3D12Device> = None;
+            if D3D12CreateDevice(&warp, D3D_FEATURE_LEVEL_11_0, &mut device).is_err() { return skip() }
+            let dev = device.unwrap();
+            let q: ID3D12InfoQueue = dev.cast().expect("debug info queue");
+            let queue: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: D3D12_COMMAND_LIST_TYPE_DIRECT, ..Default::default() }).unwrap();
+            let a_alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap();
+            let b_alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap();
+            let a: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &a_alloc, None).unwrap();
+            let b: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &b_alloc, None).unwrap();
+            let (written_desc, sampled_desc) = (texture(42, 16, 8, 1, 4), texture(67, 16, 8, 1, 0));
+            let committed = |desc: &D3D12_RESOURCE_DESC, state: D3D12_RESOURCE_STATES| {
+                let mut out: Option<ID3D12Resource> = None;
+                dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_DEFAULT, ..Default::default() }, D3D12_HEAP_FLAG_NONE, desc, state, None, &mut out).unwrap();
+                out.unwrap()
+            };
+            let read = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
+            let written = committed(&written_desc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
+            let sampled = committed(&sampled_desc, read);
+            let (w, r) = (written.as_raw() as usize, sampled.as_raw() as usize);
+            let va = 0x7AC0_0000_5000usize;
+            keep(dev.as_raw() as usize, w, va, &written_desc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS.0 as u32);
+            keep(dev.as_raw() as usize, r, va, &sampled_desc, read.0 as u32);
+            for (list, alloc) in [(&a, &a_alloc), (&b, &b_alloc)] {
+                adopt(list.as_raw(), Kind::CommandList);
+                super::super::list_x::on_create(list.as_raw(), alloc.as_raw() as usize, 0, D3D12_COMMAND_LIST_TYPE_DIRECT);
+            }
+            q.ClearStoredMessages();
+
+            // A's transition is discarded; only B runs on the native queue.
+            let tr = [0, 0, r as u32, (r as u64 >> 32) as u32, ALL, read.0 as u32, COPY_SOURCE, 0];
+            super::super::list_x::resource_barrier_x(a.as_raw(), 1, &tr);
+            let close: unsafe extern "system" fn(*mut c_void) -> i32 = std::mem::transmute(*(*(a.as_raw() as *const *const usize)).add(9));
+            assert!(close(a.as_raw()) >= 0);
+            if std::env::var_os("XCL_ALIAS_SUBMIT_A_CONTROL").is_some() {
+                let raw = a.as_raw();
+                let execute: unsafe extern "system" fn(*mut c_void, u32, *const *mut c_void) = std::mem::transmute(*(*(queue.as_raw() as *const *const usize)).add(10));
+                execute(queue.as_raw(), 1, &raw);
+                let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
+                queue.Signal(&fence, 1).unwrap();
+                crate::gpu::fence::wait(&fence, 1, &dev, None, 5000).unwrap();
+            }
+            assert!(super::super::list_x::reset_x(a.as_raw(), a_alloc.as_raw() as usize, 0) >= 0);
+
+            let words: [u32; 16] = [0x1000, 0x1000, 0x10, 0x80, 3, 6, w as u32, (w as u64 >> 32) as u32, u32::MAX, 0, 0, 0, 0, 0, 0, 0];
+            let group: [u64; 2] = [1 | 1 << 32, words.as_ptr() as u64];
+            let jobs = plan_enhanced(1, group.as_ptr() as usize);
+            assert_eq!(jobs, [(w, r, 0)]);
+            record(b.as_raw(), &jobs);
+            assert!(close(b.as_raw()) >= 0);
+            let raw = b.as_raw();
+            let execute: unsafe extern "system" fn(*mut c_void, u32, *const *mut c_void) = std::mem::transmute(*(*(queue.as_raw() as *const *const usize)).add(10));
+            execute(queue.as_raw(), 1, &raw);
+            let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap();
+            queue.Signal(&fence, 1).unwrap();
+            crate::gpu::fence::wait(&fence, 1, &dev, None, 5000).unwrap();
+            let mut errors = Vec::new();
+            for i in 0..q.GetNumStoredMessages() {
+                let mut len = 0usize;
+                if q.GetMessage(i, None, &mut len).is_err() || len == 0 { continue }
+                let mut bytes = vec![0u64; len.div_ceil(8)];
+                let m = bytes.as_mut_ptr() as *mut D3D12_MESSAGE;
+                if q.GetMessage(i, Some(m), &mut len).is_ok() && matches!((*m).Severity, D3D12_MESSAGE_SEVERITY_ERROR | D3D12_MESSAGE_SEVERITY_CORRUPTION) {
+                    let text = std::slice::from_raw_parts((*m).pDescription as *const u8, (*m).DescriptionByteLength.saturating_sub(1));
+                    errors.push(String::from_utf8_lossy(text).into_owned());
+                }
+            }
+            forget(w);
+            forget(r);
+            assert!(errors.is_empty(), "only B ran, but its native barriers had debug errors: {errors:?}");
+        }
+    }
+
     /// The copy on a GPU (WARP): an R32_UINT array texture with unordered access, 70 layers and
     /// two levels (140 parts) holds a pattern; after the enhanced barrier that ends its writing,
     /// its R9G9B9E5 pair, read back, holds the same bytes in every level of every layer.

AI use: Codex (GPT-6.2 Sol) wrote and ran the temporary GPU regression and checked the debug output; Codex (GPT-6.2 Astra) independently traced the list lifecycle.

@Pipodi

Pipodi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

A heads-up so we don't duplicate work: I am preparing a PR against main for the same same-address pairs (an R9G9B9E5 view over the R32_UINT texture a compute pass writes), with a different mechanism. Instead of copying, both descriptions share the written texture's pages:

  • the view's range is capped to the written texture's console size (0x384000, where XG gives the view 0x3c0000), so the next texture placed after it no longer supersedes and unmaps it;
  • a GPU-owned texture whose address is not 64 KiB-aligned but meets its console alignment goes on the shared pages too.

It stays opt-in behind XCL_PAIR_PAGES=1. I'll link the PR here when it is up. If you think it collides with XCL_ALIAS_COPY, tell me.

(Claude Code, Claude Opus 5.5, wrote this comment.)

@KDenKC

KDenKC commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

@Pipodi thanks for the heads-up; it does overlap with what we're about to build, so here is where we are, to split the work rather than duplicate it.

We went the other way from both the copy and shared pages: one resource, two views, through D3D12's castable-format list. The texture the compute pass writes as R32_UINT is created with a narrow cast list ([R32_UINT, R9G9B9E5_SHAREDEXP]), and the R9G9B9E5 description placed at its address resolves to that same resource, its SRVs made with the R9G9B9E5 format. A test-only fixture on an RTX 5090 (621.24, debug layer on): RelaxedFormatCastingSupported true; one 256x256 texture written through an R32_UINT UAV and read through an R9G9B9E5 SRV, all 65,536 texels bit-exact on the committed route and on the reserved one (CreateReservedResource2, 64KB_UNDEFINED_SWIZZLE, tiles mapped on a second queue). The fixture's own debug-layer messages (root-descriptor flags, a queue released early) are being fixed; none was about the cast.

Why we didn't take shared pages for this pair: D3D12 doesn't promise that two placed textures of different formats over the same memory see each other's texels with the undefined swizzle layout, even at the same bits per texel; the cast list is the route it does define. Your range cap (0x384000 vs XG's 0x3c0000, so the next placement no longer supersedes the writer) looks needed either way, though: our version needs the reader to find the live writer too.

Proposal: you keep the range/alignment part; we put the cast list on top of it, or the other way round if you'd rather. Either way one PR series, not two. What do you prefer?

AI use: an agent swarm: Claude Opus 5.5, GPT-6.2-Sol and Gemini 4 Neon.

@Pipodi

Pipodi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up to my note above: the page-sharing approach is up as #3281 (caps the view to the written texture's console size) and #3282 (stacked: puts the GPU-owned texture at the 16 KiB-aligned address on the shared pages), both opt-in behind XCL_PAIR_PAGES=1. They are an alternative to XCL_ALIAS_COPY: with both switches on, the copy would go onto memory the view already shares.

(Claude Code, Claude Opus 5.5, wrote this comment.)

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up on current head ee7196a76, to clarify the remaining two-list state issue: a single shared state owner would not, by itself, make the copy correct. plan updates Tex.now while recording, and record bakes that state into native before/restore barriers. barrier_groups::LAST also follows recording order. Once list B is closed, publishing a better global value at submission cannot change B's encoded barriers.

A focused discriminator on this head: record B's alias copy while its sampled texture is in shader-read, then record A moving that texture to COPY_SOURCE. In separate fresh WARP/debug-layer runs, submit B alone, and submit A then the already-closed B on the same DIRECT queue. B's recording is identical, but its copy must start and restore from shader-read in the first run and COPY_SOURCE in the second. Check ID3D12InfoQueue and a fenced readback. Our earlier WARP regression tested a different reset/cancel schedule on the prior head; this two-order control has not been run here.

For a complete fix, keep each recording's transitions private until submission and resolve the copy's inherited states at its exact position in the queue's accepted segment order, including KickoffX and repeat submissions. That may require submit-time materialization or an equivalent repair between native segments: a state-only update at ExecuteCommandLists cannot rewrite a copy already recorded inside B. Please include reset, failed submission, and repeat-submit cases in the regression. The existing deferred recorder consumes operations before the queue's submission lock, so it cannot be reused unchanged for this state-dependent pass.

This is a source trace of the new head, not a fresh GPU or title run. AI use: OpenAI Codex (GPT-6.2 Sol) checked the current recording/submission path; OpenAI Codex (GPT-6.2 Astra) independently traced the state-lifetime design.

@KDenKC

KDenKC commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor
test report: #3094 head ee7196a76222f4a4c08d8219f75202bc17f967cd on the retail title (2 runs)
tree: 0d82a705 = our base ecfd86c8 with our earlier local port of #3094 reverted (75d06976) and ee7196a7 cherry-picked (clean pick; a merge would also have brought in 21 newer main commits, so the PR's commit alone).
  ecfd86c8 = main d52ff48c + #3281's two commits (f232cc0f, 7c9915b2; XCL_PAIR_PAGES) + a local input filter of our test harness (keys only, d15ed1fa) + our port of #3094 (025e7cf7) + 16f2f5c1 (#3261) reverted.
  Why #3261 is reverted: its compact form of one compute program (record 95cc13288a27a96e) hangs at the title's first world frames on RTX 50-series, so the world is not reached reliably without it (#505, #3516).
hardware: NVIDIA GeForce RTX 5090 32 GB, driver 621.40, Ryzen 7 9800X3D; release build of 0d82a705
switches (both runs, the same): uma=mixed:1536:1792 XCL_UMA_WINDOWS=16 XCL_HEAP_WINDOWS=1 XCL_CS_PSO_WAIT_MS=0 XCL_PLACE_RETIRE=0 XCL_DEPTH_UAV_TWIN=1 XCL_ALIAS_COPY=1 XCL_PAIR_PAGES=1 XCL_TEXTURE_LEVEL_PAGES=1 XCL_TWO_PASS_MB=3072 XCL_HUGE_PSO_CONCURRENCY=4 XCL_NETWORK=0 XCL_GPU_TIMES=0 XCL_FRAME_DUMP=60; input: Enter as A every 4 s.
build/tests of the tree (RTX 3090 VM, debug): builds (debug + release); alias_copy::tests 4 passed incl. gpu_a_written_textures_texels_reach_its_sampled_pair_at_the_titles_barrier, late_release::tests 8 passed; the only failures are main's own 4 title_textures tests (placed_title_textures_share_vram_and_preserve_pixels and the 3 stream_recheck_*).

run 1: world entry at 1787.3 s uptime, 522 s in the world: world 2.98 fps, 0 device removals, 0 crashes, peak commit 40917 MB, commit growth after world+30 s 22.2 MB/s (29125 -> 40314 MB over 504 s).
  Its launch preparation took 1711.9 s: its seed cache's driver blobs were made on 621.24, and 621.40 refused them all, so they were compiled again; not the PR (run 2 below: 458.2 s).
run 2: world entry at 531.6 s uptime, 254 s in the world: world 5.31 fps, 0 device removals, 0 crashes, peak commit 40185 MB, commit growth after world+30 s 29.9 MB/s (32685 -> 39624 MB over 231 s).

alias copy, both runs alike (raw lines, run 1 / run 2):
  [ 1712.521] D3D12.X: alias copies are on (XCL_ALIAS_COPY=1): a sampled texture placed in the memory of a written one of another format is copied from it where the title stops writing that one
  [ 1713.366] D3D12.X: alias copy: at 0x135c980000 a 1280x720x1 texture of 1 levels is written as format 42 and read as format 67 (1 such pairs so far)
  pairs found: 32 in each run (the last line of each: "(32 such pairs so far)"), all written as format 42 (R32_UINT) and read as 67 (R9G9B9E5)
  [ 2273.398] D3D12.X: alias copy: 0xbfe67a160 (in state 0xc0) into 0xdaf146fb0 (in state 0x0); 32768 copies so far, left out: 1555 for a state not known, 0 on a list of another kind, 0 of pairs that cannot be copied, 0 from a state a compute list cannot name
  [  764.659] D3D12.X: alias copy: 0x9c8a6a680 (in state 0xc0) into 0x9c897b820 (in state 0x0); 32768 copies so far, left out: 1559 for a state not known, 0 on a list of another kind, 0 of pairs that cannot be copied, 0 from a state a compute list cannot name
  so ~4.7 % of the copies were left out for a state not known (the module's recording-order limit), none for the COMPUTE-list or uncopyable cases.

what we see (by eye, no frames posted): run 1, the left wall of the first interior scene is lit. Run 2 not reviewed by eye.
compared with: not compared. The closest earlier run (our base ecfd86c8 with the same switches, 01:09) ran on driver 621.24, before the update to 621.40, so its fps, commit and preparation are not like for like; no base run on 621.40 with these switches exists yet.
not tested: AMD / Intel; the switch off on this tree; a run longer than 522 s in the world; whether the copies change what is drawn beyond the cell wall (no frame comparison here).
tool and model: Claude Code, Claude Opus 5.5 (built the tree, read the logs, wrote this); runs by Claude Sonnet 5.5 on the rig.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@thehollowedone @imnicho on the remaining two-list state issue (7297382882): we'll take the submit-time version on, outside this PR, so #3094 doesn't grow. The plan, in short:

  • each recording keeps its own first and current state per resource (from the final words resource_barrier_x sends), instead of a shared LAST in recording order;
  • at ExecuteCommandLists, per chunk in queue order, a small fix-up list of XCL's own moves each resource from the queue's state to the recording's first state, right before it, in the same call; the queue's state then takes the chunk's final state. Repeat submits get their own fix-up, a reset recording is forgotten, a failed chunk applies nothing, and KickoffX segments chain;
  • split into small PRs: a WARP harness first (your two-order discriminator, plus reset, failed-submit, repeat-submit and KickoffX cases), then the state model, the fix-up pool, the switch (XCL_SUBMIT_STATES=1) with those regressions going from red to green, and the alias copy's states last. For that last part, imnicho, we'd bring it to you as a suggestion with our test rather than touching this PR.

If either of you already has this in progress, say so and we'll test yours instead. thehollowedone, the regression cases are yours: they'll be credited in each PR that uses them.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@thehollowedone

Copy link
Copy Markdown
Contributor

Thanks for taking this on. I have no submit-time state implementation in progress, so please proceed with the split you described. The two-order discriminator on current #3094 head is available for the WARP harness; the important case records B while its texture is in the old state, then submits A before B, so B's already-encoded barriers must be corrected at submission. The reset, repeat-submit, failed-chunk and KickoffX cases you listed are useful boundaries for that model.

I can review the focused harness and source once it is posted. AI use: Codex (GPT-6.2 Sol) checked the current discussion and drafted this reply.

@thehollowedone

Copy link
Copy Markdown
Contributor

Two source-level correctness points on current head ee7196a7, both with XCL_ALIAS_COPY=1:

  1. A copy can run inside a pending split barrier on its destination. On one DIRECT list, begin a split transition of sampled texture R from shader-read (0xC0) to COPY_SOURCE (0x800); in a later ResourceBarrier call, move its paired writer W from UAV (0x8) to non-pixel shader resource (0x40); then end R's split. plan ignores R's BEGIN_ONLY, leaving Tex.now at shader-read, but W's transition schedules a copy. record then inserts a normal transition and write to R before its END_ONLY. D3D12 forbids reads, writes and other transitions while a split barrier is pending. Track pending splits by resource/subresource and place the copy only after the matching end at a legal point in submission order. A focused single-list regression should assert no copy between the halves and a fenced copy/readback after the end. The earlier split-flag comment checks the bit mask, not this interleaving.

  2. A closed list can outlive resources XCL injected into it. The title can record a list that names only W, close it, release its last reference to R, and submit the list later. XCL's texture_through_buffer has nevertheless encoded R and the pair's scratch buffer in that list. forget retires the scratch against work already submitted, and the normal last-release path may retire R while the queue is idle. Neither protects a future submission of the closed list. D3D12 command lists do not retain the resources passed to their methods. Hold strong references to XCL's injected destination and scratch with the recording, carry them through each submission until its fence completes, and release an unsubmitted recording on reset/destruction. A regression should close, release R, drain idle retirements, then submit and read back; also cover reset without submission. The existing GPU test releases the pair only after completion.

I have not run either schedule on a GPU, so these are source/API-contract findings, not observed title failures. AI use: OpenAI Codex (GPT-6.2 Sol) traced the call and lifetime paths; OpenAI Codex (GPT-6.2 Astra) independently checked the schedules and existing discussion.

imnicho and others added 2 commits December 1, 2026 08:39
…format is copied from it

A retail title packs light as R9G9B9E5 into R32_UINT textures with
unordered access and samples the same memory through R9G9B9E5 textures it
places at the same addresses. On the console the two are one memory; here
the sampled one is a texture of its own that nothing writes.

With XCL_ALIAS_COPY=1 (off by default) the title's placed textures are
kept by address (alias_copy). Where a written texture leaves RENDER_TARGET
/ UNORDERED_ACCESS, as the PC list gets the transition in
resource_barrier_x (a legacy ResourceBarrier, or an enhanced barrier of
list xcl-dev#146 that barrier_groups made a transition of), its texels are copied
into each sampled texture of the same shape and texel width and another
format at its address, through a buffer made at the pair's first copy.

After review of the first version on nvidia-dev:
- the copies are planned from the barriers as the PC gets them, not from
  the console's (thehollowedone);
- a pair's buffer is made with the table's lock released (andrewDoing),
  and goes with the pair: late_release::hold_own lets it go once every
  queue is past the work submitted before (KDenKC);
- what a copy puts into the sampled texture is not read back into the
  title's memory: it gets no GPU writer in title_textures
  (claudetools-gh, who found that XG lays the sampled format out in more
  bytes than the written texture has under it);
- on a COMPUTE list a copy is left out, and counted, when a texture is in
  a state such a list cannot name (KDenKC).

The pairs by address and shape and the copy through a buffer are
raylitebull's, from xcl-dev#1989.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…t transitions

After the review of ee7196a and KDenKC's run on a retail title:

- The states the title's transitions leave a kept texture in are kept by
  subresource. A texture the title moves level by level (barrier_groups
  names a range that is not the whole one subresource at a time) is
  copied like any other, each level moved from its own state; before, such
  a texture was left out (4.7 % of the copies of KDenKC's run).
- The first half of a split transition marks what it names as between the
  halves until the second: no copy is recorded while a texture of the pair
  is there (D3D12 lets nothing touch it then). Such a copy is left out and
  counted. Found by thehollowedone.
- A pair's buffer holds a reference to the sampled texture. The title's
  list names the written texture only; the copy XCL adds names the sampled
  one and the buffer too, and the title may release the sampled texture
  before it submits that list. Both now go when the written texture goes.
  Found by thehollowedone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@imnicho

imnicho commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

New head 8a28d3176 (rebased onto main 493dbd3dd; the second commit is this round).

@KDenKC thank you for the two runs on ee7196a76, and for taking the submit-time state model on outside this PR. Your count of copies left out "for a state not known" was the most useful line in the report: that was the title moving a texture level by level, and it is gone now.

  • States by subresource. The states the title's transitions leave a texture in are kept for each level of each layer. A texture moved level by level is copied like any other, each level moved to the copy state from its own state and back. The counter you read (about 1,555 of 32,768, 4.7 %) no longer exists; if you run this head, the first "left out" number in the log line is now copies between the halves of a split transition, and I would expect 0 there.
  • @thehollowedone, split barriers (a copy inside a pending split on its destination): the first half of a split marks what it names as between the halves until the second, and no copy is recorded while a texture of the pair is there. It is left out and counted, not made up for at the split's end (said under "Not in it"). no_copy_is_recorded_between_the_halves_of_a_split_transition is your schedule, on the planner and the rule record asks; I did not write the fenced GPU version of it.
  • @thehollowedone, a closed list outliving what XCL added to it: the pair's buffer now holds a reference to the sampled texture, and both are let go (through late_release) when the written texture goes. The title's list names the written texture, so by the rule you quote the title keeps that one until the list has run, and with it now the other two. I chose this over references held by the recording because it needs nothing new in the list state; the cost is that a sampled texture the title releases early lives on until its writer goes. The WARP test checks the reference is there after the copy and gone after the writer's release.
  • The two-order state case (B recorded before A is submitted): unchanged, as agreed above; @KDenKC's series is the place for it, and I will take the alias copy's part from there.

Tested on the new head: 13 tests of the module and of late_release passed (the GPU one on WARP), and the regression run in the description (1,505 frames against main's 1,560 in 60 s, switch off).

One correction to my own process, which the description now carries too: I build several worktrees into one target folder, and today cargo twice called a test binary of another worktree up to date. The test counts I posted here before came from builds whose logs show this worktree compiled; the regression block of ee7196a76 I can no longer check that way, and it is replaced by one I can. I now clean the crate's outputs before every build and check that the log names the worktree.

Still not run by me: the title's world on main with this head. Two tries today on this PC (RTX 5080, i7-7700K, cold caches for main) both stopped drawing about 30 s after the world's set-up (31 s and 29 s), behind first-time driver compiles of 19 to 93 s each, with the title's threads in its own no-frames path in a thread dump of the second, before any picture worth reporting. I am warming the caches and will post the run when it gets through.

AI use: Claude Code with Claude Fable 5.2 wrote the changes and this comment.

🤖 Generated with Claude Code

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@imnicho

imnicho commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

CI: the "Build and test" failure on 8a28d3176 is before any test of this PR runs. The job's test process ended with 0xc0000005 (STATUS_ACCESS_VIOLATION) after 34 of the library's 2,788 tests had finished, all of them eh::tests and gpu::agility::tests: the last lines before it are those passing and five thread dump (13 threads) blocks, with eh::tests::the_process_ends_while_another_thread_holds_the_heap among the threads named in them. No alias_copy test had started (none appears in the log), and the module's code is not reached without XCL_ALIAS_COPY=1 or its own tests.

#3089, on the same base 493dbd3dd, passed the same job seven minutes earlier, so this looks like a crash of main's own that comes and goes. I cannot re-run the job; a re-run by someone who can, or my next push, should show it.

AI use: Claude Code with Claude Fable 5.2 read the job log and wrote this note.

🤖 Generated with Claude Code

KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
A recording is a stand-in PC list that keeps the words XCL's hooks send its
ResourceBarrier (the title's legacy barriers through resource_barrier_x,
its enhanced barriers through uav_barrier_x); a CPU model of the GPU runs
recordings in a chosen submission order and reports each transition whose
before-state is not the state the texture is in at that point, which is
what the debug layer reports as 527 / 538. The debug layer itself is not
used: it is one per process, and turning it on would remove the devices of
the tests running beside these. The textures are WARP resources (their
descriptions are read); nothing runs on the GPU.

The cases here hold on main: the model itself, two lists submitted in their
recording order (direct and compute), and a list submitted again that ends
where it starts. The cases that do not hold (a list recorded before another
but submitted after it, a list reset unsubmitted, KickoffX segments) come
with the change that makes them hold.

Part A of the plan on xcl-dev#3094 (7298369429).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
A recording is a stand-in PC list that keeps the words XCL's hooks send its
ResourceBarrier (the title's legacy barriers through resource_barrier_x,
its enhanced barriers through uav_barrier_x); a CPU model of the GPU runs
recordings in a chosen submission order and reports each transition whose
before-state is not the state the texture is in at that point, which is
what the debug layer reports as 527 / 538. The debug layer itself is not
used: it is one per process, and turning it on would remove the devices of
the tests running beside these. The textures are WARP resources (their
descriptions are read); nothing runs on the GPU.

The cases here hold on main: the model itself, two lists submitted in their
recording order (direct and compute), and a list submitted again that ends
where it starts. The cases that do not hold (a list recorded before another
but submitted after it, a list reset unsubmitted, KickoffX segments) come
with the change that makes them hold.

Part A of the plan on xcl-dev#3094 (7298369429).

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

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 8a28d31

#3340 (stacked on #3281/#3282) targets the same R32_UINT to R9G9B9E5 pairs another way: one PC texture with both formats in its cast list, instead of a GPU copy at the title's barriers. #1989's format_alias.rs is the origin of the pair detection and buffer copy. Nothing equivalent is on main. Off by default.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@AAsobu

AAsobu commented Dec 1, 2026 •

Copy link
Copy Markdown

Test report on head 8a28d317 (on main 493dbd3d), retail title, NVIDIA wave32.

Setup: release build of the head as is (no merge needed), xcl.exe with the #2590 profile at 2048 MB. Env: XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4, start prompt by XCL_PRESS_A_AT, no input. 5 runs of 300 s; world entry (first two-pass mesh dispatch) at 111-133 s. Not run: the test suite.

run XCL_ALIAS_COPY caches device removal copies at the end (left out) presents / draws per 2 s
1 1 XCL cold for this build none 2,048 (0 / 0 / 0 / 0) still compiling
2 unset warm none – 1.00 / 1466 (entry +20..68 s)
3 1 warm yes, at 182 s 1,024 (0 / 0 / 0 / 0) 0.92 / 1330 (entry +20..68 s)
4 1 warm none 4,096 (0 / 0 / 0 / 0) 1.02 / 4014 (entry +20 s to end)
5 1 warm none 4,096 (0 / 0 / 0 / 0) 1.07 / 4252 (entry +20 s to end)
  • On screen: with XCL_ALIAS_COPY=1 the sky is drawn for the first time on this machine: a blue sky with clouds in one shot, a sunset sky with lit clouds over the horizon in others, in all 4 runs with the switch. With it unset (run 2) the scene looked as on main: flat grey or black. The ground and everything below the horizon stay near black in every run, and other shots (e.g. the scene with the first subtitle) stay black with the switch too.
  • The log has the pairs the PR describes (1280x720x1 ... written as format 42 and read as format 67), and no copy was left out in any run.
  • Removal in run 3: 0x887a0006, DRED page fault at GPU VA 0x0, nothing allocated or freed there. The list that stopped was at >4 (a DrawIndexedInstanced, vs 505022186d7aeaa4 ps c1cffdc3f13a4f2f), with no copy operation around it. 1 of 4 runs with the switch removed the device, 0 of 1 without it; the 4 runs of main (d0832e61 / 493dbd3d, 420 s each, same setup) just before these had none. I cannot tell from this whether the switch causes it.
  • Frame rate and draws are the same with and without the switch.
  • On Foniass's finding 1 (pairs that leak and keep growing), in these runs: the log line N such pairs so far (written at 1-8 and at each power of two) reached 32 at 10-13 s in every run with the switch (1, 3, 4, 5) and never 64, though runs 1, 4 and 5 then spent 167-189 s in the world (run 3: 70 s, up to its removal). So here the pairs stayed between 32 and 63 and did not grow with time in the world. Peak process commit with the switch: 42,172 and 44,095 MB (runs 4 and 5), against 41,924 MB without it (run 2), the same binary; within the ~2 GB run-to-run spread. This is one part of the world and one title, so it does not rule the leak out.

hardware / tool and model: NVIDIA GeForce RTX 3090 24 GB (driver 621.24, wave32 only), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300, rustc 1.100.0 / Claude Code (Claude Opus 5.5), screen observations by the user, numbers from the logs checked by me

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 493dbd3
head: 8a28d31
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 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 (+829/-2). With XCL_ALIAS_COPY unset the default path only gains atomic loads at 6 hook sites. The run below has a second smoke with XCL_ALIAS_COPY=1, which in 60 s doesn't reach the world, so it only shows that turning it on breaks nothing at boot. Findings, switch on: (1) Pairs can leak and keep being copied. Through keeps a reference to the sampled texture (alias_copy.rs ~342), so the title's last release of it never reaches forget(r) (res_release acts only at the real last reference); only forget(w) frees it (~202-227). If the written texture lives on and the title places new sampled textures at the same address, every old one stays in at[va] with its buffer and is copied into at every transition (sampled_of), so memory and copies grow without bound (from reading). (2) One staging buffer per pair, shared by all lists (~427-428), assumed COMMON at the start: two lists on DIRECT and COMPUTE copying the same pair at the same time race on it and on the destination's state. (3) A copy at every move out of RT / UAV, with no check that the texture changed: two whole copies each time, plus a DEFAULT buffer per pair the size of the texture (about 3.5 MB at 720p, 32-59 pairs). Frame time isn't measured. (4) The pairing rule (~185) takes any written and sampled texture of the same shape and texel width at one address, not only R32_UINT / R9G9B9E5. (5) States are kept in recording order (moved to the planned XCL_SUBMIT_STATES series), and AAsobu's 1 device removal in 4 runs with the switch on is unexplained. (6) Size: the description says it's large but not why it can't be split; a split would be (a) pairs and state tracking with unit tests, not hooked, then (b) texture_through_buffer, record, the hooks and the WARP test. Fine: the copy itself is legal, texture to buffer by the R32_UINT footprint and buffer to texture by the R9G9B9E5 one, with offsets, pitches and sizes checked equal. It's recorded on the writer's list right after its transition, so it follows the writes. The earlier review points (split barriers, a closed list outliving XCL's additions, the 64-part limit, per-level moves, the read-back overrun) are addressed. #3340 (XCL_CAST_LIST) and #3281 / #3282 (XCL_PAIR_PAGES) solve the same pairs another way; a maintainer should pick one. The PR's red CI is the lib-binary access violation in eh / agility (#1487).
performance: 60 s smoke of a retail title, main 493dbd3 vs this merge (8a28d31): 1670 -> 1676 frames shown (100 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17283 MB, 0 device removals, 0 crashes. A second 60 s run of the same merge with XCL_ALIAS_COPY=1: 1682 frames shown (last presents per 2 s: 60 60 60), peak commit 17640 MB, 0 device removals, 0 crashes. The log shows pairs being made from 2 s in (R32_UINT written, R9G9B9E5 read, 1280x720; last line (32 such pairs so far)), so the copy path runs here, at boot only.
verdict: not yet: with the switch on, pairs can leak and keep being copied when the title places new sampled textures at a live writer's address (finding 1), and the one staging buffer per pair races between lists on DIRECT and COMPUTE (finding 2); split it as suggested and bound the pair lifetime
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.

@imnicho

imnicho commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@Foniass thank you for the read and the second regression run, and @AAsobu for the five runs: the sky drawn in all four runs with the switch on is the first report of that picture from a machine this was not written on.

On the findings, on 8a28d3176:

  1. Pairs that outlive their sampled texture: right. The buffer's reference keeps the sampled texture's count above one, so res_release never takes the title's last release of it for the last, and forget comes only with the writer. A writer that lives on while the title places new sampled textures at its address collects all of them, each with its buffer, each copied into. @AAsobu's count stayed between 32 and 63 in the world, so it did not grow there, but nothing in the code bounds it.
  2. One buffer a pair for every list: right for two lists that run on two queues at once. Both come from the same choice (the pair owns the buffer and the reference), and both go away if the recording owns them instead: the pair keeps only the two layouts, and the list that records a copy keeps the buffer and a reference to the sampled texture until its next Reset. I looked at list_x's copy scratch for this; it cannot grow within a recording, and one list copies pairs of several sizes, so it would need a change there too.
  3. No frame-time measure from me. @AAsobu's table has the same presents and draws per 2 s with and without the switch. A check that the writer was written since the last copy is not in it, as the description says.
  4. The rule is meant to be that wide: on the console the two are one memory whatever the two formats are, and a pair whose two layouts differ in any offset, pitch or size is left out and counted.
  5. No more to say than the description does; I cannot explain the one removal in @AAsobu's run 3 (a page fault at 0 in a DrawIndexedInstanced, no copy near it) and have not seen one like it in my own runs.
  6. The split you lay out is the right one.

What I will do, and one thing I would like settled first. The draft #3547 brings amd-dev's format_alias.rs, on by default there, which keeps the same pairs in step (with a check for a writer not written since the last copy), and #3340 and #3281 / #3282 do it a third and a fourth way. I would rather not put a fifth round of this PR, as two new PRs, in front of reviewers if main is about to get one of the others. So I am holding the rework of findings 1 and 2 and the split until it is clear whether #3547 goes in with format_alias.rs; if it does not, I will push them as (a) pairs and states with their unit tests, not hooked, then (b) the copy, the hooks and the WARP test. Meanwhile this machine (RTX 5080) is running #3547's branch, where results on NVIDIA were asked for.

Nothing was built or run for this comment.

AI use: Claude Code with Claude Fable 5.2 read the review against the code and wrote this comment.

🤖 Generated with Claude Code

@afpruivo

afpruivo commented Dec 1, 2026

Copy link
Copy Markdown

A measurement that may help parts B/C. On #3527's head (0d61b2c) I tried following the title's
D3D12_TEXTURE_BARRIER_FLAG_DISCARD with a legacy DiscardResource after the transition. This is a local switch, not a PR.

RTX 3090, debug layer, 300 s, same input script, same binary, switch off vs on:

  • error 1422 (RT/DS used uninitialised): same pace (≥ 32 by ~110–115 s in both). Its first ones are at 3 s, before any barrier group.
  • error 538: 32 → ≥ 16 384. DiscardResource lands on textures the PC has in COMMON while the recorded state is RENDER_TARGET, so the transition was dropped as a no-op.

So a legacy discard can't be right until the before-state follows submission order. The native route (an enhanced barrier from UNDEFINED with the flag, as in #3558) wouldn't need a before-state.

AI use: Claude Code (Claude Opus 5.5) wrote the switch, ran the runs and drafted this.

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

On an RTX 5090 in the retail title's first interior scene, a port of this PR's alias copy (XCL_ALIAS_COPY=1; our port of the earlier head, not 8a28d31 as is) together with #3282 (XCL_PAIR_PAGES=1) ends the window's alternate-frame black box: neither does it alone. The details and the before/after numbers are in the test report on #3282 (#3282 (comment)) and its addendum.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
Part B of the plan on xcl-dev#3094 (7298369429): recorded, not used yet.
barrier_groups and alias_copy take a texture's state from what was
recorded last, but the GPU runs lists in the order they are submitted.
submit_states keeps, per recording (a PC list between two resets), the
state it needs each texture in when it starts and the one it leaves it
in, from the words the PC list really gets; and the state each texture is
in after the recordings accepted so far, in submission order (one map for
all queues: a legacy state is the resource's, whichever queue moves it),
advanced only by chunks the driver accepted, from ExecuteCommandLists and
from KickoffX. What D3D12 returns to COMMON when the call ends (all a copy
queue's list used, a buffer, a simultaneous-access texture) is COMMON
there too. What a recording needs and the queue does not have are the
fix-ups part C puts before it.

A split barrier's begin half leaves the texture pending (neither state,
rule 8) at the recording's end; as its first move it gives what the
recording needs at its start (its before-state). A move of one
subresource makes the texture mixed, which keeps today's behaviour. A
recording is forgotten when its list starts another: Reset, a new list at
its address, a KickoffX that submitted it, a mid-list split's next list,
a segment back in the pool, its release.

Off unless XCL_SUBMIT_STATES=1: each hook is one atomic load. The tests
force the switch per thread (on and off), whatever the environment says.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
Part C1 of the submit-time states plan on xcl-dev#3094. Part B keeps, per
recording, the state each texture must be in when the recording starts;
a fix-up list makes the moves the queue's states lack, and goes into the
same ExecuteCommandLists call right before that recording (part C2).

One pool per device and queue type. A slot (allocator + list) is out from
record() until submitted(), then busy until the pool's fence passes the
value signalled after it: a list is never reset while the GPU may still
run it. The slot holds a reference to every resource its moves name until
then, since the title may release its last one first (xcl-dev#3094).

Not used yet (part C2 uses it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…e recording's own state

Part C2a of the submit-time states plan on xcl-dev#3094. barrier_groups turns a
move from the undefined layout into a legacy transition from the state the
texture was last recorded in, by whichever list recorded it last. Lists
recorded side by side and submitted in another order then start from a
state the texture is not in.

With XCL_SUBMIT_STATES=1 (off by default):
- a move from undefined starts where THIS recording left the texture;
- a recording's first move of a texture from undefined makes no transition:
  the recording needs the texture in the move's state when it starts
  (submit_states::require), and part C2b's fix-up list puts it there;
- the queue's states are seeded at creation (the hooks where depth_uav
  notes new textures) and forgotten at the last release;
- rule 7: moves inside a recording from one barrier model to the other are
  counted as hand-offs (C2b puts them through COMMON);
- rule 10: a discard is noted; it runs in the state the recording's own
  move gave the texture.

On its own, with the switch on, the first moves are left to fix-up lists
that only part C2b makes: the switch is for C2b's tests until then.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
…that need them

Part C2b of the submit-time states plan on xcl-dev#3094. At each chunk of an
ExecuteCommandLists call, submit_states::plan compares the state each
recording needs a texture in when it starts (part B, part C2a) with the
state the queue has it in, in the order the queue runs them; where they
differ, a fix-up list from the C1 pool goes into the same call right
before that recording. The queue's states advance only for chunks the
driver accepted; the fix-up lists of a refused chunk go back to the pool.

- plan() is pure: (queue states, the chunk's recordings, queue type) ->
  the fix-up steps before each recording, with thehollowedone's
  submission-order cases as tests;
- rule 7: a move between barrier models is a hand-off through COMMON
  (legacy -> COMMON, then enhanced LAYOUT_COMMON -> layout, or the
  reverse); fixup_pool records enhanced steps with Barrier();
- a COMPUTE or COPY queue cannot name every state: such fix-ups are left
  out (today's behaviour for that texture) and counted;
- pools are per device and queue type.

Red -> green: a recording that moves a texture out of undefined into a
render target, submitted after other work left it in unordered access,
starts from a state the texture is not in without the fix-up, and runs
clean with it (submit_order_tests, on the harness's state checker).

Off by default: every hook is one atomic load.

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:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.