perf(agc): select split table call groups on the GPU between rounds #25848

Merged
Remi-Bon merged 2 commits from upstream-pr/25848 into main 2026-11-24 09:31:54 +00:00
Remi-Bon commented 2026-11-22 19:23:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Remi-Bon on 2026-11-22T19:23:46Z.


What

A split table call dispatch runs its rounds from the CPU. Each round reads every lane's target back, waits for the GPU and records one dispatch per callee with its workgroup runs. A dispatch whose lanes loop over many callees pays one GPU round trip per round. In PPSA01317, a 512-round dispatch took 1.7 s.

This change lets the GPU select the workgroups of the next rounds:

  • After a CPU round, if every called target has a compiled part (up to 64 targets), the driver records a batch of rounds without waiting.
  • Batches start at 4 rounds and double up to 256 while they complete.
  • Before the callee parts of each round, Graphics/shaders/SplitSelect.comp reads the lanes' targets from the split state buffer.
    • It appends each calling workgroup to the list of every callee its lanes call, and to a list for the closing part.
    • It writes the indirect workgroup count of each list.
  • Each callee part and the closing part runs with vkCmdDispatchIndirect over its list. The split state header gains a list flag (word 5) and a list offset (word 6). SplitSliceGroup maps the launched workgroup through the list when the flag is set.
  • If a lane calls a target outside the batch's set, the selector stops the batch: the remaining rounds dispatch no workgroups. The closing part of the last round reads the targets back, so the CPU serves the new target in its next round.
  • The selector counts the rounds that ran in header word 7. The driver reads it with the targets and charges only those rounds to the round limit.

APS5_SPLIT_CPU_ROUNDS keeps every round on the CPU. APS5_SPLIT_MAX_ROUNDS sets the round limit (default 4096, as before).

Tested

  • Windows 11, MinGW Release build.
  • ctest --test-dir build -R "split|spirv|recompiler|dispatch|continuation": 103/103 passed.
    • Run with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer and the validation layer from Vulkan SDK 1.4.363.1.
    • The loader log shows Insert instance layer "VK_LAYER_KHRONOS_validation", has no was not found but was requested by env var VK_INSTANCE_LAYERS, and contains no VUID-.
  • agc_driver_split_table_call_run gains a GPU-round mode of the continued loop caller, at wave32 and wave64:
    • one CPU round, then batches of 4 GPU-selected rounds;
    • the test requires that each batch runs a round and that the output matches the CPU-round result.
  • PPSA01317 (Café scene):
    • Measured on a local tree with other unmerged split work, so not against main; no tools/trace_digest.py comparison to main is claimed. main alone does not reach the scene's split dispatches.
    • The 512-round dispatch went from 1.7 s to 0.82 s.
    • Frames still stall, on per-dispatch CPU capture rather than on rounds.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 9070, AMD driver 2.0.416 (Vulkan 1.4.359), Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5442477285 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25848). Originally posted by [Remi-Bon](https://github.com/Remi-Bon) on 2026-11-22T19:23:46Z. --- ### What A split table call dispatch runs its rounds from the CPU. Each round reads every lane's target back, waits for the GPU and records one dispatch per callee with its workgroup runs. A dispatch whose lanes loop over many callees pays one GPU round trip per round. In PPSA01317, a 512-round dispatch took 1.7 s. This change lets the GPU select the workgroups of the next rounds: - After a CPU round, if every called target has a compiled part (up to 64 targets), the driver records a batch of rounds without waiting. - Batches start at 4 rounds and double up to 256 while they complete. - Before the callee parts of each round, `Graphics/shaders/SplitSelect.comp` reads the lanes' targets from the split state buffer. - It appends each calling workgroup to the list of every callee its lanes call, and to a list for the closing part. - It writes the indirect workgroup count of each list. - Each callee part and the closing part runs with `vkCmdDispatchIndirect` over its list. The split state header gains a list flag (word 5) and a list offset (word 6). `SplitSliceGroup` maps the launched workgroup through the list when the flag is set. - If a lane calls a target outside the batch's set, the selector stops the batch: the remaining rounds dispatch no workgroups. The closing part of the last round reads the targets back, so the CPU serves the new target in its next round. - The selector counts the rounds that ran in header word 7. The driver reads it with the targets and charges only those rounds to the round limit. `APS5_SPLIT_CPU_ROUNDS` keeps every round on the CPU. `APS5_SPLIT_MAX_ROUNDS` sets the round limit (default 4096, as before). ### Tested - Windows 11, MinGW Release build. - `ctest --test-dir build -R "split|spirv|recompiler|dispatch|continuation"`: 103/103 passed. - Run with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer` and the validation layer from Vulkan SDK 1.4.363.1. - The loader log shows `Insert instance layer "VK_LAYER_KHRONOS_validation"`, has no `was not found but was requested by env var VK_INSTANCE_LAYERS`, and contains no `VUID-`. - `agc_driver_split_table_call_run` gains a GPU-round mode of the continued loop caller, at wave32 and wave64: - one CPU round, then batches of 4 GPU-selected rounds; - the test requires that each batch runs a round and that the output matches the CPU-round result. - PPSA01317 (Café scene): - Measured on a local tree with other unmerged split work, so not against `main`; no `tools/trace_digest.py` comparison to `main` is claimed. `main` alone does not reach the scene's split dispatches. - The 512-round dispatch went from 1.7 s to 0.82 s. - Frames still stall, on per-dispatch CPU capture rather than on rounds. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 9070, AMD driver 2.0.416 (Vulkan 1.4.359), Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-22 19:34:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:34:11Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the implementation and targeted test source support merging.

What I ran

Reviewed head 342c2189864dea6dcde047bb160691b91dd3f4e0 against the prepared diff. I read description.md, commits.md, manifest.json, and diff.patch, plus the changed implementation and test ranges listed below through repo_read.py. No build or tests were run; the Windows build, 103/103 tests, and measurements in the description are author-reported.

Results

Check Result Note
Diff and changed code review passed Targeted paths inspected
Build and test execution not run Author reports Windows results
Performance claims not verified No matched baseline comparison

Findings

Blocking

None.

Non-blocking

None.

Not verified

core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp was excluded from the prepared full-text files because it was too large; I inspected its changed ranges with repo_read.py. The other 10 changed files marked included in manifest.json were read at their changed sections, not in full. I did not run the reported tests or verify the performance measurements on hardware.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014057471 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25848#pullrequestreview-6014057471). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T19:34:11Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the implementation and targeted test source support merging. ## What I ran Reviewed head `342c2189864dea6dcde047bb160691b91dd3f4e0` against the prepared diff. I read `description.md`, `commits.md`, `manifest.json`, and `diff.patch`, plus the changed implementation and test ranges listed below through `repo_read.py`. No build or tests were run; the Windows build, 103/103 tests, and measurements in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code review | passed | Targeted paths inspected | | Build and test execution | not run | Author reports Windows results | | Performance claims | not verified | No matched baseline comparison | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` was excluded from the prepared full-text files because it was too large; I inspected its changed ranges with `repo_read.py`. The other 10 changed files marked included in `manifest.json` were read at their changed sections, not in full. I did not run the reported tests or verify the performance measurements on hardware. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!25848
No description provided.