Shader tests: the split-LDS read-after-read test's UAV-load negative reads its load (fails on main since #2623) #4321
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4321
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4320"
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?
@Lyrnc on GitHub · 2026-11-30 18:51 UTC · original
Lyrnc:fix/lds-wave32-rar-coalescing→main· +6 −0 · 1 files · 1 commits · merged 2026-11-30 23:37 UTCWhat fails
On
main(84bd61e2),emit::bitcode::opt::tests::hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parityfails at itsneg_uav_load_between_readscase:The five cases before it pass, and so does the same case with
BARRIERSalone. The pattern checks needdxc.exenext to the validator, so the failure shows on machines with the Windows SDK's dxc. It has been reported as "fails on main too" in #4224 (RTX 3060), #4046 (RTX 3090), #3641, #3061 and #3064.The test is wrong, not the pass
The case puts
buffer_load_dword v8between the two LDS reads, as a resource call that must keep the barrier between them. But nothing readsv8.Since #2623 (
dbdd6ada),Module::optimisedrops dead instructions inside its fixed-point loop (so dead diamonds empty out forsimplify_cfg). WithALLorDEFAULT:mergesees the load (Effect::Reads, so the barrier state is reset) and keeps the middle barrier.drop_dead_inststhen removes the load, because nothing uses it.mergefindsB R B R Bwith nothing between the reads and drops the middle barrier.BARRIERSalone runs noDEAD, so the load stays and the barrier stays. That is why only themask=ALLassertion fails. Before #2623, dead instructions went only after the last round, so the barrier stayed even though the load was gone.Dropping that barrier is right. Once the unread load is gone, the case is the same as
adjacent_rar, and the test expectsBWBRRBWBRfor that one. Two LDS reads with no write, atomic or other access between them cannot conflict. The barriers before the first read and after the second still order every write against them.To check that against hardware, I ran the fixture on an RDNA2 GPU (Radeon iGPU, gfx1036, through a HIP kernel-body oracle). A barrier there is
s_waitcnt lgkmcnt(0); s_barrier, the same as a group-sync with a group-shared fence. Every thread should get[t ^ 32, t, t + 25]:opt=0)So the console's order (one wave64, no barriers) gives what the test checks. Two 32-lane waves with the four barriers left after the coalescing (none between the reads) give the same result. The control shows the setup catches a missing barrier: with none, each wave reads the other's dwords before they are written. The oracle script is a short piece of plain GFX10 assembly. I can post it here if it's wanted.
The change (test only)
The negative now adds the loaded value into
v6beforeout[128 + t]is stored (v_add_nc_u32 v6, v8, v6). Threadtloadsout[t], which is still 0 at that point: the test host's UAV is a fresh committed resource (zeroed), and only threadtwritesout[t], after its load. So the expected outputs don't change. The load is now used under every mask, though, so the case tests what its comment says again: a UAV read between the reads keeps all five barriers.No code outside the test changes.
How it was tested
RTX 5080 (the default adapter), Windows 11, Rust 1.98.1 (pinned), with the Windows SDK's
dxc.exenext to the validator, so the pattern checks run.main): the test fails as shown above.neg_uav_load_between_reads: opt=0 BWBRBRBWBR -> BARRIERS BWBRBRBWBR, ALL BWBRBRBWBR. The other five cases print the same patterns as before.Effect::Readscalls no longer reset the barrier state inmerge. With it, the fixed case fails (neg_uav_load_between_reads mask=BARRIERS pattern,BWBRRBWBR). Without the mutation it passes under all three masks.cargo test -p victory-shader --lib -- emit::bitcode::opt --test-threads=1: 31 passed, 1 ignored, 0 failed. I stopped the full--librun partway, so it didn't hold up a GPU benchmark here. By then 275 had passed and 3 had failed. Those 3 are the ones listed as failing onmainin #3061 (barycentric_tests::first_half_values_render_on_hardware_and_warp, andrect::tests::rectangles_are_drawn_whole/the_rectangle_stage_is_a_geometry_shader), and they're nowhere near this change.cargo clippy -p victory-shader --all-targets -- -D warnings, default and--all-features: one finding, the same as onmain(field loop_caps is never read,emit/lower.rs:114, which #4297 deals with). Nothing new from the test change.cargo xtask policy: one violation, the same as onmain(victory-shader/src/native.rs, the hex run that #4224 removes).Checked for overlap
lds barrier/ read-after-read terms andopt.rs. Several PRs list this test as failing onmain, and none changes it. #3106 (barrier state onOp::VolatileLoad) touches the same pass but not this test or the case.AI use: Claude Code (an AI agent working for Lyrnc) did the analysis, the test change, the oracle runs and this text. The runs above are real runs on this machine.
🤖 Generated with Claude Code
@babuakhil on GitHub · 2026-11-30 19:16 UTC · original
This and #4328 fix the same failure of
split_lds_wave32_read_after_read_barrier_coalescing_and_parity(neg_uav_load_between_reads mask=ALL), in two ways: this one makes the load used (v6 = v8 + v6before the store), and #4328 keeps the dead load and expectsALLto drop the barrier. I ran both on Windows 11 with an RTX 3060 and the SDK'sdxc(Rust 1.98.1, pinned), each applied onmain(e1251c31); both cherry-pick cleanly.mainALLgivesBWBRRBWBR, expectsBWBRBRBWBRneg_uav_load_between_reads:opt=0→BARRIERS→ALLBWBRBRBWBR→BWBRBRBWBR→BWBRBRBWBRBWBRBRBWBR→BWBRBRBWBR→BWBRRBWBRTo see what each version of the test still guards, I made two throwaway changes to
opt.rs(not part of either PR):opt.rsEffect::Readscall arm ofmergeno longer runsbarriers.reset(), so a resource read between two LDS reads stops keeping the barriermask=BARRIERS)mask=BARRIERS)drop_dead_inststaken out ofoptimise's rounds, so dead code goes only after the loop, as before #2623mask=ALL)Both still catch the real bug. But #4328's
ALLexpectation is tied to when dead code is dropped rather than to the barrier rule, so it would fail on a harmless reordering of passes, and itsALLrun no longer covers a live resource read between the reads. With this PR the case tests a live load in all three modes, and its value passes the hardware and WARP parity checks on the 3060.So I'd take this one. #4328's analysis of why
mainfails is right; the difference is only which way the test is fixed.