Recompiler: an image_load after an image_store of the same image reads the store #2156
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2156
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2156/head"
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?
@upipibi on GitHub · 2026-11-25 06:28 UTC · original
upipibi:fix/image-load-after-store→main· +159 −8 · 6 files · 1 commits · merged 2026-11-25 10:49 UTCimage_loadreads an image through its SRV (tw0), whileimage_storeand the image atomics write its UAV (tw0 + 1). Within one dispatch the SRV need not see the UAV's writes, so a program that stores a texel and loads it back can read the old value. RDNA2 reads its own writes. On an RTX 3070 the new test reads the old value on all 64 lanes withXCL_DIRECT_DXIL=1. The HLSL path happens to see the write on this driver, but D3D12 doesn't promise it.What is in it
recomp/emit.rs:image_write_srsrcslists the T# SGPRs a program stores or does image atomics through (at most 16). Each such store or atomic records, per invocation, which image it wrote (xcl_iw{srsrc} = tw0 + 1). A laterimage_loadof the same image reads through the UAV. Every other load, and cube and mip loads (a UAV view is a single mip), stays on the SRV.dxil/lower_image.rs,dxil/lower.rs,dxil/kernel.rs: the same on the direct DXIL path, with 16 per-lane variables (VAR_IMG_WRITE) and a typed UAV load.recomp/runner.rs: the test runner now always creates the SRV of a test texture, as the runtime does. A UAV test texture had none, so its loads read 0.recomp/tests.rs:gpu_image_load_reads_a_store_of_the_same_dispatch: an 8x8 R32_UINT image set to 0xEEEEEEEE. Each lane stores 1000 + lane to its texel, loads the same texel, runss_barrier, then loads lane ^ 1's texel.image_load_of_a_stored_image_reads_through_the_uav: a codegen test that needs no GPU.Tested
main6020a33.mainwith the new test (and the runner SRV fix): it fails withXCL_DIRECT_DXIL=1on all 64 lanes, reading 0xEEEEEEEE. It passes withXCL_DIRECT_DXIL=0.gpu_suite (--skip gpu_sparse_vram): 135 passed withXCL_DIRECT_DXIL=0. With1, 134 passed and 1 failed:gpu_image_get_resinfo_1d_array, which fails onmaintoo (#2046).Regression run
Run by luckyteagirl on an AMD Radeon RX 6800M (comment),
mainand this head, pasted unedited:Not tested
ec356bc: Intel Arc A770 (JJAutoCompare, comment) and AMD RX 6800M (luckyteagirl, comment).s_barrier.s_barrieris translated as a group-memory-only barrier (emit.rs:1264,dxil/lower.rs:1005), which doesn't order UAV writes between lanes. This PR covers a lane reading an image it stored to itself. The neighbour read in the test passes on this NVIDIA driver, but D3D12 doesn't guarantee it. That would be a separate change to the barrier.AI use
🤖 Generated with Claude Code
@JJAutoCompare on GitHub · 2026-11-25 06:57 UTC · original
Tested
ec356bc5c8d41053cbd129c991c6f0e56fa319ed. The PR was open at that SHA before and after the run. The assigned worktree remained clean and detached at the SHA after testing.32.0.101.9175, Windows 11 Enterprise Evaluation 25H2 build26200.9974, Rust and Cargo1.100.0onx86_64-pc-windows-msvc, unoptimized test profile with debug info and incremental builds disabled, DXC1.9.2609.5(01b62ad4).cargo test -p xcl --lib --no-run --message-format=json. UsedCARGO_TARGET_DIR=L:/XclTooling/pr2011-990b9d4-t3-76a0502d/target,CARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0, and privateTEMPandTMPatL:/XclTooling/pr2156/run-20261125-075425-121/temp. Pinned Cargo's emitted test binary in the run directory. Its SHA-256 stayed27489121E4B0202DE2D8AA90103CB368FFD439C02E3076C19A75098C83D6B6F6.& 'L:/XclTooling/pr2156/run-20261125-075425-121/xcl-pr2156-lib-tests.exe' --exact gpu::recomp::tests::image_load_of_a_stored_image_reads_through_the_uav --nocapture --test-threads=1. The HLSL codegen assertions passed for the UAV load after a store and the SRV-only load.& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { ... }: ran& 'L:/XclTooling/pr2156/run-20261125-075425-121/xcl-pr2156-lib-tests.exe' --exact gpu::recomp::tests::gpu_image_load_reads_a_store_of_the_same_dispatch --nocapture --test-threads=1twice, withXCL_ADAPTER=A770,XCL_DXC_DIR=%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64, andXCL_DIRECT_DXIL=0(HLSL + DXC) and1(direct DXIL). Each run passed the readback checks for all 64 texels of the 8×8R32_UINTimage. Each texel contained1000 + lane, each lane's immediate load returned its own value, and its load afters_barrierreturned1000 + (lane ^ 1). The neighbor result is specific to this fixture and driver.Released the XCL Arc A770 test lock.PowerShell's saved Arc log captures both fixture outputs and exit codes. The wrapper's host messages appeared in the terminal output.L:/XclTooling/pr2156/run-20261125-075425-121/build.log,L:/XclTooling/pr2156/run-20261125-075425-121/build.jsonl,L:/XclTooling/pr2156/run-20261125-075425-121/cpu.log, andL:/XclTooling/pr2156/run-20261125-075425-121/arc.log.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 07:04 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@luckyteagirl on GitHub · 2026-11-25 07:19 UTC · original
Independent native Windows AMD check of exact PR head
ec356bc5c8d41053cbd129c991c6f0e56fa319ed. The PR asks for a paired real-title smoke and lists AMD/native wave64 as untested.Tested
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Debug tests and release title runs.XCL_ADAPTER=6800M,XCL_REQUIRE_GPU=wave64;cargo test --locked -p xcl --lib -j 2 gpu_image_load_reads_a_store_of_the_same_dispatch -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED withXCL_DIRECT_DXIL=1, and the same counts withXCL_DIRECT_DXIL=0. The 8x8 R32_UINT fixture checks each lane's store followed by its own load; its neighbor-after-barrier result is driver-specific as the PR notes.image_load_of_a_stored_image_reads_through_the_uav: 1 passed, 0 failed, 0 ignored.cargo build --locked --workspace --release -j 2: passed.Regression run
Paired guarded seven-second launches of the same owned title with isolated data and DXIL caches, no input. The
maincommit below has the same runtime source as this PR's6020a33base.Both launches reached their first frame but logged zero draws and zero dispatches. They are short startup regressions, not evidence that the title uses the image read-after-write path. The focused GPU fixture above exercises that path. I did not run the full workspace suite or a longer title session.
AI-assisted checkout, testing, smoke monitoring, log verification, and report drafting with OpenAI Codex (GPT-6). No game data was uploaded.