D3D12.X: XG CopyInto/FromSubresource take the newer library's added argument #1425
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1435"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by lukastaro on 2026-11-24T15:54:48Z.
A retail game crashed during its world loading, every run: an access violation in a
memcpywriting to title memory that was never reserved, mapped or committed. The writer was XCL'sXGTextureAddressComputer::CopyFromSubresource(vtable #9), which the game calls as(linear dst, plane, subresource, 0, tiled src, row pitch, slice pitch): its XG library has a 32-bit argument before the source pointer, which the library the oracle test uses does not have. Read the 6-argument way, the source was the 0 dword with the stack slot's old upper half, and the row pitch the low half of the real source pointer, so the second row went gigabytes past the destination.The game calls both forms, so they are told apart per call: a value of 16 bits or less in the fourth slot with address space in use at the fifth is the newer form (address space, not readable memory: a title's pages are committed on first use). A nonzero added argument is logged once and ignored; its meaning is not known (the game passes 0).
What is in it
copy_argsand the two copy methods taking either form (hle/xg.rs).hle/xg.rs).Tested
cargo build --workspace, thencargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware– no wave64 on this GPU).Regression run
main:
PR:
An offline shader precompile ran on the same machine during the main run (and less of it during the PR's), so the frame and commit numbers differ more than the change does; the 60 s stay in the game's menus, before the copy this changes.
Not tested
xg_oracle.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T16:53:12Z.
Full-suite run, since this PR has no test report yet. Tested exact head
14c8a2d(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.subresource_copies_take_both_argument_forms.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T18:19:50Z.
Review: COMMENTED
Read at
14c8a2d(merge base930e8b4; merges intomain9e3831ewithout conflicts) by reading the code; nothing of this PR was built or run here. A local logging patch onmain9e3831ewas run on a retail title (below, one run). The crash and the reading of slot #9 match #662. The test goes through the real vtable slots, and its 7-argument calls cannot pass onmain.Overlap: #684 (open since 03:28 UTC, not named here) fixes the same crash by giving slot #9 seven arguments and leaving #8 alone; #976 and #992 build on it. The two conflict in
xg.rs(git merge-tree), so only one can go in as it is. #684'sPR checksis red (no regression run in its description; retail runs that reach the call are in its comments), this one's is green.CONFIRMED: every caller we could find splits the two forms by method (#8 six arguments, #9 seven), so
copy_intoshould not guess (xg.rs:708-709).xg_xs, passes the added0uonly toCopyFromSubresource. ItsCopyIntoSubresourcecall has six arguments, with no Scarlett case.CopyIntocalls with six arguments, and a crash when #8 was read with seven. One run here of that logging patch (RTX 3060, 155 s, until the #505 null write): #8 was called at least 129 times; the 66 logged calls all fit six arguments, and each has a non-zero upper half in the pitch slot. #9 was called twice, and both calls fit seven (a zero before the source pointer). So in this run the forms split by method, as #662 says.src=0x8_0000_0000(low dword 0) and a pitch slot of0x7_00000100(a dword under a stale upper half, as in #662's dump), with title memory at that address, is taken as the newer form: it tiles from0x7_00000100with the slice pitch as row pitch (wrong bytes, or a fault). This is traced in the code; none of the 66 logged calls had a source with a low dword of at most 0xFFFF, so the run did not hit it.copy_intoas onmainand givecopy_froma plainu32beforesrc.copy_argsand itsVirtualQuerygo away, and so do two cases still misread on #9: an added value above 0xFFFF, and a nullsrc(todaya4, if its upper half is stale, becomes the source instead ofE_INVALIDARG).CONFIRMED: the oracle does not show a 6-argument
CopyFromSubresource(description;xg.rs:675-677).subresource_copies_match_the_console_librarycalls the console's slot #8 (xg_oracle.rs:400), but slot #9 only on XCL's own object (:403-405). It supports six arguments forCopyIntoonly. With the fix above, thefromtype in the oracle test, andfrom6/into7in the new one, change too.Questions for the author
SEENis shared by both methods, so the "6-argument" log line does not say which one was called. Did you see a 6-argument call on #9? (Here: none in two calls.)Verdict: correct for the calls reported;
copy_intoshould not guess,copy_fromshould be a fixed 7-argument method unless a 6-argument call on #9 was seen, and it needs a decision between this and #684.Review by Claude Code (written by Claude Opus 5.5, checked with Claude Fable 5.2 and Claude Opus 5.5); each point checked by a person before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:52:27Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by iggyvilla on 2026-11-25T08:03:09Z.
Test report on
14c8a2d(merged with #2120 onmain cbc296aasb5c481f;cargo build --release -p xcl), 2 world-load walks on RX 6650 XT 8 GB (RDNA2)/ Adrenalin 32.0.21045.29003 / 32 GB RAM (
PRELOAD=0,XCL_PSO_WAIT_MS=2000,-FromSave, commit stop at 37.8 GB).Tested: same tree and runs as the #2120 report on this machine
(
b5c481f, walksauto-20261125-154354andauto-20261125-155228).What was measured: the PR's per-form logging fires once per copy form in
both walks —
in the 6-argument format 2.5 s / 2.7 s andin the newer 7-argument format 125.5 s / 126.9 s (during world load). No0x80000003and no
+0x4dcbc9din either log: the packet-stream assert did not fire here.Not tested: a run that reaches the account-prompt assert itself (these runs
come from a save); suite run on this tree; other GPUs.
AI use: Measured by an omp agent running DeepSeek v4.1 Flash; text drafted
by Muse Spark 1.3; checked and posted by Claude Code (Claude Opus 5.5) on my
behalf; I did not run the tests or write the text.
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:57:27Z.
Test report for head
14c8a2das pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignoredsubresource_copies_take_both_argument_formsran and passedXCL_SAMPLE_*data set (game-data tests not run, so not with the title's realxglibrary)Not tested
mainAI use
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-25T12:28:17Z.
Linux / AMD RDNA4 (RADV) test report for head
14c8a2dmerged locally ontomain1a0bbe3(clean merge).Environment
experimental-11.0-20261112), vkd3d-proton v3.1 (#257+dxil-spirv53aac418), DXVKv3.1.1-209, DXC1.9.2609.5,x86_64-pc-windows-gnucross-compileTested (debug test binary under Wine,
--test-threads=1 --nocapture)hle::xg::tests: 4 passed, 0 failed, 0 ignored, 0 skipped (0.00 s), includingsubresource_copies_take_both_argument_forms.Not tested: full workspace suite, retail title run, native Windows.
AI use: T3 Code / Antigravity (Gemini 4 Neon) merged, built, ran the tests on this machine, and drafted this report.
Imported from ivall/xcl. Originally posted by Placebola on 2026-11-25T17:07:45Z.
Test report on
14c8a2dmerged ontomain06c9f55(clean merge, release build): it removes thememcpyaccess violation during the retail title's world load on this machine.Tested
xcl runon the retail title,XCL_NETWORK=0,XCL_RUN_SECONDS=200, A pressed every 4 s from 20 s, warm DXIL cache.main06c9f55alone: 2 runs out of 2 end with0xc0000005inVCRUNTIME140!memcpy(write past the destination, at 130 s and 138 s), called fromxcl::hle::xg::copy_from. One of my own manual runs onmainended the same way.main06c9f55+ this PR: 3 runs out of 3 reach 200 s with no crash and no device removal (2191 – 2466 frames shown). Each run logs both forms:called in the 6-argument format about 3 s, thencalled in the newer 7-argument format 133 – 161 s, which is whenmainalone crashes.This title calls both forms in the same run. #684 fixes the same crash, and an older tree of mine with it (
main9633138+ #684) got past this point too. But #684 readsCopyFromSubresourcein the 7-argument form only and leavesCopyIntoSubresourceas it is. This PR tells the two forms apart on every call, for both methods, so it covers more of what this title does.Not tested
cargo test,scripts/smoke.ps1; AMD; #684 on06c9f55.AI use
Imported from ivall/xcl. Originally posted by DLampos on 2026-11-25T19:06:45Z.
Independent confirmation on Linux. This is not a run of this PR's commit: I hit the same crash on a retail title (build 1.0.2.1) and made the same change locally, on
mainatc160d86. In that change,copy_fromtakes the extrau32between the subresource and the source pointer. I did not build this PR's branch.Tested
x86_64-pc-windows-gnu(release), running under Proton Experimental's Wine 11 with DXVK's dxgi and vkd3d-proton. vkd3d-proton was built from Proton's commit 2576c0b4 with two local patches for XCL's vtable swap.VKD3D_CONFIG=no_upload_hvvto get past an unrelated vkd3d-proton abort.memcpycalled fromxcl::hle::xg::copy_from. The writes went to 0x8_070c_c5f0 – 0x8_4fe0_74a0, outside anything mapped.+0x979f31), dword 0 is at[rsp+0x20], the source at[rsp+0x28]and the pitches at[rsp+0x30]/[rsp+0x38]. Read as six arguments, the row pitch became the low half of the source pointer.no_upload_hvv.Not tested
AI use
Imported from ivall/xcl. Originally posted by anes66 on 2026-11-25T20:01:41Z.
Native Windows reproduction on unmodified
main2898511, followed by CPU checks of this PR.A manual loading-screen run on Windows 10 22H2 / RTX 3060 12 GB ended at 612.097 s with a write AV in
VCRUNTIME140.dll+0x1cc83, destination0x808a1c840. The stack scan includes:Using the matching release PDB offline, Windows SDK
dbhresolvesxcl.exe+0x9d180toxcl::hle::xg::copy_from+0x2d0,hle/xg.rs:713, the row-copy call. This matches the first failure in #662. The run logged no0x8007000E, device-removal or GPU-wait-timeout message; that does not establish a general absence of memory pressure.Unmodified head
14c8a2dpasses all fourhle::xg::testshere. I added CPU coverage for pitched mips, array slices, depth/stencil planes, BC formats, volumes and reserved source addresses in #2483: six tests pass both on your head and when carried ontomaine0d93c8. The additional tests are authored underanes66; their dependency retains your original commit author.Not tested: a title run with this PR on this machine, GPU tests or the full workspace suite. A separate build is being prepared for a manual before/after check; there is no claim yet that it removes our crash.
Manual A/B follow-up, 25 November
The separate release build is now tested manually:
main2898511+ your exact runtime change (14c8a2d, cherry-picked ascb9041c) + the test-only commit, headaec6fa1. Same machine, title and launcher settings as the baseline. Existing caches and saves were retained, so this is not a cold-cache comparison.xg::copy_fromat 612.097 s.crash: null.This one run gets past the previous
copy_fromAV and remains alive until manual closure. It does not establish a general fix for the remaining loading/rendering stall. No title binaries, dumps or complete local logs are uploaded.Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:16:55Z.
Review: COMMENTED
P1 ABI-dispatch flaw: copy_args guesses ABI for both vtable methods. DirectXTex/retail evidence shows slot #8 CopyIntoSubresource is six-argument while slot #9 CopyFromSubresource carries the added 32-bit argument. Heuristically applying it to copy_into can misclassify valid calls based on source low bits/stale stack pitch and tile from wrong address; it also mishandles non-small added values/null new-form source. Keep copy_into fixed six-argument and copy_from fixed seven-argument; remove VirtualQuery guessing. Current Windows CI is also absent.
Imported from ivall/xcl. Originally posted by madaraXor on 2026-11-25T21:55:48Z.
Test report on the retail title: this fixes #646's
VCRUNTIME140memcpy crash here, and shows what the old reading does first. Tested commit:14c8a2d(this PR's head).Setup: RX 6700 XT (RDNA2), Windows 10 22H2, release build. Not plain
main:main 65fc114+ #1803, #2229, #2384 (with a local fix of its deadlock), #1790, #2385, #1795, #2246, then this PR merged on top (no conflict).XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_GPU_VIEW_BUFFERS=1, same input script in every run.Without this PR (two runs):
VCRUNTIME140.dll+0x1dcf3, write,rbx=0x40000 rdi=0x800, title frames+0x979f5b,+0x4fb0c2f,+0x50bb3f0. The return address on the stack isxg::copy_from+0x168, the instruction after itscall memcpy(disassembled with the build's PDB).0x45999000, the same value asr12in run 1's crash), and the "slice pitch" is the real row pitch. Rows 1 and 2 had already been written ~1.1 GB and ~2.2 GB past the destination, into memory the title owns, before row 3 reached an uncommitted page. Presents stopped 4 s later.With this PR: the log has
called in the 6-argument format 23 s andcalled in the newer 7-argument format 453 s, as the PR says. There is no XG write outside the destination and no crash to the end of the run, which then waits on driver compiles, a separate matter. The PR'ssubresource_copies_take_both_argument_formstest was not run separately here.The 464 s run was at 21.5 GB commit and 10 GB local VRAM, so on this machine #646's crash was not the commit wall.
Claude Code (Claude Opus 5.5): wrote this from the runs above (logs, cdb). Counts, times and RVAs only.
Imported from ivall/xcl. Originally posted by SergeAx on 2026-11-26T14:54:22Z.
Test report: on an RTX 5080 with the retail title, this fixes the 98 s crash in
copy_from(#662). Eight runs went past that point, the longest for 4 h 38 min. Tested commit: this PR's head14c8a2d, merged ontomainb49be18(merge9336fba, no conflicts).Setup:
xcl run <folder>,XCL_NETWORK=0.Without this PR: a
mainbuild crashed at 98.2 s (built from a checkout atb49be18; its log does not record the commit). That was a write access violation inVCRUNTIME140.dll+0x1dcf3, under XCL'sCopyFromSubresource, the crash of #662. The minidump of a secondmainrun shows the same crash. Amainsmoke run of 60 s ends before that point.With this PR:
xg: CopyInto/FromSubresource called in the newer 7-argument formwith … in its added argument (meaning unknown, ignored)warning never came up, so the title always passed 0 there.DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT(details).Unit tests:
cargo test -p xcl --lib hle::xg::testson the merge (debug): 4 passed, 0 failed, 0 ignored, includingsubresource_copies_take_both_argument_forms.Not tested:
AI use: Claude Code (Claude Opus 5.5) ran the runs and the tests, read the logs and wrote this report. A person drove the title (pressing Space and picking the player).
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-26T17:46:57Z.
In-title confirmation on an RTX 5080 16 GB (driver 32.0.16.1088), retail 1.0.2.1, Windows 11 26300, release. This PR's head
14c8a2dcherry-picked onto #24045b9d4ff+ #2519's scratch + the 1 GiB shader-heap profile (#2590) + thefree_asidepatch, with heap windows and the full compute precompile.0xc0000005(a 16-byte read at0xca8a78000/0xc4903a000/0x859810000) at 50–551 s, with no device removal.int3atgame_scarlett_master.exe+0x63966f(0x80000003, its Breakpad handler), no XCL exception and no device removal. Local video memory 20.8 GB;title textures: 16384 uploads left outwas reached.So
copy_fromis no longer the end here; +0x63966f is a later, different title assert (no issue mentions that offset). This matches @SergeAx's 5080 result above.AI use: OpenCode, Claude Fable 5.2 applied the PR, ran the 600 s title and wrote this.
Imported from ivall/xcl. Originally posted by johnbf8x on 2026-11-27T01:10:54Z.
RTX 3070 Ti 8 GB, Windows 10 22H2 (19045.7846): confirms the
copy_fromfix.Tested
14c8a2dmerged ontonvidia-devecc0bb5(clean merge, release build). Driver 32.0.16.2140, i7-12700K, 32 GB RAM, Agility SDK 1.620.2, retail 1.0.2.1 (Series X),XCL_NETWORK=0, warm cache.nvidia-devecc0bb5alone: 4 of 4 runs end with0xc0000005inVCRUNTIME140.dll+0x122b3(a write), writerxcl.exe+0x31943f, game stack+0x979f5b,+0x4fb0c2f,+0x50bb3f0. Three at 97-112 s, one at about 3 min (one of the four was Series S).xg: CopyInto/FromSubresource called in the 6-argument form, then... the newer 7-argument form.Not tested:
cargo test, more than one run with the PR, AMD. The run then stalls on graphics pipelines (about 5.9 s per driver compile, 0.0 FPS), which is separate from this PR.AI use: Claude Code, Claude Sonnet 5.5 ran the builds and recordings and wrote this note; the machine's owner reviewed it.
Imported from ivall/xcl. Originally posted by throny on 2026-11-30T20:10:16Z.
Closing: this change is already on
mainas commitadccb7d8(brought in by5eb48388Merge main (5b711248) into the nvidia-dev merge). This PR's diff applies in reverse cleanly on currentmain(ff0c364b), so merging it would change nothing. If something here is not onmain, say so and reopen it, or ask and I will.AI use: Claude Code (Claude Opus 5.5) checked this; part of the duplicate sweep on #3041.
Pull request closed