Repository navigation
fix(shader): link table callees that together exceed s_call_b64 range - #9068
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Title data point for this PR (data only). Title: PPSA03685, 300 s through the runner, Baseline, This PR (head The new message comes from One run per state. I did not look at the picture and I did not run the PR's tests on this machine for this comment. Not run: the PR's tests, other GPUs for this title, the console. AI-assisted (Claude Code). |
|
@xXPBSXx thanks, your reading is right. e5a02bd (pushed here) removes it. Before the first of an earlier call's copies and after each one,
AI-assisted: yes (Claude Code) |
|
@klosixgaming-arch credit where it's due: on #7413 (comment) you proposed inserting intermediate AI-assisted: yes (Claude Code) |
|
Another title with this stop: Persona 3 Reload (PPSA10872), thread #9692. Compute shader 0x2014960000, run when entering the Iwatodai Station strip mall. Windows 11, RTX 5090 (NVIDIA 617.42),
Is the 16,384-dword copy limit something this layout can raise, now that each relay only crosses one copy? Separately, is preparation time expected to grow this steeply with shader size? I can rerun this title on any head. |
|
Tested #9068 on Little Nightmares (PPSA, A. #8939 stack + #8070 + #9068: the branch-range stop is gone and the run gets further than without #9068. At about 64 s it stops in B. #7880 + #8070 + #9068, without #7395/#8939: stops earlier, at about 27 s, in Also, #7880 and the #7395 stack conflict in I did not test #9068 alone on a clean main. Logs available if useful. AI-assisted: yes. Written with AI assistance and reviewed by me. |
|
@klosixgaming-arch thank you for the Little Nightmares runs, and for testing both stacks. In stack A the branch-range stop is gone, which is the part #9068 covers. The next stop, Stack B's deeper Phi chain and the AI-assisted: yes (Claude Code) |
|
@zaidhawk thank you for the Persona 3 Reload runs, and for measuring the callee. The 16,384-dword limit is the read window of Preparation time: yes, it grows steeply on graphs this size. Ghostrunner's 104,136-dword shader (PPSA03685, linked with this PR and #8070) spent 173 s in the structurizer, past the same 120 s render-thread watchdog. #9702 brings that to about 19 s in the title. It is stacked on #9701, and #9703 on it, so this PR + #8070 + #9703's branch with your raised limit would show whether your 92K-word shader then prepares in time. AI-assisted: yes (Claude Code) |
|
@frankea thanks. I ran the stack you suggested on Persona 3 Reload (PPSA10872): the strip-mall shader now prepares before the watchdog, and the next stop is #7459. Setup: Windows 11, RTX 5090 (NVIDIA 617.42), Ryzen 7 9800X3D, WinLibs GCC 15.2.0, Release. Tree A: Offline: from a run on tree A I captured the request for compute shader 0x2014960000 just before its preparation (a local dump, not proposed): 119,922 words with all three table calls linked.
In game, entering the Iwatodai Station strip mall:
The chain has So for this title the 17,369-dword callee isn't the only thing in the way: with a larger window and #9703's stack, the next stop is #7459. I can rerun on new heads of any of these. Not covered: other GPUs, more than one run per state, anything past the strip mall. |
|
@zaidhawk thank you, that settles both questions for Persona 3 Reload: with this PR and #8070 the strip-mall shader links, and with #9701 to #9703 its 119,922-word preparation drops from 355.0 s to 32.6 s and the RenderThread watchdog no longer fires. I've added your replay and in-game result to #9702's Tested section and PPSA10872 to its Unblocks line. The 16,384-dword window you raised is AI-assisted: yes (Claude Code) |
|
Test report: Ghostrunner (PPSA03685) on Windows 10 22H2, NVIDIA GeForce RTX 3080 (driver 617.42), MinGW GCC Release build, 2026-10-23. Relinked with
So on this title the PR does what it says, and Ghostrunner joins Persona 3 Reload on the #7459 stop. AI-assisted: yes (Claude Code). |
daef563 to
ef2b164
Compare
|
Checked the segment layout and the relays word for word against the new |
What
Gran Turismo 7's World Map dispatches a compute shader whose
s_swappc_b64calls through a table of about 35 material functions, about 40,000 dwords in all. Linking it threwthe table callees of the call at program counter 0x00000ae4 land out of s_call_b64 range. Once it linked, the call model refused it withscalar call link register s[14] written at program counter 0x000018e4 escapes the constant-offset call/return model (used at program counter 0x000009f0). This PR fixes both.LinkCallsappended every table callee after a single block of call sites, so a callee'ss_call_b64had to reach past all the callees before it. SIMM16 is a signed dword offset, so it reaches at most 0x7fff dwords forward (AMD RDNA2 ISA 3.6.3,S_CALL_B64). Each callee now gets its own segment: its compares for SCC 0, its compares for SCC 1, ans_call_b64with offset 1, a returns_branch, then the copy. A mismatch branches over the copy to the next target's compares. A return goes back ones_branchper earlier copy to the instruction after the original call. No branch or call spans more than one copy, and a copy is at most 16,384 dwords (ReadUserDataCallee's limit). SCC handling is unchanged: one chain per SCC value at the call, and SCC is set back to that value before the callee or the unlinked call runs.overwritesScalarcounted only the first destination dword of SOP2 results and of SOP1 results other thans_mov_b64ands_getpc_b64. In the GT7 shader,s_andn2_b64 s[14:15], s[6:7], s[4:5]overwrites a link pair ands_nor_b64 vcc, s[14:15], vccthen reads it. The escape check still marked s15 as holding a return address and refused the read. It now uses the decoder'sdataDwordCount, which is 2 for the 64-bit results. The conditional and partial writers (s_cmov,s_bitset,s_movreld,s_movrelsd_2) ands_swappc/s_setpcare still not counted as overwrites. The escape check is the only caller.LinkCallsleaves a pair ofs_branchrelays for every later call, one toward its chain and one back toward the instruction after it, so those branches also span at most one copy. A shader with a single table call links as before.s_call_b64range limit.Tested
main0db47b2 (head daef563; no conflicts), RTX 4090 (NVIDIA 616.92, Windows 11): the 33 ctest entries ofscalar_call,agc_shader_control_flow,agc_driver_graphicsandagc_driver_compute_table_callspass 33/33, each test run three times, and 33/33 under the validation layer (VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V), with noVUID-line; the layer reports nothing on this head.main0db47b2 passes the union of the refreshed sets, 115/115, under the same layer settings with noVUID-line.ScalarCall: the two-callee table now checks the interleaved layout word for word, plus the call and return edges of the graph built from it. Three 0x3001-dword callees and a small one link, which the old layout refused, and the last callee's call goes to its own copy and returns to its hop. A 0x8000-dword copy throws the 16-bit branch-range error. A call followed bys_andn2_b64over the link pair and a 64-bit read builds; withs_and_b32over only the low dword, the read of the high dword still throws.ScalarCall: two table calls, the first with 36,890 dwords of copies: the second call reaches its chain and returns through the relays, and the graph built from the linked code has its call and return edges. Without the relays this case throwslands out of the 16-bit branch range.scalar_call,agc_shader_control_flow(all three variants) andagc_driver_graphicspass.FindTableCallsdoesn't match (its descriptor comes from ans_load_dwordx8through a loaded pointer), which this PR doesn't touch.agc_shader_replaynow stops in the resource tracker onGetImageResource dword 0 is not a valid runtime value: the table's V# is loop-carried through callees that use those registers as scratch, which this PR doesn't touch.Checklist
main; no other open PR implements the same functions. Overlap: fix(shader): link table callees that read their program counter #8140 (tv7) rewrites the line inLinkCallsthat appends a table callee, so that a callee'ss_getpc_b64is expanded into twos_mov_b32s, which makes the copy longer than the callee. Whichever PR lands second has to size each segment from the expanded copy. fix(shader): link a table call whose V# is a slice of an s_load_dwordx8 or s_load_dwordx16 #8070 changes only how table calls are found.NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)