D3D12.X: apply buffer_delta on console_list copies and guard null/sampler records #3315
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3315"
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 Kalmarv on 2026-11-29T07:26:04Z.
Problem
During
console_list::closereplay incrates/xcl/src/hle/d3d12x/console_list.rs:COPY_BUFFER_MARKERreplayedCopyBufferRegion(d, q(1), s, q(3), q(4))without addingreal::buffer_delta(dst)/real::buffer_delta(src)(unlikelist_x::copy_buffer_region_inner). Any copy involving a shifted UMA buffer read or wrote at the wrong buffer offset.COPY_TEXTURE_MARKERreplayedCopyTextureRegionwithout addingreal::buffer_delta(pResource)toPlacedFootprint.OffsetwhenType == D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT(unlikelist_x::pc_location). Any texture upload or readback using a shifted UMA buffer footprint copied from or into the wrong offset.CLEAR_UAV_MARKERonly checkedg.pc_gpu_uav != 0without checking!g.sampler && !c.sampler && c.pc_uav != 0(unlikelist_x::uav_clear_handles, which rejects sampler slots, and additionally ensuring the CPU UAV handle is non-zero before callingClearUnorderedAccessViewUint/Float).cl_resource_barrier,clear_uav, andcl_copy_texture_regiondereferencedbarriers,values,dst, andsrcwithout null-pointer guards.Fix
In
crates/xcl/src/hle/d3d12x/console_list.rs:replay_copy_buffer_region,pc_copy_location, andreplay_copy_texture_region, applyingreal::buffer_deltawithchecked_addtoCopyBufferRegionoffsets andD3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINToffsets (skipping the record cleanly if a resource is null or an offset addition overflows).clear_uav_slot_usablerequiring!g.sampler && !c.sampler && g.pc_gpu_uav != 0 && c.pc_uav != 0inCLEAR_UAV_MARKER.cl_resource_barrier(n == 0 || barriers.is_null()),clear_uav(values.is_null()), andcl_copy_texture_region(dst.is_null() || src.is_null()).clear_uav_slot_usable_requires_non_sampler_and_nonzero_handlesandnull_pointers_in_console_list_recording_are_ignored, plus end-to-end GPU testgpu_console_list_copies_apply_buffer_deltaverifying shiftedCopyBufferRegionandCopyTextureRegion(upload + readback) plus overflow rejection on a real D3D12 queue.Tested
Tested on Windows 11 Pro (Build 26200), AMD Ryzen 9 9950X, NVIDIA GeForce RTX 5070 Ti (driver
32.0.16.1074), DXC1.9.2609.5,rustc 1.99.0.cargo check --workspace --all-targets: passed, 0 errors.cargo test --lib -- console_list::tests --test-threads=1): 14 passed, 0 failed (includinggpu_console_list_copies_apply_buffer_deltaon RTX 5070 Ti).cargo test --workspace -- --test-threads=4): 2611 passed, 0 failed, 49 ignored (26 runtime-skipped by capability guards).xcl-smoke),main-ancestor baseline vs this branch (0 device removals, 0 crashes, 0 minidumps, 0 System display events):Baseline (
f0e8fdd5):Branch (
d9b869ed):Not tested
XCL_CONSOLE_LISTS=1replay inside a title using shifted console-list copies (covered by the synthetic D3D12 GPU testgpu_console_list_copies_apply_buffer_delta, while the 150 s smoke ran with default settings).AI use
Used an AI coding assistant to audit
console_list.rsagainstlist_x.rs, implement thebuffer_delta/ guard fixes and GPU test, and run all local verification and smoke checks.Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T07:38:11Z.
Verified buffer copies through console list recording and Close replay on
d9b869ed, RTX 5070 / driver 616.92. WithXCL_CONSOLE_LISTS=1, a synthetic caller issued four CopyBufferRegion records through console vtable slot 15, then Close through slot 9. Replay reported 4 copies, 0 skipped records. A native DIRECT queue executed the resulting list.The fixture used production
place_at_title_addresson separately allocated, 64 KiB-aligned coherent blocks. Each copy moved 68 bytes from guest offset 36 to guest offset 92. All four source/destination placement-delta pairs passed: (0, 0), (256, 0), (0, 768), and (256, 768) bytes.After fence completion, each destination had exactly the 17 expected address-tagged DWORDs at
dst_delta + 92, sourced fromsrc_delta + 36. All 1,007 other destination DWORDs and all 1,024 source DWORDs in each 4 KiB observation range retained their original values. This covers marker encoding and replay with independently shifted placements, beyond calling the replay helper directly. It exercises buffer copies; texture footprints, UAV clears and retail execution remain outside this fixture.AI disclosure: OpenAI Codex built and ran the fixture and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-29T14:57:10Z.
Merge-check run and written with Claude Code (Claude Opus 5.5): a test merge onto the base above, the full suite, and a 60 s
scripts/smoke.ps1run of a retail title against main on the same machine. The 4fuzz_validate_and_gpu_*failures happen on main on this machine too.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:49:50Z.
merge-check
base:
d0832e614fhead:
d9b869edd6merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 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 (console_list.rs, +316/-14, ~75 lines of code). Nothing changes by default: console lists only run with
XCL_CONSOLE_LISTS=1. The buffer_delta fix is real and applied once: on mainclose()added no delta when replaying copies (unlike list_x.rs ~6611/6651), and the backing list's slots 15/16 send XCL's own calls straight to the PC method, so there's no double shift. Each side gets its own delta, the PC buffer isdelta + byteswide so the copy stays in bounds, andchecked_addskips on overflow. Findings: (1) the tests callreplay_copy_buffer_region/replay_copy_texture_regiondirectly on an unhooked list, not throughclose(), so a mistake in the record decoding insideclose()would pass;clear_uav_slot_usableis only tested as a predicate. (2) The new helpers were inserted underclose()'s doc comment ("Turn the recorded console commands into commands on the PC list and close it."), which now documentsclear_uav_slot_usable. (3) Three changes in one PR (delta, clear-UAV guard, null guards in recording). (4) The clear-UAV guard adds little: sampler GPU slots already havepc_gpu_uav == 0(console_heap.rs ~1106), so the only new refusal is a CPU handle from a sampler heap. (5) AI use names no tool or model. Fine: the 48-byte copy-location decode is sound, the GPU test usesskip_test, and the null-pointer test would crash or fail without the guards. No smoke run: the default path doesn't reach console lists.performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: safe to merge (off by default; splitting the three changes and testing through close() would make it stronger)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T23:14:39Z.
Code review location:
crates/xcl/src/hle/d3d12x/console_list.rs; line 1020The COPY_BUFFER / COPY_TEXTURE replay now has list_x's buffer_delta handling but still skips the rest of list_x's copy bookkeeping:
note_copy_into,note_texture_write,placements::note_useandpresent::note_use. With XCL_CONSOLE_LISTS=1, a CopyBufferRegion/CopyTextureRegion into a readback buffer in a shadowed UMA window (or one placed in a GPU view) never callsnote_copy_into. The GPU-written bytes never come back to the title's CPU view after submit, so it reads stale data. Copies into kept-in-step title textures also aren't recorded as GPU writes. So these copies still differ from the same calls on a direct list.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-01T23:14:39Z.
Review: COMMENTED
Review of
d9b869ed: 2 finding(s). 1 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/console_list.rs:585: The null guards were added to cl_resource_barrier, clear_uav and cl_copy_texture_region, but the sibling hookscl_set_descriptor_heaps(heaps) andcl_set_root_constants(data) still dereference without a check.SetDescriptorHeaps(n>0, NULL)orSetComputeRoot32BitConstants(i, n>0, NULL, off)on a console list access-violates via*heaps.add(k)/slice::from_raw_parts(data, n), which is the same class of crash this PR fixes in the other hooks.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T18:20:42Z.
merge-check
base:
817eb1fc9fhead:
d9b869edd6verdict: not yet: the targeted AMD copy tests passed, but the first workspace run aborted with an access violation and the retail smoke ended early.
Windows / AMD RDNA4 (native D3D12) — shifted UMA console-list copy checks on
d9b869eClean merge onto
mainat817eb1f(merge commitffcbe5a7286689e5ea1f2b8e980bb2284a671130).git diff --checkwas clean.Setup
d3d12SDKLayers.dll, DXC 1.9.2609.5Tested
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputexited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command.SKIPPEDnoticesmainCounts are partial because two test processes aborted on each build.
0xc0000005. The table shows the rerun, which reproduced the baseline's two0xc0000409aborts instead. The cause of the one-off access violation is unconfirmed.--test-threads=1 --show-output --nocapture. This includes AMD buffer and texture copy readback at shifted offsets, null-pointer recording, and ClearUAV slot validation.uploads_start_from_each_subresources_statepassed.Shared failures and process aborts
fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsreported failures on both builds.gpu_compute_e2etest processes exited with0xc0000409on both builds.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedfor title hash2c508222.main0xc00004090xc00004090xc0000409The first run's higher startup commit did not reproduce. These exits leave frame and steady-state memory behavior unverified.
Diff review
Both buffer-copy offsets and texture placed-footprint offsets use the resource's buffer delta. The focused GPU test validated copied bytes. The recording test confirmed null pointers are skipped.
Not tested
Remaining workspace tests after the aborts and retail copy and rendering behavior.
AI use
Codex (GPT-6) merged and built the PR, ran the tests, compared the results with
main, reviewed the diff, and drafted this report.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.