Skip to content

perf(agc): leave a lazily registered shader's resolved ABI to its first use - #7644

Merged
adriadam10 merged 9 commits into
boykopovar:mainfrom
EagleBearerYS:perf/agc-lazy-resolve-shader-abi
Oct 23, 2026
Merged

adriadam10 merged 9 commits into
boykopovar:mainfrom
EagleBearerYS:perf/agc-lazy-resolve-shader-abi

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Under APS5_LAZY_SHADER_PREPARE=1, registration prepares nothing. But ResolveShaderAbi still planned and prepared every compute or pixel stage whose ABI the title resolved. A title that resolves every shader's ABI therefore prepared them all at boot, whether they ever drew.

Resident Evil Village (PPSA01556) is such a title. Its prepared shaders take a large part of its private memory at the menu: this PR saves ~3 to 4.5 GB there (see Tested), more than the ~2–3 GB we had estimated from per-program holders of ~0.5 MiB across ~6,000 programs.

With lazy preparation, ResolveShaderAbi now:

  • plans the stage with the ABI's state: its register and entry-point checks, as lazy registration keeps them;
  • records the ABI key;
  • queues the ABI's context and primitive registers on the shader.

Then the shader's first draw or dispatch plans and prepares the queued ABIs with that state, before it looks for its artifact.

  • A shader that never draws or dispatches stays unprepared.
  • One that does gets the entries eager resolution would have made.
  • A stage whose plan fails is deferred, as before.
  • Without the switch, nothing changes. Graphics-stage ABIs are still prepared when they are resolved.

Concurrent first uses. The first use of a shader with deferred ABIs marks the shader while it prepares them, then publishes all their entries together under the shader's lock. A use from another queue that arrives meanwhile waits on the shader's existing condition until they're published, then matches the published entry, so each ABI is prepared once. If no entry matches (its preparation failed, or the use's state differs), each use prepares its own entry, as without deferral. After the first use, the lookup reads one more flag under the lock it already holds.

Which workloads it helps. The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with.

  • Resident Evil Village (PPSA01556) resolves every shader's ABI at boot: ~2.9 to 4.6 GB less private memory at the menu, over three pairs (Tested).
  • On Astro's Playroom (PPSA01325), fma-rc measured no saving (comment): 16,430 MiB with this PR and 16,111 MiB on main at 600 s.
  • Nothing changes without APS5_LAZY_SHADER_PREPARE=1.

Cost at first use. The preparation moves from resolution to a shader's first draw or dispatch, on the queue worker. The Village pairs below are at the static menu, so they can't show it. A Resident Evil Village pair across the transition from the menu into first gameplay, on a warm shader cache, with and without this PR (comment, and Tested): 24:11 from Yes to the first lit gameplay frame with it, against 24:00 without, and the worst frames within the same range (85.5 s against 133.0 s at the top). On that memory-bound machine, a first-use cost smaller than its paging stalls wouldn't show.

The commits:

  1. Driver::PreparedEntries counts a registered shader's prepared entries, for the test.

  2. The change.

  3. test(agc): the lazy resolved ABI test's eager reference runs without the switch.

  4. test(agc): a lazily resolved ABI's entries, libraries and cache files are compared with eager preparation's.

  5. test(agc): stale-state cases of a deferred ABI are compared with eager preparation.

  6. test(agc): a deferred compute ABI is checked under lazy preparation.

    Commits 3 to 6 came from an adversarial review. They're described under Tested.

  7. A counter for whether a deferred ABI's first use finds its artifact among the queued entries. It tells whether the queued preparation is the use's own work or extra, through Driver::DeferredAbiUses and a [shaders] deferred ABIs: ... line.

  8. fix(agc): a deferred ABI is prepared once when queues make its first use at once (above).

  9. fix(agc): the [shaders] deferred ABIs line prints only under APS5_PROFILE_DRAW, through the profile output the [rescache] lines use.

Where the end state can differ from eager preparation, with no wrong state:

  • if the device is gone by the first use, the queued ABI is skipped, and the draw prepares its own entry;
  • if a deferred ABI's preparation fails, it is logged, and each use, the waiting ones too, prepares its own entry.

Tested

  • agc_driver_lazy_resolved_abi runs one scenario with eager and with lazy preparation, and compares the lazy run's end state with the eager run's.

    • Five pixel shaders: four resolved with empty ABI registers and one with its draw's own registers. Three of them draw.
    • Each drawn shader's prepared entries (SPIR-V content hash and source key) equal eager preparation's. The shaders that never drew hold none, and nothing is prepared or prebuilt at resolution.
    • The pipeline libraries built, once the prebuild pool has drained, equal eager preparation's, and the lazy run writes no shader-cache file the eager run didn't.
    • Stale state: the ABI's register arrays overwritten before any draw; one shader resolved with two ABIs; a second header registered and drawn, then the first registered again and drawn.
    • Each check fails when its part of the first-use preparation is removed. For example, without the prebuild device the library counts differ.
    • The first-use counter, from the counts before and after the scenario's draws:
      • the two draws whose state differs from the resolved ABI count as own, with every queued entry unmatched;
      • the shader resolved with its draw's registers counts as found and matches one entry.
    • agc_driver_lazy_resolved_abi_switch_set runs it with APS5_LAZY_SHADER_PREPARE=1 exported.
  • agc_driver_prepared_shaders_abi_deferred_compute_lazy resolves a compute ABI under the switch. Neither resolution builds a front end, and the first dispatch links both callees and writes the expected value in every lane.

  • agc_driver_prepared_shaders_abi_deferred_concurrent_lazy (commit 8):

    • Setup: a compute shader registered under the switch with its ABI resolved, so the ABI is deferred. Four threads behind a barrier submit its first dispatch on queues 0x20 to 0x23 at once, each into its own output.
    • Every output must be right, with:
      • one first use, which found its artifact;
      • no own preparation;
      • every front-end build and entry from the deferred ABI;
      • all four dispatches on the same entry.
    • Red, with ShaderRegistry.hpp and ShaderRegistry.cpp as before commit 8, in 20 of 20 runs: "four queues making the first use of one deferred ABI at once did not prepare it once (2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used)". Green in 20 of 20.
  • The profile line (commit 9): without APS5_PROFILE_DRAW, no [shaders] deferred ABIs line. With it: [shaders] deferred ABIs: 1 prepared at first use, 1 found their artifact there, 0 prepared their own; 1 of the 2 entries prepared from them never matched a use.

  • Linux, CI's configuration (a cloud worker), at the head:

    • agc_driver_lazy_resolved_abi, agc_driver_lazy_resolved_abi_switch_set, agc_driver_prepared_shaders, agc_driver_prepared_shaders_abi_deferred_compute_lazy and agc_driver_prepared_shaders_abi_deferred_concurrent_lazy pass 20 runs in a row.
    • ^agc passes 795 of 797 (57 skipped). The two failures also fail on main: agc_driver_sgpr_pattern_fill_keys fails under the sweep's parallel load, and agc_driver_storage_read_during_idle_store fails in about 1% of runs on that machine (alone: 4 of 360 runs at the head, 3 of 360 at the base).
    • Each commit builds and passes its own tests.
  • Resident Evil Village (PPSA01556), Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU, one run each. Both runs use our test tree (main with fix(agc): leave a stage the title's pipeline ABI cannot prepare to its first use #6366 and other open PRs of ours) plus perf(agc): release unused registered shader resource plans #6178, with APS5_LAZY_SHADER_PREPARE=1, heap counters on (APS5_PROFILE_HEAP=1) and GPL on. Private memory at the menu:

    menu + 1 min menu + 10 min
    without this PR 25,932 MB 26,529 MB
    with it 21,443 MB 21,915 MB
    change −4,489 MB −4,614 MB
    • Commit free at menu + 1 rises from 1,519 to 5,550 MB.
    • This is a memory change, and the pair's menu frame times don't compare: the run without it started on a cold shader cache, the run with it on a warm one. So there are no summary lines here. The cache state isn't what moved memory: a cold-cache run with this change (and APS5_RELEASE_SPIRV=1) was at 21,485 MB at menu + 1.
  • Resident Evil Village (PPSA01556), a second pair with traces, on the same two trees: without the change (964a4ea473) and with it (174358bd0d). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), APS5_LAZY_SHADER_PREPARE=1, GPL on, no heap counters, a warm shader cache in both (an untraced boot filled it first), one run each, menu only. The GPU was at P0 for 100% of the samples in both runs (mean 1,293 and 1,294 MHz); clocks weren't locked.

    • Private memory at the menu: 25,629 / 26,236 MB without the change and 21,510 / 22,072 MB with it at + 1 / + 10 min, −4,119 / −4,164 MB. That's the same saving as the first pair.

    • Frame times at the static menu, minutes 5 to 15: 13 presents in 530 s without the change (0.0245 fps, median frame 38.9 s) and 12 in 531 s with it (0.0226 fps, 42.6 s). One frame either way at ~40 s a frame, so this pair can't resolve a frame-time difference; the change is to memory.

    • The summary line from the middle of each arm's menu window, without and then with the change:

      {"commit":"964a4ea47335","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":5769,"ms":38512.704},"interval_start_s":1958.049,"interval_end_s":1996.562,"presents":1,"frame_ms":{"p50":38512.704,"p90":38512.704,"p99":38512.704,"max":38512.704},"gpu_busy_ms_per_present":360.658,"worker_busy_pct":{"queue worker 0x0":99.955,"queue worker 0x38":0.013,"queue worker 0x28":99.489,"queue worker 0x20":98.163},"top_phases_ms_per_frame":{"Driver.Packet":114619.989,"Driver.Packet.memory_wait":75600.232,"Driver.Packet.draw":37624.408,"Driver.Draw":37621.748,"Driver.Draw.draw_and_resource_release":23173.020,"Graphics.Draw":22491.874,"Graphics.Draw.draw_and_resource_release":22366.853,"Resources.Complete":15706.836},"top_phases_calls_per_s":{"Driver.Packet":198.895,"Driver.Packet.memory_wait":2.571,"Driver.Packet.draw":21.707,"Driver.Draw":21.707,"Driver.Draw.draw_and_resource_release":21.655,"Graphics.Draw":24.408,"Graphics.Draw.draw_and_resource_release":24.408,"Resources.Complete":16.981},"trace_dropped":false,"trace":""}
      {"commit":"174358bd0df9","dirty":false,"env":{"APS5_LAZY_SHADER_PREPARE":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"900:60","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"NVIDIA GeForce RTX 3070 Laptop GPU","driver":"NVIDIA 617.42","os":"Windows 10.0.26300","resolution":"3840x2160","window":{"spec":"summary_every 1","first_present":3728,"ms":49551.654},"interval_start_s":1962.416,"interval_end_s":2011.967,"presents":1,"frame_ms":{"p50":49551.654,"p90":49551.654,"p99":49551.654,"max":49551.654},"gpu_busy_ms_per_present":366.125,"worker_busy_pct":{"queue worker 0x0":99.981,"queue worker 0x38":0.023,"queue worker 0x28":99.621,"queue worker 0x20":98.978},"top_phases_ms_per_frame":{"Driver.Packet":147961.349,"Driver.Packet.memory_wait":98183.273,"Driver.Packet.draw":49127.480,"Driver.Draw":49124.666,"Driver.Draw.draw_and_resource_release":25133.673,"Graphics.Draw":23956.698,"Graphics.Draw.draw_and_resource_release":23835.429,"Shader.DrawStage":20213.190},"top_phases_calls_per_s":{"Driver.Packet":154.707,"Driver.Packet.memory_wait":1.998,"Driver.Packet.draw":16.871,"Driver.Draw":16.871,"Driver.Draw.draw_and_resource_release":16.831,"Graphics.Draw":18.970,"Graphics.Draw.draw_and_resource_release":18.970,"Shader.DrawStage":52.713},"trace_dropped":false,"trace":""}
    • tools/trace_digest.py on those two lines:

      2 intervals, 1958.0 to 2012.0 s, 2 presents
      NVIDIA GeForce RTX 3070 Laptop GPU, NVIDIA 617.42, Windows 10.0.26300, 3840x2160, commit 964a4ea47335
      commit, environment, GPU, driver or OS changed at interval 2

      # seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
      1 1958-1997 1 38512.7 38512.7 38512.7 38512.7 360.7 100 % Driver.Packet 114620.0
      2 1962-2012 1 49551.7 49551.7 49551.7 49551.7 366.1 100 % Driver.Packet 147961.3
      p99 ms  #@  0-49551.7
      gpu ms  @@  0-366.1
      
    • The two traces are on this fork release. Their 60 s windows (APS5_TRACE_SECONDS=900:60) fell in the intro, about 6 to 7 minutes before the main menu, since these trees take ~23 minutes to reach it.

  • Resident Evil Village (PPSA01556), a third pair on this head (1ba2206), menu only, one run each. Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held, and no GPU timing is claimed.

    • Both arms run main 1ff5c8a with fix(agc): put a retired import's unchanged ranges back in the write watch #8926's fix (63d5414), which Resident Evil Village needs on that main to get through its intro. One has this PR on top, and one doesn't.
    • Settings, the same in both: APS5_LAZY_SHADER_PREPARE=1, GPL on, APS5_HOST_IMPORT_MIB=6400, a warm shader cache, no profiling, no input.
    • Private memory at the static menu, without and with this PR: 22,079 and 18,297 MB on arrival (−3,782), 22,715 and 18,976 MB at + 1 min (−3,739), 24,586 and 21,654 MB at + 5 min (−2,932). The lowest commit free was 2,625 MB without it and 6,241 MB with it.
    • Unlike the first two pairs, the gap narrowed over the window: private memory grew about 670 MB a minute with this PR against about 500 without it.
    • Neither run has a fault, FATAL or refusal line.
  • Resident Evil Village (PPSA01556), the menu → first gameplay transition on this head (1ba2206), one matched pair (comment, with the summary lines and digests). Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU; clocks weren't held (P0 at 1,290 MHz in the slow intervals).

    • The trees are the third pair's: main 1ff5c8a with fix(agc): put a retired import's unchanged ranges back in the write watch #8926's fix (63d5414), with and without this PR.
    • Settings, the same in both: APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1 (with GPL on, this PC doesn't load past the menu), APS5_HOST_IMPORT_MIB=6400 and APS5_TRACE_SUMMARY_EVERY=1. Warm shader cache, the same route and the same host-import mode.
    • Yes → first lit gameplay frame: 24:00 without, 24:11 with. Worst frames after Yes: 133.0 s without, 85.5 s with.
    • The shader disk cache served 18,902 entries without and 9,452 with, with no misses.
    • Both runs page hard, and the first minute of gameplay runs at 7.6 to 11.7 s a frame. So this pair shows no measurable difference, and a first-use cost smaller than the paging stalls wouldn't show.
    • Private memory at menu + 1 min is 415 MB higher with the change in this NO_GPL pair. The pair doesn't show whether the GPL-on saving above carries over.
  • A harness on a cloud worker (Linux, lavapipe):

    • memory after registration falls from 2,531 to 139 MiB;
    • registration time falls from 670 to 4 s.
  • The adversarial review (a cloud worker). Its question: can a deferred preparation run with different state from what eager resolution would have used? The answer is no.

    • The first use builds its state from inputs fixed at resolution: the snapshot's registered state and code, the ABI's registers (copied by value), and the device (held weakly).
    • It found no product bug. Its one should-fix, the eager reference inheriting an exported switch, has its fix in the merged commits (agc_driver_lazy_resolved_abi_switch_set).
  • GitHub's runners at 1ba2206 (run): the five tests above pass 5 runs in a row on Linux. On Windows they need Vulkan and skip. The libc and libkernel suites pass on both.

Checklist

  • Based on main f47c856, rebased, and it merges cleanly with 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none (fix(agc): leave a stage the title's pipeline ABI cannot prepare to its first use #6366 is merged)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: lavapipe (Linux, a cloud worker); NVIDIA GeForce RTX 3070 Laptop GPU (Windows 11, Resident Evil Village)
  • AI-assisted: yes

@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

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 6743 docs/dev/ARCHITECTURE.md L136
PR 7682 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L996-997
PR 8180 core/libs/prx/libSceAgcDriver/CMakeLists.txt L2428

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 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1896 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5115 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
docs/dev/ARCHITECTURE.md
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/ARCHITECTURE.md
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/ARCHITECTURE.md
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6539 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6642 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6788 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6804 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6867 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 6868 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6977 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7275 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7307 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7369 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 7457 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7464 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7622 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 7677 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7684 docs/dev/ARCHITECTURE.md
PR 7705 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7800 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7978 core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 8014 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8246 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8365 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/ARCHITECTURE.md
PR 8484 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8542 core/libs/prx/libSceAgcDriver/CMakeLists.txt
docs/dev/ARCHITECTURE.md
PR 8552 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8564 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8592 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 8735 core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 8740 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 8874 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8999 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9020 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9287 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9289 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9335 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 9400 docs/dev/ARCHITECTURE.md
PR 9431 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9432 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9508 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
docs/dev/ARCHITECTURE.md
PR 9521 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9672 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9673 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9674 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9675 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9676 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9748 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9891 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9892 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9893 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9897 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9898 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
PR 9965 docs/dev/ARCHITECTURE.md
PR 10046 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10193 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
docs/dev/ARCHITECTURE.md

@EagleBearerYS
EagleBearerYS marked this pull request as ready for review October 18, 2026 21:17
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 18, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed perf numbers missing perf pull request without a before and after summary line labels Oct 19, 2026
@fma-rc

fma-rc commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

@EagleBearerYS here's Astro's Playroom (PPSA01325) with APS5_LAZY_SHADER_PREPARE=1 on this head (40e0d96) and on the main commit it merges (324e0e4). Linux, RTX 5080, one run each, 600 s with Cross pressed every 4 s. Private memory is Private_Clean + Private_Dirty from smaps_rollup:

MiB 30 s 60 s 600 s
this PR 13188 15009 16430
main 13500 16063 16111

Playroom shows no saving here. I don't have Resident Evil Village, so this doesn't test the ~4.5 GB in the description.

@adriadam10 adriadam10 self-assigned this Oct 19, 2026

@CnRJay CnRJay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The memory result is clear and repeats (menu private memory down 4,489 and 4,119 MB across two pairs, 21.4-21.9 GB against 25.6-26.5 GB), the cold-cache control shows it isn't the shader cache, and the test compares the lazy end state with eager preparation entry by entry.

What the PR does not show is the price. The preparation does not go away; it moves from boot to a shader's first draw or dispatch, on the queue worker.

  • Both Village pairs are at the static menu, at about 40 s per frame (one present in 530 s per arm). The description says they can't resolve a frame-time difference, and that is true, but it also means nothing here measures the case this change affects: the frames in which many shaders are drawn for the first time (entering the first area). Please capture the transition from menu into gameplay, warm shader cache, with and without the change, and post the worst frame times and the time to the first stable gameplay frame. If entering an area now hitches by the preparation of hundreds of ABIs, the memory is paid for with stutter.
  • "Two threads making the first use at once may each prepare an entry." That's two compiles of the same ABI on the hot path. Use a once-per-ABI flag so the second thread waits for the first, and say what the test shows about it.
  • The [shaders] deferred ABIs counter is diagnostics that prints to stderr every minute for everyone. Put it behind a profile switch, or keep it out of the PR.
  • It carries #6366's three commits first. Rebase once that merges so only this PR's commits show, as the title says.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 20, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the lazy-vs-eager end-state test is a good check. Before this can merge:

  • Conflicts with main, and the history. #6366 is merged, so please rebase onto main so only this PR's commits remain (no merge commits, per CONTRIBUTING).
  • The cost isn't measured. The memory saving is clear on Resident Evil Village, but the preparation moves to a shader's first draw/dispatch on the queue worker. Both pairs are at the static menu (~40 s per frame), so nothing covers the frames where many shaders are drawn for the first time. Please capture the menu → first gameplay transition on a warm shader cache with and without the change, and post the worst frame times and the time to the first stable gameplay frame (same ask as @CnRJay's review).
  • Duplicate preparation on the hot path. "Two threads making the first use at once may each prepare an entry" means two compiles of the same ABI. Make the first use once-per-ABI (the second thread waits) and add a test that exercises it.
  • Counter output. The [shaders] deferred ABIs: ... line goes to stderr every minute for every user (ShaderRegistry.cpp, the new fprintf(stderr, ...)). Put it behind a profile switch or drop it from this PR.
  • Evidence beyond one title. @fma-rc's Astro's Playroom run shows no saving with this head (16.4 GB vs 16.1 GB at 600 s). Please state which workloads this helps, so the switch's benefit isn't read as general.

Driver::PreparedEntries returns how many artifacts the registered header
of a shader holds prepared, after its pending registration preparation
settles, so tests can tell a prepared shader from one left to its first
use.
…st use

Under APS5_LAZY_SHADER_PREPARE=1 registration prepares nothing, but
ResolveShaderAbi still planned and prepared every compute or pixel stage
whose ABI the title resolved, so a title that resolves every shader's
ABI prepared them all at boot whether they ever drew.

With lazy preparation ResolveShaderAbi now plans the stage with the
ABI's state (its register and entry-point checks, as lazy registration
keeps them), records the ABI key, and queues the ABI's context and
primitive registers on the shader. The shader's first draw or dispatch
plans and prepares the queued ABIs with that state before it looks for
its artifact, so a shader that never draws or dispatches stays
unprepared and one that does gets the entries eager resolution would
have made. A stage whose plan fails is deferred as before. Without the
switch nothing changes; graphics-stage ABIs are still prepared when
they are resolved.

Test: agc_driver_lazy_resolved_abi resolves the ABI of four lazily
registered shaders and draws two. None holds prepared entries after
resolution, the two that never drew still hold none, and a drawn one
draws the same bytes as with eager preparation in a child process.
…he switch

agc_driver_lazy_resolved_abi spawns itself with --eager-reference to draw
the reference bytes with eager preparation, and only sets
APS5_LAZY_SHADER_PREPARE for itself after the child returns. Run with the
switch already exported, as a CI run of the whole suite with lazy
preparation does, the child inherited it, prepared nothing at its ABI
resolution and failed with "eager preparation left the resolved shader
unprepared".

The test now removes the variable before it spawns the child.
agc_driver_lazy_resolved_abi_switch_set runs it with the switch exported.
…he files with eager preparation

agc_driver_lazy_resolved_abi compared only the bytes one lazily resolved
shader drew with eager preparation's. Both processes now run the same
scenario, and the lazy one compares what it ends with against the eager
one's report:

- five synthetic pixel shaders, four resolved with empty ABI registers
  and one with its draw's own context and primitive registers, three of
  them drawn;
- each drawn shader's prepared entries, fingerprinted by the SPIR-V
  content hash and the source key, equal what eager resolution and the
  draw made: a draw with the ABI's state finds the ABI's entries, a draw
  with another state adds its own. Entries eager registration alone made
  for a state no ABI names are left out, as lazy registration makes
  none;
- the shaders that never drew hold no entries, and nothing is prepared
  or prebuilt at resolution;
- the pipeline libraries built, after the prebuild pool has drained,
  equal eager preparation's, so the first use prebuilds the registration
  module's library as resolution did;
- both runs share one shader disk cache, and the lazy run writes no file
  the eager run did not.

Driver::PreparedEntryHashes and Driver::PrebuiltLibraries expose the
fingerprints and the library counts to the test.

Each check fails when its part of the first-use preparation is removed:
without the prebuild device the libraries differ (eager 1 2 2 1, lazy
1 1 1 1), and without the ABI's context registers the shader drawn with
them holds other entries.
…paration

agc_driver_lazy_resolved_abi's eager/lazy comparison now also covers the
ways the state a deferred ABI keeps could differ at its first use:

- the ABI's context and primitive register arrays are overwritten after
  resolution and before any draw;
- one shader is resolved with two ABIs, the registered state and its
  draw's, before any use;
- a second header is registered for a shader whose ABI is queued, a draw
  uses it, then the first header is registered again and drawn.

Each drawn shader still ends with the entries eager resolution and its
draws made: drawn with the ABI's state it finds them, the second header
prepares its own, and the re-registered header finds its queued ABI's.
agc_driver_prepared_shaders_abi_deferred_compute resolves the ABI of a
compute shader whose s_swappc_b64 calls a user-data pointer and requires
the resolution to attempt its front end once. Under
APS5_LAZY_SHADER_PREPARE=1 the resolution only plans the stage and
leaves the attempt to the first dispatch, so with the switch exported
the test failed on that expectation before reaching the dispatch.

With the switch set the test now requires that neither resolution builds
a front end, and still requires the dispatch to run both callees.
agc_driver_prepared_shaders_abi_deferred_compute_lazy runs it so: the
first dispatch logs the queued ABI's failure once, links the callees and
writes 3 * (5 + 64) in every lane.
Under APS5_LAZY_SHADER_PREPARE=1 a shader's first draw or dispatch
prepares the ABIs ResolveShaderAbi queued on it, then looks for its own
artifact. Whether that artifact is among the entries the queued ABIs
just prepared decides whether the queued preparation is the use's own
work or extra.

Each first use that prepared queued ABIs now counts as found when the
artifact it uses is among the entries that preparation added, or as own
when it prepares its artifact itself. Entries prepared from queued ABIs
are marked, and the first lookup that matches one counts it, so the
entries no use ever matched are counted too. The counters are relaxed
atomics touched only by a lookup that matched or prepared. On the first
change and then at most once a minute stderr shows

  [shaders] deferred ABIs: N prepared at first use, F found their
  artifact there, O prepared their own; U of the E entries prepared
  from them never matched a use

Driver::DeferredAbiUses returns the same counts.

Test: agc_driver_lazy_resolved_abi checks that its two draws whose
state differs from the resolved ABI count as own with every queued
entry unmatched, and resolves a fifth shader's ABI with its draw's
context and primitive registers, whose draw counts as found and
matches one entry.
…at once

The first use of a shader whose ABI was deferred swapped the deferred list
out and prepared it unlocked. A second queue reaching the shader meanwhile
found the list empty and no entry yet, so it prepared an artifact of its
own under the lock, and the first use then matched that artifact instead
of the one its preparation made.

Mark the shader while its deferred ABIs are prepared and have other uses
wait on the settled condition until the entries are published. The
entries of all deferred ABIs are published together under the lock.

agc_driver_prepared_shaders_abi_deferred_concurrent_lazy submits the
first dispatches of one deferred ABI from four queues at once and requires
one first use that found its artifact, no own preparation, every
front-end build and entry to come from the deferred ABI, and all four
dispatches to use the same entry of it.
The deferred ABI line went to stderr in every run that resolved an ABI
at its first use. Print it through the profile output, like the
[rescache] and [gpu] lines, and only when APS5_PROFILE_DRAW is set. The
counters keep counting either way.
@EagleBearerYS
EagleBearerYS force-pushed the perf/agc-lazy-resolve-shader-abi branch from 40e0d96 to 1ba2206 Compare October 21, 2026 05:57
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@adriadam10 @CnRJay, thanks for the reviews. 1ba2206 is a rebase onto main with two new fixes. Point by point:

History. The branch is rebased onto main f47c856, and it merges cleanly with current main.

Once per ABI (4eeeeb6).

  • The first use marks the shader while it prepares its deferred ABIs, and publishes their entries together. A use from another queue waits on the shader's existing condition and takes the published entry.
  • If no entry matches, each use prepares its own, so a failed preparation leaves no one waiting.
  • After the first use, the lookup reads one more flag under the lock it already holds.
  • The new agc_driver_prepared_shaders_abi_deferred_concurrent_lazy submits the first dispatch of one deferred ABI from four queues at once, and requires one preparation that all four use. It failed in 20 of 20 runs before the fix ("2 front-end builds, 2 prepared entries, 1 first uses, 0 found, 0 own, 0 entries used"), and passes in 20 of 20 with it. On GitHub's runners (run) it and the four other lazy and prepared-shader tests pass 5 runs in a row on Linux; on Windows they need Vulkan and skip.

The counter line (1ba2206) prints only under APS5_PROFILE_DRAW, through the profile output the [rescache] lines use. The counters still count, for the tests.

Which workloads. The saving is the memory of entries prepared for resolved ABIs that a title never draws or dispatches with. Resident Evil Village (PPSA01556) resolves every shader's ABI at boot, and saves ~4.1 to 4.6 GB at the menu. @fma-rc's Astro's Playroom (PPSA01325) run shows no saving. Without APS5_LAZY_SHADER_PREPARE=1 nothing changes. The description now says this.

The cost at first use. A Resident Evil Village pair across the transition from the menu into first gameplay is queued, on a warm shader cache, with and without this head, both under APS5_LAZY_SHADER_PREPARE=1. It will give the worst frame times, the time from starting the game at the menu to the first stable gameplay frame, both summary lines and the digest. I'll post it when it's in.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 21, 2026
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@adriadam10 @CnRJay, here's the Resident Evil Village (PPSA01556) transition pair from the menu into first gameplay, as promised: one matched pair, without and with this PR.

Setup

  • Trees: main 1ff5c8a with fix(agc): put a retired import's unchanged ranges back in the write watch #8926 (63d5414), and the same with this PR's head 1ba2206 (074e31acbe).
  • Both arms: APS5_LAZY_SHADER_PREPARE=1, APS5_NO_GPL=1, APS5_HOST_IMPORT_MIB=6400, and APS5_TRACE_SUMMARY_EVERY=1 (summary lines only, no trace window).
  • Warm shader cache: no new cache key, and no disk-cache misses in either run.
  • The same route: about a minute at the menu, Continue, Yes, then about 3 minutes at control.
  • Both runs used the same low host-import mode (26,107 imports, 13,696 MiB without; 26,337, 14,233 MiB with).
  • RTX 3070 Laptop GPU, Ryzen 9 5900HS, 16 GB of RAM, Windows. GPU clocks weren't held; nvidia-smi showed P0 at 1,290 MHz in the slow intervals.
  • The earlier memory pairs in the description were with GPL on. With GPL on, this PC can't load past the menu, so this pair is with APS5_NO_GPL=1, and its memory compares only within the pair. In this pair, private memory at the menu is 415 MB higher with the change; it doesn't show whether the description's GPL-on saving carries over to APS5_NO_GPL=1.

Results

without with this PR
Yes → first lit gameplay frame 24:00 24:11
Five worst frames after Yes 133.0, 25.5, 23.3, 22.9, 22.0 s 85.5, 27.9, 24.9, 19.0, 18.6 s
First ~60 s of gameplay 6 frames, 7.6-9.5 s, plus one of 22.9 s 5 frames, 10.5-11.7 s
Frames over 2 s: count, mean 244, 7.3 s 274, 6.5 s
Shader disk-cache hits (misses) 18,902 (0) 9,452 (0)
Private memory at menu + 1 min 19,170 MB 19,585 MB

Per frame over the frames above 2 s, counted where a phase is among the frame's eight largest:

phase without with
Driver.Packet.memory_wait 11.5 s 10.1 s
Driver.Packet.dispatch 2.59 s 2.52 s
Resources.Complete 2.62 s 2.86 s
Graphics.Draw.draw_and_resource_release 1.75 s 1.74 s
Shader.DrawStage 0.56 s 0.12 s
Shader.ResolveGraphicsStagesAbi 0.07 s 0.05 s

"First lit gameplay frame" is the end of the opening scene's fade-in. Gameplay then runs at about 0.1 fps on this machine, so there's no stable frame rate to time.

Reading: there's no measurable difference in the time into gameplay or in the worst frames. With the change, the shader disk cache was asked for half as many entries, which fits the entries it leaves unprepared. But both runs are memory-bound: page-ins run at about 5,000 to 45,000 a second, and Driver.Packet.memory_wait is the largest phase of the slow frames. So a first-use cost smaller than the paging stalls wouldn't show here. The first minute of gameplay is slower with the change (10.5-11.7 s against 7.6-9.5 s per frame), while the run without it has a 22.9 s frame with 8.7 s in Shader.DrawStage and 8.6 s in Driver.Draw.shader_compile_and_link. One pair on this machine can't separate those from paging. I can run a second pair if you'd like one.

An earlier warm-up run with the change used the other host-import mode, which turns up on any tree, so it isn't compared here.

The first gameplay summary line of each run, and the digest of the first minute

Without (trace_digest.py):

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 2081-2089 1 7753.1 7753.1 7753.1 7753.1 227.7 100 % Driver.Packet 21628.0
2 2089-2098 1 9475.8 9475.8 9475.8 9475.8 225.5 100 % Driver.Packet 26341.5
3 2098-2107 1 8839.8 8839.8 8839.8 8839.8 226.2 100 % Driver.Packet 24897.7
4 2107-2115 1 7559.7 7559.7 7559.7 7559.7 225.6 100 % Driver.Packet 21034.4
5 2115-2123 1 7868.9 7868.9 7868.9 7868.9 452.8 100 % Driver.Packet 21841.3
6 2123-2145 1 22854.9 22854.9 22854.9 22854.9 0.0 100 % Driver.Packet 66970.4

With this PR:

# seconds presents p50 p90 p99 max GPU busy busiest worker largest phase
1 2078-2090 1 11413.6 11413.6 11413.6 11413.6 449.7 100 % Driver.Packet 30869.4
2 2090-2101 1 11653.2 11653.2 11653.2 11653.2 224.5 100 % Driver.Packet 31631.9
3 2101-2112 1 10450.8 10450.8 10450.8 10450.8 227.4 100 % Driver.Packet 28852.0
4 2112-2123 1 10750.1 10750.1 10750.1 10750.1 225.9 100 % Driver.Packet 28348.4
5 2123-2134 1 11612.9 11612.9 11612.9 11612.9 0.0 100 % Driver.Packet 32336.9
{"commit": "63d541433884", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 3492, "ms": 7753.104}, "interval_start_s": 2081.053, "interval_end_s": 2088.806, "presents": 1, "frame_ms": {"p50": 7753.104, "p90": 7753.104, "p99": 7753.104, "max": 7753.104}, "gpu_busy_ms_per_present": 227.673, "worker_busy_pct": {"queue worker 0x0": 99.82, "queue worker 0x38": 0.279, "queue worker 0x28": 99.29, "queue worker 0x20": 79.593}, "top_phases_ms_per_frame": {"Driver.Packet": 21628.011, "Driver.Packet.memory_wait": 11854.178, "Driver.Packet.dispatch": 4528.933, "Driver.Dispatch": 4505.071, "Resources.Complete": 4217.389, "Driver.Packet.draw": 3613.669, "Driver.Draw": 3611.741, "Graphics.Draw": 3085.413}, "trace_dropped": false, "trace": ""}
{"commit": "074e31acbeb2", "dirty": false, "env": {"APS5_HOST_IMPORT_MIB": "6400", "APS5_LAZY_SHADER_PREPARE": "1", "APS5_NO_GPL": "1", "APS5_PAD_INPUT_FILE": "<path>", "APS5_TRACE_DIR": "<path>", "APS5_TRACE_SUMMARY_EVERY": "1"}, "gpu": "NVIDIA GeForce RTX 3070 Laptop GPU", "driver": "NVIDIA 617.42", "os": "Windows 10.0.26300", "cpu": "AMD Ryzen 9 5900HS with Radeon Graphics", "cpu_threads": 16, "memory_mib": 15776, "title_id": "PPSA01556", "title": "Resident Evil Village", "content_version": "01.210.000", "resolution": "3840x2160", "window": {"spec": "summary_every 1", "first_present": 4767, "ms": 11413.624}, "interval_start_s": 2078.238, "interval_end_s": 2089.651, "presents": 1, "frame_ms": {"p50": 11413.624, "p90": 11413.624, "p99": 11413.624, "max": 11413.624}, "gpu_busy_ms_per_present": 449.682, "worker_busy_pct": {"queue worker 0x0": 99.83, "queue worker 0x38": 0.256, "queue worker 0x20": 76.712, "queue worker 0x28": 93.779}, "top_phases_ms_per_frame": {"Driver.Packet": 30869.398, "Driver.Packet.memory_wait": 17299.51, "Resources.Complete": 6567.612, "Driver.Packet.draw": 6277.76, "Driver.Draw": 6274.592, "Graphics.Draw": 5530.823, "Graphics.Draw.draw_and_resource_release": 5488.717, "Driver.Packet.dispatch": 5138.133}, "trace_dropped": false, "trace": ""}

@MarcZX10

Copy link
Copy Markdown
Contributor

Overlap note from PR #9626: I added a process-private-memory admission check to the non-lazy registration path, so it touches the RegisterShader branch changed here. To avoid conflicting sequencing, I marked #9626 as depending on #7644 and will adapt the guard after this PR’s disposition. If you prefer a different order or think these changes should be integrated together, please let me know. I have not changed your branch.

@MarcZX10

Copy link
Copy Markdown
Contributor

Update on my earlier overlap note: I moved the memory admission check into PlanRegistered, outside the RegisterShader hunk changed here. The current overlap check no longer reports a direct conflict with #7644, so #9626 no longer depends on it. Please disregard the previous sequencing note; I have not changed your branch.

@adriadam10
adriadam10 merged commit e94545a into boykopovar:main Oct 23, 2026
16 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the interdiff against each point of the previous review:

  • History: rebased onto main, only this PR's commits, no merge commits.
  • Once per ABI: the first use marks the shader as preparing and the other queues wait on its condition and take the published entry. The lock is retaken on every exit path. agc_driver_prepared_shaders_abi_deferred_concurrent_lazy covers four queues making the first use at once.
  • Counter line: only printed under APS5_PROFILE_DRAW.
  • Scope: stated in the description (helps Resident Evil Village, no saving on Astro's Playroom; nothing changes without APS5_LAZY_SHADER_PREPARE=1).
  • Cost: the menu to gameplay pair shows no measurable difference in the time to the first lit frame or the worst frames; both runs are paging-bound, which is noted.

Shader output is unchanged (only when entries are prepared), so there is nothing for the hardware oracle to measure; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants