Shaders: CS_TraceShadowRays_FullAdaptive translates (joins fed by a scalar load are data, on the retry only) #2993
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!2993
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2993"
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?
@JohnNajar on GitHub · 2026-11-29 19:15 UTC · original
JohnNajar:fix/loaded-join-masks→main· +102 −1 · 4 files · 2 commits · openMakes the last untranslated program in
shaders.rpftranslate:shadowmask:CS_TraceShadowRays_FullAdaptive(#dbdbf36298727135), the ray-traced shadow pass. It failed with "a lane mask holding lanes elsewhere read as data" at 0xae80.The cause
At 0xae74 the program compares
s35with each lane:v_cmp_ne_u32 vcc_lo, s35, v62.s35is plain data:s31 = s27 & 0x001fffff(0x9a38)s32 = (s23 << 5) & 0xffe00000(0x9a80, 0x9a94)s35 = s32 | s31(0x9c84)The structurizer still records
s35as a lane mask.s27reaches 0x9a38 through a join: one value comes froms_buffer_load_dwordx2 s[26:27](0x8838), and the other is an earlier join that holds a saved EXEC, left in the same register. Since that join counts as derived, the bit-field arithmetic becomes a mask, andlower::mask_dwordrefuses its numeric read in a block where not every lane runs.The change
Only after that refusal, the program is translated once more with joins that have a value straight from
s_load_*/s_buffer_load_*taken as data (structure::with_loaded_joins_data). Lane masks come from compares and EXEC, never from a constant buffer. The retry is inemit::translate, which is what a run uses, and invictory translate, so the listing says what a run does.Because it is a retry, no program that translated before changes.
Checked
victory translate --list shaders.rpf: 25,694 of 25,694 programs emit. The other 25,693 emit byte-identical DXIL to the build without the change, compared by hash per program.#dbdbf36298727135emits (1fd0654fbc824f1d), passesdxil.dll's validator (--validate), and makes a pipeline (--pipelines) on an RTX 3090 (driver 621.40). Rebuilt and rechecked on this branch (on top off889bb07).Earlier reports
shadowmask:CS_TraceShadowRays_FullAdaptive (#dbdbf36298727135), the one program of shaders.rpf that did not translate ("a lane mask holding lanes elsewhere read as data" at 0xae80), compares s35 with each lane at 0xae74. s35 is data: two bit fields of values loaded from a constant buffer (0x9a38, 0x9a80/0x9a94, joined at 0x9c84). The structurizer still made it a lane mask, through a join whose other value is a saved EXEC left in the same register (the compiler reuses s27 for both). Only after that refusal, translate once more with joins of which one value comes straight from s_load_*/s_buffer_load_* taken as data (structure::with_loaded_joins_data), in emit::translate and in `victory translate`. Every program that translated before is untouched: on shaders.rpf all 25,693 others emit byte-identical DXIL; this one now emits, passes dxil.dll's validator and makes a pipeline (RTX 3090). Co-Authored-By: Claude Opus 5.5 <[email protected]>@AimLogin on GitHub · 2026-11-29 20:46 UTC · original
Review note (read at head
491656bf, not run):The new thread-local
LOADED_JOINS_DATAis set and reset by hand (replace(true)…set(was)). Once #2917 lands, translator panics are caught and the worker thread goes on translating. A panic inside this scope would then leave the flag set, and every later program on that worker would treat loaded joins as data without anyone noticing. Routing it through #2917'swith_flagguard, as the other translator switches now do, would close that.Two small asks for confidence:
AI-assisted review.
@JohnNajar on GitHub · 2026-11-29 22:34 UTC · original
Thanks for the review. All three points are addressed in
960088ce:The switch is now put back on unwind.
with_loaded_joins_datarestores the thread-local through aDropguard, so a panic inside the retry, as caught by #2917, no longer leaves it on for later programs on that worker. Test:structure::loaded_joins_tests::the_switch_is_put_back_after_a_panic(catch_unwindaround a panicking scope, then checks the switch is off). When #2917 lands, this can become itswith_flag.A test with a control:
emit::lower::tests::a_join_fed_by_a_scalar_load_is_data_on_the_retry. It rebuilds the case in fourteen words:s_mov_b32 s27, exec_lo) on one path,s_buffer_load_dword s27on the others_and_b32 s31, s27, 0x1fffff)v_mov_b32 v0, s31) inside ans_and_saveexecControl: without the retry it must be refused with
MASK_ELSEWHERE, and it is. Withwith_loaded_joins_datait lowers. With the rule disabled (if false && loaded_data), the test fails with "a lane mask holding lanes elsewhere read as data" at the same place.cargo test -p victory-shader: 464 passed, 0 failed, 9 ignored.Census diff,
victory translate --list shaders.rpf(GTA VI 1.0.2.1), without and with the change, compared by emitted-DXIL hash per program:#dbdbf36298727135→1fd0654fbc824f1dSo only the intended program's module changes. It also passes
dxil.dll's validator and makes a pipeline on an RTX 3090 (--validate --pipelines). This census is from the first version of the retry. The guard commit does not change what is emitted, and the retry path is the same.@davemathews12 on GitHub · 2026-11-30 18:57 UTC · original
Checked against the full retail
shaders.rpf(1.0.2.1), withvictory translate --listandVICTORY_EMIT_DUMP. Base: main at84bd61e2plus #3687 (so it runs on Linux; that changes nothing on Windows).CS_TraceShadowRays_FullAdaptive(dbdbf36298727135), "a lane mask holding lanes elsewhere read as data". With this PR it translates.opt -passes=verify, LLVM 18, after replacing DXIL's data layout to get past itsi8:32). That's not the DXIL validator, but it means no malformed IR.Not checked: the DXIL validator, and the shadows on a card.
One note for merging: this conflicts in
emit/lower/tests.rswith current main (both add tests at the end of the module). The translator files merge cleanly.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.