perf(shader): keep one use list per IR value #7520

Merged
milescoviello merged 1 commit from upstream-pr/7520 into main 2026-10-20 15:26:35 +00:00
milescoviello commented 2026-10-18 11:24:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T11:24:20Z.


What

Every IrValue kept two lists of its users. uses (std::vector<IrValue*>) held the users, and operandUses (std::vector<IrUse>) held each user with the operand index it reads. AddArgument, ReplaceArgument and ReplaceAllUsesWith updated both, and every value allocated, grew and freed both. In a profile of a Release replay of 355 MXGP 26 (PPSA30839) shader requests, the allocator was 20% of all samples. Destroying IR programs, IrProgram::CreateValue and IrValue::AddArgument were its largest callers.

Only operandUses is kept now:

  • Uses() returns a view of the users in operandUses (std::views::transform). Its six callers in the recompiler only iterate it or test it with all_of, except SsaPass::TryRemoveTrivialPhi, which copied it into a vector and still does.
  • HasUses, UseCount and Invalidate read operandUses.
  • ReplaceArgument no longer searches uses, and ReplaceAllUsesWith reserves and fills one list.
  • sizeof(IrValue) drops from 152 to 128 bytes. The plan value encoder in ShaderDiskCache.cpp writes no use lists, so only its size check changes.

The two lists held the same users in the same order in all but one case: ReplaceArgument on a user that took the value in more than one operand. uses then dropped the user's first entry, and operandUses dropped the replaced operand's entry. Uses() now follows operandUses there as well, which is the list ReplaceAllUsesWith and IrUse-based passes already worked from.

shader_ir_use_rewrite counted the allocations of both lists, so two of its expectations change:

  • The allocation failure check failed each of ReplaceAllUsesWith's two reserves in turn. It now fails the one reserve that is left.
  • The growth check allowed 2 * (bit_width(count) + 1) allocations for 4,096 replacements. It now allows bit_width(count) + 1. main fails the new bound ("geometric use-list growth: IR use rewrite assertion failed"), and this PR passes it.

Tested

Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02.

  • ctest -R "^agc_|^shader_ir" on 9f25d0bf5b: 709 tests. 708 passed on the first run, with 3 skipped (host import sparse, sparse dma-buf import, stencil ref export). shader_ir_use_rewrite failed on the two expectations above, and passes with them updated. After that change, the 23 tests matching ^shader_ir|^agc_ir|^agc_shader pass.
  • agc_shader_replay --spv (Release, ANYPS5_ENABLE_SPIRV_TOOLS off, ANYPS5_NO_SHADER_CACHE=1) on 466 shader requests I had dumped with APS5_DUMP_SHADERS: 355 from PPSA30839, 107 from PPSA31162 and 4 from another app. All 462 .spv files (a few names repeat across the dumps) have the same SHA-256 on main 9f25d0bf5b and with this PR, and the replay output is identical.

Replay CPU time (perf stat -e task-clock), interleaved:

Replay main 9f25d0bf5b this PR
PPSA31162 0x1e401c0000 (1,056,287 SPIR-V words), 15 runs each 1164.7 ± 13.8 ms 1011.4 ± 20.4 ms
PPSA30839 0x10f9f30000 (1,130,170 words), 15 runs each 1293.0 ± 18.8 ms 1130.2 ± 14.4 ms
the 355 PPSA30839 requests in one replay, 3 runs each 25,227, 25,424, 25,152 ms 23,114, 22,796, 22,751 ms

That is about 13% on the two large shaders and about 9% over the whole set.

Title level: no speed claim. This is background shader preparation. I didn't run a title for it.

This touches the same IR as #7503 (ReclaimUnusedValues, which only calls HasUses) and #7518 (IrValue's constructor). They don't conflict, and each was measured on its own.

tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py lists only conflicting PRs that it could not compare on ShaderDiskCache.cpp. #6232, #6946 and #6947 have the sizeof(IrValue) check as a context line and don't change IrValue.

  • AMD on Linux: @DavidAmsellem ran the full suite on an RX 7900 XT (RADV NAVI31, Mesa 25.2.8), merged onto main 0fbfd91e5: 1637/1639 with this PR and on main, with the same two failures (#7766, #7784), and no test added, skipped or removed. That's correctness only; the speed-up wasn't measured there.

Title capture

As the perf label asks, these are captures of one title and scene on one machine. MXGP26 (PPSA30839) ran from boot with APS5_TRACE_SECONDS=0:60, ANYPS5_NO_SHADER_CACHE=1 and a fresh run directory (cold AnyPS5 and NVIDIA caches), so the shaders compile inside the window. NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04, release libs, Xvfb display, no input. main dbac9fa15b was captured five times: before the PR captures, after them, and three more times in a row after that. Each PR capture and the first two main captures followed a rebuild of the release libraries; the last three main captures did not, and they came out lower. The change is main with this PR merged on top as a local merge commit (c5944449ddce). The time is the wall time of the Shader.PrepareArtifact slices on the shader prepare threads in each trace.

capture presents frame p50 / p90 artifacts prepared prepare time, total per artifact, mean / median
main 1 194 16.7 / 32.8 ms 935 87.3 s 93.4 / 27.7 ms
main 2 195 16.7 / 34.0 ms 956 91.4 s 95.6 / 29.6 ms
main 3 166 16.7 / 28.4 ms 961 82.1 s 85.4 / 27.3 ms
main 4 161 16.7 / 27.9 ms 946 77.6 s 82.1 / 24.7 ms
main 5 183 16.7 / 22.7 ms 939 78.4 s 83.5 / 22.8 ms
this PR 186 16.7 / 36.2 ms 940 87.8 s 93.4 / 25.9 ms

The five main captures span 17.7% in total prepare time, and the 13 prepare threads run in parallel with the title, so a title capture can't resolve a recompiler change of a few percent. The replay measurement above is this change's measurement. This PR's capture falls inside the range of the five main captures.

main 1 trace, digest, main 2 trace, digest, main 3 trace, digest, main 4 trace, digest, main 5 trace, digest, this PR trace, digest

{"commit":"dbac9fa15b61","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":120148.301},"presents":194,"frame_ms":{"p50":16.686,"p90":32.765,"p99":2921.590,"max":112847.624},"gpu_busy_ms_per_present":6.483,"worker_busy_pct":{"queue worker 0x0":88.481,"queue worker 0x20":73.127},"top_phases_ms_per_frame":{"Driver.Packet":1000.862,"Driver.Packet.dispatch":503.561,"Driver.Dispatch":503.451,"Shader.PrepareArtifact":450.125,"Driver.Packet.memory_wait":424.003,"Vulkan.GraphicsPipeline":132.519,"Vulkan.GraphicsPipelineLibrary":126.497,"Vulkan.GraphicsPipelinePrebuild":77.312},"trace_dropped":false,"trace":"aps5-trace-dbac9fa15b61-3.json.gz"}
{"commit":"c5944449ddce","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":115002.952},"presents":186,"frame_ms":{"p50":16.686,"p90":36.213,"p99":2378.571,"max":108400.006},"gpu_busy_ms_per_present":5.709,"worker_busy_pct":{"queue worker 0x0":88.947,"queue worker 0x20":71.317},"top_phases_ms_per_frame":{"Driver.Packet":990.896,"Driver.Packet.dispatch":507.782,"Driver.Dispatch":507.730,"Shader.PrepareArtifact":472.125,"Driver.Packet.memory_wait":411.765,"Vulkan.GraphicsPipeline":130.351,"Vulkan.GraphicsPipelineLibrary":124.734,"Vulkan.GraphicsPipelinePrebuild":77.931},"trace_dropped":false,"trace":"aps5-trace-c5944449ddce-3.json.gz"}
  • Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04: VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -V on main e2a2914aa1 and on main + this PR (d484281b61, a local merge). main: 815 of 815 pass; with this PR: 815 of 815 pass. Neither log reports the layer missing. VUIDs on main: VUID-VkImageViewCreateInfo-usage-02275 ×6, VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 ×18, VUID-vkCmdCopyBuffer-srcBuffer-00118 ×2, VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285 ×2, VUID-vkCmdWaitEvents-srcStageMask-01158 ×2, VUID-vkSetEvent-event-09543 ×2; with this PR: VUID-VkImageViewCreateInfo-usage-02275 ×6, VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 ×18, VUID-vkCmdCopyBuffer-srcBuffer-00118 ×2, VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285 ×2, VUID-vkCmdWaitEvents-srcStageMask-01158 ×2, VUID-vkSetEvent-event-09543 ×2. None is new with this PR.
  • Windows 11 Pro 26220, RTX 4070 (NVIDIA 596.21), WinLibs GCC 15.2 r7, Release, by @screamm (comment): stacked with #7522 on main 1d4164552 + #7516 + #7494: shader_ir_use_rewrite with the tightened bounds and the 41-test set pass 3 of 3, MinGW accepts the sizeof(IrValue) == 128 assert; identical shader-cache entries and replay hashes against two main runs (Showcase PPSA99005, RetroArch PPSA99169, vkQuake PPSA99010), static frames bit-identical, and draw-path recompile time within main's spread.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04 (Linux 6.8); NVIDIA RTX 4070 (596.21), Windows 11 (@screamm)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4908666969 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T11:24:20Z. --- ### What Every `IrValue` kept two lists of its users. `uses` (`std::vector<IrValue*>`) held the users, and `operandUses` (`std::vector<IrUse>`) held each user with the operand index it reads. `AddArgument`, `ReplaceArgument` and `ReplaceAllUsesWith` updated both, and every value allocated, grew and freed both. In a profile of a Release replay of 355 MXGP 26 (PPSA30839) shader requests, the allocator was 20% of all samples. Destroying IR programs, `IrProgram::CreateValue` and `IrValue::AddArgument` were its largest callers. Only `operandUses` is kept now: - `Uses()` returns a view of the users in `operandUses` (`std::views::transform`). Its six callers in the recompiler only iterate it or test it with `all_of`, except `SsaPass::TryRemoveTrivialPhi`, which copied it into a vector and still does. - `HasUses`, `UseCount` and `Invalidate` read `operandUses`. - `ReplaceArgument` no longer searches `uses`, and `ReplaceAllUsesWith` reserves and fills one list. - `sizeof(IrValue)` drops from 152 to 128 bytes. The plan value encoder in `ShaderDiskCache.cpp` writes no use lists, so only its size check changes. The two lists held the same users in the same order in all but one case: `ReplaceArgument` on a user that took the value in more than one operand. `uses` then dropped the user's first entry, and `operandUses` dropped the replaced operand's entry. `Uses()` now follows `operandUses` there as well, which is the list `ReplaceAllUsesWith` and `IrUse`-based passes already worked from. `shader_ir_use_rewrite` counted the allocations of both lists, so two of its expectations change: - The allocation failure check failed each of `ReplaceAllUsesWith`'s two reserves in turn. It now fails the one reserve that is left. - The growth check allowed `2 * (bit_width(count) + 1)` allocations for 4,096 replacements. It now allows `bit_width(count) + 1`. `main` fails the new bound ("geometric use-list growth: IR use rewrite assertion failed"), and this PR passes it. ### Tested Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02. - `ctest -R "^agc_|^shader_ir"` on 9f25d0bf5b: 709 tests. 708 passed on the first run, with 3 skipped (host import sparse, sparse dma-buf import, stencil ref export). `shader_ir_use_rewrite` failed on the two expectations above, and passes with them updated. After that change, the 23 tests matching `^shader_ir|^agc_ir|^agc_shader` pass. - `agc_shader_replay --spv` (Release, `ANYPS5_ENABLE_SPIRV_TOOLS` off, `ANYPS5_NO_SHADER_CACHE=1`) on 466 shader requests I had dumped with `APS5_DUMP_SHADERS`: 355 from PPSA30839, 107 from PPSA31162 and 4 from another app. All 462 `.spv` files (a few names repeat across the dumps) have the same SHA-256 on `main` 9f25d0bf5b and with this PR, and the replay output is identical. **Replay CPU time** (`perf stat -e task-clock`), interleaved: | Replay | `main` 9f25d0bf5b | this PR | |---|---|---| | PPSA31162 `0x1e401c0000` (1,056,287 SPIR-V words), 15 runs each | 1164.7 ± 13.8 ms | 1011.4 ± 20.4 ms | | PPSA30839 `0x10f9f30000` (1,130,170 words), 15 runs each | 1293.0 ± 18.8 ms | 1130.2 ± 14.4 ms | | the 355 PPSA30839 requests in one replay, 3 runs each | 25,227, 25,424, 25,152 ms | 23,114, 22,796, 22,751 ms | That is about 13% on the two large shaders and about 9% over the whole set. **Title level: no speed claim.** This is background shader preparation. I didn't run a title for it. This touches the same IR as #7503 (`ReclaimUnusedValues`, which only calls `HasUses`) and #7518 (`IrValue`'s constructor). They don't conflict, and each was measured on its own. `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` lists only conflicting PRs that it could not compare on `ShaderDiskCache.cpp`. #6232, #6946 and #6947 have the `sizeof(IrValue)` check as a context line and don't change `IrValue`. - AMD on Linux: @DavidAmsellem [ran the full suite](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6272004473) on an RX 7900 XT (RADV NAVI31, Mesa 25.2.8), merged onto `main` 0fbfd91e5: 1637/1639 with this PR and on `main`, with the same two failures (#7766, #7784), and no test added, skipped or removed. That's correctness only; the speed-up wasn't measured there. ### Title capture As the `perf` label asks, these are captures of one title and scene on one machine. MXGP26 (PPSA30839) ran from boot with `APS5_TRACE_SECONDS=0:60`, `ANYPS5_NO_SHADER_CACHE=1` and a fresh run directory (cold AnyPS5 and NVIDIA caches), so the shaders compile inside the window. NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04, release libs, Xvfb display, no input. `main` dbac9fa15b61 was captured five times: before the PR captures, after them, and three more times in a row after that. Each PR capture and the first two `main` captures followed a rebuild of the release libraries; the last three `main` captures did not, and they came out lower. The change is `main` with this PR merged on top as a local merge commit (c5944449ddce). The time is the wall time of the `Shader.PrepareArtifact` slices on the `shader prepare` threads in each trace. | capture | presents | frame p50 / p90 | artifacts prepared | prepare time, total | per artifact, mean / median | |---|---:|---:|---:|---:|---:| | `main` 1 | 194 | 16.7 / 32.8 ms | 935 | 87.3 s | 93.4 / 27.7 ms | | `main` 2 | 195 | 16.7 / 34.0 ms | 956 | 91.4 s | 95.6 / 29.6 ms | | `main` 3 | 166 | 16.7 / 28.4 ms | 961 | 82.1 s | 85.4 / 27.3 ms | | `main` 4 | 161 | 16.7 / 27.9 ms | 946 | 77.6 s | 82.1 / 24.7 ms | | `main` 5 | 183 | 16.7 / 22.7 ms | 939 | 78.4 s | 83.5 / 22.8 ms | | this PR | 186 | 16.7 / 36.2 ms | 940 | 87.8 s | 93.4 / 25.9 ms | The five `main` captures span 17.7% in total prepare time, and the 13 prepare threads run in parallel with the title, so a title capture can't resolve a recompiler change of a few percent. The replay measurement above is this change's measurement. This PR's capture falls inside the range of the five `main` captures. [`main` 1 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main-digest.txt), [`main` 2 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main2-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main2-digest.txt), [`main` 3 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main3-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main3-digest.txt), [`main` 4 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main4-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main4-digest.txt), [`main` 5 trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main5-aps5-trace-dbac9fa15b61-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-main5-digest.txt), [this PR trace](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-7520-aps5-trace-c5944449ddce-3.json.gz), [digest](https://github.com/milescoviello/AnyPS5/releases/download/perf-mxgp-2026-10-19/mxgp-7520-digest.txt) ```json {"commit":"dbac9fa15b61","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":120148.301},"presents":194,"frame_ms":{"p50":16.686,"p90":32.765,"p99":2921.590,"max":112847.624},"gpu_busy_ms_per_present":6.483,"worker_busy_pct":{"queue worker 0x0":88.481,"queue worker 0x20":73.127},"top_phases_ms_per_frame":{"Driver.Packet":1000.862,"Driver.Packet.dispatch":503.561,"Driver.Dispatch":503.451,"Shader.PrepareArtifact":450.125,"Driver.Packet.memory_wait":424.003,"Vulkan.GraphicsPipeline":132.519,"Vulkan.GraphicsPipelineLibrary":126.497,"Vulkan.GraphicsPipelinePrebuild":77.312},"trace_dropped":false,"trace":"aps5-trace-dbac9fa15b61-3.json.gz"} {"commit":"c5944449ddce","dirty":false,"env":{"APS5_TRACE_SECONDS":"0:60"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 595.99.02","os":"Linux 6.8.0-147-generic","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":0,"ms":115002.952},"presents":186,"frame_ms":{"p50":16.686,"p90":36.213,"p99":2378.571,"max":108400.006},"gpu_busy_ms_per_present":5.709,"worker_busy_pct":{"queue worker 0x0":88.947,"queue worker 0x20":71.317},"top_phases_ms_per_frame":{"Driver.Packet":990.896,"Driver.Packet.dispatch":507.782,"Driver.Dispatch":507.730,"Shader.PrepareArtifact":472.125,"Driver.Packet.memory_wait":411.765,"Vulkan.GraphicsPipeline":130.351,"Vulkan.GraphicsPipelineLibrary":124.734,"Vulkan.GraphicsPipelinePrebuild":77.931},"trace_dropped":false,"trace":"aps5-trace-c5944449ddce-3.json.gz"} ``` - Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04: `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_' -V` on `main` e2a2914aa1 and on `main` + this PR (d484281b61, a local merge). `main`: 815 of 815 pass; with this PR: 815 of 815 pass. Neither log reports the layer missing. VUIDs on `main`: `VUID-VkImageViewCreateInfo-usage-02275` ×6, `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` ×18, `VUID-vkCmdCopyBuffer-srcBuffer-00118` ×2, `VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285` ×2, `VUID-vkCmdWaitEvents-srcStageMask-01158` ×2, `VUID-vkSetEvent-event-09543` ×2; with this PR: `VUID-VkImageViewCreateInfo-usage-02275` ×6, `VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605` ×18, `VUID-vkCmdCopyBuffer-srcBuffer-00118` ×2, `VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285` ×2, `VUID-vkCmdWaitEvents-srcStageMask-01158` ×2, `VUID-vkSetEvent-event-09543` ×2. None is new with this PR. - Windows 11 Pro 26220, RTX 4070 (NVIDIA 596.21), WinLibs GCC 15.2 r7, Release, by @screamm ([comment](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6293959799)): stacked with #7522 on `main` 1d4164552 + #7516 + #7494: `shader_ir_use_rewrite` with the tightened bounds and the 41-test set pass 3 of 3, MinGW accepts the `sizeof(IrValue) == 128` assert; identical shader-cache entries and replay hashes against two `main` runs (Showcase PPSA99005, RetroArch PPSA99169, vkQuake PPSA99010), static frames bit-identical, and draw-path recompile time within `main`'s spread. ### 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) - [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: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04 (Linux 6.8); NVIDIA RTX 4070 (596.21), Windows 11 (@screamm) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-18 11:35:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T11:35:05Z.


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 5500 core/shader/recompiler/ShaderDiskCache.cpp
PR 5609 core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.cpp
PR 6280 core/shader/recompiler/ShaderDiskCache.cpp
PR 6412 core/shader/recompiler/ShaderDiskCache.cpp
PR 6488 core/shader/recompiler/ShaderDiskCache.cpp
PR 6539 core/shader/recompiler/ShaderDiskCache.cpp
PR 6946 core/shader/recompiler/ShaderDiskCache.cpp
PR 6947 core/shader/recompiler/ShaderDiskCache.cpp
PR 6959 core/shader/recompiler/ShaderDiskCache.cpp
PR 6977 core/shader/recompiler/ShaderDiskCache.cpp
PR 7085 core/shader/recompiler/ShaderDiskCache.cpp
PR 7395 core/shader/recompiler/ShaderDiskCache.cpp
PR 7550 core/shader/recompiler/ShaderDiskCache.cpp
PR 7642 core/shader/recompiler/ShaderDiskCache.cpp
PR 7684 core/shader/recompiler/ShaderDiskCache.cpp
PR 7689 core/shader/recompiler/ShaderDiskCache.cpp
PR 7888 core/shader/recompiler/ShaderDiskCache.cpp
PR 8077 core/shader/recompiler/ShaderDiskCache.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249430535 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6249430535). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T11:35:05Z. --- <!-- pr-overlap --> 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 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6488](https://www.github.com/boykopovar/AnyPS5/pull/6488) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6959](https://www.github.com/boykopovar/AnyPS5/pull/6959) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7395](https://www.github.com/boykopovar/AnyPS5/pull/7395) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7550](https://www.github.com/boykopovar/AnyPS5/pull/7550) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7684](https://www.github.com/boykopovar/AnyPS5/pull/7684) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7689](https://www.github.com/boykopovar/AnyPS5/pull/7689) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 7888](https://www.github.com/boykopovar/AnyPS5/pull/7888) | `core/shader/recompiler/ShaderDiskCache.cpp` | | [PR 8077](https://www.github.com/boykopovar/AnyPS5/pull/8077) | `core/shader/recompiler/ShaderDiskCache.cpp` |
milescoviello commented 2026-10-18 12:09:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T12:09:30Z.


A note on how this composes with my other open shader preparation PRs: #7431, #7491, #7494, #7503, #7504, #7516, #7518 and #7522. I merged all nine onto main 0d078f75d3 locally, in that order, and none of them conflicted.

  • ctest -R "^agc_|^shader_ir": 710/710 pass (3 skipped: host import sparse, sparse dma-buf import, stencil ref export).
  • agc_shader_replay --spv over the 466 dumped requests: 15 of the 462 .spv files differ from main. All 15 are shaders whose f16 min/max lowering #7516 changes; I checked that #7516 alone changes them. The other 447 are byte-identical.

Release replay CPU time (task-clock), interleaved:

Replay main 0d078f75d3 all nine
PPSA31162 0x1e401c0000, 10 runs each 1149.8 ± 19.7 ms 647.2 ± 13.2 ms
PPSA30839 0x10f9f30000, 10 runs each 1280.3 ± 16.8 ms 712.6 ± 8.3 ms
the 355 PPSA30839 requests, 2 runs each 25,202 and 25,507 ms 19,036 and 19,045 ms

Each PR still stands on its own, and its description has its own measurement against main.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6249741695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6249741695). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T12:09:30Z. --- A note on how this composes with my other open shader preparation PRs: #7431, #7491, #7494, #7503, #7504, #7516, #7518 and #7522. I merged all nine onto `main` 0d078f75d3 locally, in that order, and none of them conflicted. - `ctest -R "^agc_|^shader_ir"`: 710/710 pass (3 skipped: host import sparse, sparse dma-buf import, stencil ref export). - `agc_shader_replay --spv` over the 466 dumped requests: 15 of the 462 `.spv` files differ from `main`. All 15 are shaders whose f16 min/max lowering #7516 changes; I checked that #7516 alone changes them. The other 447 are byte-identical. Release replay CPU time (`task-clock`), interleaved: | Replay | `main` 0d078f75d3 | all nine | |---|---|---| | PPSA31162 `0x1e401c0000`, 10 runs each | 1149.8 ± 19.7 ms | 647.2 ± 13.2 ms | | PPSA30839 `0x10f9f30000`, 10 runs each | 1280.3 ± 16.8 ms | 712.6 ± 8.3 ms | | the 355 PPSA30839 requests, 2 runs each | 25,202 and 25,507 ms | 19,036 and 19,045 ms | Each PR still stands on its own, and its description has its own measurement against `main`. AI-assisted: yes (Claude Code)
DavidAmsellem commented 2026-10-19 16:27:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T16:27:58Z.


First AMD-on-Linux (RADV) run of this PR. Merged onto main 0fbfd91e5 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1637/1639 with this PR, against 1637/1639 on main. The failures are the same two on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784). The PR adds no new ctest entry, and no test is skipped or removed compared with main. This checks correctness only: I did not measure the speed-up.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272004473 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6272004473). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T16:27:58Z. --- First AMD-on-Linux (RADV) run of this PR. Merged onto `main` `0fbfd91e5` (clean merge), built in full and compared with the same `main`, on the same machine. AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release. Full suite (`ANYPS5_REQUIRE_VULKAN=1 ctest -j8`): **1637/1639 with this PR**, against 1637/1639 on `main`. The failures are the same two on both, so this PR adds none: `agc_driver_image_table_vouched_lookups` (#7766, fixed by #7916) and `agc_driver_guest_memory_lifetime` (#7784). The PR adds no new ctest entry, and no test is skipped or removed compared with `main`. This checks correctness only: I did not measure the speed-up. GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38 AI-assisted: yes
milescoviello commented 2026-10-19 16:30:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T16:30:55Z.


@DavidAmsellem thank you for the RADV full-suite run. It matches main on gfx1100 with the same two failures, so this change adds none. It's in the description now.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272057243 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6272057243). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T16:30:55Z. --- @DavidAmsellem thank you for the RADV full-suite run. It matches `main` on gfx1100 with the same two failures, so this change adds none. It's in the description now. AI-assisted: yes (Claude Code)
github-actions[bot] commented 2026-10-19 16:31:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T16:31:06Z.


This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272060651 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6272060651). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T16:31:06Z. --- <!-- pr-labels-perf --> This pull request is labeled `perf`, so it needs the summary line of a capture on `main` and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both `aps5-summary.jsonl` lines, attach the two traces and add the output of `tools/trace_digest.py`.
milescoviello commented 2026-10-19 21:35:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T21:35:23Z.


The title capture the perf label asks for is now in the description, with both summary lines, the traces and the digests: MXGP26 from boot, a cold shader cache, main dbac9fa15b against main + this PR (c5944449ddce). The five main captures span 17.7% in total shader prepare time, so the capture can't resolve this change, and the replay measurement in the description is still its measurement. This PR's capture falls inside the range of the five main captures.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6277880458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6277880458). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T21:35:23Z. --- The title capture the `perf` label asks for is now in the description, with both summary lines, the traces and the digests: MXGP26 from boot, a cold shader cache, `main` dbac9fa15b61 against `main` + this PR (c5944449ddce). The five `main` captures span 17.7% in total shader prepare time, so the capture can't resolve this change, and the replay measurement in the description is still its measurement. This PR's capture falls inside the range of the five `main` captures. AI-assisted: yes (Claude Code)
screamm commented 2026-10-20 15:01:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-20T15:01:48Z.


Windows run of #7520 and #7522 together. Host: Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2 r7, Release. I stacked #7520 at d484281b6 and #7522 at cabf6ad53 on main 1d4164552 + #7516 (f099292f8) + #7494 (0aab6c1f3). None of the four shares a file, and all merges were clean. Targeted build: the shader and AGC test targets plus libs. MinGW accepts the new static_assert(sizeof(IrValue) == 128).

  • shader_ir_use_rewrite with the tightened allocation bounds: 3 of 3. agc_masked_select with the new "no dead code left" check: 3 of 3. The rest of the 41-test set also passed 3 of 3, none skipped: the ^shader_|^agc_shader_ set, agc_ir_reclaim, agc_constant_phi and the f16/f32 min/max GPU tests.
  • Shader output, three homebrews, fresh shader cache directory per run, 60 s: Showcase PPSA99005 52 entries, RetroArch PPSA99169 24, vkQuake PPSA99010 52. Entry count, keys and payloads are the same for two main runs and this stack. I matched keys with the source-version word masked and compared payloads with host pointers masked: 5 Showcase entries hold a host address and differ between two main runs too. Showcase's two dumped compute requests replay (agc_shader_replay --spv) to identical SHA-256 on main and the stack.
  • One cold-cache title pass of the stack per title, 90 s, run after a main/#7516+#7494 A B A B. Settings: ANYPS5_NO_SHADER_CACHE=1, a freshly relinked run directory, APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1 APS5_TRACE_SUMMARY_EVERY=10. No stop line. These titles compile on the draw path; they have no Shader.PrepareArtifact slices. Draw-path recompile time over the run, summed from the [draw] driver phases lines:
    • vkQuake 2245.5 ms against main 2594.5 / 2223.2 ms.
    • Showcase 39.7 ms against main 46.8 / 35.0 ms.
    • RetroArch 9111 presents against 8924 / 9118 on main, p50 8.34 ms in all.
    • All within the main range. This is one run, so it shows no regression, not a speed-up.
  • Frame dumps: vkQuake's static console and loading screens are bit-identical with main. The animated frames differ between two main runs too, so they can't be compared.
  • A negative control doesn't apply to a bit-exact optimisation. I didn't repeat your two negative checks (main against the new UseRewrite bound, and MaskedSelect without the inner DCE).
  • tools/check_conventions.py --base origin/main and git diff --check: pass.

Not checked: a full build, the agc_driver_ GPU suite (the RADV full-suite run above covers that on AMD), replay CPU time, an A B A B of these two on their own, AMD/Intel on Windows.

Written with Claude Code assistance (validation by a subagent, reviewed in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6293959799 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6293959799). Originally posted by [screamm](https://github.com/screamm) on 2026-10-20T15:01:48Z. --- Windows run of #7520 and #7522 together. Host: Windows 11 Pro 26220, NVIDIA GeForce RTX 4070 driver 596.21, Ryzen 7 5700X, WinLibs MinGW-w64 GCC 15.2 r7, Release. I stacked #7520 at `d484281b6` and #7522 at `cabf6ad53` on `main` `1d4164552` + #7516 (`f099292f8`) + #7494 (`0aab6c1f3`). None of the four shares a file, and all merges were clean. Targeted build: the shader and AGC test targets plus `libs`. MinGW accepts the new `static_assert(sizeof(IrValue) == 128)`. - `shader_ir_use_rewrite` with the tightened allocation bounds: 3 of 3. `agc_masked_select` with the new "no dead code left" check: 3 of 3. The rest of the 41-test set also passed 3 of 3, none skipped: the `^shader_|^agc_shader_` set, `agc_ir_reclaim`, `agc_constant_phi` and the f16/f32 min/max GPU tests. - Shader output, three homebrews, fresh shader cache directory per run, 60 s: Showcase PPSA99005 52 entries, RetroArch PPSA99169 24, vkQuake PPSA99010 52. Entry count, keys and payloads are the same for two `main` runs and this stack. I matched keys with the source-version word masked and compared payloads with host pointers masked: 5 Showcase entries hold a host address and differ between two `main` runs too. Showcase's two dumped compute requests replay (`agc_shader_replay --spv`) to identical SHA-256 on `main` and the stack. - One cold-cache title pass of the stack per title, 90 s, run after a `main`/#7516+#7494 A B A B. Settings: `ANYPS5_NO_SHADER_CACHE=1`, a freshly relinked run directory, `APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1 APS5_TRACE_SUMMARY_EVERY=10`. No stop line. These titles compile on the draw path; they have no `Shader.PrepareArtifact` slices. Draw-path recompile time over the run, summed from the `[draw] driver phases` lines: - vkQuake 2245.5 ms against `main` 2594.5 / 2223.2 ms. - Showcase 39.7 ms against `main` 46.8 / 35.0 ms. - RetroArch 9111 presents against 8924 / 9118 on `main`, p50 8.34 ms in all. - All within the `main` range. This is one run, so it shows no regression, not a speed-up. - Frame dumps: vkQuake's static console and loading screens are bit-identical with `main`. The animated frames differ between two `main` runs too, so they can't be compared. - A negative control doesn't apply to a bit-exact optimisation. I didn't repeat your two negative checks (`main` against the new UseRewrite bound, and MaskedSelect without the inner DCE). - `tools/check_conventions.py --base origin/main` and `git diff --check`: pass. Not checked: a full build, the `agc_driver_` GPU suite (the RADV full-suite run above covers that on AMD), replay CPU time, an A B A B of these two on their own, AMD/Intel on Windows. Written with Claude Code assistance (validation by a subagent, reviewed in this session).
milescoviello commented 2026-10-20 15:03:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:03:45Z.


Thanks @screamm, the first Windows title runs of this one, and the identical cache entries and replay hashes are the right check for a bit-exact change. Added to the description.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294001017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6294001017). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T15:03:45Z. --- Thanks @screamm, the first Windows title runs of this one, and the identical cache entries and replay hashes are the right check for a bit-exact change. Added to the description. AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-20 15:27:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T15:27:56Z.


Checked that every Uses() caller only iterates it or uses all_of (SsaPass::TryRemoveTrivialPhi copies it), that HasUses, UseCount and Invalidate read operandUses, that the use order is unchanged, and that the updated shader_ir_use_rewrite bounds match the single remaining list. The AMD run by @DavidAmsellem covers the full suite on RADV; merged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294519782 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6294519782). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-20T15:27:56Z. --- Checked that every `Uses()` caller only iterates it or uses `all_of` (`SsaPass::TryRemoveTrivialPhi` copies it), that `HasUses`, `UseCount` and `Invalidate` read `operandUses`, that the use order is unchanged, and that the updated `shader_ir_use_rewrite` bounds match the single remaining list. The AMD run by @DavidAmsellem covers the full suite on RADV; merged.
milescoviello commented 2026-10-20 15:46:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T15:46:48Z.


Thanks @adriadam10 for checking the callers and for the merge.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6294928544 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7520#issuecomment-6294928544). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T15:46:48Z. --- Thanks @adriadam10 for checking the callers and for the merge. 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!7520
No description provided.