perf(agc): store a write-back's changed bytes without a masked non-temporal store #8930

Merged
JJenkx merged 4 commits from upstream-pr/8930 into main 2026-10-28 23:15:30 +00:00
JJenkx commented 2026-10-21 06:36:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T06:36:48Z.


What

Choose the store for partially changed 16-byte write-back chunks by changed-byte density and host CPU vendor. A chunk with at most ChangedByteStoreLimit() changed bytes uses ordinary byte stores; denser chunks use MASKMOVDQU. The limit is 16 on AuthenticAMD and 4 on other vendors. Fully changed chunks retain their vector store, untouched bytes remain untouched, and sfence runs if a masked store was used. The changed-byte count uses SSE2 psadbw without requiring POPCNT.

The policy retains the measured Ryzen title behavior while keeping the reviewer's faster Intel masked-store path for dense chunks. The threshold is measured only on the Ryzen 9 7950X and the reviewer's Core i9-14900KF; other CPU generations remain unmeasured and are recorded as debt. Tests exercise limits 0, 4, 16 and the host-selected limit, both sides of the density cut-off, aligned/unaligned writes and a tail.

Tested

Current-main correctness refresh, 2026-10-25: head eb0b59ccc212870e3cc66df1b2671cf6931d6a46 is four linear commits on main b90d009d9f73354cbea239a74a8f7e2dcd138772. Every added/removed line in the four changed files is preserved from old head ef525ba0b82; the rebase only resolves additive debt context and retains main's swept-staging entry. Source clean, conventions and whitespace pass. Local merge-tree is clean against newer main 49d1f9b07ec (not rebuilt).

Built full libs and all seven selected test executables on both pinned main and candidate, Linux GCC 16.2.1 Release, bundled SPIRV-Tools enabled. The same 11 focused CTest groups pass three consecutive times on each arm (33 passes each), zero skips and zero VUID errors. Required Vulkan and disabled shader caching are set. Every repetition of all ten GPU groups loads Khronos validation (36 actual layer insertions per arm); the PM4 group is CPU-only. Hardware: Ryzen 9 7950X, RX 6650 XT / RADV Mesa 26.2.4, Arch Linux 7.2.9.

The candidate PM4 fixture covers limits 0, 4, 16 and the host-selected limit at densities around the cut-off, aligned/unaligned destinations and a tail. This host selects AMD limit 16; exercising limit 4 functionally is not an Intel-host timing result. The selected groups cover PM4, storage split/write-back blocks, partially resident snapshot/pending stores, storage flush ordering, no-window/overhang write-back (including the draw-pipeline variant), and the sampled-cache case without storage-image multisampling.

The first attempted comparison was rejected for seven skip stubs excluded by the inherited execution-source selector; a second configuration attempt incorrectly used Boolean ON for the source-name selector and ran no tests. Both attempts are preserved. The completed comparison explicitly selects the five required execution sources and has no skips.

Current source patch, source-preservation proof, full build/configuration logs and verbose main/candidate tests. SHA-256: 1456a1e353a987886fbdb4b0c87832cd3970fb5a55ac1caf526a36fed6cc135e; downloaded copy verified.

No new title/performance, Windows, Intel-host or full-suite result is claimed. The historical speed evidence below retains its original exact revisions and caveats; it is not a fresh measurement of this rebased head.

Historical performance and earlier correctness evidence

Linux 7.2.9 (Arch), Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4.

Speed: Minecraft Dungeons II (PPSA16064) 01.000.000, same scene on both sides: the Accessibility menu, reached by one Cross press at 45 s. Captured with APS5_TRACE_SECONDS=90:30 and no other trace or profile switch. Both runtimes were seeded with the same shader cache and saves before every run. Runs alternated main, change, main, change in one session, with no build running. Summary lines of the first pair:

main 9f4ddf7cf9:

{"commit":"9f4ddf7cf985","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"90:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 90:30","first_present":1484,"ms":30717.688},"presents":11,"frame_ms":{"p50":2786.389,"p90":2859.945,"p99":2861.640,"max":2861.640},"gpu_busy_ms_per_present":134.533,"worker_busy_pct":{"queue worker 0x0":99.929,"queue worker 0x20":99.941},"top_phases_ms_per_frame":{"Driver.Packet":5581.059,"Driver.Packet.dispatch":1417.102,"Driver.Dispatch":1399.326,"Graphics.Draw":1391.752,"Graphics.Draw.draw_and_resource_release":1380.655,"Driver.Packet.device_lock":1106.407,"Resources.Complete":1099.844,"Driver.Packet.draw":1096.719},"trace_dropped":false,"trace":"aps5-trace-9f4ddf7cf985-2743770.json.gz"}

This PR (9f4ddf7cf9 + ef9f2785be):

{"commit":"ef9f2785bee2","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"90:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 90:30","first_present":1498,"ms":31631.740},"presents":12,"frame_ms":{"p50":2639.080,"p90":2701.094,"p99":2736.178,"max":2736.178},"gpu_busy_ms_per_present":133.311,"worker_busy_pct":{"queue worker 0x0":99.891,"queue worker 0x20":99.907},"top_phases_ms_per_frame":{"Driver.Packet":5266.291,"Driver.Packet.dispatch":1562.397,"Driver.Dispatch":1548.805,"Graphics.Draw":1290.048,"Graphics.Draw.draw_and_resource_release":1279.352,"Driver.Packet.draw":1062.174,"Driver.Draw":1062.048,"Resources.Complete":1056.489},"trace_dropped":false,"trace":"aps5-trace-ef9f2785bee2-2796190.json.gz"}
run commit presents in 30 s frame p50 p90 GPU busy per present
main 1 9f4ddf7cf9 11 2786.4 ms 2859.9 ms 134.5 ms
PR 1 ef9f2785bee2 12 2639.1 ms 2701.1 ms 133.3 ms
main 2 9f4ddf7cf9 11 2825.2 ms 2910.1 ms 137.6 ms
PR 2 ef9f2785bee2 12 2679.0 ms 2833.0 ms 134.4 ms

All four traces report dropped: no in the tools/trace_digest.py header, with the default event limit. Frame p50 is about 5 % lower in both pairs. An earlier pair agrees: main 2736.1 / 2803.2 ms against 2615.8 / 2577.7 ms. That pair is not in the table because the PR build there was stamped dirty (built before the commit). The scene is still CPU-bound by the write-backs and GuestBufferMemory::AcquireRegistered. This is a small part of the frame, not a fix for that scene.

Disclosed deviations from the Performance report form, identical on both sides: the harness writes the title's stdout to a file, and perf record attached at 123 s, after the trace window ended at 120 s.

Traces (aps5-trace-*.json.gz, open in ui.perfetto.dev), summary lines, tools/trace_digest.py output, both annotate excerpts and the test logs: 20261021-write-changed-byte-stores-PPSA16064.tar.gz

Correctness, historical (measured on the first head ef9f2785be over main 9f4ddf7cf9, before the review revision; the final-head gate is under Revision below): agc_driver_pm4 already checks that WriteChanged writes exactly the changed bytes, including partially changed chunks and a tail (testWriteChangedKeepsUntouchedBytes, testWriteChangedStoresExactlyTheChangedRuns), and testWriteChangedChunksOfEveryDensity checks chunks with exactly 3, 10, 13 and 16 changed bytes. Focused write-back tests on main and on this PR:

  • Command: ctest -R 'agc_driver_pm4$|partially_resident|storage_flush|write_back|writeback|storage_texture|storage_image' -V with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1.
  • The Khronos layer 1.4.363 was loaded with VK_ADD_LAYER_PATH, and VK_LOADER_DEBUG=layer shows it inserted in all 9 tests in both logs. Neither log reports was not found but was requested by env var VK_INSTANCE_LAYERS.
  • Results: main 9/9, this PR 9/9. VUID- errors: 0 in both.

tools/check_conventions.py --base origin/main passes. The PR overlap tool lists #6185 on the same lines. #6186 is stacked on it and was not compared automatically because it conflicts. Both change the store mask but keep _mm_maskmoveu_si128; whichever lands second keeps the other's mask and this store.

Historical revision (ef525ba0b8, rebased on main f3456a4152):

  • agc_driver_pm4 passes 3/3. testWriteChangedChunksOfEveryDensity now writes chunks with 3, 4, 5, 10, 13 and 16 changed bytes through limits 0, 4 and 16 and the host's limit. It does so both aligned and one byte off with a 5-byte tail, and checks every guest byte, including the bytes outside the write. It fails when the masked store's mask is inverted.

  • Final-head focused write-back gate, validation layer on: ctest -R 'agc_driver_pm4$|partially_resident|storage_flush|write_back|writeback|storage_texture|storage_image' -V. This now matches 11 tests. It ran with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (layer loaded through VK_ADD_LAYER_PATH), ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, on the RX 6650 XT (RADV Mesa 26.2.4), for three builds:

    • main f3456a4152;
    • this PR at ef525ba0b8 (on this AMD CPU the limit is 16, so byte stores at every density);
    • a private build of ef525ba0b8 with ChangedByteStoreLimit() forced to 4, so every CPU takes the non-AMD path.

    All three: 11/11 passed, VK_LOADER_DEBUG=layer shows the Khronos layer inserted 12 times, and the log never says was not found but was requested by env var VK_INSTANCE_LAYERS. VUID- errors: 0, 0 and 0. I did not instrument whether these GPU tests produce chunks with more than 4 changed bytes. MASKMOVDQU itself is covered by agc_driver_pm4 at limits 0 and 4.

  • Zen 4 microbenchmark (synthetic, 32 MiB, every chunk partly changed): with the psadbw count, the limit-4 path is within about 3 % of pure byte stores at 1 to 4 changed bytes and of pure MASKMOVDQU at 5 to 15.

  • On AMD the revision takes the same stores as the measured head; the only addition is a predictable compare. A matched old-head / new-head pair in the title is diagnostic only: the game's log was redirected by my harness, and the four arms were not adjacent. Its p50 differences were +1.3 % and -19 %, which is run-to-run spread, not a measurement. A form-compliant capture with a visible terminal could not be made on this machine. No Intel run is mine: the Intel numbers above are the reviewer's. A rerun of this head on their machine would be the check for the non-AMD path.

Checklist

  • Based on current main; no other open PR implements the same functions (rebased on b90d009d9f7; head eb0b59ccc21; local merge clean against 49d1f9b07ec)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 6650 XT (RADV NAVI23), Mesa 26.2.4, Linux 7.2.9 (Arch)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947462597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8930). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-21T06:36:48Z. --- ### What Choose the store for partially changed 16-byte write-back chunks by changed-byte density and host CPU vendor. A chunk with at most `ChangedByteStoreLimit()` changed bytes uses ordinary byte stores; denser chunks use `MASKMOVDQU`. The limit is 16 on `AuthenticAMD` and 4 on other vendors. Fully changed chunks retain their vector store, untouched bytes remain untouched, and `sfence` runs if a masked store was used. The changed-byte count uses SSE2 `psadbw` without requiring POPCNT. The policy retains the measured Ryzen title behavior while keeping the reviewer's faster Intel masked-store path for dense chunks. The threshold is measured only on the Ryzen 9 7950X and the reviewer's Core i9-14900KF; other CPU generations remain unmeasured and are recorded as debt. Tests exercise limits 0, 4, 16 and the host-selected limit, both sides of the density cut-off, aligned/unaligned writes and a tail. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> **Current-main correctness refresh, 2026-10-25:** head `eb0b59ccc212870e3cc66df1b2671cf6931d6a46` is four linear commits on main `b90d009d9f73354cbea239a74a8f7e2dcd138772`. Every added/removed line in the four changed files is preserved from old head `ef525ba0b82`; the rebase only resolves additive debt context and retains main's swept-staging entry. Source clean, conventions and whitespace pass. Local merge-tree is clean against newer main `49d1f9b07ec` (not rebuilt). Built full `libs` and all seven selected test executables on both pinned main and candidate, Linux GCC 16.2.1 Release, bundled SPIRV-Tools enabled. The same **11 focused CTest groups pass three consecutive times on each arm (33 passes each), zero skips and zero VUID errors**. Required Vulkan and disabled shader caching are set. Every repetition of all ten GPU groups loads Khronos validation (36 actual layer insertions per arm); the PM4 group is CPU-only. Hardware: Ryzen 9 7950X, RX 6650 XT / RADV Mesa 26.2.4, Arch Linux 7.2.9. The candidate PM4 fixture covers limits 0, 4, 16 and the host-selected limit at densities around the cut-off, aligned/unaligned destinations and a tail. This host selects AMD limit 16; exercising limit 4 functionally is not an Intel-host timing result. The selected groups cover PM4, storage split/write-back blocks, partially resident snapshot/pending stores, storage flush ordering, no-window/overhang write-back (including the draw-pipeline variant), and the sampled-cache case without storage-image multisampling. The first attempted comparison was rejected for seven skip stubs excluded by the inherited execution-source selector; a second configuration attempt incorrectly used Boolean `ON` for the source-name selector and ran no tests. Both attempts are preserved. The completed comparison explicitly selects the five required execution sources and has no skips. [Current source patch, source-preservation proof, full build/configuration logs and verbose main/candidate tests](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/pr8930-headeb0b59cc-mainb90-storage-validation.tar.gz). SHA-256: `1456a1e353a987886fbdb4b0c87832cd3970fb5a55ac1caf526a36fed6cc135e`; downloaded copy verified. No new title/performance, Windows, Intel-host or full-suite result is claimed. The historical speed evidence below retains its original exact revisions and caveats; it is not a fresh measurement of this rebased head. ### Historical performance and earlier correctness evidence Linux 7.2.9 (Arch), Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4. **Speed**: Minecraft Dungeons II (PPSA16064) 01.000.000, same scene on both sides: the Accessibility menu, reached by one Cross press at 45 s. Captured with `APS5_TRACE_SECONDS=90:30` and no other trace or profile switch. Both runtimes were seeded with the same shader cache and saves before every run. Runs alternated main, change, main, change in one session, with no build running. Summary lines of the first pair: `main` 9f4ddf7cf9: ```json {"commit":"9f4ddf7cf985","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"90:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 90:30","first_present":1484,"ms":30717.688},"presents":11,"frame_ms":{"p50":2786.389,"p90":2859.945,"p99":2861.640,"max":2861.640},"gpu_busy_ms_per_present":134.533,"worker_busy_pct":{"queue worker 0x0":99.929,"queue worker 0x20":99.941},"top_phases_ms_per_frame":{"Driver.Packet":5581.059,"Driver.Packet.dispatch":1417.102,"Driver.Dispatch":1399.326,"Graphics.Draw":1391.752,"Graphics.Draw.draw_and_resource_release":1380.655,"Driver.Packet.device_lock":1106.407,"Resources.Complete":1099.844,"Driver.Packet.draw":1096.719},"trace_dropped":false,"trace":"aps5-trace-9f4ddf7cf985-2743770.json.gz"} ``` This PR (9f4ddf7cf9 + ef9f2785be): ```json {"commit":"ef9f2785bee2","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_SECONDS":"90:30"},"gpu":"AMD Radeon RX 6650 XT (RADV NAVI23)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","cpu":"AMD Ryzen 9 7950X 16-Core Processor","cpu_threads":32,"memory_mib":127901,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.000.000","resolution":"3840x2160","window":{"spec":"seconds 90:30","first_present":1498,"ms":31631.740},"presents":12,"frame_ms":{"p50":2639.080,"p90":2701.094,"p99":2736.178,"max":2736.178},"gpu_busy_ms_per_present":133.311,"worker_busy_pct":{"queue worker 0x0":99.891,"queue worker 0x20":99.907},"top_phases_ms_per_frame":{"Driver.Packet":5266.291,"Driver.Packet.dispatch":1562.397,"Driver.Dispatch":1548.805,"Graphics.Draw":1290.048,"Graphics.Draw.draw_and_resource_release":1279.352,"Driver.Packet.draw":1062.174,"Driver.Draw":1062.048,"Resources.Complete":1056.489},"trace_dropped":false,"trace":"aps5-trace-ef9f2785bee2-2796190.json.gz"} ``` | run | commit | presents in 30 s | frame p50 | p90 | GPU busy per present | |---|---|---|---|---|---| | main 1 | 9f4ddf7cf985 | 11 | 2786.4 ms | 2859.9 ms | 134.5 ms | | PR 1 | ef9f2785bee2 | 12 | 2639.1 ms | 2701.1 ms | 133.3 ms | | main 2 | 9f4ddf7cf985 | 11 | 2825.2 ms | 2910.1 ms | 137.6 ms | | PR 2 | ef9f2785bee2 | 12 | 2679.0 ms | 2833.0 ms | 134.4 ms | All four traces report `dropped: no` in the `tools/trace_digest.py` header, with the default event limit. Frame p50 is about 5 % lower in both pairs. An earlier pair agrees: main 2736.1 / 2803.2 ms against 2615.8 / 2577.7 ms. That pair is not in the table because the PR build there was stamped dirty (built before the commit). The scene is still CPU-bound by the write-backs and `GuestBufferMemory::AcquireRegistered`. This is a small part of the frame, not a fix for that scene. Disclosed deviations from the Performance report form, identical on both sides: the harness writes the title's stdout to a file, and `perf record` attached at 123 s, after the trace window ended at 120 s. Traces (`aps5-trace-*.json.gz`, open in ui.perfetto.dev), summary lines, `tools/trace_digest.py` output, both annotate excerpts and the test logs: [20261021-write-changed-byte-stores-PPSA16064.tar.gz](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/20261021-write-changed-byte-stores-PPSA16064.tar.gz) **Correctness, historical** (measured on the first head `ef9f2785be` over `main` `9f4ddf7cf9`, before the review revision; the final-head gate is under Revision below): `agc_driver_pm4` already checks that `WriteChanged` writes exactly the changed bytes, including partially changed chunks and a tail (`testWriteChangedKeepsUntouchedBytes`, `testWriteChangedStoresExactlyTheChangedRuns`), and `testWriteChangedChunksOfEveryDensity` checks chunks with exactly 3, 10, 13 and 16 changed bytes. Focused write-back tests on `main` and on this PR: - Command: `ctest -R 'agc_driver_pm4$|partially_resident|storage_flush|write_back|writeback|storage_texture|storage_image' -V` with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`. - The Khronos layer 1.4.363 was loaded with `VK_ADD_LAYER_PATH`, and `VK_LOADER_DEBUG=layer` shows it inserted in all 9 tests in both logs. Neither log reports `was not found but was requested by env var VK_INSTANCE_LAYERS`. - Results: `main` 9/9, this PR 9/9. `VUID-` errors: 0 in both. `tools/check_conventions.py --base origin/main` passes. The PR overlap tool lists #6185 on the same lines. #6186 is stacked on it and was not compared automatically because it conflicts. Both change the store mask but keep `_mm_maskmoveu_si128`; whichever lands second keeps the other's mask and this store. **Historical revision (`ef525ba0b8`, rebased on `main` `f3456a4152`):** - `agc_driver_pm4` passes 3/3. `testWriteChangedChunksOfEveryDensity` now writes chunks with 3, 4, 5, 10, 13 and 16 changed bytes through limits 0, 4 and 16 and the host's limit. It does so both aligned and one byte off with a 5-byte tail, and checks every guest byte, including the bytes outside the write. It fails when the masked store's mask is inverted. - **Final-head focused write-back gate, validation layer on:** `ctest -R 'agc_driver_pm4$|partially_resident|storage_flush|write_back|writeback|storage_texture|storage_image' -V`. This now matches 11 tests. It ran with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (layer loaded through `VK_ADD_LAYER_PATH`), `ANYPS5_NO_SHADER_CACHE=1` and `ANYPS5_REQUIRE_VULKAN=1`, on the RX 6650 XT (RADV Mesa 26.2.4), for three builds: - `main` `f3456a4152`; - this PR at `ef525ba0b8` (on this AMD CPU the limit is 16, so byte stores at every density); - a private build of `ef525ba0b8` with `ChangedByteStoreLimit()` forced to 4, so every CPU takes the non-AMD path. All three: 11/11 passed, `VK_LOADER_DEBUG=layer` shows the Khronos layer inserted 12 times, and the log never says `was not found but was requested by env var VK_INSTANCE_LAYERS`. `VUID-` errors: 0, 0 and 0. I did not instrument whether these GPU tests produce chunks with more than 4 changed bytes. `MASKMOVDQU` itself is covered by `agc_driver_pm4` at limits 0 and 4. - Zen 4 microbenchmark (synthetic, 32 MiB, every chunk partly changed): with the `psadbw` count, the limit-4 path is within about 3 % of pure byte stores at 1 to 4 changed bytes and of pure `MASKMOVDQU` at 5 to 15. - On AMD the revision takes the same stores as the measured head; the only addition is a predictable compare. A matched old-head / new-head pair in the title is diagnostic only: the game's log was redirected by my harness, and the four arms were not adjacent. Its p50 differences were +1.3 % and -19 %, which is run-to-run spread, not a measurement. A form-compliant capture with a visible terminal could not be made on this machine. No Intel run is mine: the Intel numbers above are the reviewer's. A rerun of this head on their machine would be the check for the non-AMD path. ### 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 (rebased on `b90d009d9f7`; head `eb0b59ccc21`; local merge clean against `49d1f9b07ec`) - [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) - [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 6650 XT (RADV NAVI23), Mesa 26.2.4, Linux 7.2.9 (Arch) - [x] AI-assisted: yes
JJenkx commented 2026-10-22 12:33:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T12:33:34Z.


Note for reviewers: a teammate measured Demon's Souls (PPSA01341) with this PR and saw slower frames: p50 76.6 and 64.8 ms on main, against 132.5 and 173.4 ms with this PR. They flagged it themselves as unconfirmed, because the trace windows started at very different points in the game.

I tried to make it a controlled comparison on a Radeon RX 6650 XT, RADV Mesa 26.2.4:

  • Both sides used the full library set built at this PR's base 9f4ddf7cf9. The PR side swaps in only libSceAgcDriver.prx from ef9f2785be.
  • Same seeded shader cache, cleared saves, alternating base and PR.

I couldn't get matched scenes. On this title the start-up path changes from run to run even with no input: the same 140–180 s window lands on the publisher logos, the "LANGUAGE SELECT" menu or the "On the first day" intro, depending on the run. One base run also stopped on APS5_ADDRESS_COPY_MAX_MIB at 189 s, unrelated to this PR. Across the complete traces, frame p50 is 109–116 ms on base and 102–140 ms with this PR, but the scenes don't match, so it shows neither a regression nor a gain here.

The traces also have no slice for WriteChanged alone; it falls under Driver.Packet.flush_between_packets. So I couldn't compare the function's own cost either. The Minecraft Dungeons II measurement in the description is the only matched-scene result for this PR so far.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6340843774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8930#issuecomment-6340843774). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T12:33:34Z. --- Note for reviewers: a teammate measured **Demon's Souls (PPSA01341)** with this PR and saw slower frames: p50 76.6 and 64.8 ms on `main`, against 132.5 and 173.4 ms with this PR. They flagged it themselves as unconfirmed, because the trace windows started at very different points in the game. I tried to make it a controlled comparison on a Radeon RX 6650 XT, RADV Mesa 26.2.4: - Both sides used the full library set built at this PR's base `9f4ddf7cf9`. The PR side swaps in only `libSceAgcDriver.prx` from `ef9f2785be`. - Same seeded shader cache, cleared saves, alternating base and PR. I couldn't get matched scenes. On this title the start-up path changes from run to run even with no input: the same 140–180 s window lands on the publisher logos, the "LANGUAGE SELECT" menu or the "On the first day" intro, depending on the run. One base run also stopped on `APS5_ADDRESS_COPY_MAX_MIB` at 189 s, unrelated to this PR. Across the complete traces, frame p50 is 109–116 ms on base and 102–140 ms with this PR, but the scenes don't match, so it shows neither a regression nor a gain here. The traces also have no slice for `WriteChanged` alone; it falls under `Driver.Packet.flush_between_packets`. So I couldn't compare the function's own cost either. The Minecraft Dungeons II measurement in the description is the only matched-scene result for this PR so far. AI-assisted: yes (Claude Code).
JJenkx commented 2026-10-22 13:10:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T13:10:07Z.


New commit 51cd838855: a 16-byte chunk with 10 or more changed bytes now takes _mm_maskmoveu_si128 again, and fewer changed bytes take the byte stores. The sfence runs only when a masked store was issued.

Why. I benchmarked the 16-byte loop directly, outside the emulator. It's the function's loop body verbatim, run single-threaded on one Ryzen 9 7950X core, best of 7. With byte stores, the cost depends on how many bytes of a chunk changed. A chunk with 15 changed bytes costs 15 scalar stores, which is slower than one masked store. Write-backs where most chunks are almost fully changed could therefore get slower with the previous head. This may be what showed up in the Demon's Souls runs in my last comment; I couldn't confirm that in the title.

32 MiB buffer with every 16-byte chunk partly changed, N distinct changed bytes per chunk, in ms:

N base (masked only) previous head (bytes only) this head (threshold 10)
1 12.48 3.34 3.81
3 12.93 6.02 5.70
5 12.62 7.19 7.69
8 12.66 10.29 10.82
11 12.94 14.22 12.39
15 12.59 18.01 12.45

With half of the chunks partly changed, the same pattern holds: at N = 15, base 12.54, previous head 13.81 and this head 13.63 ms. Reading an unrelated 32 MiB array right after each write-back showed no consistent difference between the variants, so I see no cache-pollution cost from the byte stores. Every variant leaves the destination byte-identical to the expected result. Source: 20261022-pr8930-writechanged-bench.cpp.

Test. The new testWriteChangedChunksOnBothStorePaths in agc_driver_pm4 writes chunks with exactly 3, 13, 10 and 16 changed bytes, so the threshold sits on a boundary chunk. It checks that every changed byte is stored and no unchanged byte is touched. ctest -R '^agc_driver_pm4' with ANYPS5_REQUIRE_VULKAN=1: 14 passed, and agc_driver_pm4_replay and _replay_tool were not run because the replay tool target wasn't built. tools/check_conventions.py passes.

The Minecraft Dungeons II numbers in the description were measured on the previous head. That title's partly changed chunks would now take the masked store only if 10 or more of their bytes changed. I'll remeasure it on this head before asking for review again.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6341574154 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8930#issuecomment-6341574154). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T13:10:07Z. --- New commit `51cd838855`: a 16-byte chunk with **10 or more changed bytes** now takes `_mm_maskmoveu_si128` again, and fewer changed bytes take the byte stores. The `sfence` runs only when a masked store was issued. **Why.** I benchmarked the 16-byte loop directly, outside the emulator. It's the function's loop body verbatim, run single-threaded on one Ryzen 9 7950X core, best of 7. With byte stores, the cost depends on how many bytes of a chunk changed. A chunk with 15 changed bytes costs 15 scalar stores, which is slower than one masked store. Write-backs where most chunks are almost fully changed could therefore get slower with the previous head. This may be what showed up in the Demon's Souls runs in my last comment; I couldn't confirm that in the title. 32 MiB buffer with every 16-byte chunk partly changed, N distinct changed bytes per chunk, in ms: | N | base (masked only) | previous head (bytes only) | this head (threshold 10) | |---|---|---|---| | 1 | 12.48 | 3.34 | 3.81 | | 3 | 12.93 | 6.02 | 5.70 | | 5 | 12.62 | 7.19 | 7.69 | | 8 | 12.66 | 10.29 | 10.82 | | 11 | 12.94 | 14.22 | 12.39 | | 15 | 12.59 | 18.01 | 12.45 | With half of the chunks partly changed, the same pattern holds: at N = 15, base 12.54, previous head 13.81 and this head 13.63 ms. Reading an unrelated 32 MiB array right after each write-back showed no consistent difference between the variants, so I see no cache-pollution cost from the byte stores. Every variant leaves the destination byte-identical to the expected result. Source: [20261022-pr8930-writechanged-bench.cpp](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/20261022-pr8930-writechanged-bench.cpp). **Test.** The new `testWriteChangedChunksOnBothStorePaths` in `agc_driver_pm4` writes chunks with exactly 3, 13, 10 and 16 changed bytes, so the threshold sits on a boundary chunk. It checks that every changed byte is stored and no unchanged byte is touched. `ctest -R '^agc_driver_pm4'` with `ANYPS5_REQUIRE_VULKAN=1`: 14 passed, and `agc_driver_pm4_replay` and `_replay_tool` were not run because the replay tool target wasn't built. `tools/check_conventions.py` passes. The Minecraft Dungeons II numbers in the description were measured on the previous head. That title's partly changed chunks would now take the masked store only if 10 or more of their bytes changed. I'll remeasure it on this head before asking for review again. AI-assisted: yes (Claude Code).
JJenkx commented 2026-10-22 14:42:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T14:42:55Z.


Head is now fb25202abd. I've reverted the 10-changed-byte threshold from 51cd838855. The code is back to the measured ef9f2785be, and the only addition is the density test, now testWriteChangedChunksOfEveryDensity.

Why. I measured the threshold in the title before asking for review again. Minecraft Dungeons II (PPSA16064), the same Accessibility-menu scene and method as the description: one Cross at 45 s, APS5_TRACE_SECONDS=90:30, seeded cache, alternating base and candidate. Every run used the full library set built at 9f4ddf7cf9; only libSceAgcDriver.prx differs. All eight traces report dropped: no, and all 120 s screenshots show the Accessibility menu.

run driver frame p50 p90
base 9f4ddf7cf9 2825.4 ms 2850.6 ms
threshold 51cd838855 2801.3 ms 2904.2 ms
base 9f4ddf7cf9 2783.4 ms 2865.0 ms
threshold 51cd838855 2825.7 ms 2887.8 ms
base 9f4ddf7cf9 2764.5 ms 2809.7 ms
byte stores ef9f2785be 2719.8 ms 2744.2 ms
base 9f4ddf7cf9 2689.7 ms 2736.0 ms
byte stores ef9f2785be 2464.6 ms 2610.6 ms

With the threshold the title is no faster than base. With byte stores for every partially changed chunk it's faster again (−1.6 % and −8.4 %), in line with the description's pairs from yesterday. So in this title, byte stores beat the masked store even for chunks where most bytes changed. My single-threaded benchmark predicted the opposite for chunks with 10 or more changed bytes. Timing a read of the destination right after the write didn't explain the difference, and I don't know what does. I'm going with the in-title measurement. The benchmark's case of chunks with 11–15 changed bytes, where it shows byte stores up to 1.6× slower than the masked store, remains a possible cost on some titles. I haven't measured it in one; the Demon's Souls runs above didn't have matched scenes.

agc_driver_pm4 passes with the density test, and tools/check_conventions.py passes.

Traces with SHA256SUMS, digests, screenshots and the three drivers' hashes: 20261022-pr8930-threshold-check-PPSA16064.tar.gz (sha256 f35d8bcb890060d045b31d172d4fd3c8c030692b52e2573538b6d4ad45a290d0).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343543302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8930#issuecomment-6343543302). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T14:42:55Z. --- Head is now `fb25202abd`. I've reverted the 10-changed-byte threshold from `51cd838855`. The code is back to the measured `ef9f2785be`, and the only addition is the density test, now `testWriteChangedChunksOfEveryDensity`. **Why.** I measured the threshold in the title before asking for review again. Minecraft Dungeons II (PPSA16064), the same Accessibility-menu scene and method as the description: one Cross at 45 s, `APS5_TRACE_SECONDS=90:30`, seeded cache, alternating base and candidate. Every run used the full library set built at `9f4ddf7cf9`; only `libSceAgcDriver.prx` differs. All eight traces report `dropped: no`, and all 120 s screenshots show the Accessibility menu. | run | driver | frame p50 | p90 | |---|---|---|---| | base | `9f4ddf7cf9` | 2825.4 ms | 2850.6 ms | | threshold | `51cd838855` | 2801.3 ms | 2904.2 ms | | base | `9f4ddf7cf9` | 2783.4 ms | 2865.0 ms | | threshold | `51cd838855` | 2825.7 ms | 2887.8 ms | | base | `9f4ddf7cf9` | 2764.5 ms | 2809.7 ms | | byte stores | `ef9f2785be` | 2719.8 ms | 2744.2 ms | | base | `9f4ddf7cf9` | 2689.7 ms | 2736.0 ms | | byte stores | `ef9f2785be` | 2464.6 ms | 2610.6 ms | With the threshold the title is no faster than base. With byte stores for every partially changed chunk it's faster again (−1.6 % and −8.4 %), in line with the description's pairs from yesterday. So in this title, byte stores beat the masked store even for chunks where most bytes changed. My single-threaded benchmark predicted the opposite for chunks with 10 or more changed bytes. Timing a read of the destination right after the write didn't explain the difference, and I don't know what does. I'm going with the in-title measurement. The benchmark's case of chunks with 11–15 changed bytes, where it shows byte stores up to 1.6× slower than the masked store, remains a possible cost on some titles. I haven't measured it in one; the Demon's Souls runs above didn't have matched scenes. `agc_driver_pm4` passes with the density test, and `tools/check_conventions.py` passes. Traces with `SHA256SUMS`, digests, screenshots and the three drivers' hashes: [20261022-pr8930-threshold-check-PPSA16064.tar.gz](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/20261022-pr8930-threshold-check-PPSA16064.tar.gz) (sha256 `f35d8bcb890060d045b31d172d4fd3c8c030692b52e2573538b6d4ad45a290d0`). AI-assisted: yes (Claude Code).
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!8930
No description provided.