shader: run SRT slot and descriptor reads of block plans from a table #1456

Closed
github-bot wants to merge 2 commits from gh-pr/1456/head into gh-pr/1456/base
Owner

@⁠NeySlim on GitHub · 2026-10-12 15:17 UTC · original
NeySlim:perf/srt-jit-blocks → main · +882 −5 · 4 files · 2 commits · closed without merging

Follow-up to f848d276. Tested in God of War Ragnarok (PPSA08332, 05.005).

The x86 SRT walker only takes flat plans. In God of War Ragnarok 86-88% of stage walks are plans with block conditions and captured reads, so they all go through the interpreter, even though their reads have the shape the walker already handles (LoadAddressU32 at a constant offset under user-data pointers or a parent table). Only 7-9% of walks use the compiled path, and RefreshFlatBuffer costs 27-35 ms per frame on the GPU command thread. The descriptors of these plans are also evaluated one DWORD at a time by the interpreter.

Change

  • shader: run SRT slot reads of block and captured plans from a table: when the whole-plan walker rejects a plan, each SRT slot read is compiled into a small data table (ResourcePlan::SrtReadTable): one record per memoized read, with its pointer words (user data or another record) and its constant offset. A short loop runs the records with the same order, bounds, 48-bit mask, alignment, memo and captured addresses as EvaluateRawRead. RefreshFlatBuffer still walks blocks and conditions in C++ and runs the table for those slots. Clean reads and other shapes stay interpreted. If a table read fails, the interpreter evaluates the slot again, so failures behave as before.
  • shader: read SRT descriptors and constant buffers from the read table: a descriptor whose DWORDs are all such reads, user data or immediates gets an entry in the same table, also for plans the whole-plan walker takes. ReadConstBuffer reads with a constant or shifted-index offset become records too, with the walker's bounds (records, or stride * records bytes). An out-of-bounds constant-buffer DWORD fails the table read and the interpreter returns 0 for it, as on main.

The first version of this PR generated x86 code per plan. Profiling the GPU command thread in game showed that code was limited by the front end, not by memory: 24% of the thread's cycles for 4% of its micro-ops, 98% of its loads hitting L1, samples spread over about 11,000 addresses on 2,100 code pages. Every plan had its own code buffer, so each materialization (about 2,000 per frame) ran cold code. The table loop stays hot, is faster in game (below) and adds no generated code; the whole-plan walker is unchanged.

Test

  • TestCompiledSrtReadsFollowBlocks (from the first version): a plan with a memory-dependent branch and a nested table, both branches compared with the interpreter (flat DWORDs, captured and strict reads, memo reuse, truncated user data, address underflow/overflow).
  • TestCompiledSrtDescriptorReads: compiled descriptors against the interpreter (values, captured reads and their order, strict reads), memo reuse after a compiled slot, truncated user data, address underflow and overflow, constant-buffer bounds with and without stride, shifted index overflow.
  • TestCompiledSrtReadTable: table layout (one record per shared read, order, descriptor words) and 540 stride, records, index and truncated user data configurations compared with the interpreter (success, values, descriptors, captured reads).
  • Each of these changes to the table loop makes them fail: memo never hit or never stored, address not recorded, 48-bit mask or alignment dropped, either address bound or the user-data bound dropped, pointer words swapped, a wrong immediate DWORD, constant-buffer bound or stride too large, word 3 of the V# skipped, index shift off by one or not aligned.
  • A table read that fails too often (a bound that is too strict) is not visible in these tests: the interpreter reads the value again, so only the time changes.
  • resource_tracking, resource_materialization and shader_cfg tests pass; ctest has the same failures as main. GPU suite, one case per process: same results as main (783 of 847 pass on this machine).
  • In game, a check mode evaluated every slot and descriptor read from the table again with a separate interpreter walker: 4.3 G checks over two runs, no difference.

Performance

God of War Ragnarok, new game, warm caches, on top of my other open PRs (main alone does not get in game), same build except this PR. Fps, and CPU time of the GPU command thread per frame:

cutscene sled
interpreter (without this PR) 15.1 fps, 56.1 ms 12.9 fps, 67.8 ms
first version (x86 code, slots only) 15.6 fps, 53.6 ms 13.4 fps, 64.3 ms
table, slots only (first commit) 16.8 fps, 48.3 ms 14.5 fps, 57.9 ms
table, slots and descriptors 17.6 fps, 45.5 ms 15.2 fps, 53.9 ms

Means of 2, 4, 3 and 6 runs, each run within 0.4 fps of its mean. The stack has none of the later SRT changes (#1828 and after), so the frame rates are lower than in my other PRs. The later Freya window is not comparable (deaths and tip screens at different times).

Not tested on Windows. Nothing platform specific is added: no generated code, no calling convention. The Windows run on this PR was on the first version; the tests are the same plus the descriptor and table ones.

AI use

I used Claude Code to write the change and the tests and to run the measurements above. I reviewed the code and the results before opening the PR.

**@⁠NeySlim** on GitHub · 2026-10-12 15:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456) `NeySlim:perf/srt-jit-blocks` → `main` · +882 −5 · 4 files · 2 commits · closed without merging Follow-up to f848d276. Tested in God of War Ragnarok (PPSA08332, 05.005). The x86 SRT walker only takes flat plans. In God of War Ragnarok 86-88% of stage walks are plans with block conditions and captured reads, so they all go through the interpreter, even though their reads have the shape the walker already handles (`LoadAddressU32` at a constant offset under user-data pointers or a parent table). Only 7-9% of walks use the compiled path, and `RefreshFlatBuffer` costs 27-35 ms per frame on the GPU command thread. The descriptors of these plans are also evaluated one DWORD at a time by the interpreter. ## Change - `shader: run SRT slot reads of block and captured plans from a table`: when the whole-plan walker rejects a plan, each SRT slot read is compiled into a small data table (`ResourcePlan::SrtReadTable`): one record per memoized read, with its pointer words (user data or another record) and its constant offset. A short loop runs the records with the same order, bounds, 48-bit mask, alignment, memo and captured addresses as `EvaluateRawRead`. `RefreshFlatBuffer` still walks blocks and conditions in C++ and runs the table for those slots. Clean reads and other shapes stay interpreted. If a table read fails, the interpreter evaluates the slot again, so failures behave as before. - `shader: read SRT descriptors and constant buffers from the read table`: a descriptor whose DWORDs are all such reads, user data or immediates gets an entry in the same table, also for plans the whole-plan walker takes. `ReadConstBuffer` reads with a constant or shifted-index offset become records too, with the walker's bounds (records, or stride * records bytes). An out-of-bounds constant-buffer DWORD fails the table read and the interpreter returns 0 for it, as on main. The first version of this PR generated x86 code per plan. Profiling the GPU command thread in game showed that code was limited by the front end, not by memory: 24% of the thread's cycles for 4% of its micro-ops, 98% of its loads hitting L1, samples spread over about 11,000 addresses on 2,100 code pages. Every plan had its own code buffer, so each materialization (about 2,000 per frame) ran cold code. The table loop stays hot, is faster in game (below) and adds no generated code; the whole-plan walker is unchanged. ## Test - `TestCompiledSrtReadsFollowBlocks` (from the first version): a plan with a memory-dependent branch and a nested table, both branches compared with the interpreter (flat DWORDs, captured and strict reads, memo reuse, truncated user data, address underflow/overflow). - `TestCompiledSrtDescriptorReads`: compiled descriptors against the interpreter (values, captured reads and their order, strict reads), memo reuse after a compiled slot, truncated user data, address underflow and overflow, constant-buffer bounds with and without stride, shifted index overflow. - `TestCompiledSrtReadTable`: table layout (one record per shared read, order, descriptor words) and 540 stride, records, index and truncated user data configurations compared with the interpreter (success, values, descriptors, captured reads). - Each of these changes to the table loop makes them fail: memo never hit or never stored, address not recorded, 48-bit mask or alignment dropped, either address bound or the user-data bound dropped, pointer words swapped, a wrong immediate DWORD, constant-buffer bound or stride too large, word 3 of the V# skipped, index shift off by one or not aligned. - A table read that fails too often (a bound that is too strict) is not visible in these tests: the interpreter reads the value again, so only the time changes. - resource_tracking, resource_materialization and shader_cfg tests pass; ctest has the same failures as main. GPU suite, one case per process: same results as main (783 of 847 pass on this machine). - In game, a check mode evaluated every slot and descriptor read from the table again with a separate interpreter walker: 4.3 G checks over two runs, no difference. ## Performance God of War Ragnarok, new game, warm caches, on top of my other open PRs (main alone does not get in game), same build except this PR. Fps, and CPU time of the GPU command thread per frame: | | cutscene | sled | |---|---|---| | interpreter (without this PR) | 15.1 fps, 56.1 ms | 12.9 fps, 67.8 ms | | first version (x86 code, slots only) | 15.6 fps, 53.6 ms | 13.4 fps, 64.3 ms | | table, slots only (first commit) | 16.8 fps, 48.3 ms | 14.5 fps, 57.9 ms | | table, slots and descriptors | 17.6 fps, 45.5 ms | 15.2 fps, 53.9 ms | Means of 2, 4, 3 and 6 runs, each run within 0.4 fps of its mean. The stack has none of the later SRT changes (#1828 and after), so the frame rates are lower than in my other PRs. The later Freya window is not comparable (deaths and tip screens at different times). Not tested on Windows. Nothing platform specific is added: no generated code, no calling convention. The Windows run on this PR was on the first version; the tests are the same plus the descriptor and table ones. ## AI use I used Claude Code to write the change and the tests and to run the measurements above. I reviewed the code and the results before opening the PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:09 +00:00
github-bot closed this pull request 2026-11-26 09:57:09 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-12 15:23 UTC · original · edited 2026-10-22 19:53 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 9fc67da73d0be0178872edd3f71a3dff353344d8 and 9b9ede47b4.

📒 Files selected for processing: 4
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.h
  • tests/ResourceMaterializationTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The resource plan now stores compiled SRT read tables and per-slot entry maps. The compiler builds entries for eligible reads and descriptor words. SrtWalker evaluates compiled entries when memory access and capture conditions allow, and uses interpreted evaluation when compiled evaluation is unavailable or fails. Tests compare compiled and interpreted results across control-flow, descriptor, and address-boundary cases.

Suggested reviewers: nmzik

Priority: ⬆️ High

Change: Feature

Merge Risk: ⚪ Minimal · up to 9b9ed

This change compiles SRT slot and descriptor reads into a table-driven path and falls back to the existing interpreter when a compiled read fails. No actionable merge-blocking risk was found. The reported tests and in-game comparisons support parity with the interpreted path.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: executing SRT slot and descriptor reads from a table for block plans.
Description check Passed The description is directly related to the changeset. It explains the compiled SRT read table, descriptor reads, fallback behavior, tests, performance results, and validation.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-12 15:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6127268340) · edited 2026-10-22 19:53 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1456?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/f5f4e7d48a825c1e820f3d5bdc2c6138ba93303c/.coderabbit.yaml>) - **Commit**: [f5f4e7d](<https://github.com/KytyPS5/KytyPS5/commit/f5f4e7d48a825c1e820f3d5bdc2c6138ba93303c>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8f5de54b-f5db-4794-9073-e8dc1f65628f` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 9fc67da73d0be0178872edd3f71a3dff353344d8 and 9b9ede47b441f43a19295615caae5e3acfab0423. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 4</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.h` * `tests/ResourceMaterializationTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The resource plan now stores compiled SRT read tables and per-slot entry maps. The compiler builds entries for eligible reads and descriptor words. SrtWalker evaluates compiled entries when memory access and capture conditions allow, and uses interpreted evaluation when compiled evaluation is unavailable or fails. Tests compare compiled and interpreted results across control-flow, descriptor, and address-boundary cases. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"9b9ede47b441f43a19295615caae5e3acfab0423" --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>9b9ed</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `9b9ed` --> <!-- final_review_risk_coverage:{"sourceCommitId":"9b9ede47b441f43a19295615caae5e3acfab0423","coveredCommitId":"9b9ede47b441f43a19295615caae5e3acfab0423","kind":"reviewed"} --> This change compiles SRT slot and descriptor reads into a table-driven path and falls back to the existing interpreter when a compiled read fails. No actionable merge-blocking risk was found. The reported tests and in-game comparisons support parity with the interpreted path. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: executing SRT slot and descriptor reads from a table for block plans. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset. It explains the compiled SRT read table, descriptor reads, fallback behavior, tests, performance results, and validation. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1456)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-20 18:09 UTC · original

Tested this on Windows, since that was still open: 9fc67da7 applied cleanly on main 7b7f9a70, Windows 11, clang-cl 19.1.5, Release, RX 9070 XT and Ryzen 7600X iGPU.

  • resource_materialization_tests (with the new TestCompiledSrtReadsFollowBlocks), resource_tracking_tests and shader_cfg_tests pass; the last two print the same output as on main.
  • To check that the compiled reads really run on Windows (the KYTY_SYSV_ABI call), I made a memo hit return the entry's generation instead of its value: resource_materialization_tests then crashes, so the compiled path runs and the test catches a broken routine.
  • The compute suite (811 entries on both GPUs, native and with 32-wide host subgroups) and the 30 graphics cases give the same results with and without this PR (including main's known IndirectBufferStore failure on this GPU).

I also measured it in Demon's Souls (PPSA01341, main 0cad4672 plus #1630 to get past #1660, a CPU-bound character-creation scene at about 6 fps on a Ryzen 7600X), two runs each, both sides with the same lab counters around RefreshFlatBuffer:

  • The compiled path is used a lot: about two thirds of the slot reads in the interpreted walk (80-90k per second) go through it.
  • In that scene the time per interpreted walk barely changes (46.4 and 42.9 µs without, 40.5 and 43.9 µs with), which is within the difference between two runs of the same build, and the frame rate stays the same. So the gain depends on the game; your God of War numbers show where it matters.
  • In that scene more time goes into the whole-plan walker (about 2,500 calls per second at 83-118 µs each) than into the interpreted walk, so that is where Demon's Souls would gain most.
**@⁠Nawid3333** on GitHub · 2026-10-20 18:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6297787770) Tested this on Windows, since that was still open: 9fc67da7 applied cleanly on main 7b7f9a70, Windows 11, clang-cl 19.1.5, Release, RX 9070 XT and Ryzen 7600X iGPU. - `resource_materialization_tests` (with the new `TestCompiledSrtReadsFollowBlocks`), `resource_tracking_tests` and `shader_cfg_tests` pass; the last two print the same output as on main. - To check that the compiled reads really run on Windows (the `KYTY_SYSV_ABI` call), I made a memo hit return the entry's generation instead of its value: `resource_materialization_tests` then crashes, so the compiled path runs and the test catches a broken routine. - The compute suite (811 entries on both GPUs, native and with 32-wide host subgroups) and the 30 graphics cases give the same results with and without this PR (including main's known `IndirectBufferStore` failure on this GPU). I also measured it in Demon's Souls (PPSA01341, main 0cad4672 plus #1630 to get past #1660, a CPU-bound character-creation scene at about 6 fps on a Ryzen 7600X), two runs each, both sides with the same lab counters around `RefreshFlatBuffer`: - The compiled path is used a lot: about two thirds of the slot reads in the interpreted walk (80-90k per second) go through it. - In that scene the time per interpreted walk barely changes (46.4 and 42.9 µs without, 40.5 and 43.9 µs with), which is within the difference between two runs of the same build, and the frame rate stays the same. So the gain depends on the game; your God of War numbers show where it matters. - In that scene more time goes into the whole-plan walker (about 2,500 calls per second at 83-118 µs each) than into the interpreted walk, so that is where Demon's Souls would gain most.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-20 19:39 UTC · original

Thanks for the Windows run, that was the missing piece. Makes sense for Demon's Souls: GoW spends its time in the interpreted walk, DeS in the whole-plan walker. I'll look at that one separately.

**@⁠NeySlim** on GitHub · 2026-10-20 19:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6299728527) Thanks for the Windows run, that was the missing piece. Makes sense for Demon's Souls: GoW spends its time in the interpreted walk, DeS in the whole-plan walker. I'll look at that one separately.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-20 20:20 UTC · original

@⁠NeySlim I measured the whole-plan walker in that Demon's Souls scene with counters around the compiled call and in the fault handler: about 99% of its time is spent in page faults on its guest reads, each followed by a buffer readback (about 2 ms). Without the faults a walk takes under 1 µs. About 95% of those faults read bytes that the buffer cache tracks as GPU-modified, so the readback itself is needed there; only about 5% are pages protected for other bytes. So the cost is the readback of GPU-written SRT data, not the walker code. #1254 lowers the CPU waits in that scene a lot but not these readbacks (numbers on #1254).

**@⁠Nawid3333** on GitHub · 2026-10-20 20:20 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6300605452) @⁠NeySlim I measured the whole-plan walker in that Demon's Souls scene with counters around the compiled call and in the fault handler: about 99% of its time is spent in page faults on its guest reads, each followed by a buffer readback (about 2 ms). Without the faults a walk takes under 1 µs. About 95% of those faults read bytes that the buffer cache tracks as GPU-modified, so the readback itself is needed there; only about 5% are pages protected for other bytes. So the cost is the readback of GPU-written SRT data, not the walker code. #1254 lowers the CPU waits in that scene a lot but not these readbacks (numbers on #1254).
Author
Owner

@⁠NeySlim on GitHub · 2026-10-22 19:49 UTC · original

I reworked this one: the compiled reads are now a data table run by a small loop instead of x86 code generated per plan. A profile of the GPU command thread showed the generated code was bound by the front end (each plan had its own code buffer, so every materialization ran cold code), and the table is faster in game: in the opening cutscene the GPU command thread goes from 53.6 to 48.3 ms per frame with the slots alone, and to 45.5 ms with the descriptors (15.6 -> 17.6 fps). It also removes the platform question, since nothing is generated or called with a special ABI anymore. I moved the descriptor reads from #1828 in here too, as they use the same table. @⁠Nawid3333 your Windows run was on the old version; the tests are the same plus the descriptor and table ones, in case you want to run them again.

**@⁠NeySlim** on GitHub · 2026-10-22 19:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6349842334) I reworked this one: the compiled reads are now a data table run by a small loop instead of x86 code generated per plan. A profile of the GPU command thread showed the generated code was bound by the front end (each plan had its own code buffer, so every materialization ran cold code), and the table is faster in game: in the opening cutscene the GPU command thread goes from 53.6 to 48.3 ms per frame with the slots alone, and to 45.5 ms with the descriptors (15.6 -> 17.6 fps). It also removes the platform question, since nothing is generated or called with a special ABI anymore. I moved the descriptor reads from #1828 in here too, as they use the same table. @⁠Nawid3333 your Windows run was on the old version; the tests are the same plus the descriptor and table ones, in case you want to run them again.
Author
Owner

@⁠Nawid3333 on GitHub · 2026-10-22 23:39 UTC · original

@⁠NeySlim I reran it on Windows with the table version: 9b9ede47 (both commits) applied cleanly on main 79837b42, Windows 11, clang-cl 19.1.5, Release, RX 9070 XT and Ryzen 7600X iGPU.

  • resource_materialization_tests passes, including the three new tests (TestCompiledSrtReadsFollowBlocks, TestCompiledSrtDescriptorReads, TestCompiledSrtReadTable). resource_tracking_tests and shader_cfg_tests pass and print the same output as on main.
  • To check that the table path really runs on Windows, I made two deliberate bugs, one at a time. A memo hit returning the entry's generation instead of its value crashes the test. An immediate table word copying the marker instead of the value fails it with "compiled descriptor lost a DWORD, its order or a current value". So the tests catch both.
  • The compute suite (836 entries on both GPUs, native and with 32-wide host subgroups) and the graphics cases give the same results with and without this PR, and the 30 graphics fragment shaders are byte-identical.

I also ran it in Demon's Souls (PPSA01341, the character-creation scene from my earlier comment): main 79837b42 + #1630 (to get past #1660), with and without this PR, two 11-minute runs each with the same input script.

  • All four runs reach character creation with no crash and the same number of compute shaders. The screenshots I compared look the same, and the overlay shows 6.9 FPS with and without the PR.
  • In the two runs that ran at the same pace, the program step (where the SRT reads run) took 74.8 -> 70.9 us per dispatch and 124.3 -> 117.3 us per draw, about 5% less. That is within the difference between runs, though (the other pair varied more), and the frame rate is unchanged.
  • As before, this scene is bound by readbacks of GPU-written data (about 720 ms/s), so it doesn't show your God of War gain. No regression either.
**@⁠Nawid3333** on GitHub · 2026-10-22 23:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6353738981) @⁠NeySlim I reran it on Windows with the table version: 9b9ede47 (both commits) applied cleanly on main 79837b42, Windows 11, clang-cl 19.1.5, Release, RX 9070 XT and Ryzen 7600X iGPU. - `resource_materialization_tests` passes, including the three new tests (`TestCompiledSrtReadsFollowBlocks`, `TestCompiledSrtDescriptorReads`, `TestCompiledSrtReadTable`). `resource_tracking_tests` and `shader_cfg_tests` pass and print the same output as on main. - To check that the table path really runs on Windows, I made two deliberate bugs, one at a time. A memo hit returning the entry's generation instead of its value crashes the test. An immediate table word copying the marker instead of the value fails it with "compiled descriptor lost a DWORD, its order or a current value". So the tests catch both. - The compute suite (836 entries on both GPUs, native and with 32-wide host subgroups) and the graphics cases give the same results with and without this PR, and the 30 graphics fragment shaders are byte-identical. I also ran it in Demon's Souls (PPSA01341, the character-creation scene from my earlier comment): main 79837b42 + #1630 (to get past #1660), with and without this PR, two 11-minute runs each with the same input script. - All four runs reach character creation with no crash and the same number of compute shaders. The screenshots I compared look the same, and the overlay shows 6.9 FPS with and without the PR. - In the two runs that ran at the same pace, the program step (where the SRT reads run) took 74.8 -> 70.9 us per dispatch and 124.3 -> 117.3 us per draw, about 5% less. That is within the difference between runs, though (the other pair varied more), and the frame rate is unchanged. - As before, this scene is bound by readbacks of GPU-written data (about 720 ms/s), so it doesn't show your God of War gain. No regression either.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-23 17:34 UTC · original

Thanks for rerunning it, and for the two deliberate bugs, that's a good check of the table path. No regression in Demon's Souls is what I wanted to see; as you say that scene is bound by the readbacks, not the walk.

**@⁠NeySlim** on GitHub · 2026-10-23 17:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6370913982) Thanks for rerunning it, and for the two deliberate bugs, that's a good check of the table path. No regression in Demon's Souls is what I wanted to see; as you say that scene is bound by the readbacks, not the walk.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-24 22:56 UTC · original

Closing this. The x86 SRT walker now on main (d7856753e) covers it, and on GoW Ragnarök it gives the same frame rate as this branch, so there is nothing left to land here.

**@⁠NeySlim** on GitHub · 2026-10-24 22:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1456#issuecomment-6390587950) Closing this. The x86 SRT walker now on main (d7856753e) covers it, and on GoW Ragnarök it gives the same frame rate as this branch, so there is nothing left to land here.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.