Shaders: VICTORY_LDS_EXACT=1 orders LDS in a lane-branch region by the dwords it touches (369cbe906ea72764 on 32-lane GPUs) #500
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!500
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-500"
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?
@Yorivel on GitHub · 2026-11-25 01:47 UTC · original
Yorivel:fix/lds-exact-regions→main· +148 −2 · 1 files · 2 commits · openProblem
On a 32-lane host (NVIDIA), a wave64 compute program with LDS and a group over 32 threads is split into two host waves.
lds_meetingsputs group barriers at the edges of lane-branch regions, and refuses the program when one region both reads and writes LDS. Every non-read counts as a write there, atomics included, and addresses are not looked at.369cbe906ea72764(GTA VI prologue, group 64, no cross-lane ops) is refused only for that reason (VICTORY_WAVE_WHY=1:[LDS in a group over 32, an LDS read and write in one lane-branch region]). It then falls back toWaveSize(64), andCreateComputePipelineStaterefuses it withE_INVALIDARGon every run. Its LDS use is a fixed set of counters:ds_addto slots at bytes 8/12/16/20;ds_addto bytes 16/20;No read in a region touches a dword a write in the same region touches, so the barriers at the region edges already keep the console's order.
Change (opt-in:
VICTORY_LDS_EXACT=1)lds_meetingsrefuses a region only where two accesses may touch the same dword and need an order:Dsaddress that is av_mov_b32/s_mov_b32of an inline constant or literal, plus the instruction's offset, is known.read2/write2scale by the element size (×64 forst64) and wide forms cover their dwords. Any other address is taken to touch every dword, so the old answer stands there.add/sub/min/max/and/or/xor, the_rtnform being the same kind.wrxchg,cmpst,inc/dec(wrapping) andsrc2forms stay writes.The default path is unchanged. Unit tests are in
lds_exact_tests.Results (RTX 4090, driver 621.40, Windows 11, diag build)
VICTORY_HOST_MAX_WAVE=32 victory translate --validate --pipelines:369cbe906ea72764emits, validates and creates a host pipeline. The other wave64 refusals of this scene (2da4beb386509b77,2cc4c197ee29e291,02384a60fda6f2d0,6b82bc7d22016cb5) still keep 64 lanes: they also read masks as data, usev_mbcnt/v_readlane, or index LDS per lane.Tested together with #461, #190 and #156, which bring
5dc3b25986622949and6f225b641c5b0708toWaveSize(32)here as well.🤖 Generated with Claude Code
f85101b: the same four refusals, plus pipelines left "being made" for the whole run #904@ArturoWolff on GitHub · 2026-11-25 05:11 UTC · original · edited 2026-11-25 05:21 UTC
Linux check isolating #500 from the other three PRs in the RTX 4090 report: on
310c6ebplus60b651e, I replayed two compute containers matched by size and runtime hash to our earlier Proton frame 2250. In that earlier run both host pipelines returned0x80070057.Same native translator binary, host wave limit 32; only
VICTORY_LDS_EXACTchanged. Microsoft's Linuxdxvaccepted all four outputs;dxc -dumpbinreported:369cbe906ea7276402384a60fda6f2d0That independently pins the first shader's wave-size change to this PR alone. The second is also the shader we saw explicitly refused on stock
310c6ebin #599; this switch leaves its shader binary unchanged. I don't have a Linux pipeline result to add to your Windows one: the bounded GE-Proton/llvmpipe probe timed out during device initialization, before pipeline creation. No dispatch or game launch here.Warm-cache reproduction: the first setting wins. The table above is fresh translation. I then ran the same target through the production
shader_cache::host_shadermodule, using a fresh process per invocation and the same disposable disk cache across each pair. Native Linux, wave limit fixed at 32, device view-heap probe stubbed. After priming with0, switching to1hit the 6,300-byte entry; a direct translation in that same process produced 8,768 bytes. Reversing the order in a separate directory hit 8,768 bytes with0instead of 6,300. This can mask a real A/B in either direction; it doesn't tell us whether it affected your particular run.Tested fix: add
"VICTORY_LDS_EXACT",beside"VICTORY_WAVE_OWN_BITS",incrates/victory-gpu/src/shader_cache.rs(build()). With just that change to the cache module, both0 → 1 → 0and1 → 0 → 1gave miss, miss, hit, and every result matched direct translation byte-for-byte. Same class as #199, different switch. Separate cache directories suffice for comparisons until this is keyed; no need to delete an existing cache.AI disclosure: Hermes Agent ran the translator and cache comparisons, tested the one-line fix, and wrote this comment on ArturoWolff’s behalf.
@im-a-cat on GitHub · 2026-11-25 07:21 UTC · original
Checked merging
#500onto currentfxceless/main(a26859f, stacked locally with#47,#461,#190, and#592):victory-shaderpass on Windows 11 / RTX 4060 Ti (includinglds_exact_tests::kindsandlds_exact_tests::conflicts).main(>= 8dd30ab),crates/victory-shader/build.rsautomatically collects every"VICTORY_*"literal fromcrates/victory-shader/srcintoVICTORY_SHADER_SWITCHES, whichtranslation_fingerprint()hashes intoshader_cache::build(). Once rebased/merged on currentmain,VICTORY_LDS_EXACTenters the shader cache key automatically without touchingshader_cache.rs.lds_meetingsinemit/lower.rsconflicts trivially with#592at thereads[r] && writes[r]loop (both compose cleanly), and stacking#190+#500+#592ontoa26859f(514,840B) putslower.rsat532,765B, overxtask policy's524,288B per-file limit.@avt0m4t48 on GitHub · 2026-11-25 14:24 UTC · original
I reproduced a false disjoint-address result on
60b651ewithVICTORY_LDS_EXACT=1. The synthetic program initializesv1=0for every lane, writesv1=4underlane < s0, restores EXEC, then runs a read fromv1and a write to address 0 underlane < s1.When
s1 > s0, the additional reading lanes still have address 0. The existing analysis reported[(Read, Some([1])), (Write, Some([0]))]andlds_meetingsapproved the split. Separate host waves can then observe an order the console's single wave would avoid.The test and small candidate change skip guarded VGPR definitions in the constant-address map. The synthetic read becomes unknown and the analysis refuses the split. A control with the same move made unconditionally still takes the disjoint-address path. The Linux shader suite passed 174 tests with two ignored. This verifies the regional analysis on synthetic programs. I did not run the reported retail shader or measure how many existing programs the conservative check would retain.
Regression and candidate
AI-assisted using Codex.
@Dathinel on GitHub · 2026-11-25 20:50 UTC · original · edited 2026-11-25 20:51 UTC
RTX 3050 Laptop (4 GB), Windows, Series S profile. In our baseline log, compute
369cbe906ea72764was reported as translated and then refused by D3D12. It accounted for 0.8–1.5 dropped dispatches per frame in each of the last 30 reporting intervals. Two useful controls,02384a60fda6f2d0and2da4beb386509b77, also appeared in all 30.There is an important attribution issue for anyone testing this PR in a stack. DexNom/VIctory#40 reports creating the particle visibility pipeline on a 5060 Ti through a different fallback, while both control pipelines remained refused. Comet#68 independently tracks a per-frame refusal of the particle pipeline. For a local A/B, keep the wide fallback fixed in both runs, match cache warm-up, and compare creation and dispatch for those three hashes. A successful PSO alone cannot establish a visual or FPS gain.
On
f8ea5d9with a local, more conservative variant of #500, we also tested nine synthetic programs under all four combinations ofVICTORY_LDS_FLAGSandVICTORY_LDS_EXACTon the 3050. With both enabled, the flag and three disjoint-counter cases ran at Wave32 and matched all 64 output words for each of 18 input combinations. The five other cases retained Wave64, including a partially overwritten address across a basic-block boundary. The shader suite passed 226 tests with four ignored. These results cover the guarded variant; the particle pipeline still needs an enabled-run measurement on this card.Cache check on the guarded build: all four switch combinations produced distinct translation fingerprints, and repeating the first reproduced its fingerprint. The disk shader cache includes this fingerprint in its key, so the same directory can be used for the correctness comparison. Warm both variants equally if measuring timing.
AI-assisted (Codex).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.