perf(recompiler): read the buffer stride and presence at run time in compute modules #5353

Closed
Pipodi wants to merge 1 commit from upstream-pr/5353 into main
Pipodi commented 2026-10-13 17:44:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-13T17:44:39Z.


What

A specialized compute module bakes four words of each buffer V#: the stride (dwords[1] & 0xffff0000), the format word (dwords[3]), whether the buffer is present, and the base misalignment. When a program is dispatched with a different stride, or once with an absent buffer and later with a real one, the module differs only in those constants. The driver still compiles each one as a new pipeline, from scratch.

With this change compute modules read the stride and the presence from the V# at run time, the way registration-form modules (#4152) already do:

  • descriptor() takes word1 and present from the V# operands for compute stages. The record count was already a run-time value there.
  • Formatted buffer helper: in compute modules it uses the stride, swizzle and valid parameters its callers already pass, instead of the specialization constants.
  • DescriptorBindingBuilder::Prepare no longer adds those two constants for compute stages, so modules that differ only in them get the same specialization and the same pipeline.

What stays baked: the format word, because a run-time format makes the driver compile every format decoder (#4152 item 13), and the misalignment, because the unaligned store loops it would otherwise keep caused hangs (#4152 item 15). Graphics stages are unchanged.

Why

Ghost of Yōtei (PPSA26344) dispatches its largest compute programs (1.1–1.5M SPIR-V words) first with one buffer absent and later with it present. The two modules are structurally identical: diffing them shows only 44–132 constants changed. These are the absent buffer's stride, its presence flag, and the folded results (8 → 192, false → true). A cold boot builds both.

Measured offline: agc_compute_pipeline_replay, RTX 4090, driver 617.42, fresh driver cache per run, idle machine. Modules from captured pipelines; for the run-time form, the constants that differ between a pair are replaced with push-constant loads.

compile time
0x800022d100 present, specialized 51.9 s / 51.8 s
0x800022d100 present, stride and presence at run time 52.0 s / 55.7 s
0x8000261500 present, specialized 82.4 s
0x8000261500 present, stride and presence at run time 81.8 s
13 programs, absent variants (the builds this removes) 103 s in total
13 programs, present variants 484 s in total

Reading the two values at run time does not slow the driver's compile down, unlike the run-time format and component selectors measured in #4152. A cold boot of this title then compiles 13 fewer giant pipelines, about 103 s on this machine. That's 18% of those programs' compile time.

Tested

Windows 11 Pro 26200, RTX 4090, driver 617.42.

  • agc_driver_buffer_descriptor_runtime: new stride 16 case. In specialized form the aligned, records 37, stride 16 and absent cases must give byte-identical SPIR-V and the same pipeline variant, and every case still checks the values it reads. On main the new check fails ("the stride, record count or presence of the V# changed the compute module").
  • Full suite (ctest -j 16): 1096/1097. agc_driver_pixel_lds failed once under the parallel run; on its own it passes 4 times in 4. It's a pixel-shader test this change doesn't touch, and #4152 reports the same test as unstable on an RTX 4090.

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 in TechnicalDebt (none)
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA26344, shorter cold boot
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4847172328 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-13T17:44:39Z. --- ### What A specialized compute module bakes four words of each buffer V#: the stride (`dwords[1] & 0xffff0000`), the format word (`dwords[3]`), whether the buffer is present, and the base misalignment. When a program is dispatched with a different stride, or once with an absent buffer and later with a real one, the module differs only in those constants. The driver still compiles each one as a new pipeline, from scratch. With this change compute modules read the stride and the presence from the V# at run time, the way registration-form modules (#4152) already do: - **`descriptor()`** takes `word1` and `present` from the V# operands for compute stages. The record count was already a run-time value there. - **Formatted buffer helper:** in compute modules it uses the stride, swizzle and valid parameters its callers already pass, instead of the specialization constants. - **`DescriptorBindingBuilder::Prepare`** no longer adds those two constants for compute stages, so modules that differ only in them get the same specialization and the same pipeline. What stays baked: the format word, because a run-time format makes the driver compile every format decoder (#4152 item 13), and the misalignment, because the unaligned store loops it would otherwise keep caused hangs (#4152 item 15). Graphics stages are unchanged. ### Why Ghost of Yōtei (PPSA26344) dispatches its largest compute programs (1.1–1.5M SPIR-V words) first with one buffer absent and later with it present. The two modules are structurally identical: diffing them shows only 44–132 constants changed. These are the absent buffer's stride, its presence flag, and the folded results (`8 → 192`, `false → true`). A cold boot builds both. Measured offline: `agc_compute_pipeline_replay`, RTX 4090, driver 617.42, fresh driver cache per run, idle machine. Modules from captured pipelines; for the run-time form, the constants that differ between a pair are replaced with push-constant loads. | | compile time | |---|---| | `0x800022d100` present, specialized | 51.9 s / 51.8 s | | `0x800022d100` present, stride and presence at run time | 52.0 s / 55.7 s | | `0x8000261500` present, specialized | 82.4 s | | `0x8000261500` present, stride and presence at run time | 81.8 s | | 13 programs, absent variants (the builds this removes) | 103 s in total | | 13 programs, present variants | 484 s in total | Reading the two values at run time does not slow the driver's compile down, unlike the run-time format and component selectors measured in #4152. A cold boot of this title then compiles 13 fewer giant pipelines, about 103 s on this machine. That's 18% of those programs' compile time. ### Tested Windows 11 Pro 26200, RTX 4090, driver 617.42. - **`agc_driver_buffer_descriptor_runtime`:** new `stride 16` case. In specialized form the `aligned`, `records 37`, `stride 16` and `absent` cases must give byte-identical SPIR-V and the same pipeline variant, and every case still checks the values it reads. On `main` the new check fails ("the stride, record count or presence of the V# changed the compute module"). - **Full suite** (`ctest -j 16`): 1096/1097. `agc_driver_pixel_lds` failed once under the parallel run; on its own it passes 4 times in 4. It's a pixel-shader test this change doesn't touch, and #4152 reports the same test as unstable on an RTX 4090. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt (none) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA26344, shorter cold boot - [x] GPUs tested: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CnRJay commented 2026-10-14 00:53:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T00:53:38Z.

Review: COMMENTED


Well-documented change, and the compile-time measurement is careful. One side of the trade-off is missing, though: what the run-time form costs when the pipeline executes.

Specialization constants are there so the driver compiler can fold the stride into every address computation and drop the code of an absent buffer entirely. Reading them from the V# turns that into per-access ALU work, an extra predicate per load/store, and, for 1.1–1.5M-word programs, possibly higher register pressure. If occupancy drops, every dispatch of these programs gets slower for the rest of the session. The replay table shows the compile doesn't get slower, but not whether the dispatch does.

The two costs are also paid at different times:

  • The 103 s saved is a cold-boot, cold-driver-cache cost. Once the driver cache holds the absent variants, a second boot doesn't build them again.
  • Any GPU-time cost of the run-time form is paid every frame, on every boot.

Before this goes in for all compute stages, I'd like to see GPU time for these dispatches in both forms: the trace's GPU ranges for the Yōtei programs, or agc_compute_pipeline_replay timing a dispatch rather than the compile. If one form costs measurably more on large programs, a narrower option is to read stride and presence at run time only where a variant with a different stride or presence was actually seen for the program. That covers the absent-then-present pattern here without changing every compute module.

The code changes look consistent with the registration-form path (descriptor() reuses its run-time presence expression, Prepare drops exactly the two constants), and the new sameModule checks are a good guard.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5511813915 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#pullrequestreview-5511813915). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T00:53:38Z. **Review:** COMMENTED --- Well-documented change, and the compile-time measurement is careful. One side of the trade-off is missing, though: what the run-time form costs when the pipeline **executes**. Specialization constants are there so the driver compiler can fold the stride into every address computation and drop the code of an absent buffer entirely. Reading them from the V# turns that into per-access ALU work, an extra predicate per load/store, and, for 1.1–1.5M-word programs, possibly higher register pressure. If occupancy drops, every dispatch of these programs gets slower for the rest of the session. The replay table shows the compile doesn't get slower, but not whether the dispatch does. The two costs are also paid at different times: - The 103 s saved is a cold-boot, cold-driver-cache cost. Once the driver cache holds the absent variants, a second boot doesn't build them again. - Any GPU-time cost of the run-time form is paid every frame, on every boot. Before this goes in for all compute stages, I'd like to see GPU time for these dispatches in both forms: the trace's GPU ranges for the Yōtei programs, or `agc_compute_pipeline_replay` timing a dispatch rather than the compile. If one form costs measurably more on large programs, a narrower option is to read stride and presence at run time only where a variant with a different stride or presence was actually seen for the program. That covers the absent-then-present pattern here without changing every compute module. The code changes look consistent with the registration-form path (`descriptor()` reuses its run-time presence expression, `Prepare` drops exactly the two constants), and the new `sameModule` checks are a good guard.
oneandonlydean commented 2026-10-14 05:10:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:10:49Z.


CnRJay's question is the one that decides this: compute modules now read the stride and presence at run time, which may cost GPU time on every dispatch, and the 103 s saved is a cold-cache cost only.
Please add the summary lines of main and of this change from the same machine and scene in PPSA26344 after a warm-up (warm driver cache), so the in-game cost shows, per the performance template.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161392728 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6161392728). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:10:49Z. --- CnRJay's question is the one that decides this: compute modules now read the stride and presence at run time, which may cost GPU time on every dispatch, and the 103 s saved is a cold-cache cost only. Please add the summary lines of main and of this change from the same machine and scene in PPSA26344 after a warm-up (warm driver cache), so the in-game cost shows, per the performance template.
Pipodi commented 2026-10-14 12:24:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T12:24:07Z.


I measured on PPSA26344 what @CnRJay and @oneandonlydean asked for: the GPU time per dispatch, and the template's summary lines after a warm-up. In short, I found no measurable GPU cost. The run-time form does add a cold-boot cost that the PR description doesn't mention.

Builds. Both builds are this PR's base 18c438b10 plus the same additions. git diff A B is identical to this PR's diff. The additions are what the title needs to boot and reach the scene:

  • #4222, #758, #4450, #4475 and #4487 (#4487 merged after 18c438b10; without it both builds abort on format 169);
  • local: startup dialogs and entitlements, unnormalized samplers with wrap clamped, LRU caps on prepared and source SPIR-V, reuse of dedicated descriptor pools by shape (CPU only);
  • a store-and-log fallback where e5449936f throws. It never fired on this base.

None of these change how buffer accesses are emitted. Machine: RTX 4090, NVIDIA 617.42, Windows 10.0.26200, 3840x2160. Both builds ran with the same env: APS5_HOST_IMPORT_MIB=16384 APS5_STAGING_POOL_MIB=2048 APS5_PREPARED_SPIRV_MIB=6144 APS5_NO_SNAPSHOT_CHECK=1.

Scene. The loading phase, presents 700 to 760 (APS5_TRACE_FRAMES=700:60), where the large compute programs are dispatched. A later scene was out of reach: about 10 minutes after the loading spinner, the title takes commit headroom to 0 on this 32 GB machine.

Runs. For each build, I ran warm-up boots until the shader disk cache was complete. Then I restarted it with only the trace switch set. Every capture had 0 disk cache misses. I captured A twice, before and after B, to see how much boots differ.

Summary lines (presents 700 to 760):

commit gpu_busy_ms_per_present frame_ms p50 / p90 / max window
A, 1st 3991a1dde05c 161.9 5,897 / 20,688 / 96,072 633 s
B efa6abe062b5 161.3 5,746 / 12,191 / 98,700 600 s
A, 2nd 3991a1dde05c 172.6 5,964 / 23,175 / 91,526 667 s

The two A captures differ by 6.4% in GPU busy time, and B is 3.6% below their mean, inside that spread. Frame times in this window are set by CPU shader preparation (8 prepare threads about 90% busy, Shader.PrepareArtifact the top phase), not by the GPU. So I don't read anything into the frame time differences either.

Full summary lines
{"commit":"3991a1dde05c","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":632962.969},"presents":60,"frame_ms":{"p50":5896.623,"p90":20688.487,"p99":96072.009,"max":96072.009},"gpu_busy_ms_per_present":161.921,"worker_busy_pct":{"queue worker 0x0":95.331,"queue worker 0x52":2.502,"queue worker 0x53":0.000,"queue worker 0x20":20.826,"queue worker 0x30":83.878,"queue worker 0x38":63.937,"queue worker 0x48":38.948},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":74869.129,"Driver.Packet":32128.767,"Driver.Packet.memory_wait":17431.423,"Driver.Packet.dispatch":11452.506,"Driver.Dispatch":11394.126,"Vulkan.Dispatch":4680.173,"Vulkan.Dispatch.shader_resources":2773.425,"Driver.Packet.draw":2358.596},"trace_dropped":false,"trace":"aps5-trace-3991a1dde05c-992.json.gz"}
{"commit":"efa6abe062b5","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":600167.746},"presents":60,"frame_ms":{"p50":5745.546,"p90":12190.507,"p99":98699.558,"max":98699.558},"gpu_busy_ms_per_present":161.283,"worker_busy_pct":{"queue worker 0x0":97.659,"queue worker 0x52":2.006,"queue worker 0x53":0.000,"queue worker 0x20":16.577,"queue worker 0x30":89.573,"queue worker 0x38":71.100,"queue worker 0x48":48.580},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":65536.928,"Driver.Packet":32532.015,"Driver.Packet.memory_wait":17833.247,"Driver.Packet.dispatch":10936.666,"Driver.Dispatch":10894.506,"Vulkan.Dispatch":4957.292,"Vulkan.Dispatch.shader_resources":3225.030,"Driver.Packet.draw":2812.923},"trace_dropped":false,"trace":"aps5-trace-efa6abe062b5-39452.json.gz"}
{"commit":"3991a1dde05c","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":667207.631},"presents":60,"frame_ms":{"p50":5963.690,"p90":23174.549,"p99":91525.777,"max":91525.777},"gpu_busy_ms_per_present":172.584,"worker_busy_pct":{"queue worker 0x0":95.540,"queue worker 0x52":2.283,"queue worker 0x53":0.000,"queue worker 0x20":20.093,"queue worker 0x30":85.578,"queue worker 0x48":41.073,"queue worker 0x38":64.426},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":77927.278,"Driver.Packet":34288.922,"Driver.Packet.memory_wait":18581.194,"Driver.Packet.dispatch":11905.527,"Driver.Dispatch":11839.389,"Vulkan.Dispatch":4928.006,"Vulkan.Dispatch.shader_resources":3054.908,"Driver.Packet.draw":2860.376},"trace_dropped":false,"trace":"aps5-trace-3991a1dde05c-6540.json.gz"}

GPU time per dispatch (APS5_PROFILE_GPU=1, warm, presents 100 to 500; no pipeline was built in this range in either run):

program A dispatches A ms/dispatch B dispatches B ms/dispatch B vs A
0x800036e100 420 23.37 392 22.34 -4%
0x80003cb200 420 19.33 392 19.43 +1%
0x8000253100 419 2.00 392 1.91 -5%
0x80003a1d00 420 1.17 392 1.30 +11%
0x80003c8100 419 0.76 392 0.73 -4%
0x80003cee00 419 0.66 392 0.63 -5%

The programs that take the most GPU time are within 5% either way. Programs under 1 ms vary by up to 20% in both directions. In presents 700 to 760, 0x80001e5f00 (1.8M words) took 10.65 ms per dispatch in A and 10.17 ms in B. B's run built a pipeline inside that range, so I'd only take the direction from it. These numbers come from [gputime], which lists the 12 hottest programs per 10 s.

Cold boot, not in the description. With empty caches, B shows its first frame at about 462 s, against 141 s for A. The absent-buffer variants were cheap to build: A builds 0x8000289300's first variant in 10.7 s. In B that program always has its full code, so its first build takes 86.5 s, about what A pays later for the present variant (85 s). Builds hold the GPU mutex on main, so this cost lands before the first frame. The giants also still build a second full variant in B (0x800022d100: 50.5 s, then 58.0 s), because only the stride and presence split goes away. I couldn't measure end-to-end cold time to the same present: the cold A run aborted (before #4487 was added) and the cold B run ran out of disk space. Once warm, B shows its first frame at 40 s.

So: in this title I found no GPU cost per dispatch or per present. The trade is a cold-only one: fewer variants in total, at the price of a longer wait before the first frame. Celegans12 reported on #675 that specializing buffer slots that are null when first bound took these programs from 37 variants to 6. That keeps the cheap builds, so it may be worth comparing with this PR or with the narrower option.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168255309 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6168255309). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-14T12:24:07Z. --- I measured on PPSA26344 what @CnRJay and @oneandonlydean asked for: the GPU time per dispatch, and the template's summary lines after a warm-up. In short, I found no measurable GPU cost. The run-time form does add a cold-boot cost that the PR description doesn't mention. **Builds.** Both builds are this PR's base 18c438b10 plus the same additions. `git diff A B` is identical to this PR's diff. The additions are what the title needs to boot and reach the scene: - #4222, #758, #4450, #4475 and #4487 (#4487 merged after 18c438b10; without it both builds abort on format 169); - local: startup dialogs and entitlements, unnormalized samplers with wrap clamped, LRU caps on prepared and source SPIR-V, reuse of dedicated descriptor pools by shape (CPU only); - a store-and-log fallback where e5449936f throws. It never fired on this base. None of these change how buffer accesses are emitted. Machine: RTX 4090, NVIDIA 617.42, Windows 10.0.26200, 3840x2160. Both builds ran with the same env: `APS5_HOST_IMPORT_MIB=16384 APS5_STAGING_POOL_MIB=2048 APS5_PREPARED_SPIRV_MIB=6144 APS5_NO_SNAPSHOT_CHECK=1`. **Scene.** The loading phase, presents 700 to 760 (`APS5_TRACE_FRAMES=700:60`), where the large compute programs are dispatched. A later scene was out of reach: about 10 minutes after the loading spinner, the title takes commit headroom to 0 on this 32 GB machine. **Runs.** For each build, I ran warm-up boots until the shader disk cache was complete. Then I restarted it with only the trace switch set. Every capture had 0 disk cache misses. I captured A twice, before and after B, to see how much boots differ. **Summary lines** (presents 700 to 760): | | commit | gpu_busy_ms_per_present | frame_ms p50 / p90 / max | window | |---|---|---|---|---| | A, 1st | 3991a1dde05c | 161.9 | 5,897 / 20,688 / 96,072 | 633 s | | B | efa6abe062b5 | 161.3 | 5,746 / 12,191 / 98,700 | 600 s | | A, 2nd | 3991a1dde05c | 172.6 | 5,964 / 23,175 / 91,526 | 667 s | The two A captures differ by 6.4% in GPU busy time, and B is 3.6% below their mean, inside that spread. Frame times in this window are set by CPU shader preparation (8 prepare threads about 90% busy, `Shader.PrepareArtifact` the top phase), not by the GPU. So I don't read anything into the frame time differences either. <details><summary>Full summary lines</summary> ``` {"commit":"3991a1dde05c","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":632962.969},"presents":60,"frame_ms":{"p50":5896.623,"p90":20688.487,"p99":96072.009,"max":96072.009},"gpu_busy_ms_per_present":161.921,"worker_busy_pct":{"queue worker 0x0":95.331,"queue worker 0x52":2.502,"queue worker 0x53":0.000,"queue worker 0x20":20.826,"queue worker 0x30":83.878,"queue worker 0x38":63.937,"queue worker 0x48":38.948},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":74869.129,"Driver.Packet":32128.767,"Driver.Packet.memory_wait":17431.423,"Driver.Packet.dispatch":11452.506,"Driver.Dispatch":11394.126,"Vulkan.Dispatch":4680.173,"Vulkan.Dispatch.shader_resources":2773.425,"Driver.Packet.draw":2358.596},"trace_dropped":false,"trace":"aps5-trace-3991a1dde05c-992.json.gz"} {"commit":"efa6abe062b5","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":600167.746},"presents":60,"frame_ms":{"p50":5745.546,"p90":12190.507,"p99":98699.558,"max":98699.558},"gpu_busy_ms_per_present":161.283,"worker_busy_pct":{"queue worker 0x0":97.659,"queue worker 0x52":2.006,"queue worker 0x53":0.000,"queue worker 0x20":16.577,"queue worker 0x30":89.573,"queue worker 0x38":71.100,"queue worker 0x48":48.580},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":65536.928,"Driver.Packet":32532.015,"Driver.Packet.memory_wait":17833.247,"Driver.Packet.dispatch":10936.666,"Driver.Dispatch":10894.506,"Vulkan.Dispatch":4957.292,"Vulkan.Dispatch.shader_resources":3225.030,"Driver.Packet.draw":2812.923},"trace_dropped":false,"trace":"aps5-trace-efa6abe062b5-39452.json.gz"} {"commit":"3991a1dde05c","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"16384","APS5_NO_SNAPSHOT_CHECK":"1","APS5_PREPARED_SPIRV_MIB":"6144","APS5_STAGING_POOL_MIB":"2048","APS5_TRACE_FRAMES":"700:60"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","resolution":"3840x2160","window":{"spec":"frames 700:60","first_present":700,"ms":667207.631},"presents":60,"frame_ms":{"p50":5963.690,"p90":23174.549,"p99":91525.777,"max":91525.777},"gpu_busy_ms_per_present":172.584,"worker_busy_pct":{"queue worker 0x0":95.540,"queue worker 0x52":2.283,"queue worker 0x53":0.000,"queue worker 0x20":20.093,"queue worker 0x30":85.578,"queue worker 0x48":41.073,"queue worker 0x38":64.426},"top_phases_ms_per_frame":{"Shader.PrepareArtifact":77927.278,"Driver.Packet":34288.922,"Driver.Packet.memory_wait":18581.194,"Driver.Packet.dispatch":11905.527,"Driver.Dispatch":11839.389,"Vulkan.Dispatch":4928.006,"Vulkan.Dispatch.shader_resources":3054.908,"Driver.Packet.draw":2860.376},"trace_dropped":false,"trace":"aps5-trace-3991a1dde05c-6540.json.gz"} ``` </details> **GPU time per dispatch** (`APS5_PROFILE_GPU=1`, warm, presents 100 to 500; no pipeline was built in this range in either run): | program | A dispatches | A ms/dispatch | B dispatches | B ms/dispatch | B vs A | |---|---|---|---|---|---| | `0x800036e100` | 420 | 23.37 | 392 | 22.34 | -4% | | `0x80003cb200` | 420 | 19.33 | 392 | 19.43 | +1% | | `0x8000253100` | 419 | 2.00 | 392 | 1.91 | -5% | | `0x80003a1d00` | 420 | 1.17 | 392 | 1.30 | +11% | | `0x80003c8100` | 419 | 0.76 | 392 | 0.73 | -4% | | `0x80003cee00` | 419 | 0.66 | 392 | 0.63 | -5% | The programs that take the most GPU time are within 5% either way. Programs under 1 ms vary by up to 20% in both directions. In presents 700 to 760, `0x80001e5f00` (1.8M words) took 10.65 ms per dispatch in A and 10.17 ms in B. B's run built a pipeline inside that range, so I'd only take the direction from it. These numbers come from `[gputime]`, which lists the 12 hottest programs per 10 s. **Cold boot, not in the description.** With empty caches, B shows its first frame at about 462 s, against 141 s for A. The absent-buffer variants were cheap to build: A builds `0x8000289300`'s first variant in 10.7 s. In B that program always has its full code, so its first build takes 86.5 s, about what A pays later for the present variant (85 s). Builds hold the GPU mutex on main, so this cost lands before the first frame. The giants also still build a second full variant in B (`0x800022d100`: 50.5 s, then 58.0 s), because only the stride and presence split goes away. I couldn't measure end-to-end cold time to the same present: the cold A run aborted (before #4487 was added) and the cold B run ran out of disk space. Once warm, B shows its first frame at 40 s. So: in this title I found no GPU cost per dispatch or per present. The trade is a cold-only one: fewer variants in total, at the price of a longer wait before the first frame. Celegans12 reported on #675 that specializing buffer slots that are null when first bound took these programs from 37 variants to 6. That keeps the cheap builds, so it may be worth comparing with this PR or with the narrower option.
github-actions[bot] commented 2026-10-15 12:07:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:07:35Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6977 core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp L63

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 5371 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 5609 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 6177 core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp
PR 6412 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp
PR 6539 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
PR 6947 core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191667976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6191667976). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:07:35Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp` [L63](https://github.com/boykopovar/AnyPS5/blob/bf2053816976bb9c821e37df58ef64a7362b81c7/core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp#L63) | | | 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 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvRuntimeBuffer.cpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp` |
CnRJay commented 2026-10-16 21:54:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-16T21:54:23Z.

Review: COMMENTED


Thanks @Pipodi, this answers the question I asked: no GPU cost per dispatch or per present, with the top programs within 5% in both directions and the A/A spread (6.4%) larger than the A/B difference.

That leaves the cold boot as the real price of this change: first frame at about 462 s against 141 s, because the stride and presence split no longer lets the large programs build a cheap variant first. That is a regression for every first launch with an empty cache, and the description should state it. The shipped trade is "fewer variants in total, 3x longer wait before the first frame", and a user who has never run the title sees only the second part.

Two things to settle before this goes further:

  • Compare against the narrower option from #675 (specialize slots that are null when first bound, 37 variants down to 6). If it keeps the cheap builds and gets a similar steady-state result, the run-time form is the wrong approach for these programs.
  • Builds hold the GPU mutex on main, so the longer builds block the first present. If the run-time form stays, the 86.5 s build of 0x8000289300 should not run under that lock.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5554128497 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#pullrequestreview-5554128497). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-16T21:54:23Z. **Review:** COMMENTED --- Thanks @Pipodi, this answers the question I asked: no GPU cost per dispatch or per present, with the top programs within 5% in both directions and the A/A spread (6.4%) larger than the A/B difference. That leaves the cold boot as the real price of this change: first frame at about 462 s against 141 s, because the stride and presence split no longer lets the large programs build a cheap variant first. That is a regression for every first launch with an empty cache, and the description should state it. The shipped trade is "fewer variants in total, 3x longer wait before the first frame", and a user who has never run the title sees only the second part. Two things to settle before this goes further: - Compare against the narrower option from #675 (specialize slots that are null when first bound, 37 variants down to 6). If it keeps the cheap builds and gets a similar steady-state result, the run-time form is the wrong approach for these programs. - Builds hold the GPU mutex on main, so the longer builds block the first present. If the run-time form stays, the 86.5 s build of `0x8000289300` should not run under that lock.
oneandonlydean commented 2026-10-16 23:29:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:29:25Z.


Agreed with @CnRJay's review. The cold-boot cost (first frame at about 462 s against 141 s with empty caches) should be in the description, since it's what every first launch pays. Before this goes further I'd also like the comparison with the narrower option from #675 (specializing slots that are null when first bound), and, if the run-time form stays, the 86.5 s build of 0x8000289300 moved out from under the GPU mutex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226613934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6226613934). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-16T23:29:25Z. --- Agreed with @CnRJay's review. The cold-boot cost (first frame at about 462 s against 141 s with empty caches) should be in the description, since it's what every first launch pays. Before this goes further I'd also like the comparison with the narrower option from #675 (specializing slots that are null when first bound), and, if the run-time form stays, the 86.5 s build of `0x8000289300` moved out from under the GPU mutex.
Pipodi commented 2026-10-17 10:41:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-17T10:41:09Z.


@CnRJay @oneandonlydean I measured all three on current main, and the result goes against this PR: on today's main, reading presence at run time costs the cold boot 120 s and saves nothing in total.

Setup. PPSA26344, RTX 4090, NVIDIA 617.42, Windows 11 Pro 26200. Three builds on main 6e7ba928a plus what the title needs to boot (startup dialogs and entitlements, #6867, #6537, #6958, a blend skip for 10_11_11 targets, two log lines), differing only in libSceAgcDriver.prx:

  • P: main
  • Q: main + this PR (34372f735)
  • R: main + the narrow option: stride at run time, presence still specialized, so a buffer absent at first bind keeps the cheap build

Each arm ran one cold boot for 1200 s, in the order P, Q, R, with default settings. Each started with an empty shader cache, pipeline cache and NVIDIA driver cache. The NVIDIA cache was moved aside before each run; our earlier cold runs had silently hit it. Each run was checked to be cold: 1.08M words of 0x800022d100 take 11.9 s in P.

P (main) Q (this PR) R (narrow)
first lit frame 141 s 261 s 141 s
frames at 300 / 600 / 900 / 1200 s 671 / 696 / 748 / 755 459 / 692 / 753 / 760 674 / 700 / 750 / 789
compute builds ≥ 1 s 62, 907 s 51, 1000 s 62, 946 s
builds of ≥ 1M-word programs 15, 483 s 12, 539 s 15, 512 s
compute pipelines created (under the GPU mutex) 342 (0) 290 (0) 354 (0)
Builds of the ≥ 1M-word programs, per arm
program P Q R
0x8000196500 4×: 43.5, 42.8, 42.2, 36.6 s 4×: 54.5, 54.9, 54.2, 47.7 s 4×: 45.9, 46.1, 46.1, 39.0 s
0x80001abb00 2×: 45.7, 35.4 s 2×: 52.2, 46.7 s 2×: 50.5, 38.0 s
0x80001c0d00 53.8 s 60.1 s 57.2 s
0x80001d5700 2×: 13.0, 13.0 s 13.7 s 2×: 13.1, 13.6 s
0x80001e5f00 57.6 s 60.6 s 60.5 s
0x800022d100 3×: 11.9, 11.8, 31.0 s 2×: 31.5, 31.1 s 3×: 12.0, 11.5, 30.9 s
0x8000261500 2×: 11.3, 33.3 s 32.4 s 2×: 11.4, 36.3 s

What this shows, with one run per arm:

  • This PR removes the cheap absent-buffer builds (11–13 s each: 0x80001d5700, 0x800022d100, 0x8000261500) as intended. The programs that still build several variants (0x8000196500, 0x80001abb00) build about 10–25% slower, though, so the total goes up by about 90 s and the first frame comes 120 s later. A single run can't separate that slowdown from run-to-run noise (R is also 3–7% slower than P per build). Either way, the 103 s saved offline doesn't show up here.
  • The narrow option matches main: the same 62 builds and the same first frame. In this window no program was dispatched with only a different stride, so reading the stride at run time saves nothing either.
  • The variant churn left is 0x8000196500 (4 builds) and 0x80001abb00 (2), in all three arms. Their variants differ in something other than buffer stride and presence, so neither form addresses it.
  • The GPU mutex: 0 compute pipelines are created under it in any arm, which confirms #5989 covers that point.

So this PR shouldn't merge, and the narrow option isn't worth a PR on this evidence. I'm closing it. Thanks both for pushing for the cold measurement.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232936839 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6232936839). Originally posted by [Pipodi](https://github.com/Pipodi) on 2026-10-17T10:41:09Z. --- @CnRJay @oneandonlydean I measured all three on current `main`, and the result goes against this PR: on today's `main`, reading presence at run time costs the cold boot 120 s and saves nothing in total. **Setup.** PPSA26344, RTX 4090, NVIDIA 617.42, Windows 11 Pro 26200. Three builds on `main` 6e7ba928a plus what the title needs to boot (startup dialogs and entitlements, #6867, #6537, #6958, a blend skip for 10_11_11 targets, two log lines), differing only in `libSceAgcDriver.prx`: - **P:** `main` - **Q:** `main` + this PR (34372f735) - **R:** `main` + the narrow option: stride at run time, presence still specialized, so a buffer absent at first bind keeps the cheap build Each arm ran one cold boot for 1200 s, in the order P, Q, R, with default settings. Each started with an empty shader cache, pipeline cache and NVIDIA driver cache. The NVIDIA cache was moved aside before each run; our earlier cold runs had silently hit it. Each run was checked to be cold: 1.08M words of `0x800022d100` take 11.9 s in P. | | P (`main`) | Q (this PR) | R (narrow) | |---|---|---|---| | first lit frame | 141 s | **261 s** | 141 s | | frames at 300 / 600 / 900 / 1200 s | 671 / 696 / 748 / 755 | 459 / 692 / 753 / 760 | 674 / 700 / 750 / 789 | | compute builds ≥ 1 s | 62, 907 s | 51, 1000 s | 62, 946 s | | builds of ≥ 1M-word programs | 15, 483 s | 12, 539 s | 15, 512 s | | compute pipelines created (under the GPU mutex) | 342 (0) | 290 (0) | 354 (0) | <details><summary>Builds of the ≥ 1M-word programs, per arm</summary> | program | P | Q | R | |---|---|---|---| | `0x8000196500` | 4×: 43.5, 42.8, 42.2, 36.6 s | 4×: 54.5, 54.9, 54.2, 47.7 s | 4×: 45.9, 46.1, 46.1, 39.0 s | | `0x80001abb00` | 2×: 45.7, 35.4 s | 2×: 52.2, 46.7 s | 2×: 50.5, 38.0 s | | `0x80001c0d00` | 53.8 s | 60.1 s | 57.2 s | | `0x80001d5700` | 2×: 13.0, 13.0 s | 13.7 s | 2×: 13.1, 13.6 s | | `0x80001e5f00` | 57.6 s | 60.6 s | 60.5 s | | `0x800022d100` | 3×: 11.9, 11.8, 31.0 s | 2×: 31.5, 31.1 s | 3×: 12.0, 11.5, 30.9 s | | `0x8000261500` | 2×: 11.3, 33.3 s | 32.4 s | 2×: 11.4, 36.3 s | </details> What this shows, with one run per arm: - **This PR** removes the cheap absent-buffer builds (11–13 s each: `0x80001d5700`, `0x800022d100`, `0x8000261500`) as intended. The programs that still build several variants (`0x8000196500`, `0x80001abb00`) build about 10–25% slower, though, so the total goes up by about 90 s and the first frame comes 120 s later. A single run can't separate that slowdown from run-to-run noise (R is also 3–7% slower than P per build). Either way, the 103 s saved offline doesn't show up here. - **The narrow option** matches `main`: the same 62 builds and the same first frame. In this window no program was dispatched with only a different stride, so reading the stride at run time saves nothing either. - **The variant churn left** is `0x8000196500` (4 builds) and `0x80001abb00` (2), in all three arms. Their variants differ in something other than buffer stride and presence, so neither form addresses it. - **The GPU mutex:** 0 compute pipelines are created under it in any arm, which confirms #5989 covers that point. So this PR shouldn't merge, and the narrow option isn't worth a PR on this evidence. I'm closing it. Thanks both for pushing for the cold measurement. AI-assisted: yes (Claude Code)
oneandonlydean commented 2026-10-17 10:45:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T10:45:03Z.


Thanks for measuring all three arms with cold caches. A 120 s cold-boot cost with no saving in total on current main is a clear answer, and closing makes sense.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232969475 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5353#issuecomment-6232969475). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T10:45:03Z. --- Thanks for measuring all three arms with cold caches. A 120 s cold-boot cost with no saving in total on current main is a clear answer, and closing makes sense.

Pull request closed

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!5353
No description provided.