Shaders: CS_TraceShadowRays_FullAdaptive translates (joins fed by a scalar load are data, on the retry only) #2993
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by JohnNajar on 2026-11-29T19:15:59Z.
Makes 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
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by AimLogin on 2026-11-29T20:46:16Z.
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.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by JohnNajar on 2026-11-29T22:34:10Z.
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.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by davemathews12 on 2026-11-30T18:57:27Z.
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
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.