Shaders: a descriptor read from the first lane but picked, joined or copied back before a waterfall loop is traced as each lane's own #2829
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#2829
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?
@BastienRodz on GitHub · 2026-11-25 21:38 UTC · original
resource::Tracer::classifytraces everyv_readfirstlane_b32result as "the dwords each lane holds". That holds only for the reads that a waterfall loop at the access compares, the onestrackproves throughfirst_lane_words. Reads that reachclassifyany other way get the same per-lane treatment with nothing proving it. The per-lane descriptors came in with #307 and #566.Shape 1: read, copied back to VGPRs, then a waterfall loop.
13f91cathe image traces toFetched { load: (0, 5) }, and each lane samples with its own entry. In a run on vkd3d-proton with entry(v0 & 1) << 5, the result alternates[1.0, 2.0, 1.0, 2.0, ...]. The console would give the first lane's value,1.0, in all 32 lanes.Shape 2: picked by
s_cselect(or joined at an SGPR phi) after the read.v4..v7to the buffer at 0x20.v_readfirstlane s[12:15], thens_cselect_b64 s[12:15], s[12:15], s[28:31].buffer_loadthat only lanes 16 and up run.Main traces this to
Select { [Loaded 0x0, Loaded 0x20] }. The first lane is lane 0, which holds 0x20, so the console reads 0x20 whatever SCC is. Main checks that the dwords agree only in the lanes that access the descriptor, not in the lanes that run the read.Expected. The same rule main already applies to a first-lane read at the access without a waterfall loop: such a read is one lane's, so a descriptor that can differ between lanes is refused ("a descriptor read from the first lane outside a waterfall loop").
Found by reading the code and checked with synthetic programs; I have no in-game observation. No game data. Analysis assisted by Claude Code.
github-bot referenced this issue2026-11-26 05:15:19 +00:00
@Marvisak on GitHub · 2026-11-25 21:46 UTC · original · edited 2026-11-26 00:45 UTC
Automated triage for the maintainers.
Confirmed by reading
main(63bcca4). Incrates/victory-shader/src/resource.rs,Tracer::classifysends any words that are allv_readfirstlane_b32results (first_lane_source) toper_lane, without condition.trackproves only the reads thatfirst_lane_wordsfinds directly at an access, throughTracer::waterfall. Reads that reachclassifythroughselect/phi, or through a copy back into VGPRs, therefore become per-lane descriptors with nothing proving it, and the refusal "a descriptor read from the first lane outside a waterfall loop" is never reached for them.The per-lane path came in with #307 and #566 (both merged). Open PR #2831 addresses this issue; per the comparison above it also refuses masked writes that put the identical descriptor back, which the PR's review should weigh.
Generated by Claude Code
@rezioliver-collab on GitHub · 2026-11-25 22:09 UTC · original
I reproduced the SGPR phi variant of shape 2 on an Apple M1. #2831 correctly rejects the case where lanes hold different descriptors. It also rejects a masked write that copies the identical descriptor back, even from the exact same source registers.
All 32 lanes initially hold the descriptor at table offset
0x20. Eachphi(read, copy)below lists the table offsets traced on the first-lane and scalar-copy paths, respectively.4a53da72)74169903)0x00phi(0x00, 0x20)phi(0x20, 0x20)phi(0x20, 0x20)0x20phi(0x20, 0x20)s[28:31]registers used for the initial writephi(0x20, 0x20)I ran a native CPU-side
victory-shaderintegration test on macOS 14.7 with Rust 1.98.1, using synthetic GFX10 Wave32 compute shaders. A scalar branch keeps the fourv_readfirstlane_b32results on one path and copiess[28:31]on the other. The test checked thatbuffer_load_dwordconsumes four two-input SGPR phis, one for each ofs12throughs15, then checked the resource tracker's result.In the first row, lane 0 still holds
0x20whenv_readfirstlane_b32runs with fullEXEC. Only the later buffer load is restricted to lanes 16–31, so both scalar paths should give0x20. All three rejections on #2831 occurred at the buffer load (0x78) witha per-lane descriptor written where some lanes may keep the old one. Applying #2831 to the tested main commit gave the same four results as the PR head.