Shaders: glc loads aren't marked globally coherent, so cross-workgroup waits may never see the write #725
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#725
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Dufftwt on GitHub · 2026-11-24 08:26 UTC · original
What's wrong
On RDNA2,
glcon a buffer or image load means "skip the per-CU (L0) cache". It's how one workgroup sees another workgroup's writes: LLVM's GFX10 memory model (AMDGPUUsage) lowers an agent-scope atomic load tobuffer/global/flat_load glc=1 dlc=1. Titles use it for cross-workgroup spin waits and look-back scans.The lowering never marks a handle globally coherent (
IsGloballyCoherent, props bit0x4000, in DXC'sDxilResourceProperties.h):crates/victory-shader/src/emit/lower.rs:6075-6076) and image handles (:5470-5475) only setIsUAV.glcis looked at only to decide whether an atomic returns its old value (:5519,:5546,:6095).So a
glcload becomes an ordinary, group-coherent UAV load. The host compiler may keep it in a register or a non-coherent cache, or hoist it out of a loop.Example
A spin wait such as the one in #452:
I haven't shown that the missing flag is the cause of #452's hangs: it's one plausible cause.
Suggested fix
OR
0x4000into a UAV handle's props when the access hasglc(props are already part of the handle cache key). For that to reach heap descriptors, they first have to be known as UAVs (#724).Not tested: a test asserting the props (as in #724) would show the missing flag. A behavioural test on WARP would depend on timing, so I haven't written one.
Related
@Hiiva on GitHub · 2026-11-24 09:05 UTC · original
Implemented DXIL IsGloballyCoherent (0x4000) on GLC UAV buffer and image accesses, including image atomics. Regression test checks the SRV/UAV property bits, and shader Clippy passes. The change is combined with heap UAV inference for #724 on https://github.com/Hiiva/VIctory/tree/hiiva/heap-uav-coherence (fa119dd, 5c26db0). GPU behavioral improvement is not yet established. AI-assisted; no game assets.
@RID-Games on GitHub · 2026-11-24 09:45 UTC · original · edited 2026-11-24 10:22 UTC
Same note as on #724: the branch marks glc UAV accesses coherently, but a heap descriptor read only by
glcloads (the spin-wait in this issue's example) is never inferred as a UAV — the pre-pass filter isstore || atomic, andresource_flags(false, true)is 0 — so it still gets a plain SRV handle and no0x4000. Markingglcaccesses in the #724 pre-pass (as the issue prescribes: "store, atomic or glc") is what makes this fix reach heap descriptors. Verified the branch's tests on Linux: 72 passed. AI-assisted.@dpalacios69 on GitHub · 2026-11-24 10:22 UTC · original
Prepared a standalone branch on
ffe310ecovering both #724 and #725 (including theglc-only heap load spin-wait case noted above):dpalacios69/VIctory@fix/shader-glc-globally-coherent.Lower::new(crates/victory-shader/src/emit/lower.rs) infers resource-heap UAVs keyed by(param, byte_offset, dynamic)fromstore,atomic, orglcloads (excludingimage_sample*and descriptor loadss_load_dword*), and routess_buffer_loadon UAVs to raw UAV handles instead of CBV.IsGloballyCoherent(0x4000) into UAV handle properties whencache.glcis set on buffer, image, ands_buffer_loadaccesses.glcloads matches #724/#725 soglc-only heap spin-waits get0x500B, with the caveat noted by @Hiiva that aglcload on a read-only heap SRV would be annotated as a UAV.cargo test -p victory-shader --locked: 101 passed, 0 failed, 1 ignored, including 5 new tests;clippy -D warningsclean onlower.rs;cargo xtask policyok). DXIL validator (dxil.dll) and GPU execution were not run locally.AI-assisted; no game data used.
@Wasler on GitHub · 2026-11-24 12:04 UTC · original
Confirmed empirically on RTX 5060 Ti (
origin/mainffe310e+ PR#568+ PR#334): ORing0x4000(IsGloballyCoherent) into image/buffer UAV handle props whenglcis set cleared the11-list compute loop hang (9ef9a9d818b27236/4fcf26015f70eecf) withoutVICTORY_SHADER_LOOP_LIMIT(full report in #732).@Sunkiller-qc on GitHub · 2026-11-24 13:13 UTC · original
Some data on how often this shader shows up in hangs.
9ef9a9d818b27236, the program Wasler's run stopped looping in onceglcwas marked coherent, is also in the failing work in other reports:ffe310e): it's the dispatch in list 10 of 11 when the device is removed (0x887A0006).fa5ef73with the debug layer): the fault is in list 10 of 11, whose compute dispatches are82849f7a614208eb,9afd549c4f530901,2dc602192abf6288,9ef9a9d818b27236,4fcf26015f70eecfandba4e20a2fd348338. #781 hasba4e20a2fd348338in the same list.AwkGrep256 still hangs on RX 9070 XT under vkd3d-proton with the fix (3 of 3, 13–17 s after this pipeline is created). So it doesn't look like the whole story on AMD, but it is the same shader on both vendors. There's no PR for this yet. dpalacios69's
fix/shader-glc-globally-coherentalso covers the glc-only heap load case RID-Games pointed out.@Marvisak on GitHub · 2026-11-25 01:48 UTC · original
Automated triage for the maintainers.
Confirmed on current
main. Incrates/victory-shader/src/emit/lower.rs, UAV handle props are built only from0x1000(IsUAV) inLower::buffer, the image lowering andLower::descriptor_data. Nothing in the file setsIsGloballyCoherent(0x4000), andglcdoesn't change a handle's props. So aglcload is lowered as an ordinary UAV load. For heap descriptors, this also depends on #724, since their loads aren't known to be UAV loads at all.Evidence that it matters in the title: in the comments, marking
glcUAV handles coherent ended the compute loop hang in9ef9a9d818b27236on an RTX 5060 Ti, and that program appears in the failing list in other hang reports (#59, #781). It wasn't enough on an RX 9070 XT under vkd3d-proton, so it may be one cause among several there.The fix is in an open pull request: #1271 (with #724) sets
0x1000 | 0x4000onglcUAV accesses and infers heap UAVs first. It's labelled as needing a rebase onto currentmain. The fork branches in the comments (Hiiva, dpalacios69) are alternatives.Generated by Claude Code