Skip to content

fix(shader): follow scheduled jump table index writes - #7630

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
JJenkx:fix/shader-scheduled-table-index
Oct 20, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
JJenkx:fix/shader-scheduled-table-index

Conversation

@JJenkx

@JJenkx JJenkx commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Recognize bounded two-dword PC-relative jump tables when unrelated instructions separate the index bound, index shift and base-address calculation. The existing matcher requires the bound and shift immediately before the three base-address instructions. A shader in Crimson Spires PPSA03568 instead schedules vector work in those gaps and is refused at s_setpc_b64 PC 0x3e0.

Reuse the conservative last-writer search for the SMEM offset register to identify its scale and bound. Intervening writes to that register or control-flow boundaries still reject the match; the existing bound, scale, branch-entry, table-range and destination checks remain. No dynamic indirect-branch fallback or title-specific path is added.

One commit eaa6d89ff9 on main 8d17389a73. The depth-bounds fix in #7627 is excluded from this branch; it is only a prerequisite for the native integration evidence below.

Tested

Linux Release, GCC 16.2.1, Ryzen 9 7950X; AMD RX 6650 XT, RADV Mesa 26.2.4.

  • Refreshed standalone branch: full runtime libs, control-flow and scalar-setpc targets build. Four focused CTests pass, no skips (0.34 s), with ANYPS5_REQUIRE_VULKAN=1: control-flow default, iteration-selection-off, forced fallback, and scalar-setpc GPU readback.
  • Synthetic control-flow coverage uses SGPR and VCC indices with vector instructions between operations and checks the exact table values and three destinations. Rewritten indices and branches in the sequence are refused; both subgroup sizes compile.
  • GPU readback executes the existing scalar-setpc workload plus scheduled variants for wave32, wave64, and wave64 on subgroup32, checking all existing lane outputs. The inserted instructions require relocating the loop's backwards direct branch; table/base/target relative offsets stay intact.
  • Negative control on the original c34 decoder with the new tests fails at the scheduled synthetic table (unsupported dynamic s_setpc_b64 PC 0x38); restored candidate passes. The private captured title request changes from its PC 0x3e0 refusal to a full 54,275-word SPIR-V result. No title code or serialized requests are attached.
  • Native integration 4be62bfde14d = main c34e9d855c + fix(agc): preserve infinite depth bounds #7627 + this shader change: input at46.79 s passes the previous crash, loading screenshot at60 s and opening-story screen at110 s visually inspected. Ordinary close at121.32 s; exit0 after123.33 s, process gone, temporary udmabuf limit restored to64 MiB. Explicit existing APS5_PLAYGO_UNLISTED_CHUNKS=installed was used because this dump lacks chunk metadata. Gameplay, FPS gains and visual completeness are untested. This native result is the older integration, not the refreshed standalone branch.
  • Conventions and whitespace pass. Overlap tool reports only unavailable comparison against base-conflicting feat: run PS4 games on the AGC driver — Limbo (CUSA01664) in game (integration branch) #6977; its GraphBuilder diff changes fetch/user-data call tracking, not this matcher. No code dependency on it.

Sanitized validation and test/negative-control logs, assets prefixed crimson-scheduled. Local Windows and full-suite runs were not performed. Contributor validation is recorded below.

Contributor validation: LeandroLP23 reports all four focused CTests passing three runs each with ANYPS5_REQUIRE_VULKAN=1 and no skips on Windows 11 26300, Radeon 860M (RDNA 3.5), AMD driver 32.0.13058.8001, WinLibs GCC 15.2.0 r7 Release. That build combines main c3591adf9 with #7629, #7630 and #7627; this is contributor integration validation, not an isolated Windows run of this branch. MarcZX10 reviewed the #6977 overlap warning and found that its PS4 GCN control-flow changes implement separate behavior.

savvaniss independently reports all four focused tests passing three runs each on Windows 11 Pro 26300, Intel UHD 770 (32.0.101.7088) and AMD RX 9070 XT (32.0.31041.1004), WinLibs GCC 15.2.0 r7 Release. The tested composition merges exact head eaa6d89ff into main f3059421f, with shader caching disabled and serial CTest. A control using this PR's tests on that main without its implementation fails all four tests on both GPUs. This is contributor composition evidence, not our own Windows run or a title-performance result.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none. Native title evidence additionally uses fix(agc): preserve infinite depth bounds #7627; source and regression tests are independent.
  • Fixes: none
  • Unblocks: none (removes a shader refusal observed in PPSA03568; no existing Game bring-up discussion found and gameplay is untested).
  • GPUs tested: AMD RX 6650 XT, RADV Mesa26.2.4, Linux. Contributor integration: Radeon 860M, AMD32.0.13058.8001, Windows11 26300 (LeandroLP23).
  • AI-assisted: yes

@JJenkx

JJenkx commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up native validation on newer main 5057673804b2 plus #7627 and this shader change (local integration e3635481b941): the full runtime and focused targets build, and all four focused CTests pass with Vulkan required (zero skips, 0.36 s).

A five-minute run now advances beyond the opening quotation: scheduled Cross input enters the in-car scene with narration at 200 s, then a later dialogue line with Erika’s portrait at 280 s. Both captures were visually inspected. Ordinary close at 301.51 s; exit zero at 303.51 s; native process gone and temporary udmabuf limit restored to 64 MiB. This used the same explicit installed-chunk override recorded above.

Sanitized native validation and focused test log. This establishes opening dialogue progression for the two-fix integration, not full gameplay, visual correctness or an FPS improvement.

@github-actions

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 6977 core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp

@LeandroLP23

Copy link
Copy Markdown
Contributor

Windows and AMD's proprietary driver, since the description lists Windows and other GPUs as not tested. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main c3591adf9 with #7629, #7630 and #7627 merged together (each merge clean, built once).

With ANYPS5_REQUIRE_VULKAN=1, agc_shader_control_flow, agc_shader_control_flow_iteration_selection_off, agc_shader_control_flow_forced_fallback and agc_driver_scalar_setpc pass 3 runs of 3, with no skips.

AI-assisted

@MarcZX10

Copy link
Copy Markdown
Contributor

I manually checked the overlap bot warning against #6977. That PR is a broad PS4 GCN/Limbo integration and is currently conflicted; its GraphBuilder.cpp change is gated to PS4 GCN shader control flow, while this PR changes scheduled jump-table index tracking for the existing path. The code changes do not implement the same behavior. The reported Windows/Radeon 860M focused CTest runs also add useful validation for this PR.

@LeandroLP23 LeandroLP23 mentioned this pull request Oct 18, 2026
12 tasks done
@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 18, 2026
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 18, 2026
@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: the four tests fail on main and pass with this PR on an Intel UHD 770 and an AMD RX 9070 XT.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head eaa6d89ff merged into main f3059421f. "Without" means this PR's test files on main f3059421f, with none of its other changes.

Tests, ×3 UHD 770 RX 9070 XT
This head: agc_driver_scalar_setpc, agc_shader_control_flow, agc_shader_control_flow_forced_fallback, agc_shader_control_flow_iteration_selection_off 4 of 4 pass 4 of 4 pass
Without all 4 fail all 4 fail

I also ran full CTest with this PR and the 14 other open AGC PRs I tested in the same batch merged together (#7647, #7641, #7627, #7603, #7600, #7591, #7579, #7535, #7533, #7474, #7462, #7050, #7048, #7650). Neither GPU showed a failure beyond main's own, except #7650's new test.

AI-assisted: yes (Claude Code)

@JJenkx

JJenkx commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Additional Windows validation with this PR alone on upstream main fd423f9b2e4051e84aec3d4315a6f15a90c3473e: cherry-picked exact PR head eaa6d89ff981f558f8213ac1b3dd5f9abd51eb6f, producing local validation head 5eac5e88134251f5607397ab41a75540ee4fbad3. No other PR changes were included.

Windows 11 Enterprise build 22621, Ryzen 9 5950X, Radeon RX 6700 XT, AMD proprietary Vulkan driver 26.8.1 (Vulkan API 1.4.315), WinLibs GCC 15.2.0 UCRT r7, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON. ANYPS5_REQUIRE_VULKAN=1; the execution test explicitly selected the RX 6700 XT.

Built agc_shader_control_flow_tests and agc_driver_scalar_setpc_tests, then ran:

ctest --test-dir build-full-gcc15 --output-on-failure --no-tests=error --timeout 30 -j 1 --repeat until-fail:3 -R '^(agc_shader_control_flow|agc_shader_control_flow_iteration_selection_off|agc_shader_control_flow_forced_fallback|agc_driver_scalar_setpc)$' --output-junit windows-sync69-pr7630.xml

All four tests passed three consecutive runs each (12 executions), with zero skips; CTest total time 9.49 seconds. Saved JUnit reports four tests, zero failures, zero disabled and zero skipped. This is focused test coverage, not a title performance comparison.

AI-assisted validation.

@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@github-actions github-actions Bot removed the unblocks title Names a title ID on the Unblocks line label Oct 20, 2026
@adriadam10
adriadam10 merged commit 809aab7 into boykopovar:main Oct 20, 2026
13 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Rechecked against current main: the new GraphBuilder changes touch the table-call/descriptor search, not resolveJumpTable or findLastWriter, so the matcher change and its checks (adjacent base-address triple, writer search stopping at branches/setpc/endpgm, bound/scale/branch-entry/table-range) are unchanged, and the tests still pin the exact table values, the rejected rewritten-index cases and the GPU readback in both wave sizes; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants