Repository navigation
An Ampere BRX finds its c1 jump table when the block that loads it was split later - #2010
Valtterios wants to merge 1 commit into
Conversation
e97b983 to
95d5545
Compare
…s split later Symptom: 16 pixel shaders of Pokémon Pokopia (0400A3A01EE4C000) failed with "BRX with no target found in the c1 jump table", although the LDC of the table's base (LDC c[0x1][R20+0x790]) is on the only path to the BRX. Cause: Block.Split gives the right half the left half's successors, but their predecessor lists still name the left half. FindBrxTableAmpere walks those lists back to the LDC, so when the block holding the LDC was split after its successors were linked (a later branch lands inside it), the walk from the BRX started in the left half, before the load, and met another write of the register (or the program's start) and gave up. Fix: after each split the Ampere decoder points the moved successors' predecessors at the right half. The Maxwell decoder is left as it is. Checked: test_dmsh_control_flow.py has a new case (a table loaded in a block split later by a branch back into it): it fails on the translator of main with the same error and passes with this one; the other control flow cases pass. 4,017 of Pokopia's shaders (4,001 random ones and the 16), translated with the translator before and after: the 8,002 SPIR-V and reflection files of the 4,001 that translated before are byte-identical, and the 16 translate and compile for macOS. The translator is rebuilt and dmsh_chain.lock and dmsh_chain.h are updated, so every game's shaders are built again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95d5545 to
61aa12a
Compare
…s split later: Block.Split gave the right half the left half's successors but left their predecessor lists naming the left half. Both decoders walk those lists back from a BRX to the load of its jump table (FindBrxTableAmpere, the Maxwell decoder's FindBrxTargetRange), so when the block holding the LDC was split after its successors were linked (a later branch lands inside it), the walk started in the left half, before the load, and met another write of the register or the program's start: "BRX with no target found in the c1 jump table" on 16 pixel shaders of Pokémon Pokopia (an LDC c[0x1][R20+0x790], then a conditional BRA to the BRX). Split now points each moved successor's predecessor entry at the right half, for both decoders; nothing else reads the decoder's lists except for their count (the IR's BasicBlock lists are another graph). PR #2010 mended the lists after the Ampere decoder's split only and shipped the .NET DLL main no longer uses; its diagnosis, its test and its reference entry are kept, the repair moved into Split, and the native translator is rebuilt (dmsh_chain.lock, DMSH_CHAIN 3ae08e02ec6a: every game's shader libraries rebuild). Checked: test_dmsh_control_flow's new test_table_loaded_in_a_block_split_later fails on the old translator with that error and passes on this one; the 26 dm/gfx/tests/test_dmsh_*.py give the same results with both otherwise (test_dmsh_pairs has one error with both: it needs DM_GAME); test_docs, test_nsp_chain, tool_lock.py --check-tools pass. Old and new translator on every shader of three games, SPIR-V and reflection files compared byte for byte: Splatoon Raiders (Ampere, 27,192 shaders, 54,384 files), Octopath Traveler II (Maxwell, 13,980, 27,960) and Fire Emblem Three Houses (Maxwell, 1,372, 2,744), no file differs and no shader fails with either. The author's run with the PR's form: Pokopia's 16 shaders translate and compile for macOS, 4,001 others byte-identical. Not run: Pokopia's shaders with this form (its files are not on hand), any game, regress.py (no shader of the three games changes), the iPhone. Open: no Maxwell shader that the repair changes is known, so that side is checked by reading only (PR #2010) Co-authored-by: Valtterios <34726970+Valtterios@users.noreply.github.com>
|
Landed on main as 3553400, with you as co-author. Your diagnosis, the test and the reference entry are kept. Two things differ from the PR:
Checked here: your test fails on the old translator and passes on the new one. Old and new translator give byte-identical SPIR-V and reflection files for every shader of Splatoon Raiders (27,192), Octopath Traveler II (13,980) and Fire Emblem Three Houses (1,372). Not checked here: Pokopia, whose files I do not have at hand. Could you rebuild its shaders on main and confirm that the 16 translate? |
|
Thanks for taking it, and for moving the repair into How I checked:
Not checked: the iOS libraries, a full build of all 131,426 shaders on main, and the game in play with this chain. |
What and why
16 pixel shaders of Pokémon Pokopia (0400A3A01EE4C000) failed with
BRX with no target found in the c1 jump table, although the LDC that loads the table's base is on the only path to the BRX.Block.Splitgives the right half the left half's successors but leaves their predecessor lists naming the left half.FindBrxTableAmperewalks those lists back to the LDC, so when the block holding the LDC was split after its successors were linked (a later branch lands inside it), the walk from the BRX started in the left half, before the load, and gave up. After each split the Ampere decoder now points the moved successors' predecessors at the right half (MovePredecessorsAmpere). The Maxwell decoder is left as it is.Reference entry:
docs/reference/shaders.md, "An Ampere jump table loaded in a block split later".Checked
test_dmsh_control_flow.pyhas a new case,test_table_loaded_in_a_block_split_later. It fails on main's translator with the same error and passes with this one. The otherdm/gfx/tests/test_dmsh_*.pygive the same results with both translators (test_dmsh_ampere_mem,test_dmsh_meshstageandtest_dmsh_pairsfail the same way on main here).dmsh_build.py, not in play.regress.py check --games: not run. The change is limited to the Ampere decoder's block splits, and the byte-identical comparison above stands in for it on Pokopia. No Switch 1 shader can change.Docs
docs/reference/shaders.md, andpython3 dm/tools/docs_symptoms.pywas rundmsh_chain.py --headerwas run anddm/gfx/nvn/dmsh_chain.his part of the change🤖 Generated with Claude Code